库存修改
This commit is contained in:
@@ -94,6 +94,7 @@ class InvRequisitionService
|
|||||||
//$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
//$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||||
$appro = new \app\common\service\InvRequisitionApproveService();
|
$appro = new \app\common\service\InvRequisitionApproveService();
|
||||||
//requisition_id:申请id
|
//requisition_id:申请id
|
||||||
|
//approve_id:审核步骤id
|
||||||
//action:审批动作:1通过 2驳回
|
//action:审批动作:1通过 2驳回
|
||||||
//comment:审批意见
|
//comment:审批意见
|
||||||
return $appro->approve($param['requisition_id'], $param['approve_id'], $request->user->uid, $param['action'], $param['comment'], $attachment);
|
return $appro->approve($param['requisition_id'], $param['approve_id'], $request->user->uid, $param['action'], $param['comment'], $attachment);
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ class InvItemService
|
|||||||
* @param int $changeQty 变动数量:>0 入库,<0 出库
|
* @param int $changeQty 变动数量:>0 入库,<0 出库
|
||||||
* @param bool $allowNegative 是否允许库存变成负数,默认不允许
|
* @param bool $allowNegative 是否允许库存变成负数,默认不允许
|
||||||
* @param array $options 额外选项(用于记录日志)
|
* @param array $options 额外选项(用于记录日志)
|
||||||
|
* - change_type: 变动类型
|
||||||
* - biz_type: 业务类型
|
* - biz_type: 业务类型
|
||||||
* - biz_no: 单据号
|
* - biz_no: 单据号
|
||||||
* - operator_id: 操作人ID
|
* - operator_id: 操作人ID
|
||||||
@@ -223,6 +224,7 @@ class InvItemService
|
|||||||
'change_qty' => $changeQty,
|
'change_qty' => $changeQty,
|
||||||
'before_qty' => $beforeQty,
|
'before_qty' => $beforeQty,
|
||||||
'after_qty' => $item->stock_qty,
|
'after_qty' => $item->stock_qty,
|
||||||
|
'change_type' => $options['change_type'] ?? null,
|
||||||
'biz_type' => $options['biz_type'] ?? null,
|
'biz_type' => $options['biz_type'] ?? null,
|
||||||
'biz_no' => $options['biz_no'] ?? null,
|
'biz_no' => $options['biz_no'] ?? null,
|
||||||
'operator_id' => $options['operator_id'] ?? null,
|
'operator_id' => $options['operator_id'] ?? null,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\common\service;
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use app\common\model\InvItem;
|
||||||
use app\common\model\User;
|
use app\common\model\User;
|
||||||
use app\common\validate\InvRequisitionApproveValidate;
|
use app\common\validate\InvRequisitionApproveValidate;
|
||||||
use app\common\traits\crud\CrudServiceTrait;
|
use app\common\traits\crud\CrudServiceTrait;
|
||||||
@@ -169,6 +170,7 @@ class InvRequisitionApproveService
|
|||||||
->count();
|
->count();
|
||||||
if($action == 1){
|
if($action == 1){
|
||||||
if(count($steps) == $pass){
|
if(count($steps) == $pass){
|
||||||
|
//判断是否都是消耗品,是否需要归还
|
||||||
$requisitionItem = Db::table('inv_requisition_item')
|
$requisitionItem = Db::table('inv_requisition_item')
|
||||||
->where('requisition_id', $requisition->id)
|
->where('requisition_id', $requisition->id)
|
||||||
->where('is_consumable_snap', 0)
|
->where('is_consumable_snap', 0)
|
||||||
@@ -179,6 +181,15 @@ class InvRequisitionApproveService
|
|||||||
Db::table('inv_requisition')->where('id', $requisition->id)->update(['status'=>19]);
|
Db::table('inv_requisition')->where('id', $requisition->id)->update(['status'=>19]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//更改库存
|
||||||
|
$requisitionItem = Db::table('inv_requisition_item')
|
||||||
|
->where('requisition_id', $requisition->id)
|
||||||
|
->get();
|
||||||
|
foreach ($requisitionItem as $item) {
|
||||||
|
//$invItem = InvItem::where('id', $item->item_id)->first();
|
||||||
|
(new InvItemService())->stockOut($item->item_id,$item->approved_qty);
|
||||||
|
}
|
||||||
|
|
||||||
// $requisition->status = 12;
|
// $requisition->status = 12;
|
||||||
// $requisition->save();
|
// $requisition->save();
|
||||||
return ['status' => 'complete', 'msg' => '已通过'];
|
return ['status' => 'complete', 'msg' => '已通过'];
|
||||||
@@ -200,7 +211,7 @@ class InvRequisitionApproveService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 4) 通过 => 进入下一步或结束
|
// 4) 通过 => 进入下一步
|
||||||
Db::table('inv_requisition')->where('id', $requisitionId)->update(['status'=>11]);
|
Db::table('inv_requisition')->where('id', $requisitionId)->update(['status'=>11]);
|
||||||
$requisitionItem = Db::table('inv_requisition_item')->where('requisition_id', $requisitionId)->first();
|
$requisitionItem = Db::table('inv_requisition_item')->where('requisition_id', $requisitionId)->first();
|
||||||
$item_id = Db::table('inv_item')->where('id', $requisitionItem->item_id)->first();
|
$item_id = Db::table('inv_item')->where('id', $requisitionItem->item_id)->first();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use app\common\model\InvItem;
|
|||||||
use app\common\model\InvRequisition;
|
use app\common\model\InvRequisition;
|
||||||
use app\common\model\InvRequisitionItem;
|
use app\common\model\InvRequisitionItem;
|
||||||
use app\common\model\InvRequisitionReturn;
|
use app\common\model\InvRequisitionReturn;
|
||||||
|
use app\common\model\InvStockLog;
|
||||||
use app\common\model\User;
|
use app\common\model\User;
|
||||||
use app\common\service\UserService;
|
use app\common\service\UserService;
|
||||||
use app\common\validate\InvRequisitionItemReturnValidate;
|
use app\common\validate\InvRequisitionItemReturnValidate;
|
||||||
@@ -591,6 +592,17 @@ class InvRequisitionItemReturnService
|
|||||||
}
|
}
|
||||||
$return->status = $status;
|
$return->status = $status;
|
||||||
$return->save();
|
$return->save();
|
||||||
|
if($status == 1){
|
||||||
|
//更改库存
|
||||||
|
$returnItem = Db::table('inv_requisition_item_return')
|
||||||
|
->where('requisition_id', $return->id)
|
||||||
|
->get();
|
||||||
|
foreach ($returnItem as $item) {
|
||||||
|
//$invItem = InvItem::where('id', $item->item_id)->first();
|
||||||
|
(new InvItemService())->stockIn($item->item_id,$item->return_qty,['change_type'=>InvStockLog::CHANGE_TYPE_IN_RETURN,
|
||||||
|
'biz_type'=>InvStockLog::BIZ_TYPE_RETURN,]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 保存归还审核附件
|
// 保存归还审核附件
|
||||||
foreach ($attachment as $attac) {
|
foreach ($attachment as $attac) {
|
||||||
|
|||||||
Reference in New Issue
Block a user