172 行
6.7 KiB
PHP
可执行文件
172 行
6.7 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Common\Model;
|
|
|
|
//[1.7.90]
|
|
|
|
/**
|
|
* GoodsSkuModel删除
|
|
* Class RetailGoodsModel
|
|
* @package Common\Model
|
|
*/
|
|
class RetailSkuGoodsModel extends BaseModel
|
|
{
|
|
protected $tableName = 'retail_sku_goods';
|
|
const ID = 'id'; //int(11) NOT NULL AUTO_INCREMENT,
|
|
const STORE_ID = 'store_id'; //int(11) DEFAULT '0' COMMENT '门店id',
|
|
const GOODS_ID = 'goods_id'; //int(11) DEFAULT '0' COMMENT '商品id',
|
|
const SKU_ID_LIST = 'sku_id_list'; //varchar(255) DEFAULT NULL COMMENT '规格id拼接',
|
|
const PURCHASE_PRICE = 'purchase_price'; //decimal(10,2) DEFAULT '0.00' COMMENT '成本价',
|
|
const LAST_PURCHASE_PRICE = 'last_purch_price'; //decimal(10,2) DEFAULT '0.00' COMMENT '最后一次进价',
|
|
const ONLINE_PRICE = 'online_price'; //decimal(10,2) DEFAULT NULL COMMENT '商城价',
|
|
const RETAIL_PRICE = 'retail_price'; //decimal(10,2) DEFAULT NULL COMMENT '门店价',
|
|
const GOODS_IMG = 'goods_img'; //varchar(255) DEFAULT NULL COMMENT '规格图片',
|
|
const GOODS_NUM = 'goods_num'; //int(11) DEFAULT '0' COMMENT '商品库存',
|
|
const SKU_NUM = 'sku_num'; //decimal(10,3) DEFAULT '1.000' COMMENT '规格基数',
|
|
const SHOP_MEM_PRICE = 'shop_mem_price'; //decimal(10,2) DEFAULT NULL COMMENT '商城会员价格',
|
|
const STORE_MEM_PRICE = 'store_mem_price'; //decimal(10,2) DEFAULT NULL COMMENT '店内会员价格',
|
|
const PLUS_PRICE = 'plus_price'; //decimal(10,2) DEFAULT NULL COMMENT 'plus会员价',
|
|
const ADD_TIME = 'add_time'; //varchar(20) DEFAULT NULL COMMENT '添加时间',
|
|
const STATUS = 'status'; //tinyint(1) DEFAULT '1' COMMENT '0不启用 1启用',
|
|
const STATE = 'state'; //tinyint(1) DEFAULT '0' COMMENT '0正常 1删除',
|
|
const TYPE = 'type'; //varchar(255) DEFAULT '1' COMMENT '1单选 2多选',
|
|
const SKU_GOODS_NUMBER = 'sku_goods_number'; //规格货号
|
|
const MORE_NUM = 'more_num'; //规格超量
|
|
const LESS_NUM = 'less_num'; //规格预警
|
|
const SKU_CODE = 'sku_code'; //varchar(255) DEFAULT NULL COMMENT '商品规格条码',
|
|
const PD_NUM = 'pd_num'; //varchar(11) DEFAULT '' COMMENT '盘点数量',
|
|
const GOODS_IMG_ID = 'goods_img_id'; //varchar(255) DEFAULT '0' COMMENT '图片id',
|
|
const GUIDE_ROYALTY_PRICE = 'guide_royalty_price';// decimal(10,2) DEFAULT '0.00' COMMENT '导购员线下固定金提成',
|
|
const GUIDE_ROYALTY_ONLINE_PRICE = 'guide_royalty_online_price';// decimal(10,2) DEFAULT '0.00' COMMENT '导购员线上固定金提成',
|
|
const SHOP_MEM_INTEGRAL='shop_mem_integral'; //商城会员价自定义营销的积分
|
|
const PLUS_MEM_INTEGRAL='plus_mem_integral'; //plus会员价自定义营销的积分
|
|
const STORE_MEM_INTEGRAL='store_mem_integral'; //店内会员价自定义营销的积分
|
|
const WEIGHT_VALUE='weight_value'; //重量
|
|
|
|
// //收银员获取商品SKU
|
|
// public function getCashierSku($where){
|
|
// $field = $this::ID.','.$this::SKU_ID_LIST.','.$this::RETAIL_PRICE.','.$this::GOODS_IMG.','.$this::SKU_NUM.','.$this::GOODS_NUM.','.$this::SKU_CODE.','.$this::STORE_MEM_PRICE.','.$this::PLUS_PRICE;
|
|
// $order = $this::RETAIL_PRICE.' asc';
|
|
// $goodsSku = $this
|
|
// ->where($where)
|
|
// ->order($order)
|
|
// ->field($field)
|
|
// ->select();
|
|
// return $goodsSku;
|
|
// }
|
|
/*
|
|
* 商品数量作条件查询商品列表
|
|
* @param $where 条件
|
|
* @param $field 查询字段
|
|
*/
|
|
public function getSkuGoodsList($where, $field = 'k.*', $order = 'k.id asc')
|
|
{
|
|
$info = $this->alias('k')
|
|
->join('ls_retail_store_sale_goods as s on k.id=s.sku_id and s.attribute_state=2')
|
|
->where($where)
|
|
->field($field)
|
|
->order($order)
|
|
->select();
|
|
return $info;
|
|
}
|
|
|
|
/*
|
|
* 商品数量作条件查询字段
|
|
* @param $where 条件
|
|
* @param $field 查询字段
|
|
*/
|
|
public function getSkuGoodsFields($where, $field, $order = 'k.id asc')
|
|
{
|
|
$info = $this->alias('k')
|
|
->join('ls_retail_store_sale_goods as s on k.id=s.sku_id', 'LEFT')
|
|
->where($where)
|
|
->order($order)
|
|
->getField($field, true);
|
|
return $info;
|
|
}
|
|
|
|
/**
|
|
* 进销存版 find
|
|
* @param $map
|
|
* @param $field
|
|
* @return array
|
|
*/
|
|
public function getSkuGoodsInfo($map, $field = 'k.*')
|
|
{
|
|
$info = $this->alias('k')
|
|
->join('ls_retail_store_sale_goods as s on k.id = s.sku_id')
|
|
->field($field)
|
|
->where($map)
|
|
->find();
|
|
return $info;
|
|
}
|
|
|
|
public function getHostSkuList($map, $fields = '*', $order = 's.id asc')
|
|
{
|
|
if (empty($map)) {
|
|
return array();
|
|
}
|
|
$time = time();
|
|
$list = $this->alias('s')
|
|
->join("ls_retail_host as h on s.id=h.sku_id AND h.type=2 AND h.starttime<={$time} AND h.endtime>={$time} AND h.state=1 AND h.status=1", 'LEFT')
|
|
->where($map)
|
|
->order($order)
|
|
->field($fields)
|
|
->select();
|
|
return $list;
|
|
}
|
|
|
|
|
|
/**
|
|
* 商户调拨门店的规格商品库存详情
|
|
* @param $parameter
|
|
* [
|
|
* merchant_goods_sku_id 商户的规格id
|
|
* merchant_id 商户id
|
|
* ]
|
|
* @return mixed
|
|
*/
|
|
public function getSyncMerchantGoodsSkuInfo($parameter)
|
|
{
|
|
$where = array(
|
|
'k.state'=>0,
|
|
'k.sku_mgoods_id'=>$parameter['merchant_goods_sku_id'],
|
|
's.merchant_id'=>$parameter['merchant_id'],
|
|
's.status'=>array('in','0,1')
|
|
);
|
|
$page = $parameter['page']?$parameter['page']:1;
|
|
$limit = $parameter['limit']?$parameter['limit']:10;
|
|
$list = $this->alias('k')
|
|
->join('ls_retail_store_sale_goods as s on k.id=s.sku_id and k.goods_id=s.goods_id')
|
|
->field("s.store_id,s.goods_num,s.id,s.goods_id,s.sku_id")
|
|
->where($where)
|
|
->page($page,$limit)
|
|
->select();
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* 商户调拨门店的规格商品库存详情
|
|
* @param $parameter
|
|
* [
|
|
* merchant_goods_sku_id 商户的规格id
|
|
* merchant_id 商户id
|
|
* ]
|
|
* @return mixed
|
|
*/
|
|
public function getSyncMerchantGoodsSkuCount($parameter)
|
|
{
|
|
$where = array(
|
|
'k.state'=>0,
|
|
'k.sku_mgoods_id'=>$parameter['merchant_goods_sku_id'],
|
|
's.merchant_id'=>$parameter['merchant_id'],
|
|
's.status'=>array('in','0,1')
|
|
);
|
|
$count = $this->alias('k')
|
|
->join('ls_retail_store_sale_goods as s on k.id=s.sku_id and k.goods_id=s.goods_id')
|
|
->where($where)
|
|
->count();
|
|
return $count;
|
|
}
|
|
}
|