|
|
@@ -53,17 +53,16 @@ class Lists extends Backend
|
|
|
}
|
|
|
|
|
|
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
|
|
- $list = $this->model->with('products')
|
|
|
+ $list = $this->model->with('products')->with('productarea')->with('productareastop')->with('productorder')
|
|
|
->where($where)
|
|
|
->order($sort, $order)
|
|
|
->paginate($limit);
|
|
|
- $productOrder = new ProductOrder();
|
|
|
+
|
|
|
foreach ($list as &$item) {
|
|
|
- $item['hold_num'] = $productOrder::where('product_id', $item->id)->where('status', 'in',[$productOrder::Paid, $productOrder::Transferred, $productOrder::Freeze])->count();//持有数量
|
|
|
- $item['total_num']= $this->productArea::where('product_id', $item->id)->count();
|
|
|
- $item['sell_num'] = $this->productArea::where('product_id', $item->id)->where('status', $this->productArea::Stop)->count();
|
|
|
+ $item['hold_num'] = $item->productorder? count($item->productorder): 0;//持有数量
|
|
|
+ $item['total_num']= $item->productarea? count($item->productarea): 0;
|
|
|
+ $item['sell_num'] = $item->productareastop? count($item->productareastop): 0;
|
|
|
}
|
|
|
-
|
|
|
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
|
|
return json($result);
|
|
|
}
|
|
|
@@ -165,27 +164,7 @@ class Lists extends Backend
|
|
|
|
|
|
|
|
|
|
|
|
- //判断是否存在相同元素
|
|
|
- private function setEqualArea(int $product_id,array $areaArr, array $areaArrTxt, int $type): bool
|
|
|
- {
|
|
|
- foreach ($areaArr as $key=>$row)
|
|
|
- {
|
|
|
- $arr['product_id'] = $product_id;
|
|
|
- $arr['province'] = $row[0]??0;
|
|
|
- $arr['city'] = $row[1]??0 ;
|
|
|
- $arr['area'] = $row[2]??0;
|
|
|
- $arr['county'] = $row[3]??0;
|
|
|
- $arr['address'] = $areaArrTxt[$key][0];
|
|
|
- if(!empty($type)){
|
|
|
- if($this->productArea::where('product_id',$arr['product_id'])
|
|
|
- ->where('province',$arr['province'])
|
|
|
- ->where('city',$arr['city'])->where('area',$arr['area'])
|
|
|
- ->where('county',$arr['county'])
|
|
|
- ->count() > 0) continue;
|
|
|
- }
|
|
|
- $this->productArea::create($arr);
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|