diff --git a/app/admin/controller/delivery_service/DeliveryServiceController.php b/app/admin/controller/delivery_service/DeliveryServiceController.php new file mode 100644 index 0000000..66ce172 --- /dev/null +++ b/app/admin/controller/delivery_service/DeliveryServiceController.php @@ -0,0 +1,95 @@ +dataLists(new DeliveryServiceLists()); + } + + + /** + * @notes 添加配送员 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function add() + { + $params = (new DeliveryServiceValidate())->post()->goCheck('add'); + $result = DeliveryServiceLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(DeliveryServiceLogic::getError()); + } + + + /** + * @notes 编辑配送员 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function edit() + { + $params = (new DeliveryServiceValidate())->post()->goCheck('edit'); + $result = DeliveryServiceLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(DeliveryServiceLogic::getError()); + } + + + /** + * @notes 删除配送员 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function delete() + { + $params = (new DeliveryServiceValidate())->post()->goCheck('delete'); + DeliveryServiceLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取配送员详情 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function detail() + { + $params = (new DeliveryServiceValidate())->goCheck('detail'); + $result = DeliveryServiceLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/delivery_service/DeliveryServiceLists.php b/app/admin/lists/delivery_service/DeliveryServiceLists.php new file mode 100644 index 0000000..5940c9c --- /dev/null +++ b/app/admin/lists/delivery_service/DeliveryServiceLists.php @@ -0,0 +1,65 @@ + ['uid', 'nickname', 'phone', 'status','type'], + ]; + } + + + /** + * @notes 获取配送员列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/08/08 14:07 + */ + public function lists(): array + { + return DeliveryService::where($this->searchWhere) + ->field(['id', 'uid', 'nickname', 'phone', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取配送员数量 + * @return int + * @author admin + * @date 2024/08/08 14:07 + */ + public function count(): int + { + return DeliveryService::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index d1201c4..e4f0267 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -16,6 +16,7 @@ use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use app\common\lists\ListsExcelInterface; +use app\common\model\psi\warehouse_storege\WarehouseStorege; /** * 商品列表列表 @@ -54,49 +55,17 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa */ public function lists(): array { - $class_all = $this->request->get('class_all'); - if ($class_all) { - //查3级别的 - $arr = Cate::where('pid', $class_all)->column('id'); - if ($arr) { - $arr2 = Cate::where('pid', 'in', $arr)->column('id'); - $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)]; - } else { - $this->searchWhere[] = ['cate_id', '=', $class_all]; - } - } $is_warehouse = $this->request->get('is_warehouse', 0); $order_type = $this->request->get('order_type', 0); - $userShip = 0; - if (!empty($this->params['user_id'])) { - $userShip = User::where('id', $this->params['user_id'])->value('user_ship'); - } + $query = StoreProduct::where($this->searchWhere); - if (isset($this->params['type_filter'])) { - $query->where('product_type', '<>', 5); - if ($this->params['type_filter'] == 0) { - $query->where(function ($query) { - $query->where('product_type', 6)->whereOr('is_show', 0); - }); - } else { - $query->where('is_show', 1); - } - } - if (!empty($this->params['activity_zone_form_id'])) { - $exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id'); - $query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds); - } - $storeId = $this->params['store_id'] ?? 0; + $is_true = true; - if ($storeId > 0) { - $is_true = SystemStore::isSelfOperate($storeId); - } - if (!empty($this->params['product_status'])) { - $query->onlyTrashed(); - } + + $list = $query->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use ($is_warehouse, $userShip, $order_type, $is_true) { + ->select()->each(function ($item) use ($is_warehouse,$order_type, $is_true) { $item['product_id'] = $item['id']; $item['bar_code_two'] = ''; if (in_array($item['unit'], [2, 21])) { @@ -134,38 +103,16 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['product_type_name'] = '普通商品'; } $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); - $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); $category = StoreCategory::where('id', 'in', [$item['top_cate_id'], $item['two_cate_id'], $item['cate_id']])->column('name'); $item['cate_name'] = implode('/', $category); - if ($is_warehouse == 1) { - $item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); - } else { - $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); - $item['stock'] = bcadd($nums, $stock); - } - if ($userShip == 4) { - $item['price'] = $item['cost']; - } + $item['stock'] = WarehouseStorege::where('product_id', $item['id'])->sum('nums'); if ($item['is_show'] == 1) { $item['status_msg'] = '上架|常用'; } else { $item['status_msg'] = '下架|不常用|是否有替换'; } - if ($order_type == 2) { - $price = StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); - if ($price > 0) { - $item['price'] = $price; - $item['store_name'] = $item['store_name'] . '|活动价'; - } - }elseif($is_true == true && $userShip>0){ - $item['price'] = $item['vip_price']; - $item['store_name'] = $item['store_name'] . '|会员价'; - } return $item; })?->toArray(); - // if ($userShip > 0 && $userShip != 4) { - // $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0); - // } return $list; } @@ -178,33 +125,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa */ public function count(): int { - $export = $this->request->get('export'); - if ($export == 1) { - $class_all = $this->request->get('class_all'); - if ($class_all) { - //查3级别的 - $arr = Cate::where('pid', $class_all)->column('id'); - if ($arr) { - $arr2 = Cate::where('pid', 'in', $arr)->column('id'); - $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)]; - } else { - $this->searchWhere[] = ['cate_id', '=', $class_all]; - } - } - } $query = StoreProduct::where($this->searchWhere); - if (isset($this->params['type_filter'])) { - if ($this->params['type_filter'] == 0) { - $query->where(function ($query) { - $query->where('product_type', 6)->whereOr('is_show', 0); - }); - } else { - $query->where('is_show', 1); - } - } - if (!empty($this->params['product_status'])) { - $query->onlyTrashed(); - } return $query->count(); } @@ -239,7 +160,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa 'purchase' => '采购价', 'cost' => '商户', 'price' => '零售', - 'rose' => '毛利率', 'bar_code' => '条码', ]; return $data; diff --git a/app/admin/lists/supplier/SupplierLists.php b/app/admin/lists/supplier/SupplierLists.php index 9d82998..8ec4574 100644 --- a/app/admin/lists/supplier/SupplierLists.php +++ b/app/admin/lists/supplier/SupplierLists.php @@ -44,7 +44,7 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface public function lists(): array { return Supplier::where($this->searchWhere) - ->field(['id', 'category_id', 'mer_name', 'phone', 'settle_cycle', 'address', 'mark']) + ->field(['id', 'category_id', 'name', 'phone', 'settle_cycle', 'address', 'mark']) ->limit($this->limitOffset, 100) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/common/model/psi/psi_order/PsiOrder.php b/app/common/model/delivery_service/DeliveryService.php similarity index 50% rename from app/common/model/psi/psi_order/PsiOrder.php rename to app/common/model/delivery_service/DeliveryService.php index 310b0ff..6ab230f 100644 --- a/app/common/model/psi/psi_order/PsiOrder.php +++ b/app/common/model/delivery_service/DeliveryService.php @@ -1,6 +1,6 @@ dataLists(new PsiOrderLists()); + return $this->dataLists(new PurchaseOrderLists()); } @@ -58,7 +56,8 @@ class PsiOrderController extends BaseAdminController { $params = $this->request->post(); $params['admin_id'] = $this->adminId; - $result = WarehouseOrderLogic::add($params); + $params['warehouse_id']=1; + $result = PurchaseOrderLogic::add($params); if (true === $result) { return $this->success('添加成功', [], 1, 1); } diff --git a/app/psi/controller/psi_product/PsiProductController.php b/app/psi/controller/purchase_product/PurchaseProductController.php similarity index 91% rename from app/psi/controller/psi_product/PsiProductController.php rename to app/psi/controller/purchase_product/PurchaseProductController.php index 5cd9a39..03d1eeb 100644 --- a/app/psi/controller/psi_product/PsiProductController.php +++ b/app/psi/controller/purchase_product/PurchaseProductController.php @@ -1,19 +1,19 @@ dataLists(new PsiProductLists()); + return $this->dataLists(new PurchaseProductLists()); } diff --git a/app/psi/lists/psi_order/PsiOrderLists.php b/app/psi/lists/purchase_order/PurchaseOrderLists.php similarity index 50% rename from app/psi/lists/psi_order/PsiOrderLists.php rename to app/psi/lists/purchase_order/PurchaseOrderLists.php index e210f4d..6f6c61e 100644 --- a/app/psi/lists/psi_order/PsiOrderLists.php +++ b/app/psi/lists/purchase_order/PurchaseOrderLists.php @@ -1,23 +1,22 @@ ['financial_pm', 'supplier_id', 'warehouse_id', 'store_id','id'], - '%like'=>['code'], + '=' => ['warehouse_id', 'id'], + '%like' => ['code'], 'between_time' => 'create_time' ]; } @@ -48,23 +47,12 @@ class PsiOrderLists extends BaseAdminDataLists implements ListsSearchInterface, */ public function lists(): array { - return PsiOrder::where($this->searchWhere) - ->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'code', 'financial_pm', 'admin_id', 'batch', 'mark', 'purchase', 'total_price', 'status', 'create_time','oid', 'order_type']) + return PurchaseOrder::where($this->searchWhere) + ->field(['id', 'code', 'admin_id', 'batch', 'mark', 'total_price', 'status', 'create_time', 'oid', 'order_type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { - if ($item->financial_pm == 0) { - $item->financial_pm_name = '出库'; - } else { - $item->financial_pm_name = '入库'; - } - if ($item->financial_pm == 0) { - if ($item->store_id) { - $item->system_store = SystemStore::where('id', $item->store_id)->value('name'); - } else { - $item->system_store = ''; - } - } + if ($item->admin_id) { $item->admin_name = Admin::where('id', $item->admin_id)->value('name'); } else { @@ -75,11 +63,6 @@ class PsiOrderLists extends BaseAdminDataLists implements ListsSearchInterface, } else { $item->warehouse_name = ''; } - if ($item->supplier_id) { - $item->supplier_name = Supplier::where('id', $item->supplier_id)->value('mer_name'); - }else{ - $item->supplier_name = ''; - } if (!empty($item['order_type'])) { $item->order_type_name = getOrderTypeName($item->order_type); } @@ -96,7 +79,7 @@ class PsiOrderLists extends BaseAdminDataLists implements ListsSearchInterface, */ public function count(): int { - return PsiOrder::where($this->searchWhere)->count(); + return PurchaseOrder::where($this->searchWhere)->count(); } /** * @notes 导出文件名 @@ -121,32 +104,15 @@ class PsiOrderLists extends BaseAdminDataLists implements ListsSearchInterface, */ public function setExcelFields(): array { - $financial_pm = $this->request->get('financial_pm'); - if ($financial_pm == 1) { - $data = [ - 'create_time' => '操作时间', - 'warehouse_name' => '仓库', - 'supplier_name' => '供应商', - 'code' => '单号', - 'financial_pm_name' => '状态', - 'admin_name' => '填写人员', - 'completed_amount' => '已结金额', - 'outstanding_amount' => '未结金额', - 'total_price' => '总金额', - 'mark' => '备注', - ]; - } else { - $data = [ - 'create_time' => '操作时间', - 'warehouse_name' => '仓库', - 'supplier_name' => '供应商', - 'code' => '单号', - 'financial_pm_name' => '状态', - 'admin_name' => '填写人员', - 'total_price' => '总金额', - 'mark' => '备注', - ]; - } + $data = [ + 'create_time' => '操作时间', + 'warehouse_name' => '仓库', + 'code' => '单号', + 'admin_name' => '填写人员', + 'total_price' => '总金额', + 'mark' => '备注', + ]; + return $data; } } diff --git a/app/psi/lists/psi_product/PsiProductLists.php b/app/psi/lists/purchase_product/PurchaseProductLists.php similarity index 59% rename from app/psi/lists/psi_product/PsiProductLists.php rename to app/psi/lists/purchase_product/PurchaseProductLists.php index 1a1f5d4..fe905d7 100644 --- a/app/psi/lists/psi_product/PsiProductLists.php +++ b/app/psi/lists/purchase_product/PurchaseProductLists.php @@ -1,6 +1,6 @@ ['warehouse_id', 'financial_pm', 'product_id','store_id','oid','supplier_id','is_pay','code'], + '=' => ['warehouse_id', 'product_id','oid','supplier_id','code'], 'between_time' => 'create_time' ]; } @@ -72,11 +72,11 @@ class PsiProductLists extends BaseAdminDataLists implements ListsSearchInterface return []; } } - $query = PsiProduct::where($this->searchWhere); + $query = PurchaseProduct::where($this->searchWhere); if (isset($this->params['is_group']) && $this->params['is_group'] == 1) { - $query->group('product_id')->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'sum(nums) nums', 'price', 'purchase', 'cost', 'sum(total_price) total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay', 'order_type','vip_price']); + $query->group('product_id')->field(['id', 'code','oid','admin_id','supplier_id', 'warehouse_id', 'product_id', 'sum(nums) nums', 'price', 'sum(total_price) total_price', 'manufacture', 'expiration_date', 'mark', 'create_time', 'order_type']); } else { - $query->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay', 'order_type','vip_price']); + $query->field(['id', 'code','oid','admin_id','supplier_id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'manufacture', 'expiration_date', 'mark', 'create_time', 'order_type']); } return $query ->limit($this->limitOffset, $this->limitLength) @@ -86,27 +86,11 @@ class PsiProductLists extends BaseAdminDataLists implements ListsSearchInterface $item->store_name = ''; $item->image = ''; $item->price = $item['price']??0; - $item->purchase = $item['purchase']??0; $item->unit_name = ''; $item->store_info = ''; $item->top_cate_name = ''; - if ($item->financial_pm == 0) { - $item->financial_pm_name = '出库'; - } else { - $item->financial_pm_name = '入库'; - } - if ($item->store_id > 0) { - $item->system_store_name = SystemStore::where('id', $item->store_id)->value('name'); - } else { - $item->system_store_name = ''; - } - if ($item->status == 0) { - $item->status_name = '未确认'; - } elseif ($item->status == 1) { - $item->status_name = '已确认'; - } else { - $item->status_name = '库存不足'; - } + $item->financial_pm_name = '入库'; + if ($item->admin_id) { $item->admin_name = Admin::where('id', $item->admin_id)->value('name'); } else { @@ -132,15 +116,10 @@ class PsiProductLists extends BaseAdminDataLists implements ListsSearchInterface }else{ $item->supplier_name = ''; } - $item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : ''; - $item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : ''; if (!empty($item['order_type'])) { $item->order_type_name = getOrderTypeName($item->order_type); } - if ($item->order_type == 5) { - $item->outbound = '无须出库'; - } }) ->toArray(); } @@ -155,9 +134,9 @@ class PsiProductLists extends BaseAdminDataLists implements ListsSearchInterface public function count(): int { if ($this->ids) { - return PsiProduct::whereIn('id', $this->ids)->where($this->searchWhere)->count(); + return PurchaseProduct::whereIn('id', $this->ids)->where($this->searchWhere)->count(); } else { - return PsiProduct::where($this->searchWhere)->count(); + return PurchaseProduct::where($this->searchWhere)->count(); } } /** @@ -168,11 +147,9 @@ class PsiProductLists extends BaseAdminDataLists implements ListsSearchInterface */ public function setFileName(): string { - $financial_pm = $this->request->get('financial_pm'); - if ($financial_pm == 1) { - return '入库列表'; - } - return '出库列表'; + + return '入库列表'; + } @@ -184,45 +161,22 @@ class PsiProductLists extends BaseAdminDataLists implements ListsSearchInterface */ public function setExcelFields(): array { - $financial_pm = $this->request->get('financial_pm'); - if ($financial_pm == 1) { + $data = [ 'admin_name' => '操作人员', 'warehouse_name' => '仓库', 'supplier_name' => '供应商', 'store_name' => '商品名称', 'financial_pm_name' => '出入库', - 'code' => '入库单', + 'code' => '入库单号', 'batch' => '批次', 'nums' => '数量', 'manufacture' => '生产日期', 'expiration_date' => '保质期', - 'purchase' => '采购价', - 'price' => '零售', + 'price' => '采购价', 'total_price' => '总价', 'create_time' => '操作时间', ]; - } else { - $data = [ - 'id' => 'id', - 'admin_name' => '操作人员', - 'warehouse_name' => '仓库', - 'store_name' => '商品名称', - 'top_cate_name' => '分类', - 'store_info' => '规格', - 'unit_name' => '单位', - 'financial_pm_name' => '出入库', - 'code' => '出库单', - 'system_store_name' => '门店', - 'nums' => '数量', - 'purchase' => '供货价', - 'vip_price' => '会员价', - 'price' => '零售价', - 'total_price' => '供货总价', - 'create_time' => '操作时间', - ]; - } - return $data; } } diff --git a/app/psi/logic/psi_order/PsiOrderLogic.php b/app/psi/logic/purchase_order/PurchaseOrderLogic.php similarity index 79% rename from app/psi/logic/psi_order/PsiOrderLogic.php rename to app/psi/logic/purchase_order/PurchaseOrderLogic.php index a2aa5b2..10ec2c5 100644 --- a/app/psi/logic/psi_order/PsiOrderLogic.php +++ b/app/psi/logic/purchase_order/PurchaseOrderLogic.php @@ -1,21 +1,24 @@ $params['warehouse_id'], - 'supplier_id' => $params['supplier_id'], - 'code' => $params['code'], + 'order_type' => $params['order_type']??0, + 'oid' => 0, 'admin_id' => $params['admin_id'], - 'financial_pm' => 1, 'batch' => 0, - 'mark' => $params['remark'], - 'total_price' => $params['remark'], - 'completed_amount' => $params['completed_amount']??0, - 'outstanding_amount' => $params['outstanding_amount']??0, + 'code' => $code, + 'mark' => $params['remark'] ?? '', + 'total_price' => 0 ]; - - $total_price = 0; - foreach ($params['product_arr'] as $k => $v) { - $total_price += $v['total_price']; - } - $arr['total_price'] = $total_price; - $res = WarehouseOrder::create($arr); + $res = PurchaseOrder::create($arr); + $product_arr=[]; foreach ($params['product_arr'] as $k => $v) { + if($v['product_id']<=0){ + continue ; + } $data['admin_id'] = $params['admin_id']; + $data['order_type'] = $params['order_type']; $data['store_id'] = 0; $data['oid'] = $res['id']; - $data['supplier_id'] = $params['supplier_id']; + $data['supplier_id'] = 0; $data['warehouse_id'] = $params['warehouse_id']; - $data['code'] = $params['code']; + $data['code'] = $code; $data['product_id'] = $v['product_id']; + $data['need_nums'] = $v['nums']; $data['nums'] = $v['nums']; - $data['purchase'] = $v['purchase']; + $data['price'] = $v['price']; $data['total_price'] = $v['total_price']; - $data['financial_pm'] = 1; - if (!empty($v['manufacture'])) { - $data['manufacture'] = $v['manufacture']; - } - if (!empty($v['expiration_date'])) { - $data['expiration_date'] = $v['expiration_date']; - } - WarehouseProductLogic::add($data,1,$params['admin_id']); + $product_arr[]=$data; } + (new PurchaseProduct())->saveAll($product_arr); + $total_price=PurchaseProduct::where('oid', $res['id'])->sum('total_price'); + PurchaseOrder::where('id', $res['id'])->update(['total_price' => $total_price]); Db::commit(); return true; } catch (\Throwable $e) { Db::rollback(); - throw new BusinessException($e->getMessage()); + throw new Exception($e->getMessage()); } }