75 行
2.6 KiB
PHP
可执行文件
75 行
2.6 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Common\Model;
|
|
//[1.5.66]
|
|
|
|
/**
|
|
* SkuList删除
|
|
* Class RetailSkuListModel
|
|
* @package Common\Model
|
|
*/
|
|
class RetailSkuListModel extends BaseModel
|
|
{
|
|
protected $tableName = 'retail_sku_list';
|
|
const ID = 'id'; //int(11) NOT NULL AUTO_INCREMENT,
|
|
const ATTR_ID = 'attr_id'; //int(11) DEFAULT NULL COMMENT '所属属性id',
|
|
const MERCHANT_ID = 'merchant_id'; //int(11) DEFAULT NULL COMMENT '商户id',
|
|
const STORE_ID = 'store_id'; //int(11) DEFAULT NULL COMMENT '门店id(门店添加时写)',
|
|
const NAME = 'name'; //varchar(255) DEFAULT NULL,
|
|
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'; //tinyint(1) DEFAULT '1' COMMENT '1常用 2不常用',
|
|
|
|
/**
|
|
* 收银员获取商品SKU
|
|
* @param $where
|
|
* @return mixed
|
|
*/
|
|
public function getCashierSkuList($where)
|
|
{
|
|
$tempAttr = $this->alias('l')
|
|
->join('ls_retail_sku_attr as a on l.' . $this::ATTR_ID . '=a.id')
|
|
->where($where)
|
|
->field('a.id,a.name')
|
|
->find();
|
|
return $tempAttr;
|
|
}
|
|
|
|
/**
|
|
* 获取固定规格值所属的规格属性数量
|
|
* @param $merchant_id 商户ID
|
|
* @param $all_sku_list_id 规格值ID
|
|
* @return int
|
|
* @throws \think\Exception
|
|
*/
|
|
public function getAttrCount($merchant_id, $all_sku_list_id)
|
|
{
|
|
$count = M('retail_sku_attr as a')
|
|
->join('ls_retail_sku_list as l on l.attr_id=a.id')
|
|
->field('a.*')
|
|
->where(array('a.merchantid' => $merchant_id, 'a.state' => 0, 'l.id' => array('in', $all_sku_list_id)))
|
|
->count('distinct(l.attr_id)');
|
|
return intval($count);
|
|
}
|
|
|
|
/**
|
|
* 根据规格属性值ID获取规格属性
|
|
* @param $list_id
|
|
* @return array|false|mixed|\PDOStatement|string|\think\Model|null
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function getAttrInfo($list_id)
|
|
{
|
|
$data = M('retail_sku_attr as s')
|
|
->join('ls_retail_sku_list as l on l.attr_id=s.id')
|
|
->where(array('s.state' => 0, 'l.id' => $list_id))
|
|
->group('l.attr_id')
|
|
->field('s.id,s.name')
|
|
->find();
|
|
return $data ? $data : array();
|
|
}
|
|
} |