调整基类更新后置方法&&增加转交、业务单详情
This commit is contained in:
@@ -144,7 +144,7 @@ class PurchaseOrdersService
|
||||
}
|
||||
}
|
||||
|
||||
return $this->postProcess(ucfirst($scene), $order);
|
||||
return $this->postProcess(ucfirst($scene), $order, ['is_resubmit'=>$data['is_resubmit']]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -213,11 +213,9 @@ class PurchaseOrdersService
|
||||
*/
|
||||
protected function afterServiceStore($res)
|
||||
{
|
||||
// if ($res->status == 1) {
|
||||
// $this->startApproval($res, ['resubmitted'=>0]);
|
||||
// }
|
||||
|
||||
$this->startApproval($res, ['resubmitted'=>0]);
|
||||
if ($res->status == 1) {
|
||||
$this->startApproval($res, ['resubmitted'=>0]);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -227,6 +225,28 @@ class PurchaseOrdersService
|
||||
$appro->start('purchase_orders', 'purchase_orders', $item->id, ['resubmitted'=>0], $item->buyer_id);
|
||||
}
|
||||
|
||||
protected function afterServiceUpdate($res, $data)
|
||||
{
|
||||
if ($data['is_resubmit'] == 0 && $res->status == 1) {
|
||||
$this->startApproval($res);
|
||||
}
|
||||
if ($data['is_resubmit'] == 1) {
|
||||
$instance = \app\common\model\ApprovalInstances::where('biz_id', $res->id)->where('flow_type', 'purchase_orders')->first();
|
||||
if ( $instance === null) {
|
||||
throw new BusinessException('未找到审批实例');
|
||||
}
|
||||
// 审批服务
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
// 重新提交
|
||||
$appro->resubmit($instance->id, $instance->initiator_id, ['resubmitted'=>1], $data['remark']);
|
||||
// 添加到讨论
|
||||
if (!empty($data['remark'])) {
|
||||
$appro->postDiscussion($instance->id, $instance->initiator_id, $data['remark'], false, [], 'name');
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
public function serviceResubmit(Request $request, array $data = [])
|
||||
{
|
||||
@@ -271,4 +291,47 @@ class PurchaseOrdersService
|
||||
$info->status = $data['status'];
|
||||
return $info->save();
|
||||
}
|
||||
|
||||
|
||||
public function formatData($data)
|
||||
{
|
||||
$contractFile = $data['contract_file'] ? explode(',', $data['contract_file']) : [];
|
||||
$contractFileUrl = [];
|
||||
if (count($contractFile) > 0) {
|
||||
foreach ($contractFile as $file) {
|
||||
$contractFileUrl[] = (new \app\common\service\OssService)->generatePrivateUrl($file);
|
||||
}
|
||||
}
|
||||
$result = [
|
||||
'id' => $data['id'],
|
||||
'order_no' => $data['order_no'],
|
||||
'pi_no' => $data['pi_no'],
|
||||
'buyer_id' => $data['buyer_id'],
|
||||
'buyer_name' => $data['buyer_name'],
|
||||
'contract_file' => $contractFile,
|
||||
'contract_file_url' => $contractFileUrl,
|
||||
'status' => $data['status'],
|
||||
'remark' => $data['remark']
|
||||
];
|
||||
$temps = [];
|
||||
if (isset($data['items']) && count($data['items']) > 0) {
|
||||
foreach ($data['items'] as $record) {
|
||||
if (!in_array($record['stockOrder']['id'], array_keys($temps))) {
|
||||
$temps[$record['stockOrder']['id']] = [
|
||||
'id' => $record['stockOrder']['id'],
|
||||
'order_no' => $record['stockOrder']['order_no'],
|
||||
'salesperson_snapshot' => $record['stockOrder']['salesperson_snapshot'],
|
||||
'biz_date' => date('Y-m-d', $record['stockOrder']['biz_date'])
|
||||
];
|
||||
}
|
||||
$temps[$record['stockOrder']['id']]['stock_order_items'][] =[
|
||||
'id' => $record['stockOrderItems']['id'],
|
||||
'model_snapshot' => $record['stockOrderItems']['model_snapshot'],
|
||||
'unique_id' => $record['stockOrderItems']['unique_id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$result['stock_order'] = array_values($temps);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user