diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index 444ab116..86a9b49e 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -336,7 +336,7 @@ class WorkbenchController extends BaseAdminController public function update_negative_zero() { $parmas = $this->request->get(); - $res = WarehouseLogic::updateNegativeZero($parmas); + $res = WarehouseLogic::updateNegativeZero($parmas,$this->adminId); if($res){ return $this->data([], '操作成功'); }else{ diff --git a/app/admin/controller/inventory_transfer/InventoryTransferController.php b/app/admin/controller/inventory_transfer/InventoryTransferController.php index ee717520..4f57f4ec 100644 --- a/app/admin/controller/inventory_transfer/InventoryTransferController.php +++ b/app/admin/controller/inventory_transfer/InventoryTransferController.php @@ -39,7 +39,7 @@ class InventoryTransferController extends BaseAdminController public function add() { $params = (new InventoryTransferValidate())->post()->goCheck('add'); - $result = InventoryTransferLogic::add($params); + $result = InventoryTransferLogic::add($params,$this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index 56889932..8a819c7d 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -242,7 +242,7 @@ class StoreOrderController extends BaseAdminController $data['purchase'] = $storeProduct['purchase']; $data['oid'] = $res['id']; $data['financial_pm'] = 0; - WarehouseProductLogic::add($data); + WarehouseProductLogic::add($data,1,$this->adminId); $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); } diff --git a/app/admin/controller/system_store_storage/SystemStoreStorageController.php b/app/admin/controller/system_store_storage/SystemStoreStorageController.php index deb30eee..9e0f3534 100644 --- a/app/admin/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/admin/controller/system_store_storage/SystemStoreStorageController.php @@ -62,7 +62,7 @@ class SystemStoreStorageController extends BaseAdminController if($id==0){ return $this->fail('参数错误'); } - SystemStoreStorageLogic::edit(['id'=>$id,'admin_id'=>$this->adminId]); + SystemStoreStorageLogic::edit(['id'=>$id,'admin_id'=>$this->adminId], $this->adminId); return $this->success('操作成功',[]); } diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index 1053faee..54dfe5a4 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -113,7 +113,7 @@ class WarehouseOrderController extends BaseAdminController $data['oid'] = $res['id']; $data['financial_pm'] = 0; $data['price'] = $storeProduct['price']; - WarehouseProductLogic::setOutbound($data); + WarehouseProductLogic::setOutbound($data,1,$this->adminId); $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); } diff --git a/app/admin/controller/warehouse_product/WarehouseProductController.php b/app/admin/controller/warehouse_product/WarehouseProductController.php index 3a3368c3..9799ff4e 100644 --- a/app/admin/controller/warehouse_product/WarehouseProductController.php +++ b/app/admin/controller/warehouse_product/WarehouseProductController.php @@ -40,28 +40,28 @@ class WarehouseProductController extends BaseAdminController { return $this->fail('当前接口废弃'); - $params = $this->request->post(); + // $params = $this->request->post(); - foreach ($params['product_arr'] as $k => $v) { - $data['admin_id'] = $this->adminId; - $data['store_id'] = 0; - $data['supplier_id'] = $params['supplier_id']; - $data['warehouse_id'] = $params['warehouse_id']; - $data['code'] = $params['code']; - $data['product_id'] = $v['product_id']; - $data['nums'] = $v['nums']; - $data['purchase'] = $v['purchase']; - $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); - } - return $this->success('添加成功', [], 1, 1); + // foreach ($params['product_arr'] as $k => $v) { + // $data['admin_id'] = $this->adminId; + // $data['store_id'] = 0; + // $data['supplier_id'] = $params['supplier_id']; + // $data['warehouse_id'] = $params['warehouse_id']; + // $data['code'] = $params['code']; + // $data['product_id'] = $v['product_id']; + // $data['nums'] = $v['nums']; + // $data['purchase'] = $v['purchase']; + // $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); + // } + // return $this->success('添加成功', [], 1, 1); } @@ -90,7 +90,7 @@ class WarehouseProductController extends BaseAdminController public function delete() { $params = (new WarehouseProductValidate())->post()->goCheck('delete'); - WarehouseProductLogic::delete($params); + WarehouseProductLogic::delete($params,$this->adminId); return $this->success('删除成功', [], 1, 1); } @@ -140,7 +140,7 @@ class WarehouseProductController extends BaseAdminController public function set_nums() { $params=$this->request->post(); - $result = WarehouseProductLogic::settNums($params); + $result = WarehouseProductLogic::settNums($params,$this->adminId); return $this->success(''); } } diff --git a/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php b/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php index cca57105..103b4de6 100644 --- a/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php +++ b/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php @@ -56,7 +56,7 @@ class WarehouseProductStoregeController extends BaseAdminController public function edit() { $params = $this->request->post(); - $result = WarehouseProductStoregeLogic::edit($params); + $result = WarehouseProductStoregeLogic::edit($params,$this->adminId); return $this->success('编辑成功', [], 1, 1); } diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 4c9916f5..3128e932 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -417,7 +417,7 @@ class BeforehandOrderLogic extends BaseLogic 'code' => $res['code'], 'unit' => $arr['unit'] ?? 0, ]; - WarehouseProductLogic::setOutbound($data); + WarehouseProductLogic::setOutbound($data,1,$admin_id); } $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); @@ -491,7 +491,7 @@ class BeforehandOrderLogic extends BaseLogic 'code' => $res['code'], 'unit' => $arr['unit'] ?? 0, ]; - WarehouseProductLogic::setOutbound($data); + WarehouseProductLogic::setOutbound($data,1,$admin_id); } $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 25f59a5d..c243543b 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -254,7 +254,7 @@ class BeforehandOrderCartInfoLogic extends BaseLogic StoreProduct::where('id',$v['product_id'])->save($product_arr); } if ($data['nums'] > 0) { - WarehouseProductLogic::add($data); + WarehouseProductLogic::add($data,1,$params['admin_id']); } PurchaseProductOffer::where('id', $v['id'])->update(['status' => 1, 'is_storage' => 1]); } diff --git a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php index 39a61e46..736fc4b4 100644 --- a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php +++ b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php @@ -27,7 +27,7 @@ class InventoryTransferLogic extends BaseLogic * @author admin * @date 2024/08/13 16:18 */ - public static function add(array $params): bool + public static function add(array $params,$admin_id=0): bool { $one_before_nums = 0; $one_after_nums = 0; @@ -84,20 +84,20 @@ class InventoryTransferLogic extends BaseLogic if($params['one_type']==1){ $find=StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->find(); $find->save(['stock' =>bcsub( $find['stock'],$params['nums'],2)]); - SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], -1, Request()->url()); + SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], -1, Request()->url(),$admin_id); } elseif ($params['one_type'] == 2) { $find=WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->find(); $find->save(['nums' =>bcsub( $find['nums'],$params['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], -1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], -1, Request()->url(),$admin_id); } if($params['two_type']==1){ $find=StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->find(); $find->save(['stock' =>bcadd( $find['stock'],$params['nums'],2)]); - SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], 1, Request()->url()); + SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], 1, Request()->url(),$admin_id); } elseif ($params['two_type'] == 2) { $find=WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->find(); $find->save(['nums' =>bcadd( $find['nums'],$params['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], 1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], 1, Request()->url(),$admin_id); } Db::commit(); return true; diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index 191c5d51..831c77a4 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -267,17 +267,17 @@ class WarehouseLogic extends BaseLogic /** * 负库存更新归0 */ - public static function updateNegativeZero($parmas) + public static function updateNegativeZero($parmas,$admin_id=0) { if ($parmas['type'] == 1) { $res = StoreProduct::where('id', $parmas['id'])->update(['stock' => 0]); - SqlChannelLog('StoreProduct', $parmas['id'], 0, 0, Request()->url()); + SqlChannelLog('StoreProduct', $parmas['id'], 0, 0, Request()->url(),$admin_id); } elseif ($parmas['type'] == 2) { $res = StoreBranchProduct::where('id', $parmas['id'])->update(['stock' => 0]); - SqlChannelLog('StoreBranchProduct', $parmas['id'], 0, 0, Request()->url()); + SqlChannelLog('StoreBranchProduct', $parmas['id'], 0, 0, Request()->url(),$admin_id); } elseif ($parmas['type'] == 3) { $res = WarehouseProductStorege::where('id', $parmas['id'])->update(['nums' => 0]); - SqlChannelLog('WarehouseProductStorege', $parmas['id'], 0, 0, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $parmas['id'], 0, 0, Request()->url(),$admin_id); } return $res; } diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index e1394f7a..95a1debc 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -77,7 +77,7 @@ class StoreBranchProductLogic extends BaseLogic * @author admin * @date 2024/06/07 13:56 */ - public static function stock(array $params, $type = 1): bool + public static function stock(array $params, $type = 1,$admin_id=0): bool { Db::startTrans(); try { @@ -88,7 +88,7 @@ class StoreBranchProductLogic extends BaseLogic $branchStock = bcadd($storeBranchProduct['stock'], $params['nums'], 2); StoreBranchProduct::update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)],['id'=> $params['id']]); - SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], 1, Request()->url()); + SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], 1, Request()->url(),$admin_id); StoreProduct::update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)],['id'=> $params['product_id']]); } else { @@ -96,7 +96,7 @@ class StoreBranchProductLogic extends BaseLogic $stock = bcsub($find['stock'], $params['nums'], 2); StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)],['id'=>$params['id']]); - SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], -1, Request()->url()); + SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], -1, Request()->url(),$admin_id); StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)],['id'=>$params['product_id']]); } diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index 3622c5db..2309fcf9 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -59,7 +59,7 @@ class SystemStoreStorageLogic extends BaseLogic * @author admin * @date 2024/06/06 17:06 */ - public static function edit(array $params): bool + public static function edit(array $params,$admin_id=0): bool { Db::startTrans(); try { @@ -70,13 +70,13 @@ class SystemStoreStorageLogic extends BaseLogic $branch_product=StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->find(); if($branch_product){ $branch_product->save(['stock'=>$branch_product['stock']+$find['nums']]); - SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url()); + SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url(),$admin_id); }else{ $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct); $storeBranchProduct->stock = $find['nums']; $storeBranchProduct->save(); - SqlChannelLog('StoreBranchProduct', $storeBranchProduct['id'], $find['nums'], 1,Request()->url()); + SqlChannelLog('StoreBranchProduct', $storeBranchProduct['id'], $find['nums'], 1,Request()->url(),$admin_id); } }else{ $find->save(['status'=>1,'staff_id'=>$params['staff_id']??0,'admin_id'=>$params['admin_id']??0,'mark'=>'确认时间:'.date('Y-m-d H:i:s',time())]); diff --git a/app/admin/logic/warehouse_order/WarehouseOrderLogic.php b/app/admin/logic/warehouse_order/WarehouseOrderLogic.php index f2e97607..9734ad22 100644 --- a/app/admin/logic/warehouse_order/WarehouseOrderLogic.php +++ b/app/admin/logic/warehouse_order/WarehouseOrderLogic.php @@ -67,7 +67,7 @@ class WarehouseOrderLogic extends BaseLogic if (!empty($v['expiration_date'])) { $data['expiration_date'] = $v['expiration_date']; } - WarehouseProductLogic::add($data); + WarehouseProductLogic::add($data,1,$params['admin_id']); } Db::commit(); return true; @@ -118,7 +118,7 @@ class WarehouseOrderLogic extends BaseLogic $data['purchase'] = $v['prices']; $data['total_price'] = bcmul($v['prices'], $v['nums'], 2); } - WarehouseProductLogic::add($data); + WarehouseProductLogic::add($data,1,$params['admin_id']); } $find = WarehouseProduct::where('oid', $params['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); if ($find) { diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 1f96c6f0..e031fb19 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -33,7 +33,7 @@ class WarehouseProductLogic extends BaseLogic * @author admin * @date 2024/07/31 16:55 */ - public static function add(array $params, $type = 1) + public static function add(array $params, $type = 1,$admin_id=0) { // Db::startTrans(); try { @@ -53,7 +53,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()); + SqlChannelLog('WarehouseProductStorege', $storege['id'], $after_nums, 1, Request()->url(),$admin_id); } } else { @@ -77,7 +77,7 @@ class WarehouseProductLogic extends BaseLogic $data['nums'] = -$params['nums']; } $storege = WarehouseProductStorege::create($data); - SqlChannelLog('WarehouseProductStorege', $storege['id'], -$params['nums'], 1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $storege['id'], -$params['nums'], 1, Request()->url(),$admin_id); } } @@ -110,7 +110,7 @@ class WarehouseProductLogic extends BaseLogic $data['expiration_date'] = strtotime($params['expiration_date']); } $res = WarehouseProduct::create($data); - SqlChannelLog('WarehouseProduct', $res['id'], $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url()); + SqlChannelLog('WarehouseProduct', $res['id'], $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url(),$admin_id); return $res; } catch (\Throwable $e) { @@ -121,7 +121,7 @@ class WarehouseProductLogic extends BaseLogic /** * 设置出库商品 */ - public static function setOutbound(array $params, $type = 1) + public static function setOutbound(array $params, $type = 1,$admin_id=0) { Db::startTrans(); try { @@ -144,7 +144,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()); + SqlChannelLog('WarehouseProductStorege', $storege['id'], bcsub($storege['nums'], $params['nums']), -1, Request()->url(),$admin_id); } else { $data = [ 'warehouse_id' => $params['warehouse_id'], @@ -153,7 +153,7 @@ class WarehouseProductLogic extends BaseLogic 'total_price' => 0 ]; $storege = WarehouseProductStorege::create($data); - SqlChannelLog('WarehouseProductStorege', $storege->id, -$params['nums'], -1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $storege->id, -$params['nums'], -1, Request()->url(),$admin_id); } } else { $storege['nums'] = 0; @@ -182,7 +182,7 @@ class WarehouseProductLogic extends BaseLogic 'mark' => $params['mark'] ?? '', ]; $res = WarehouseProduct::create($data); - SqlChannelLog('WarehouseProduct', $res->id, $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url()); + SqlChannelLog('WarehouseProduct', $res->id, $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url(),$admin_id); Db::commit(); return $res; @@ -249,17 +249,17 @@ class WarehouseProductLogic extends BaseLogic * @author admin * @date 2024/07/31 16:55 */ - public static function delete(array $params): bool + public static function delete(array $params,$admin_id=0): bool { $res = WarehouseProduct::where('id', $params['id'])->find(); if ($res) { $res->delete(); if ($res['financial_pm'] == 1) { $find = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->save(); - SqlChannelLog('WarehouseProductStorege', $find['id'], $res['nums'], -1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $find['id'], $res['nums'], -1, Request()->url(),$admin_id); } elseif ($res['financial_pm'] == 0) { $find = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->save(); - SqlChannelLog('WarehouseProductStorege', $find['id'], $res['nums'], 1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $find['id'], $res['nums'], 1, Request()->url(),$admin_id); } $find = WarehouseProduct::where('oid', $res['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); if ($find) { @@ -300,14 +300,14 @@ class WarehouseProductLogic extends BaseLogic * @param $id * @return void */ - public static function settNums($params) + public static function settNums($params,$admin_id=0) { Db::startTrans(); try { $res = WarehouseProduct::where('id', $params['id'])->find(); if ($res) { - self::decStock($res); - self::incStock($res, $params); + self::decStock($res,$admin_id); + self::incStock($res, $params,$admin_id); $datas = [ 'nums' => $params['nums'], 'total_price' => bcmul($params['nums'], $res['price'], 2), @@ -344,28 +344,28 @@ class WarehouseProductLogic extends BaseLogic } //减少 - private static function decStock($res) + private static function decStock($res,$admin_id=0) { $res1 = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id']) ->where('product_id', $res['product_id'])->find(); $res1->save(['nums'=>bcsub($res1['nums'], $res['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], -1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], -1, Request()->url(),$admin_id); $res->save(['nums'=>bcsub($res['nums'], $res['nums'],2)]); - SqlChannelLog('WarehouseProduct', $res['id'], $res['nums'], -1, Request()->url()); + SqlChannelLog('WarehouseProduct', $res['id'], $res['nums'], -1, Request()->url(),$admin_id); } //增加 - private static function incStock($res, $params) + private static function incStock($res, $params,$admin_id=0) { $res1 = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id']) ->where('product_id', $res['product_id']) ->find(); $res1->save(['nums'=>bcadd($res1['nums'], $params['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], 1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $res1['id'], $res['nums'], 1, Request()->url(),$admin_id); $res->save(['nums'=>bcadd($res['nums'], $params['nums'],2)]); - SqlChannelLog('WarehouseProduct', $res['id'], $res['nums'], 1, Request()->url()); + SqlChannelLog('WarehouseProduct', $res['id'], $res['nums'], 1, Request()->url(),$admin_id); } } diff --git a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php index f1567fc6..19314681 100644 --- a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php +++ b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php @@ -116,11 +116,11 @@ class WarehouseProductReturnLogic extends BaseLogic } $res=WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->find(); $res->save(['nums' =>bcadd( $res['nums'],$params['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], 1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], 1, Request()->url(),$params['admin_id']); } elseif ($params['financial_pm'] == 0 && $params['return_type'] == 2) { $res=WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->find(); $res->save(['nums' =>bcsub( $res['nums'],$params['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], -1, Request()->url()); + SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], -1, Request()->url(),$params['admin_id']); } } diff --git a/app/admin/logic/warehouse_product_storege/WarehouseProductStoregeLogic.php b/app/admin/logic/warehouse_product_storege/WarehouseProductStoregeLogic.php index 35e21387..52b9d1fe 100644 --- a/app/admin/logic/warehouse_product_storege/WarehouseProductStoregeLogic.php +++ b/app/admin/logic/warehouse_product_storege/WarehouseProductStoregeLogic.php @@ -37,14 +37,14 @@ class WarehouseProductStoregeLogic extends BaseLogic * @author admin * @date 2024/08/01 10:22 */ - public static function edit(array $params): bool + public static function edit(array $params,$admin_id=0): bool { Db::startTrans(); try { $find=WarehouseProductStorege::where('id',$params['id'])->find(); if($find){ $find->save(['nums'=>$params['nums']]); - SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url()); + SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url(),$admin_id); } Db::commit(); return true; diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index c1277288..2aa3f0e1 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -315,13 +315,9 @@ class IndexController extends BaseApiController public function aa(){ $boyd = $this->request->post(); - // 计算body的MD5值 - $microtime = microtime(true); -// 将秒和微秒数转换为毫秒级时间戳 -$millisecondTimestamp = number_format($microtime * 1000, 0, '', ''); // 输出结果 - $time = $millisecondTimestamp; + $time = $this->request->header('timestamp'); // 需要签名的数据 $data = [ diff --git a/app/common/logic/ChangeLogLogic.php b/app/common/logic/ChangeLogLogic.php index ed277316..497b94e8 100644 --- a/app/common/logic/ChangeLogLogic.php +++ b/app/common/logic/ChangeLogLogic.php @@ -7,7 +7,7 @@ use app\common\model\change_log\ChangeLog; class ChangeLogLogic extends BaseLogic { - public function insert($model='',$link_id=0,$nums=0,$pm=0,$url=''):void + public function insert($model='',$link_id=0,$nums=0,$pm=0,$url='',$admin_id=0):void { $info=\Chance\Log\facades\OperationLog::getLog(); ChangeLog::create([ @@ -17,6 +17,7 @@ class ChangeLogLogic extends BaseLogic 'pm' => $pm, 'mark' => $info, 'url' => $url, + 'admin_id' => $admin_id, 'create_time' => time() ]); \Chance\Log\facades\OperationLog::clearLog(); diff --git a/app/functions.php b/app/functions.php index a1ba54d9..76519f76 100644 --- a/app/functions.php +++ b/app/functions.php @@ -555,9 +555,9 @@ function channelLog($data, $type, $title = '更新前') * @param pm 1:增加 -1:减少 * @param url 请求地址 */ -function SqlChannelLog($model='', $id=0, $nums=0,$pm=0,$url=''):void +function SqlChannelLog($model='', $id=0, $nums=0,$pm=0,$url='',$admin_id=0):void { - (new ChangeLogLogic())->insert($model, $id, $nums, $pm, $url); + (new ChangeLogLogic())->insert($model, $id, $nums, $pm, $url,$admin_id); } // if (!function_exists('getNewOrderSn')) {