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(); } }