diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index 071cfa386..5c0a32030 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -10,6 +10,7 @@ use app\admin\logic\warehouse_order\WarehouseOrderLogic; use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\admin\validate\warehouse_order\WarehouseOrderValidate; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_order\StoreOrder; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; @@ -263,6 +264,13 @@ class WarehouseOrderController extends BaseAdminController $order['delivery_time']=date('Y-m-d H:i:s',$order['delivery_time']); $order['pay_time']=$order['create_time']; $order['order_id']=$order['code']; + + if($order['oid']>0){ + $orders=StoreOrder::where('id',$order['oid'])->findOrEmpty(); + $order['real_name']=$orders['real_name']; + $order['user_phone']=$orders['user_phone']; + $order['user_address']=$orders['user_address']; + } $file_path = $xlsx->export($data, $system_store, $order); return $this->success('导出成功', ['url' => $file_path]); 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..5bbfb08e5 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'=>'店铺收支','url'=>'/pagesOrder/statistics/index'], ]; 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..e85d6710d --- /dev/null +++ b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -0,0 +1,34 @@ +request->__set('store_id',5); + return $this->dataLists(new StoreOrderCartInfoLists()); + } + + public function group_lists() + { + $this->request->__set('store_id',5); + return $this->dataLists(new StoreOrderCartInfoGroupLists()); + } +} diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php new file mode 100644 index 000000000..a2dcf4cea --- /dev/null +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -0,0 +1,39 @@ +dataLists(new SystemStoreStorageLists()); + } + /** + * @notes 获取商品分类列表 + * @return + * @author likeadmin + * @date 2024/04/23 10:27 + */ + public function group_lists() + { + return $this->dataLists(new SystemStoreStorageGroupLists()); + } + +} diff --git a/app/api/lists/branch_product/BranchProductLists.php b/app/api/lists/branch_product/BranchProductLists.php new file mode 100644 index 000000000..d4853886e --- /dev/null +++ b/app/api/lists/branch_product/BranchProductLists.php @@ -0,0 +1,98 @@ + [ '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 + { + $store_id = $this->request->__get('store_id'); + if (!$store_id) return []; + + $fields = 'id,top_cate_id,cate_id,product_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,total_price'; + + $this->searchWhere[] = ['status', '=', 1]; + $this->searchWhere[] = ['store_id', '=', $store_id]; + $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){ + $item->distribution_nums=WarehouseProduct::where(['store_id'=>$item['store_id'],'product_id'=>$item['product_id'],'financial_pm'=>0])->sum('nums'); + $item->sales=StoreOrderCartInfo::where(['product_id'=>$item['product_id'],'store_id'=>$item['store_id'],'is_pay'=>1])->sum('cart_num'); + }) + ->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/order/OrderList.php b/app/api/lists/order/OrderList.php index 5e6652654..525ebac18 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -46,7 +46,6 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface $userId = $this->request->userId; if (!$userId) return []; $data = StoreOrder::with(['store'])->where($this->searchWhere)->where(['uid'=>$userId]) - ->whereIn('shipping_type',[1,2]) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() diff --git a/app/api/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php b/app/api/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php new file mode 100644 index 000000000..31aaa6659 --- /dev/null +++ b/app/api/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php @@ -0,0 +1,96 @@ + '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('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['is_pay', '=', 1]; + $this->searchWhere[] = ['status', '>=', 0]; + $this->searchWhere[] = ['store_id', '=', $store_id]; + $query = StoreOrderCartInfo::where($this->searchWhere); + $query->field('store_id,product_id,price,sum(total_price) as total_price,sum(cart_num) as cart_num'); + return $query->limit($this->limitOffset, $this->limitLength) + ->group('product_id') + ->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(); + } +} 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..b15faf5b0 --- /dev/null +++ b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -0,0 +1,96 @@ + '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('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['is_pay', '=', 1]; + $this->searchWhere[] = ['status', '>=', 0]; + $this->searchWhere[] = ['store_id', '=', $store_id]; + $query = StoreOrderCartInfo::where($this->searchWhere); + $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 diff --git a/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php new file mode 100644 index 000000000..84fbaca3d --- /dev/null +++ b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php @@ -0,0 +1,115 @@ + 'create_time', + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return []; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['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 + { + $fields = 'store_id,product_id,sum(nums) as nums,mark'; + if ($this->request->get('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['type', '=', 1]; + $this->searchWhere[] = ['status', '=', 1]; + return SystemStoreStorage::where($this->searchWhere) + ->field($fields) + ->group('product_id') + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select()->each(function ($item) { + $find=StoreProduct::where('id', $item['product_id'])->with(['className', 'unitName']) + ->field('id,store_name,image,unit,cate_id,store_info')->find(); + if($find){ + $item['store_name'] = $find['store_name']; + $item['image'] = $find['image']; + $item['unit_name'] = $find['unit_name']; + $item['class_name'] = $find['class_name']; + $item['store_info'] = $find['store_info']; + }else{ + $item['product_name'] = ''; + $item['product_image'] = ''; + $item['product_unit'] = ''; + $item['product_cate'] = ''; + $item['store_info'] = ''; + } + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return SystemStoreStorage::where($this->searchWhere) + ->count(); + } +} diff --git a/app/api/lists/system_store_storage/SystemStoreStorageLists.php b/app/api/lists/system_store_storage/SystemStoreStorageLists.php new file mode 100644 index 000000000..f3674d2cb --- /dev/null +++ b/app/api/lists/system_store_storage/SystemStoreStorageLists.php @@ -0,0 +1,116 @@ + 'create_time', + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return []; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['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 + { + $fields = 'id,store_id,staff_id,product_id,warehouse_id,nums,mark,status'; + if ($this->request->get('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['type', '=', 1]; + return SystemStoreStorage::where($this->searchWhere) + ->field($fields) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select()->each(function ($item) { + if($item['staff_id']>0){ + $item['staff_name']=SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name'); + } + $find=StoreProduct::where('id', $item['product_id'])->with(['className', 'unitName']) + ->field('id,store_name,image,unit,cate_id,store_info')->find(); + if($find){ + $item['store_name'] = $find['store_name']; + $item['image'] = $find['image']; + $item['unit_name'] = $find['unit_name']; + $item['class_name'] = $find['class_name']; + $item['store_info'] = $find['store_info']; + }else{ + $item['product_name'] = ''; + $item['product_image'] = ''; + $item['product_unit'] = ''; + $item['product_cate'] = ''; + $item['store_info'] = ''; + } + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return SystemStoreStorage::where($this->searchWhere) + ->count(); + } +} diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index a3f0b74c8..046e50d24 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -217,7 +217,6 @@ class OrderLogic extends BaseLogic // } //成本价 收益 $order = [ - 'create_time' => time(), 'order_id' => $params['order_id'] ?? getNewOrderId('PF'), 'total_price' => self::$total_price, //总价 'cost' => self::$cost, //成本价1- diff --git a/app/common/service/xlsx/OrderDetail.php b/app/common/service/xlsx/OrderDetail.php index 2fa5e115d..d210cad63 100644 --- a/app/common/service/xlsx/OrderDetail.php +++ b/app/common/service/xlsx/OrderDetail.php @@ -109,8 +109,16 @@ class OrderDetail $sheet->setCellValue('A' . $count + 12, '下单人',); $sheet->mergeCells('B' . ($count + 12) . ':C' . $count + 12); + $sheet->setCellValue('B' . ($count + 12), $order['real_name']??''); + $sheet->setCellValue('D' . $count + 12, '电话'); - + $sheet->mergeCells('E' . ($count + 12) . ':F' . $count + 12); + $sheet->setCellValue('E' . ($count + 12), $order['user_phone']??''); + + $sheet->setCellValue('G' . $count + 12, '地址'); + $sheet->mergeCells('H' . ($count + 12) . ':J' . $count + 12); + $sheet->setCellValue('H' . ($count + 12), $order['user_address']??''); + $sheet->setCellValue('A' . $count + 13, '仓库',); $sheet->mergeCells('B' . ($count + 13) . ':C' . $count + 13); $sheet->setCellValue('D' . $count + 13, '送货');