|
@@ -71,7 +71,7 @@ class ReorderChild extends Base
|
|
|
'orderCode' => $saleReturn['orderCode'],
|
|
|
'returnCode' => $param['returnCode'],
|
|
|
'outCode' => $param['type'] == 2 ? $orderOutChild[$value['outChildCode']]['outCode'] : '',
|
|
|
- 'outChildCode' => $value['outChildCode'],
|
|
|
+ 'outChildCode' => $value['outChildCode'] ?? '',
|
|
|
'order_out_child_status' => $param['type'] == 2 ? $orderOutChild[$value['outChildCode']]['status'] : '',
|
|
|
'saleReturnChildCode' => substr(makeNo('KCC'), 0, -2) . str_pad($i++, 2, '0', STR_PAD_LEFT),
|
|
|
'type' => $param['type'],
|
|
@@ -148,7 +148,7 @@ class ReorderChild extends Base
|
|
|
//库管收货(退货工单)
|
|
|
public function receive()
|
|
|
{
|
|
|
- $param = $this->request->only(['id', 'good_receive_type', 'loss_num', 'remark' => '', 'record' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['id', 'good_receive_type', 'loss_num', 'remark' => ''], 'post', 'trim');
|
|
|
|
|
|
$val = Validate::rule([
|
|
|
'id|ID' => 'require|number|gt:0',
|
|
@@ -168,7 +168,7 @@ class ReorderChild extends Base
|
|
|
->where(['a.is_del' => 0, 'a.id' => $param['id']])
|
|
|
->findOrEmpty();
|
|
|
if (empty($info)) return json_show(1004, '该退货工单不存在');
|
|
|
- if ($info['status'] == 1) return json_show(1004, '该退货工单已收货');
|
|
|
+ if ($info['status'] != 1) return json_show(1004, '该退货工单已收货');
|
|
|
if ($param['loss_num'] > $info['num']) return json_show(1004, '丢失数量大于下单数量');
|
|
|
|
|
|
Db::startTrans();
|
|
@@ -186,7 +186,6 @@ class ReorderChild extends Base
|
|
|
'good_receive_type' => $param['good_receive_type'],
|
|
|
'loss_num' => $param['loss_num'],
|
|
|
'remark' => $param['remark'],
|
|
|
- 'record' => $param['record']
|
|
|
]);
|
|
|
|
|
|
//检查所属销售单的退货工单是否全部完成退货
|
|
@@ -202,18 +201,25 @@ class ReorderChild extends Base
|
|
|
//维护销售单
|
|
|
$order = Db::name('sale')->where(['is_del' => 0, 'id' => $info['saleid']])->findOrEmpty();
|
|
|
//未发货数量要减去发货单上的发货数量
|
|
|
- $out_send_num = Db::name('order_out')
|
|
|
- ->where(['is_del' => 0, 'orderCode' => $info['orderCode'], 'status' => [0, 1]])
|
|
|
- ->sum('send_num');
|
|
|
+// $out_send_num = Db::name('order_out')
|
|
|
+// ->where(['is_del' => 0, 'orderCode' => $info['orderCode'], 'status' => [0, 1]])
|
|
|
+// ->sum('send_num');
|
|
|
|
|
|
- $order['wsend_num'] -= $out_send_num;
|
|
|
+// $order['wsend_num'] -= $out_send_num;
|
|
|
|
|
|
$thnum = $info['thnum'];//退货总数量
|
|
|
- if ($order['wsend_num'] < $thnum) throw new Exception("销售单未发货数量不足退货");
|
|
|
+// if ($order['wsend_num'] < $thnum) throw new Exception("销售单未发货数量不足退货");
|
|
|
+
|
|
|
+ //如果 发货 维护销售单的
|
|
|
+ //else 未发货数量减,
|
|
|
+ if ($info['order_out_status'] == 1) {
|
|
|
+ $order['wsend_num'] -= $thnum;
|
|
|
+ $order['send_num'] += $thnum;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// $lor = $order['status'];
|
|
|
|
|
|
- $lor = $order['status'];
|
|
|
- $order['wsend_num'] -= $thnum;
|
|
|
- $order['send_num'] += $thnum;
|
|
|
$order['status'] = $order['wsend_num'] == 0 ? 2 : ($order['send_num'] == 0 ? 0 : 1);
|
|
|
$order['send_status'] = $order['wsend_num'] == 0 ? 3 : ($order['send_num'] == 0 ? 1 : 2);
|
|
|
$order['th_num'] += $thnum;
|
|
@@ -225,19 +231,19 @@ class ReorderChild extends Base
|
|
|
$uap = Db::name("sale")->save($order);
|
|
|
if ($uap == false) throw new Exception('销售单订单更新失败');
|
|
|
|
|
|
- ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
- "order_code" => $order["orderCode"],//出库单号
|
|
|
- "status" => $lor,//这里的status是之前的值
|
|
|
- "action_remark" => '',//备注
|
|
|
- "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
- ], "XSQRD", $order['status'], $order);
|
|
|
-
|
|
|
- ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
- "order_type" => 'XSQRD',
|
|
|
- "order_code" => $order["orderCode"],//出库单号
|
|
|
- "order_id" => $order["id"],
|
|
|
- "order_status" => $order['status'], "before_status" => $lor
|
|
|
- ]);
|
|
|
+// ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+// "order_code" => $order["orderCode"],//出库单号
|
|
|
+// "status" => $lor,//这里的status是之前的值
|
|
|
+// "action_remark" => '',//备注
|
|
|
+// "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
+// ], "XSQRD", $order['status'], $order);
|
|
|
+//
|
|
|
+// ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+// "order_type" => 'XSQRD',
|
|
|
+// "order_code" => $order["orderCode"],//出库单号
|
|
|
+// "order_id" => $order["id"],
|
|
|
+// "order_status" => $order['status'], "before_status" => $lor
|
|
|
+// ]);
|
|
|
}
|
|
|
|
|
|
//发货工单数量减少
|
|
@@ -271,4 +277,49 @@ class ReorderChild extends Base
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //详情
|
|
|
+ public function info()
|
|
|
+ {
|
|
|
+ $param = $this->request->only(['id'], 'post', 'trim');
|
|
|
+
|
|
|
+ $val = Validate::rule(['id' => 'require|number|gt:0']);
|
|
|
+
|
|
|
+ if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
+
|
|
|
+ $info = Db::name('sale_return_child')
|
|
|
+ ->where(['is_del' => 0, 'id' => $param['id']])
|
|
|
+ ->findOrEmpty();
|
|
|
+
|
|
|
+ return empty($info) ? json_show(1004, '该退货工单不存在') : json_show(0, '获取退货工单详情成功', $info);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新退货工单标记
|
|
|
+ public function setRecord()
|
|
|
+ {
|
|
|
+
|
|
|
+ $param = $this->request->only(['id', 'record'], 'post', 'trim');
|
|
|
+
|
|
|
+ $val = Validate::rule([
|
|
|
+ 'id|退货工单id' => 'require|number|gt:0',
|
|
|
+ 'record|标记内容' => 'require',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
+
|
|
|
+ $temp = Db::name('sale_return_child')
|
|
|
+ ->field('id')
|
|
|
+ ->where(['is_del' => 0, 'id' => $param['id']])
|
|
|
+ ->findOrEmpty();
|
|
|
+
|
|
|
+ if (empty($temp)) return json_show(1004, '该退货工单不存在');
|
|
|
+
|
|
|
+ $rs = Db::name('sale_return_child')
|
|
|
+ ->where(['is_del' => 0, 'id' => $param['id']])
|
|
|
+ ->update(['record' => $param['record'], 'updatetime' => date('Y-m-d H:i:s')]);
|
|
|
+
|
|
|
+ return $rs ? json_show(0, '更新退货工单标记内容成功') : json_show(1004, '更新退货工单标记内容失败');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|