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/store_order_cart_info/StoreOrderCartInfoController.php b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php index 3eb6b0fea..e85d6710d 100644 --- a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php +++ b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -4,8 +4,8 @@ namespace app\api\controller\store_order_cart_info; use app\api\controller\BaseApiController; -use app\api\lists\store_order_cart_info\CateLists; - +use app\api\lists\store_order_cart_info\StoreOrderCartInfoGroupLists; +use app\api\lists\store_order_cart_info\StoreOrderCartInfoLists; /** * 商品销量控制器 @@ -22,8 +22,13 @@ class StoreOrderCartInfoController extends BaseApiController */ public function lists() { - return $this->dataLists(new CateLists()); + $this->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/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 index 8bc43530a..b15faf5b0 100644 --- a/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -44,19 +44,20 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI { $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'); + 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', '=', 1]; + $this->searchWhere[] = ['store_id', '=', $store_id]; $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'); - } + $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(); 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, '送货');