初始库存变化
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\logic\InvItemLogic;
|
||||
use app\common\model\User;
|
||||
use app\common\validate\InvItemValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\InvItem;
|
||||
use support\Redis;
|
||||
use support\Request;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
@@ -114,8 +116,30 @@ class InvItemService
|
||||
$data['is_consumable'] = 0;
|
||||
$data['stock_qty'] = $data['stock_qty']??1;
|
||||
$data['location'] = '';
|
||||
|
||||
Redis::set('inv_store_u_stock', $request->user->uid, 'EX', 30);
|
||||
|
||||
return $data;
|
||||
}
|
||||
public function afterServiceStore($res)
|
||||
{
|
||||
$uid = redis::get('inv_store_u_stock');
|
||||
$name = $uid ? User::where('id', $uid)->value('name') : '';
|
||||
Redis::del('inv_store_u_stock');
|
||||
// 记录库存变化日志
|
||||
$this->recordStockLog([
|
||||
'item_id' => $res['id'],
|
||||
'item_name_snap' => $res['item_name'],
|
||||
'change_qty' => $res['stock_qty'],
|
||||
'before_qty' => 0,
|
||||
'after_qty' => $res['stock_qty'],
|
||||
'biz_type' => 1,
|
||||
'biz_no' => '',
|
||||
'operator_id' => $uid,
|
||||
'operator_name' => $name,
|
||||
'remark' => '初始数量',
|
||||
], $res['stock_qty']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user