|
|
|
@ -197,6 +197,67 @@ class Goods extends GoodsModel |
|
|
|
|
return $info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function presaleGoodsList() |
|
|
|
|
{ |
|
|
|
|
$info = PreSale::where([ |
|
|
|
|
'store_id' => request()->header()['storeid'], |
|
|
|
|
'is_change' => 0, |
|
|
|
|
'status' => 1, |
|
|
|
|
])->order('id desc')->find(); |
|
|
|
|
|
|
|
|
|
if ($info) { |
|
|
|
|
$goods = explode(',', $info->goods_list); |
|
|
|
|
|
|
|
|
|
$list = goods::alias('a') |
|
|
|
|
->join('goods_category_rel b', 'a.goods_id = b.goods_id')->where([ |
|
|
|
|
'a.store_id' => request()->header()['storeid'], |
|
|
|
|
'a.status' => 10, |
|
|
|
|
'b.category_id' => $_GET['category_id'] |
|
|
|
|
])->whereIn('a.goods_id', $goods)->field('a.goods_id,a.goods_name,a.goods_price_min,b.category_id,a.sales_initial,a.sales_actual')->select()->toArray(); |
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function presaleCateList() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
$info = PreSale::where([ |
|
|
|
|
'store_id' => request()->header()['storeid'], |
|
|
|
|
'is_change' => 0, |
|
|
|
|
'status' => 1, |
|
|
|
|
])->order('id desc')->find(); |
|
|
|
|
if ($info) { |
|
|
|
|
$goods = explode(',', $info->goods_list); |
|
|
|
|
$list = goods::alias('a') |
|
|
|
|
->join('goods_category_rel b', 'a.goods_id = b.goods_id') |
|
|
|
|
->join('category c', 'c.category_id = b.category_id') |
|
|
|
|
->where([ |
|
|
|
|
'a.store_id' => request()->header()['storeid'], |
|
|
|
|
'a.status' => 10, |
|
|
|
|
'c.parent_id' => 0, |
|
|
|
|
])->whereIn('a.goods_id', $goods)->field('c.*,a.sales_initial,a.sales_actual')->select()->toArray(); |
|
|
|
|
|
|
|
|
|
$list = $this->removeDuplicatesByField($list, 'category_id'); |
|
|
|
|
$res['info'] = $info; |
|
|
|
|
$res['category'] = $list; |
|
|
|
|
return $res; |
|
|
|
|
} |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function removeDuplicatesByField($array, $field) |
|
|
|
|
{ |
|
|
|
|
$uniqueArray = array(); |
|
|
|
|
foreach ($array as $item) { |
|
|
|
|
if (!isset($uniqueArray[$item[$field]])) { |
|
|
|
|
$uniqueArray[$item[$field]] = $item; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return array_values($uniqueArray); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function canlpresale() |
|
|
|
|
{ |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(true); |
|
|
|
|