refactor(warehouse): 重构仓库相关逻辑
- 优化库存增减操作,使用单独的方法进行处理 - 添加 SqlChannelLog 函数用于记录日志 - 修改 IndexController 中的 aa 方法,用于处理签名验证
This commit is contained in:
parent
902069b4f9
commit
f534328987
@ -82,14 +82,22 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
'two_id' => $params['two_id']
|
'two_id' => $params['two_id']
|
||||||
]);
|
]);
|
||||||
if($params['one_type']==1){
|
if($params['one_type']==1){
|
||||||
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->dec('stock', $params['nums'])->update();
|
$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());
|
||||||
} elseif ($params['one_type'] == 2) {
|
} elseif ($params['one_type'] == 2) {
|
||||||
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->dec('nums', $params['nums'])->update();
|
$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());
|
||||||
}
|
}
|
||||||
if($params['two_type']==1){
|
if($params['two_type']==1){
|
||||||
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->inc('stock', $params['nums'])->update();
|
$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());
|
||||||
} elseif ($params['two_type'] == 2) {
|
} elseif ($params['two_type'] == 2) {
|
||||||
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->inc('nums', $params['nums'])->update();
|
$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());
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
@ -37,7 +37,6 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
// Db::startTrans();
|
// Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$before_nums = 0;
|
|
||||||
$after_nums = 0;
|
$after_nums = 0;
|
||||||
if ($params['order_type'] != 6) {
|
if ($params['order_type'] != 6) {
|
||||||
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
|
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
|
||||||
@ -48,23 +47,24 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
if (!$storeProduct) {
|
if (!$storeProduct) {
|
||||||
throw new BusinessException('商品不存在');
|
throw new BusinessException('商品不存在');
|
||||||
}
|
}
|
||||||
if($storeProduct['purchase']<=0){
|
if ($storeProduct['purchase'] <= 0) {
|
||||||
$total_price=0;
|
$total_price = 0;
|
||||||
}else{
|
} else {
|
||||||
$total_price = bcmul($after_nums, $storeProduct['purchase'], 2);
|
$total_price = bcmul($after_nums, $storeProduct['purchase'], 2);
|
||||||
}
|
}
|
||||||
WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price], ['id' => $storege['id']]);
|
WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price], ['id' => $storege['id']]);
|
||||||
|
SqlChannelLog('WarehouseProductStorege', $storege['id'], $after_nums, 1, Request()->url());
|
||||||
|
|
||||||
}
|
}
|
||||||
$before_nums = $storege['nums'];
|
|
||||||
} else {
|
} else {
|
||||||
$after_nums = $params['nums'];
|
$after_nums = $params['nums'];
|
||||||
$storeProduct = StoreProduct::where('id', $params['product_id'])->findOrEmpty();
|
$storeProduct = StoreProduct::where('id', $params['product_id'])->findOrEmpty();
|
||||||
if (!$storeProduct) {
|
if (!$storeProduct) {
|
||||||
throw new BusinessException('商品不存在');
|
throw new BusinessException('商品不存在');
|
||||||
}
|
}
|
||||||
if($storeProduct['purchase']<=0){
|
if ($storeProduct['purchase'] <= 0) {
|
||||||
$total_price=0;
|
$total_price = 0;
|
||||||
}else{
|
} else {
|
||||||
$total_price = bcmul($after_nums, $storeProduct['purchase'], 2);
|
$total_price = bcmul($after_nums, $storeProduct['purchase'], 2);
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
@ -77,6 +77,8 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
$data['nums'] = -$params['nums'];
|
$data['nums'] = -$params['nums'];
|
||||||
}
|
}
|
||||||
$storege = WarehouseProductStorege::create($data);
|
$storege = WarehouseProductStorege::create($data);
|
||||||
|
SqlChannelLog('WarehouseProductStorege', $storege['id'], -$params['nums'], 1, Request()->url());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$batch_count = WarehouseProduct::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id'], 'financial_pm' => $params['financial_pm'], 'store_id' => $params['store_id']])->count();
|
$batch_count = WarehouseProduct::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id'], 'financial_pm' => $params['financial_pm'], 'store_id' => $params['store_id']])->count();
|
||||||
@ -89,8 +91,8 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
'financial_pm' => $params['financial_pm'],
|
'financial_pm' => $params['financial_pm'],
|
||||||
'batch' => $batch_count + 1,
|
'batch' => $batch_count + 1,
|
||||||
'nums' => $params['nums'],
|
'nums' => $params['nums'],
|
||||||
'before_nums' => $before_nums,
|
'before_nums' => 0,
|
||||||
'after_nums' => $after_nums,
|
'after_nums' => 0,
|
||||||
'price' => $params['price'] ?? '',
|
'price' => $params['price'] ?? '',
|
||||||
'purchase' => $params['purchase'] ?? '',
|
'purchase' => $params['purchase'] ?? '',
|
||||||
// 'cost' => $params['cost'] ?? '',
|
// 'cost' => $params['cost'] ?? '',
|
||||||
@ -108,6 +110,8 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
$data['expiration_date'] = strtotime($params['expiration_date']);
|
$data['expiration_date'] = strtotime($params['expiration_date']);
|
||||||
}
|
}
|
||||||
$res = WarehouseProduct::create($data);
|
$res = WarehouseProduct::create($data);
|
||||||
|
SqlChannelLog('WarehouseProduct', $res['id'], $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url());
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
@ -125,7 +129,7 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
if ($params['order_type'] != 6) {
|
if ($params['order_type'] != 6) {
|
||||||
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
|
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
|
||||||
if ($storege) {
|
if ($storege) {
|
||||||
if(in_array($params['order_type'],[1,4])){
|
if (in_array($params['order_type'], [1, 4])) {
|
||||||
SystemStoreStorage::create([
|
SystemStoreStorage::create([
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'admin_id' => $params['admin_id'],
|
'admin_id' => $params['admin_id'],
|
||||||
@ -140,6 +144,7 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
$after_nums = bcsub($storege['nums'], $params['nums']);
|
$after_nums = bcsub($storege['nums'], $params['nums']);
|
||||||
$total_price = bcmul($after_nums, $params['purchase'], 2);
|
$total_price = bcmul($after_nums, $params['purchase'], 2);
|
||||||
WarehouseProductStorege::update(['nums' => bcsub($storege['nums'], $params['nums']), 'total_price' => $total_price], ['id' => $storege['id']]);
|
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());
|
||||||
} else {
|
} else {
|
||||||
$data = [
|
$data = [
|
||||||
'warehouse_id' => $params['warehouse_id'],
|
'warehouse_id' => $params['warehouse_id'],
|
||||||
@ -148,6 +153,7 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
'total_price' => 0
|
'total_price' => 0
|
||||||
];
|
];
|
||||||
$storege = WarehouseProductStorege::create($data);
|
$storege = WarehouseProductStorege::create($data);
|
||||||
|
SqlChannelLog('WarehouseProductStorege', $storege->id, -$params['nums'], -1, Request()->url());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$storege['nums'] = 0;
|
$storege['nums'] = 0;
|
||||||
@ -176,6 +182,8 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
'mark' => $params['mark'] ?? '',
|
'mark' => $params['mark'] ?? '',
|
||||||
];
|
];
|
||||||
$res = WarehouseProduct::create($data);
|
$res = WarehouseProduct::create($data);
|
||||||
|
SqlChannelLog('WarehouseProduct', $res->id, $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url());
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $res;
|
return $res;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
@ -195,42 +203,20 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$before_nums = 0;
|
|
||||||
$after_nums = 0;
|
|
||||||
$find = WarehouseOrder::where('id', $params['oid'])->find();
|
$find = WarehouseOrder::where('id', $params['oid'])->find();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
$res = WarehouseProduct::where('id', $params['id'])->find();
|
$res = WarehouseProduct::where('id', $params['id'])->find();
|
||||||
|
self::decStock($res);
|
||||||
if ($find['financial_pm'] == 1) {
|
self::incStock($res, $params);
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->update();
|
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
|
|
||||||
|
|
||||||
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
|
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $params['nums'])->update();
|
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
|
|
||||||
$before_nums = $warehouseProductStorege['nums'];
|
|
||||||
$after_nums = $warehouseProductStorege['nums'] + $params['nums'];
|
|
||||||
} else {
|
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->update();
|
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
|
|
||||||
|
|
||||||
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
|
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $params['nums'])->update();
|
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
|
|
||||||
$before_nums = $warehouseProductStorege['nums'];
|
|
||||||
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
|
|
||||||
}
|
|
||||||
$datas = [
|
$datas = [
|
||||||
'nums' => $params['nums'],
|
'nums' => $params['nums'],
|
||||||
'before_nums' => $before_nums,
|
|
||||||
'after_nums' => $after_nums,
|
|
||||||
'total_price' => $params['total_price'],
|
'total_price' => $params['total_price'],
|
||||||
];
|
];
|
||||||
if($find['financial_pm']==1){
|
if ($find['financial_pm'] == 1) {
|
||||||
$datas['supplier_id'] = $params['supplier_id'];
|
$datas['supplier_id'] = $params['supplier_id'];
|
||||||
$datas['pay_type'] = $params['pay_type'];
|
$datas['pay_type'] = $params['pay_type'];
|
||||||
$datas['purchase'] = $params['purchase'];
|
$datas['purchase'] = $params['purchase'];
|
||||||
}else{
|
} else {
|
||||||
$datas['price'] = $params['price'];
|
$datas['price'] = $params['price'];
|
||||||
}
|
}
|
||||||
if (isset($params['manufacture']) && $params['manufacture'] != '') {
|
if (isset($params['manufacture']) && $params['manufacture'] != '') {
|
||||||
@ -239,7 +225,7 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
if (isset($params['expiration_date']) && $params['expiration_date'] != '') {
|
if (isset($params['expiration_date']) && $params['expiration_date'] != '') {
|
||||||
$datas['expiration_date'] = strtotime($params['expiration_date']);
|
$datas['expiration_date'] = strtotime($params['expiration_date']);
|
||||||
}
|
}
|
||||||
WarehouseProduct::where('id', $params['id'])->update($datas);
|
$res->save($datas);
|
||||||
$finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
$finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||||
if ($finds) {
|
if ($finds) {
|
||||||
WarehouseOrder::where('id', $params['oid'])->update([
|
WarehouseOrder::where('id', $params['oid'])->update([
|
||||||
@ -269,14 +255,11 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
if ($res) {
|
if ($res) {
|
||||||
$res->delete();
|
$res->delete();
|
||||||
if ($res['financial_pm'] == 1) {
|
if ($res['financial_pm'] == 1) {
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->update();
|
$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());
|
||||||
} elseif ($res['financial_pm'] == 0) {
|
} elseif ($res['financial_pm'] == 0) {
|
||||||
$stock = StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->value('stock');
|
$find = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->save();
|
||||||
if ($stock < $res['nums']) {
|
SqlChannelLog('WarehouseProductStorege', $find['id'], $res['nums'], 1, Request()->url());
|
||||||
throw new BusinessException('商品库存不足,无法退回');
|
|
||||||
}
|
|
||||||
StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->dec('stock', $res['nums'])->update();
|
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->update();
|
|
||||||
}
|
}
|
||||||
$find = WarehouseProduct::where('oid', $res['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
$find = WarehouseProduct::where('oid', $res['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
@ -321,44 +304,15 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$res = WarehouseProduct::where('id',$params['id'])->find();
|
$res = WarehouseProduct::where('id', $params['id'])->find();
|
||||||
if ($res) {
|
if ($res) {
|
||||||
if ($res['financial_pm'] == 1) {
|
self::decStock($res);
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->update();
|
self::incStock($res, $params);
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
|
$datas = [
|
||||||
|
'nums' => $params['nums'],
|
||||||
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
|
'total_price' => bcmul($params['nums'], $res['price'], 2),
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $params['nums'])->update();
|
];
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
|
$res->save($datas);
|
||||||
$before_nums = $warehouseProductStorege['nums'];
|
|
||||||
$after_nums = $warehouseProductStorege['nums'] + $params['nums'];
|
|
||||||
} else {
|
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->update();
|
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update();
|
|
||||||
|
|
||||||
$warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find();
|
|
||||||
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $params['nums'])->update();
|
|
||||||
StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update();
|
|
||||||
$before_nums = $warehouseProductStorege['nums'];
|
|
||||||
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
|
|
||||||
}
|
|
||||||
if($res['financial_pm']==1){
|
|
||||||
$datas=[
|
|
||||||
'nums' => $params['nums'],
|
|
||||||
'before_nums' => $before_nums,
|
|
||||||
'after_nums' => $after_nums,
|
|
||||||
'total_price' => bcmul($params['nums'], $res['purchase'], 2),
|
|
||||||
|
|
||||||
];
|
|
||||||
}else{
|
|
||||||
$datas=[
|
|
||||||
'nums' => $params['nums'],
|
|
||||||
'before_nums' => $before_nums,
|
|
||||||
'after_nums' => $after_nums,
|
|
||||||
'total_price' => bcmul($params['nums'], $res['price'], 2),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
WarehouseProduct::where('id', $params['id'])->update($datas);
|
|
||||||
$finds = WarehouseProduct::where('oid', $res['oid'])->field('sum(nums) as nums')->find();
|
$finds = WarehouseProduct::where('oid', $res['oid'])->field('sum(nums) as nums')->find();
|
||||||
if ($finds) {
|
if ($finds) {
|
||||||
WarehouseOrder::where('id', $res['oid'])->update([
|
WarehouseOrder::where('id', $res['oid'])->update([
|
||||||
@ -388,4 +342,35 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//减少
|
||||||
|
private static function decStock($res)
|
||||||
|
{
|
||||||
|
$res = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])
|
||||||
|
->where('product_id', $res['product_id'])
|
||||||
|
->dec('nums', $res['nums'])
|
||||||
|
->save();
|
||||||
|
SqlChannelLog('WarehouseProductStorege', $res['id'], $res['nums'], -1, Request()->url());
|
||||||
|
|
||||||
|
$res2 = StoreBranchProduct::where('id', $res['id'])
|
||||||
|
->dec('stock', $res['nums'])
|
||||||
|
->update();
|
||||||
|
SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], -1, Request()->url());
|
||||||
|
}
|
||||||
|
|
||||||
|
//增加
|
||||||
|
private static function incStock($res, $params)
|
||||||
|
{
|
||||||
|
$res = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])
|
||||||
|
->where('product_id', $res['product_id'])
|
||||||
|
->inc('nums', $params['nums'])
|
||||||
|
->save();
|
||||||
|
SqlChannelLog('WarehouseProductStorege', $res['id'], $res['nums'], 1, Request()->url());
|
||||||
|
|
||||||
|
|
||||||
|
$res2 = StoreBranchProduct::where('id', $res['id'])
|
||||||
|
->inc('stock', $params['nums'])
|
||||||
|
->save();
|
||||||
|
SqlChannelLog('StoreBranchProduct', $res2['id'], $res['nums'], 1, Request()->url());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,13 @@ class WarehouseProductReturnLogic extends BaseLogic
|
|||||||
WarehouseOrder::where(['id' => $find['oid']])->update(['total_price' => $total_price]);
|
WarehouseOrder::where(['id' => $find['oid']])->update(['total_price' => $total_price]);
|
||||||
BeforehandOrder::update(['pay_price' => $total_price], ['id' => $params['bhoid']]);
|
BeforehandOrder::update(['pay_price' => $total_price], ['id' => $params['bhoid']]);
|
||||||
}
|
}
|
||||||
WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->inc('nums', $params['nums'])->update();
|
$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());
|
||||||
} elseif ($params['financial_pm'] == 0 && $params['return_type'] == 2) {
|
} elseif ($params['financial_pm'] == 0 && $params['return_type'] == 2) {
|
||||||
WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->dec('nums', $params['nums'])->update();
|
$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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ class WarehouseProductStoregeLogic extends BaseLogic
|
|||||||
$find=WarehouseProductStorege::where('id',$params['id'])->find();
|
$find=WarehouseProductStorege::where('id',$params['id'])->find();
|
||||||
if($find){
|
if($find){
|
||||||
$find->save(['nums'=>$params['nums']]);
|
$find->save(['nums'=>$params['nums']]);
|
||||||
|
SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url());
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
@ -11,6 +11,7 @@ use app\admin\logic\tools\GeneratorLogic;
|
|||||||
use app\api\lists\purchase_product_offer\PurchaseProductOfferListsTwo;
|
use app\api\lists\purchase_product_offer\PurchaseProductOfferListsTwo;
|
||||||
use app\api\logic\order\OrderLogic as OrderOrderLogic;
|
use app\api\logic\order\OrderLogic as OrderOrderLogic;
|
||||||
use app\common\cache\ExportCache;
|
use app\common\cache\ExportCache;
|
||||||
|
use app\common\logic\ChangeLogLogic;
|
||||||
use app\common\logic\PayNotifyLogic;
|
use app\common\logic\PayNotifyLogic;
|
||||||
use app\common\logic\store_order\StoreOrderLogic;
|
use app\common\logic\store_order\StoreOrderLogic;
|
||||||
use app\common\model\beforehand_order_record\BeforehandOrderRecord;
|
use app\common\model\beforehand_order_record\BeforehandOrderRecord;
|
||||||
@ -50,14 +51,15 @@ use PhpOffice\PhpWord\Settings;
|
|||||||
use PhpOffice\PhpWord\IOFactory;
|
use PhpOffice\PhpWord\IOFactory;
|
||||||
use PhpOffice\PhpWord\Shared\Converter;
|
use PhpOffice\PhpWord\Shared\Converter;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
|
use Chance\Log\facades\OperationLog;
|
||||||
|
|
||||||
class IndexController extends BaseApiController
|
class IndexController extends BaseApiController
|
||||||
{
|
{
|
||||||
public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config', 'push', 'purchase_product_offer'];
|
public $notNeedLogin = ['aa','index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config', 'push', 'purchase_product_offer'];
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
d(1);
|
d(1);
|
||||||
$arr = Db::name('ceshi_copy')->select();
|
$arr = Db::name('ceshi_copy')->select();
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
$data = [
|
$data = [
|
||||||
@ -301,8 +303,8 @@ class IndexController extends BaseApiController
|
|||||||
if ($find) {
|
if ($find) {
|
||||||
Db::name('wps_product')->where('id', $find['id'])->update($arr);
|
Db::name('wps_product')->where('id', $find['id'])->update($arr);
|
||||||
} else {
|
} else {
|
||||||
$arr['product_id']=$data['product_id'];
|
$arr['product_id'] = $data['product_id'];
|
||||||
$arr['name']=$data['name'];
|
$arr['name'] = $data['name'];
|
||||||
Db::name('wps_product')->insert($arr);
|
Db::name('wps_product')->insert($arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,4 +312,53 @@ class IndexController extends BaseApiController
|
|||||||
return $this->fail('时间不能为空');
|
return $this->fail('时间不能为空');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function aa(){
|
||||||
|
$boyd = $this->request->post();
|
||||||
|
// 计算body的MD5值
|
||||||
|
$microtime = microtime(true);
|
||||||
|
|
||||||
|
// 将秒和微秒数转换为毫秒级时间戳
|
||||||
|
$millisecondTimestamp = number_format($microtime * 1000, 0, '', '');
|
||||||
|
// 输出结果
|
||||||
|
$time = $millisecondTimestamp;
|
||||||
|
|
||||||
|
// 需要签名的数据
|
||||||
|
$data = [
|
||||||
|
'appid' => 'e328e0d083784b8cbbd8a45e2a13b430',
|
||||||
|
'timestamp' => $time,
|
||||||
|
'version' => "1.0.0"
|
||||||
|
];
|
||||||
|
$md5='{}';
|
||||||
|
if($boyd){
|
||||||
|
$md5 = md5(json_encode($boyd,true));
|
||||||
|
$data['md5']=$md5;
|
||||||
|
}else{
|
||||||
|
$md5 = md5($md5);
|
||||||
|
$data['md5']=$md5;
|
||||||
|
}
|
||||||
|
// 获取token
|
||||||
|
$token=$this->request->header('token');
|
||||||
|
if($token){
|
||||||
|
$data['token']=$token;
|
||||||
|
}
|
||||||
|
// 按字母顺序排序
|
||||||
|
ksort($data);
|
||||||
|
|
||||||
|
// 转换为JSON字符串
|
||||||
|
$jsonString = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
// RSA私钥
|
||||||
|
$privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKYtaukWByNHG8VZsvfIwEeJUKa0t2RaNNMp/IlgWj/29aK+nCZZC+zROc8xjQAAHKbQgwXeFzizzDb98Q8Qavgo+8zuNi2V45sj12+7yC1tfX4zRkm4Yqri+YifJLNXxoh46dvx9CsNrKT/e5we6irxaWJoXxGxeZ4pA1JpcrwHAgMBAAECgYBnoELe/yGMWjdzJbB42/MrqPFmQ6NpLOdsFu6oLDGbWcFrrzlooHbTQtWt4tRuf6NeUwChlBEfBt/+GvVL040gF2T2ylsMi3biktZDSlT/+DI7H5S1x4aBplIBc4yAp/vrFTyWmxdULEksap2BUf5fEqG/CVcWMI2zszORQi4QAQJBAO4z9FsOyPZ0ycrCFmQD9AYPzmnBvgTg/uU0xGY7yus8zIt29TL1uE77/ksmGxJQXXcRUt2ytPVm9YqXnXS/EgcCQQCyl9l7Kdr/eifOcRd9wAAXwsHKkjfJR1Vd1igv5wCZqSkXK2qxxvQDPE98HugosNkFxuyedFbfrbSQpPUjnIYBAkAyDXK8K4go2XOJim0ACSCeoXWjHVXbWpfU+9iFDu1drsHgUFfHpIBdAHB3xAMOPxrUqSw7b5C8vCy+OYuZe4jDAkAdpsqMAWID4sMzKmGtFjCtwT8to+MxPu+0ebcIZQEbghN5blLzm0WuN9g2kmcXQm114RYuJMC7uHpvPYQZ2oYBAkBBzytKuG5EhbsI5flwxYGTDvQtY1TGvsYVrt0anirPa9xVq+RYC2Jr9zk0j8s13QhXoVwAO6seO7cYN9n8J65t";
|
||||||
|
|
||||||
|
// 解码私钥
|
||||||
|
$privateKeyPem = "-----BEGIN PRIVATE KEY-----\n" . wordwrap($privateKey, 64, "\n", true) . "\n-----END PRIVATE KEY-----";
|
||||||
|
// 获取私钥资源
|
||||||
|
$privateKeyResource = openssl_pkey_get_private($privateKeyPem);
|
||||||
|
openssl_sign($jsonString, $signature, $privateKeyResource, OPENSSL_ALGO_SHA1);
|
||||||
|
|
||||||
|
// 将签名进行Base64编码
|
||||||
|
$signatureString = base64_encode($signature);
|
||||||
|
|
||||||
|
d($md5,$time,$signatureString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
* Here is your custom functions.
|
* Here is your custom functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use app\common\logic\ChangeLogLogic;
|
||||||
use app\common\service\FileService;
|
use app\common\service\FileService;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
|
|
||||||
@ -546,7 +547,18 @@ function channelLog($data, $type, $title = '更新前')
|
|||||||
$log = Log::channel($type);
|
$log = Log::channel($type);
|
||||||
$log->info($title, $data);
|
$log->info($title, $data);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 日志记录
|
||||||
|
* @param model 模型
|
||||||
|
* @param id 更新的模型组件id
|
||||||
|
* @param nums 更新的数量
|
||||||
|
* @param pm 1:增加 -1:减少
|
||||||
|
* @param url 请求地址
|
||||||
|
*/
|
||||||
|
function SqlChannelLog($model='', $id=0, $nums=0,$pm=0,$url=''):void
|
||||||
|
{
|
||||||
|
(new ChangeLogLogic())->insert($model, $id, $nums, $pm, $url);
|
||||||
|
}
|
||||||
// if (!function_exists('getNewOrderSn')) {
|
// if (!function_exists('getNewOrderSn')) {
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user