From 902069b4f9c02895c648167c915023ba0be3fa3c Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 3 Jan 2025 17:48:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=90=8E=E5=8F=B0=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=A2=84=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderController.php | 310 ++++++++++++++++++ .../BeforehandOrderCartInfoController.php | 170 ++++++++++ .../store_product/StoreProductController.php | 10 + 3 files changed, 490 insertions(+) create mode 100644 app/store/controller/beforehand_order/BeforehandOrderController.php create mode 100644 app/store/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php diff --git a/app/store/controller/beforehand_order/BeforehandOrderController.php b/app/store/controller/beforehand_order/BeforehandOrderController.php new file mode 100644 index 000000000..c903435fb --- /dev/null +++ b/app/store/controller/beforehand_order/BeforehandOrderController.php @@ -0,0 +1,310 @@ +request->get(); + $params['store_id'] = $this->request->adminInfo['store_id'] ?? 0; + $this->request->setGet($params); + return $this->dataLists(new BeforehandOrderLists()); + } + + public function warehousing_lists() + { + return $this->dataLists(new BeforehandOrderTwoLists()); + } + + public function outbound_lists() + { + return $this->dataLists(new BeforehandOrderThreeLists()); + } + + /** + * @notes 添加预订单表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function add() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $params['store_id'] = $this->request->adminInfo['store_id'] ?? 0; + $other_data = [ + 'nickname' => $params['nickname'] ?? '', + 'phone' => $params['phone'] ?? '', + 'address' => $params['address'] ?? '', + 'arrival_time' => $params['arrival_time'] ?? '', + 'purpose' => $params['purpose'] ?? '', + 'tables' => $params['tables'] ?? '', + 'days' => $params['days'] ?? '', + 'chef' => $params['chef'] ?? '', + 'chef_phone' => $params['chef_phone'] ?? '', + 'splitting_officer' => $params['splitting_officer'] ?? '', + 'merchandiser' => $params['merchandiser'] ?? '', + 'distribution_personnel' => $params['distribution_personnel'] ?? '', + 'transporter' => $params['transporter'] ?? '', + 'system_store_name' => $params['system_store_name'] ?? '', + 'regional_manager' => $params['regional_manager'] ?? '', + ]; + $params['other_data'] = $other_data; + $result = BeforehandOrderLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + /** + * 生成支付订单 + */ + public function generateOrder() + { + $params = $this->request->post(); + $result = BeforehandOrderLogic::generateOrder($params); + return $this->success('生成成功', [], 1, 1); + } + + /** + * 一键出库 + */ + public function createOutboundOrder() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $result = BeforehandOrderLogic::createOutboundOrder($params); + + return $this->success('出库成功', [], 1, 1); + } + + /** + * 一键报损出库 + */ + public function createOutboundDamageOrder() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $result = BeforehandOrderLogic::createOutboundOrder($params); + + return $this->success('出库成功', [], 1, 1); + } + + /** + * @notes 订单转预定单 + * @return \think\response\Json + */ + public function orderTransferAdvanceOrder() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $params['mark'] = '订单转预定单'; + $result = BeforehandOrderLogic::orderTransferAdvanceOrder($params); + return $this->success('转单成功', [], 1, 1); + } + + /** + * @notes 编辑预订单表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function edit() + { + $params = $this->request->post(); + $result = BeforehandOrderLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BeforehandOrderLogic::getError()); + } + + + /** + * @notes 删除预订单表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function delete() + { + $params = $this->request->post(); + BeforehandOrderLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取预订单表详情 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function detail() + { + $params = $this->request->get(); + $result = BeforehandOrderLogic::detail($params); + return $this->data($result); + } + + /** + * 导出标签 + */ + public function export() + { + $params = $this->request->post(); + $order = BeforehandOrder::where('id', $params['id'])->field('outbound_id,order_sn')->find(); + if (!$order) { + return $this->fail('未生成出库单'); + } + $warehouseOrder = WarehouseOrder::where('id', $order['outbound_id'])->field('store_id,delivery_time')->find(); + $system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('name'); + $data = WarehouseProduct::where('oid', $order['outbound_id'])->field('product_id,nums')->select() + ->each(function ($item) use ($system_store, $warehouseOrder, $order) { + $find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find(); + $unit_name = StoreProductUnit::where('id', $find['unit'])->value('name'); + $item['system_store'] = $system_store; + $item['subtitle'] = $item['oid'] . ' ' . convertStringToNumber($item['nums']) . '/' . $unit_name; + $item['store_name'] = $find['store_name']; + if ($warehouseOrder['oid']) { + $find = StoreOrder::where('order_id', $order['order_sn'])->field('real_name,user_address')->find(); + if ($find) { + $item['address'] = $find['real_name'] . ' ' . $find['user_address']; + } else { + $item['address'] = '无地址'; + } + } else { + $item['address'] = '无地址'; + } + }) + ->toArray(); + $file_path = (new Beforehand())->export($data, $system_store); + return $this->success('导出成功', ['url' => $file_path]); + } + + + /** + * 导出订单 + */ + public function export_order() + { + $params = $this->request->post(); + $order = BeforehandOrder::where('id', $params['id'])->find(); + + $cart_info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select(); + + $file_path = (new Beforehand())->order($order, $cart_info); + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 导出清单 + */ + public function export_order_list() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::OrderList($params); + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 导出分单 + */ + public function order_allocation() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::OrderAllocation($params); + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 采购信息 + */ + public function order_info() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::OrderInfo($params); + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 导出出库 + */ + public function order_outbound() + { + $params = $this->request->post(); + if (!empty($params['type']) && $params['type'] == 2) { + $file_path = BeforehandOrderLogic::OrderOutbound2($params); + } else { + $file_path = BeforehandOrderLogic::OrderOutbound($params); + } + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 导出会员出库 + */ + public function order_outbound3() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::OrderOutbound3($params); + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 导出财务出库 + */ + public function order_outbound_finance() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::OrderOutboundFinance($params); + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 导出退库 + */ + public function stock_return() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::StockReturn($params); + return $this->success('导出成功', ['url' => $file_path]); + } + + /** + * 导出退供应商 + */ + public function return_supplier() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::ReturnSupplier($params); + return $this->success('导出成功', ['url' => $file_path]); + } +} diff --git a/app/store/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php b/app/store/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php new file mode 100644 index 000000000..dd94a3fa0 --- /dev/null +++ b/app/store/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php @@ -0,0 +1,170 @@ +dataLists(new BeforehandOrderCartInfoLists()); + } + + + /** + * @notes 添加预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function add() + { + $params = $this->request->post(); + $result = BeforehandOrderCartInfoLogic::add($params); + return $this->success('添加成功', [], 1, 1); + + } + /** + * @notes 添加预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function append_add() + { + $params = $this->request->post(); + $result = BeforehandOrderCartInfoLogic::appendAdd($params); + return $this->success('追加成功', [], 1, 1); + + } + + /** + * @notes 编辑预订单购物详情无需采购 + */ + public function procurement_status(){ + $id=$this->request->post('id'); + + $res=BeforehandOrderCartInfo::where('id',$id)->find(); + $find=PurchaseProductOffer::where(['product_id'=>$res['product_id'],'order_id'=>$res['bhoid']])->find(); + if (empty($find)) { + $rawSql = "JSON_CONTAINS(source_order_info, '{\"source_order_id\": {$res['bhoid']}}')"; + $find = PurchaseProductOffer::where(['product_id' => $res['product_id']])->whereRaw($rawSql)->find(); + } + if($find){ + if($find['buyer_confirm']==1){ + return $this->fail('该商品已采购完成,无法更改状态'); + }else{ + if (!empty($find['source_order_info'])) { + $json = $find['source_order_info']; + foreach ($json as $key => $value) { + if ($value['source_order_id'] == $res['bhoid']) { + $find->need_num = $find->need_num - $value['need_num']; + unset($json[$key]); + break; + } + } + $find->source_order_info = array_values($json); + } + if ($find->need_num <= 0) { + $find->delete_time = time(); + } + $find->save(); + } + } + $res->save(['is_buyer'=>-1]); + if($res){ + return $this->success('操作成功',[],1,1); + }else{ + return $this->fail('操作失败'); + } + } + + + /** + * @notes 一键入库 + */ + public function one_click_storage(){ + $params=$this->request->post(); + $params['admin_id']=$this->adminId; + BeforehandOrderCartInfoLogic::oneClickStorage($params); + return $this->success('入库成功', [], 1, 1); + } + /** + * @notes 编辑预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function edit() + { + $params = $this->request->post(); + $params['admin_id']=$this->adminId; + $result = BeforehandOrderCartInfoLogic::edit($params); + return $this->success('编辑成功', [], 1, 1); + + } + + + /** + * @notes 删除预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function delete() + { + $params = $this->request->post(); + BeforehandOrderCartInfoLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取预订单购物详情表详情 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function detail() + { + $params = $this->request->get(); + $result = BeforehandOrderCartInfoLogic::detail($params); + return $this->data($result); + } + /** + * 修改数量 + */ + public function edit_nums() + { + $params = $this->request->post(); + $result = BeforehandOrderCartInfoLogic::editNums($params); + return $this->data($result); + } + + public function fix() + { + $params = $this->request->get(); + BeforehandOrderCartInfoLogic::fixAcceptNum($params); + return $this->data([]); + } + +} \ No newline at end of file diff --git a/app/store/controller/store_product/StoreProductController.php b/app/store/controller/store_product/StoreProductController.php index c873d0331..1372813d0 100644 --- a/app/store/controller/store_product/StoreProductController.php +++ b/app/store/controller/store_product/StoreProductController.php @@ -4,6 +4,7 @@ namespace app\store\controller\store_product; use app\admin\lists\store_branch_product\StoreBranchProductLists; +use app\admin\lists\store_product\StoreProductLists; use app\common\controller\Definitions; use app\store\controller\BaseAdminController; use app\store\logic\store_branch_product\StoreBranchProductLogic; @@ -139,4 +140,13 @@ class StoreProductController extends BaseAdminController { return $this->fail('门店禁止手动增减商品库存'); } + + /** + * 商品列表 + */ + public function adminLists() + { + return $this->dataLists(new StoreProductLists()); + } + }