|
|
@@ -29,20 +29,23 @@ class Product extends Api
|
|
|
{
|
|
|
$list = $productsModel->where('status', 1)->column('id,'.$this->lan.'_title as title');
|
|
|
$resp = array();
|
|
|
-
|
|
|
- foreach ($list as $kk =>$val)
|
|
|
- {
|
|
|
- $pro= $productPopular->alias('a')
|
|
|
- ->join("product_list b", "b.id=a.product_id", "LEFT")
|
|
|
- ->field('a.id,'.'b.'.$this->lan.'_name as name,a.product_id,b.thum as img_url,price,cost_price,stock,num,start_time,end_time,a.status')
|
|
|
- ->where('a.status', '<', $productPopular::STOP)
|
|
|
- ->where('b.type_id', $kk)
|
|
|
- ->order('a.status')
|
|
|
- ->select();
|
|
|
-
|
|
|
- $resp[] = ['type_id'=>$kk,'title'=>$val, 'product'=>$pro];
|
|
|
+ foreach ($list as $kk =>$val) {
|
|
|
+ $list= $productLists->where('type_id', $kk)->field('id,thum as img_url,'.$this->lan.'_name as name')->select();
|
|
|
+ foreach ($list as $key => &$item) {
|
|
|
+ $pro =$productPopular
|
|
|
+ ->field('id,product_id,price,cost_price,stock,num,start_time,end_time,status')
|
|
|
+ ->where('product_id', $item->id)
|
|
|
+ ->where('status', '<', $productPopular::STOP)
|
|
|
+ ->order('start_time')
|
|
|
+ ->find();
|
|
|
+ if(!empty($pro)){
|
|
|
+ $item['pro'] = $pro;
|
|
|
+ }else{
|
|
|
+ unset($list[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $resp[] = ['type_id'=>$kk,'title'=>$val, 'product'=>$list];
|
|
|
}
|
|
|
-
|
|
|
$this->success('', $resp);
|
|
|
}
|
|
|
|