From 730dc782698f710ec3fb8b52a5f57ca3e086f12a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 19 Sep 2024 15:25:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=92=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../warehouse_order/WarehouseOrderLists.php | 73 ++++++++++++++++--- .../logic/store_order/StoreOrderLogic.php | 4 +- app/api/logic/order/OrderLogic.php | 8 +- app/common/logic/CapitalFlowLogic.php | 14 ++-- 4 files changed, 80 insertions(+), 19 deletions(-) diff --git a/app/admin/lists/warehouse_order/WarehouseOrderLists.php b/app/admin/lists/warehouse_order/WarehouseOrderLists.php index 491184e7b..df831b171 100644 --- a/app/admin/lists/warehouse_order/WarehouseOrderLists.php +++ b/app/admin/lists/warehouse_order/WarehouseOrderLists.php @@ -10,13 +10,14 @@ use app\common\model\auth\Admin; use app\common\model\supplier\Supplier; use app\common\model\system_store\SystemStore; use app\common\model\warehouse\Warehouse; +use app\common\lists\ListsExcelInterface; /** * 仓储商品单列表 * Class WarehouseOrderLists * @package app\admin\listswarehouse_order */ -class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInterface +class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface { @@ -29,8 +30,8 @@ class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInter public function setSearch(): array { return [ - '='=>['financial_pm','supplier_id','warehouse_id','store_id'], - 'between_time' => 'create_time' + '=' => ['financial_pm', 'supplier_id', 'warehouse_id', 'store_id'], + 'between_time' => 'create_time' ]; } @@ -47,20 +48,20 @@ class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInter public function lists(): array { return WarehouseOrder::where($this->searchWhere) - ->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'code', 'financial_pm', 'admin_id', 'batch', 'mark', 'purchase', 'total_price', 'status', 'create_time','completed_amount','outstanding_amount']) + ->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'code', 'financial_pm', 'admin_id', 'batch', 'mark', 'purchase', 'total_price', 'status', 'create_time', 'completed_amount', 'outstanding_amount']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item){ + ->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->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) { @@ -91,5 +92,55 @@ class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInter { return WarehouseOrder::where($this->searchWhere)->count(); } + /** + * @notes 导出文件名 + * @return string + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + $financial_pm = $this->request->get('financial_pm'); + if ($financial_pm == 0) { + return '出库单列表'; + } else { + return '入库单列表'; + } + } -} \ No newline at end of file + + /** + * @notes 导出字段 + * @return string[] + * @date 2022/11/24 16:17 + */ + 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' => '备注', + ]; + } + return $data; + } +} diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index d340cad97..02a3e8f97 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -11,6 +11,7 @@ use app\common\model\store_order\StoreOrder; use app\common\logic\BaseLogic; use app\common\logic\CommissionnLogic; use app\common\logic\PayNotifyLogic; +use app\common\model\dict\DictData; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_finance_flow_product\StoreFinanceFlowProduct; @@ -42,11 +43,12 @@ class StoreOrderLogic extends BaseLogic public static function add(array $params): bool { $cartId = []; + $vendors_store=DictData::where('type_value','vendors_store')->column('value'); foreach ($params['product_arr'] as $k => $v) { $v['uid'] = $params['user_id']; $v['store_id'] = $params['store_id']; $v['cart_num'] = $v['stock']; - if(in_array($params['store_id'],[17,18])){ + if(in_array($params['store_id'],$vendors_store)){ StoreBranchProduct::where('id', $v['id'])->update(['price' => $v['price'], 'vip_price' => $v['price'], 'cost' => $v['price'], 'purchase' => $v['price']]); } unset($v['id']); diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index b87517eb0..a3f0b74c8 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -95,8 +95,12 @@ class OrderLogic extends BaseLogic if($source==0){ $source=$v['source']; } - $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); - + if ($source == 2) { + $field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find(); + } else { + $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); + } if (!$find) { throw new BusinessException('商品不存在'); } diff --git a/app/common/logic/CapitalFlowLogic.php b/app/common/logic/CapitalFlowLogic.php index 6590a2759..bd4e7c410 100644 --- a/app/common/logic/CapitalFlowLogic.php +++ b/app/common/logic/CapitalFlowLogic.php @@ -100,7 +100,7 @@ class CapitalFlowLogic extends BaseLogic * @param $mark * @return mixed */ - public function storeIncome($category, $linkType, $linkId, $amount, $mark = '',$key='') + public function storeIncome($category, $linkType, $linkId, $amount, $mark = '', $key = '') { $model = new CapitalFlow(); $model->store_id = $this->store['id']; @@ -108,8 +108,8 @@ class CapitalFlowLogic extends BaseLogic $model->link_type = $linkType; $model->link_id = $linkId; $model->amount = $amount; - $model->before_balance = $this->store[$key]??0; - $model->balance = bcadd($this->store[$key]??0, $amount, 2); + $model->before_balance = $this->store[$key] ?? 0; + $model->balance = bcadd($this->store[$key] ?? 0, $amount, 2); $model->create_time = date('Y-m-d H:i:s'); $model->type = 'in'; $model->title = $this->getTitle($category, $amount); @@ -129,7 +129,7 @@ class CapitalFlowLogic extends BaseLogic * @param $mark * @return mixed */ - public function storeExpense($category, $linkType, $linkId, $amount, $mark = '',$key='') + public function storeExpense($category, $linkType, $linkId, $amount, $mark = '', $key = '') { $model = new CapitalFlow(); $model->store_id = $this->store['store_id']; @@ -138,7 +138,7 @@ class CapitalFlowLogic extends BaseLogic $model->link_type = $linkType; $model->link_id = $linkId; $model->amount = $amount; - $model->before_balance = $this->store[$key]??0; + $model->before_balance = $this->store[$key] ?? 0; $model->balance = bcsub($this->store[$key], $amount, 2); $model->create_time = date('Y-m-d H:i:s'); $model->type = 'out'; @@ -188,6 +188,10 @@ class CapitalFlowLogic extends BaseLogic return "订单退回到采购款{$amount}元"; case 'store_paid_deposit_add': return "门店增加保证金{$amount}元"; + case 'store_attrition_add': + return "门店增加损耗金{$amount}元"; + case 'store_money_add': + return "门店增加余额{$amount}元"; default: return "订单支付{$amount}元"; }