diff --git a/app/api/controller/branch_product/BranchProductController.php b/app/api/controller/branch_product/BranchProductController.php new file mode 100644 index 000000000..c08f43515 --- /dev/null +++ b/app/api/controller/branch_product/BranchProductController.php @@ -0,0 +1,19 @@ +dataLists(new BranchProductLists()); + } +} diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index ab251819a..462caf03d 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -200,12 +200,13 @@ class StoreController extends BaseApiController */ public function menu_list(){ $menu=[ - ['name'=>'每日配送统计'], - ['name'=>'累计配送统计'], - ['name'=>'每日销量统计'], - ['name'=>'累计销量统计'], - ['name'=>'商品库存'], - ['name'=>'店铺收支'] + ['name'=>'每日配送统计','url'=>'/pagesOrder/deliveryOrder/index'], + ['name'=>'累计配送统计','url'=>'/pagesOrder/deliveryOrder/count'], + ['name'=>'每日销量统计','url'=>'/pagesOrder/productSales/index'], + ['name'=>'累计销量统计','url'=>'/pagesOrder/productSales/count'], + ['name'=>'商品库存','url'=>'/pagesOrder/store_product/index'], + ['name'=>'订单列表','url'=>'/pagesOrder/delivery/index'], + ['name'=>'店铺收支'], ]; return $this->success('ok',['menu'=>$menu]); } diff --git a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php new file mode 100644 index 000000000..3eb6b0fea --- /dev/null +++ b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -0,0 +1,29 @@ +dataLists(new CateLists()); + } + + +} diff --git a/app/api/lists/branch_product/BranchProductLists.php b/app/api/lists/branch_product/BranchProductLists.php new file mode 100644 index 000000000..109f22be7 --- /dev/null +++ b/app/api/lists/branch_product/BranchProductLists.php @@ -0,0 +1,104 @@ + [ 'cate_id', 'top_cate_id', 'two_cate_id'], + '%pipe_like%' => ['store_name' => 'store_name|bar_code'], + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return ['sell' => 'price', 'sales' => 'sales',]; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['sort'=>'desc','price' => 'asc', 'id' => 'desc']; + } + + /** + * @notes 获取商品列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function lists(): array + { + // $order = $this->request->get('order', ''); + // $field = $this->request->get('field', ''); + // if (empty($order) || empty($field)) { + // $order = $this->sortOrder; + // } else { + // $order = [$field => $order]; + // } + $fields = 'id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,is_lack'; + + $tag = ''; + + $this->searchWhere[] = ['is_show', '=', 1]; + $this->searchWhere[] = ['product_type', 'in', [0,4]]; + return StoreBranchProduct::where($this->searchWhere) + ->field($fields) + ->with(['className', 'unitName']) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select()->each(function ($item) use ($tag) { + if($item['is_lack']==1){ + $tag='缺货'; + } + $item['tag'] = $tag; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return StoreBranchProduct::where($this->searchWhere) + ->count(); + } +} diff --git a/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php new file mode 100644 index 000000000..8bc43530a --- /dev/null +++ b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -0,0 +1,95 @@ + 'create_time' + ]; + } + + + /** + * @notes 获取地址列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @date 2024/04/27 11:26 + */ + public function lists(): array + { + $store_id=$this->request->__get('store_id'); + if(!$store_id) return []; + // if ($this->request->get('start_time') == '') { + // $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; + // } + $is_group=$this->request->get('is_group'); + $this->searchWhere[] = ['is_pay', '=', 1]; + $this->searchWhere[] = ['status', '>=', 0]; + $this->searchWhere[] = ['store_id', '=', 1]; + $query = StoreOrderCartInfo::where($this->searchWhere); + if ($is_group == 1) { + $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); + } else { + $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid'); + } + return $query->limit($this->limitOffset, $this->limitLength) + ->select()->each(function ($item){ + $find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find(); + if ($find) { + $item['image'] = $find['image']; //商品图片 + + $item['store_name'] = $find['store_name']; //商品名称 + + $item['store_info'] = $find['store_info']; //商品规格 + $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; + $item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name') ?? ''; + } else { + $item['image'] = ''; //商品图片 + $item['store_name'] = ''; //商品名称 + $item['store_info'] = ''; //商品规格-(数据库叫商品简介) + $item['unit_name'] = ''; // + $item['cate_name'] = ''; // + $item['system_store'] = ''; // + } + return $item; //返回处理后的数据。 + }) + ->toArray(); + } + + + /** + * @notes 获取地址数量 + * @return int + * @date 2024/04/27 11:26 + */ + public function count(): int + { + return StoreOrderCartInfo::where($this->searchWhere)->count(); + } + +} \ No newline at end of file