diff --git a/app/admin/controller/inventory_transfer_order/InventoryTransferOrderController.php b/app/admin/controller/inventory_transfer_order/InventoryTransferOrderController.php index 26c3147b..765e0680 100644 --- a/app/admin/controller/inventory_transfer_order/InventoryTransferOrderController.php +++ b/app/admin/controller/inventory_transfer_order/InventoryTransferOrderController.php @@ -91,5 +91,17 @@ class InventoryTransferOrderController extends BaseAdminController return $this->data($result); } + /** + * @notes 审核商品调拨订单 + * @author admin + * @date 2025/01/24 09:59 + */ + public function audit() + { + $params = (new InventoryTransferOrderValidate())->post()->goCheck('delete'); + $order = InventoryTransferOrderLogic::detail($params); + InventoryTransferOrderLogic::audit($order); + return $this->success('删除成功', [], 1, 1); + } } \ No newline at end of file diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index 54dfe5a4..07eac52e 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -106,6 +106,7 @@ class WarehouseOrderController extends BaseAdminController 'admin_id' => $this->adminId, 'type' => $type, 'order_type' => 0, + 'code' => $code, ]; $storeProduct = StoreProduct::where('id', $arr['id'])->find(); $data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2); diff --git a/app/admin/lists/inventory_transfer/InventoryTransferLists.php b/app/admin/lists/inventory_transfer/InventoryTransferLists.php index e875741f..a21e93ac 100644 --- a/app/admin/lists/inventory_transfer/InventoryTransferLists.php +++ b/app/admin/lists/inventory_transfer/InventoryTransferLists.php @@ -33,7 +33,7 @@ class InventoryTransferLists extends BaseAdminDataLists implements ListsSearchIn public function setSearch(): array { return [ - '=' => ['type'], + '=' => ['type', 'product_id'], 'between_time' => 'create_time' ]; } @@ -70,7 +70,11 @@ class InventoryTransferLists extends BaseAdminDataLists implements ListsSearchIn return []; } } - return InventoryTransfer::where($this->searchWhere) + $query = InventoryTransfer::where($this->searchWhere); + if (!empty($this->params['warehouse_id'])) { + $query->whereRaw("(one_type=2 and one_id={$this->params['warehouse_id']}) or (two_type=2 and two_id={$this->params['warehouse_id']})"); + } + return $query ->field(['id','oid', 'product_id', 'nums', 'one_before_nums', 'one_after_nums','two_before_nums','two_after_nums', 'one_type','two_type', 'one_id', 'two_id', 'create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) @@ -117,7 +121,11 @@ class InventoryTransferLists extends BaseAdminDataLists implements ListsSearchIn return 0; } } else { - return InventoryTransfer::where($this->searchWhere)->count(); + $query = InventoryTransfer::where($this->searchWhere); + if (!empty($this->params['warehouse_id'])) { + $query->whereRaw("(one_type=2 and one_id={$this->params['warehouse_id']}) or (two_type=2 and two_id={$this->params['warehouse_id']})"); + } + return $query->count(); } } diff --git a/app/admin/lists/inventory_transfer_order/InventoryTransferOrderLists.php b/app/admin/lists/inventory_transfer_order/InventoryTransferOrderLists.php index 86115fe9..ea64eec8 100644 --- a/app/admin/lists/inventory_transfer_order/InventoryTransferOrderLists.php +++ b/app/admin/lists/inventory_transfer_order/InventoryTransferOrderLists.php @@ -45,7 +45,7 @@ class InventoryTransferOrderLists extends BaseAdminDataLists implements ListsSea public function lists(): array { return InventoryTransferOrder::where($this->searchWhere) - ->field(['id', 'order_id', 'one_id', 'one_type', 'two_id', 'two_type', 'types', 'total_nums', 'total_price','mark']) + ->field(['id', 'order_id', 'one_id', 'one_type', 'two_id', 'two_type', 'types', 'total_nums', 'total_price','mark', 'status']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php b/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php index cb6dbd1e..7d9c42eb 100644 --- a/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php +++ b/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php @@ -84,60 +84,16 @@ class InventoryTransferOrderLogic extends BaseLogic 'two_id' => $params['two_id'], 'types' => $types, 'mark' => $params['mark']??'', + 'status' => ($params['two_type'] == 2 && $types == 0) ? 0 : 1, ]); foreach ($insert as $k => $v) { $insert[$k]['oid'] = $order['id']; } InventoryTransfer::insertAll($insert); - if($types==1){ - Db::commit(); - return true; + if($types==0 && $params['two_type']==1){ + self::audit($params, $insert, $admin_id); } - foreach ($insert as $v) { - if($params['one_type']==1){ - $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find(); - $find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]); - SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); - } elseif ($params['one_type'] == 2) { - $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['one_id'])->find(); - $find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); - } - if($params['two_type']==1){ - $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['two_id'])->find(); - if (empty($find)) { - $storeProduct = StoreProduct::field('top_cate_id,two_cate_id,cate_id,store_name,image,price,vip_price,cost,purchase,keyword,bar_code,store_info,rose,product_type,unit,batch,store_batch,label_id,is_lack,manufacturer_information')->where('id', $v['product_id'])->find()->toArray(); - $find = new StoreBranchProduct(); - $find->product_id = $v['product_id']; - $find->store_id = $params['two_id']; - $find->stock = $v['nums']; - $find->setAttrs($storeProduct); - $find->save(); - } else { - $find->save(['stock' =>bcadd( $find['stock'],$v['nums'],2)]); - } - SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); - } elseif ($params['two_type'] == 2) { - $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['two_id'])->find(); - if (empty($find)) { - $find = new WarehouseProductStorege(); - $find->warehouse_id = $params['two_id']; - $find->product_id = $v['product_id']; - $find->nums = $v['nums']; - $find->save(); - } else { - $find->save(['nums' =>bcadd( $find['nums'],$v['nums'],2)]); - } - SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); - } - $productSourceLinkInfoLogic = new ProductSourceLinkInfoLogic(); - $productSourceLinkInfoLogic->setInfo([ - 'oid' => $v['oid'], - 'product_id' => $v['product_id'], - ]); - $productSourceLinkInfoLogic->transfer(); - } Db::commit(); return true; } catch (\Throwable $e) { @@ -146,6 +102,59 @@ class InventoryTransferOrderLogic extends BaseLogic } } + public static function audit($order = null, $products = null, $admin_id = 0) + { + if (empty($products)) { + $products = InventoryTransfer::where('oid', $order['id'])->select()->toArray(); + } + foreach ($products as $v) { + if($order['one_type']==1){ + $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $order['one_id'])->find(); + $find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]); + SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); + } elseif ($order['one_type'] == 2) { + $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $order['one_id'])->find(); + $find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]); + SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); + } + if($order['two_type']==1){ + $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $order['two_id'])->find(); + if (empty($find)) { + $storeProduct = StoreProduct::field('top_cate_id,two_cate_id,cate_id,store_name,image,price,vip_price,cost,purchase,keyword,bar_code,store_info,rose,product_type,unit,batch,store_batch,label_id,is_lack,manufacturer_information')->where('id', $v['product_id'])->find()->toArray(); + $find = new StoreBranchProduct(); + $find->product_id = $v['product_id']; + $find->store_id = $order['two_id']; + $find->stock = $v['nums']; + $find->setAttrs($storeProduct); + $find->save(); + } else { + $find->save(['stock' =>bcadd( $find['stock'],$v['nums'],2)]); + } + SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); + } elseif ($order['two_type'] == 2) { + $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $order['two_id'])->find(); + if (empty($find)) { + $find = new WarehouseProductStorege(); + $find->warehouse_id = $order['two_id']; + $find->product_id = $v['product_id']; + $find->nums = $v['nums']; + $find->save(); + } else { + $find->save(['nums' =>bcadd( $find['nums'],$v['nums'],2)]); + } + SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); + } + InventoryTransferOrder::where('id', $order['id'])->update(['status' => 1]); + + $productSourceLinkInfoLogic = new ProductSourceLinkInfoLogic(); + $productSourceLinkInfoLogic->setInfo([ + 'oid' => $v['oid'], + 'product_id' => $v['product_id'], + ]); + $productSourceLinkInfoLogic->transfer(); + } + } + /** * @notes 编辑商品调拨订单 diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index e3acc8ca..376af570 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -55,7 +55,7 @@ class WarehouseProductLogic extends BaseLogic $total_price = bcmul($after_nums, $storeProduct['purchase'], 2); } WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price], ['id' => $storege['id']]); - SqlChannelLog('WarehouseProductStorege', $storege['id'], $after_nums, 1, Request()->url(),$admin_id); + SqlChannelLog('WarehouseProductStorege', $storege['id'], $params['nums'], 1, Request()->url(),$admin_id); } } else { @@ -149,7 +149,7 @@ class WarehouseProductLogic extends BaseLogic $after_nums = bcsub($storege['nums'], $params['nums']); $total_price = bcmul($after_nums, $params['purchase'], 2); WarehouseProductStorege::update(['nums' => bcsub($storege['nums'], $params['nums']), 'total_price' => $total_price], ['id' => $storege['id']]); - SqlChannelLog('WarehouseProductStorege', $storege['id'], bcsub($storege['nums'], $params['nums']), -1, Request()->url(),$admin_id); + SqlChannelLog('WarehouseProductStorege', $storege['id'], $params['nums'], -1, Request()->url(),$admin_id); } else { $data = [ 'warehouse_id' => $params['warehouse_id'], @@ -158,7 +158,7 @@ class WarehouseProductLogic extends BaseLogic 'total_price' => 0 ]; $storege = WarehouseProductStorege::create($data); - SqlChannelLog('WarehouseProductStorege', $storege->id, -$params['nums'], -1, Request()->url(),$admin_id); + SqlChannelLog('WarehouseProductStorege', $storege->id, $params['nums'], -1, Request()->url(),$admin_id); } } else { $storege['nums'] = 0; diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 05fc6f4f..8b119e06 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -125,6 +125,9 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis if ($off_activity == 0 && $user_ship == 5 && $item['top_cate_id'] == 15189) { $item['price'] = $item['cost']; } + if ($user_ship == 4) { + $item['price'] = $item['cost']; + } if($item['is_lack']==1){ $tag='缺货'; }