|
@@ -15,7 +15,7 @@ class AfterChild extends Base
|
|
public function getList()
|
|
public function getList()
|
|
{
|
|
{
|
|
|
|
|
|
- $param = $this->request->only(['page' => 1, 'size' => 10, 'returnCode' => '', 'status' => '', 'orderCode' => '', 'outCode' => '', 'order_type' => '', 'supplierNo' => '', 'is_authority' => 0,'type'=>''], 'post', 'trim');
|
|
|
|
|
|
+ $param = $this->request->only(['page' => 1, 'size' => 10, 'returnCode' => '', 'status' => '', 'orderCode' => '', 'outCode' => '', 'order_type' => '', 'supplierNo' => '', 'is_authority' => 0, 'type' => ''], 'post', 'trim');
|
|
|
|
|
|
$db = Db::name('order_return_child')
|
|
$db = Db::name('order_return_child')
|
|
->alias('a')
|
|
->alias('a')
|
|
@@ -130,31 +130,22 @@ class AfterChild extends Base
|
|
if ($value['return_num'] <= 0) continue;//数量为0的不再处理
|
|
if ($value['return_num'] <= 0) continue;//数量为0的不再处理
|
|
$insert[] = [
|
|
$insert[] = [
|
|
'returnCode' => $param['returnCode'],
|
|
'returnCode' => $param['returnCode'],
|
|
- 'orderCode' => $order_out['orderCode'],
|
|
|
|
- 'outCode' => $info['outCode'],
|
|
|
|
- 'order_out_child_status' => $order_out_child[$value['outChildCode']]['status'],
|
|
|
|
'outChildCode' => $value['outChildCode'],
|
|
'outChildCode' => $value['outChildCode'],
|
|
- 'send_wsm_code' => $order_out_child[$value['outChildCode']]['wsm_code'],
|
|
|
|
- 'send_num' => $order_out_child[$value['outChildCode']]['num'],
|
|
|
|
|
|
+ 'order_out_child_status' => $order_out_child[$value['outChildCode']]['status'],
|
|
'return_num' => $value['return_num'],
|
|
'return_num' => $value['return_num'],
|
|
'return_wsm_code' => $value['return_wsm_code'],
|
|
'return_wsm_code' => $value['return_wsm_code'],
|
|
- 'can_sell_num' => 0,
|
|
|
|
- 'defective_num' => 0,
|
|
|
|
- 'loss_num' => 0,
|
|
|
|
'apply_id' => $this->uid,
|
|
'apply_id' => $this->uid,
|
|
'apply_name' => $this->uname,
|
|
'apply_name' => $this->uname,
|
|
- 'status' => 1,
|
|
|
|
'is_del' => 0,
|
|
'is_del' => 0,
|
|
|
|
+ 'status' => 1,
|
|
'remark' => '',
|
|
'remark' => '',
|
|
'addtime' => $date,
|
|
'addtime' => $date,
|
|
- 'updatetime' => $date,
|
|
|
|
- 'type' => 1,
|
|
|
|
- 'return_num_total' => 0
|
|
|
|
|
|
+ 'updatetime' => $date
|
|
];
|
|
];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if ($insert) Db::name('order_return_child')->insertAll($insert);
|
|
|
|
|
|
+ if ($insert) Db::name('order_return_prepare')->insertAll($insert);
|
|
|
|
|
|
Db::name('order_return')
|
|
Db::name('order_return')
|
|
->where(['is_del' => 0, 'id' => $info['id'], 'status' => 11])
|
|
->where(['is_del' => 0, 'id' => $info['id'], 'status' => 11])
|
|
@@ -192,16 +183,25 @@ class AfterChild extends Base
|
|
if (empty($order_return)) return json_show(1004, '售后申请单不存在');
|
|
if (empty($order_return)) return json_show(1004, '售后申请单不存在');
|
|
if ($order_return['status'] != 12) return json_show(1004, '售后申请单状态有误');
|
|
if ($order_return['status'] != 12) return json_show(1004, '售后申请单状态有误');
|
|
|
|
|
|
- $info = Db::name('order_return_child')
|
|
|
|
|
|
+ //退货工单设置信息
|
|
|
|
+ $info = Db::name('order_return_prepare')
|
|
->alias('a')
|
|
->alias('a')
|
|
- ->leftJoin('order_out_child b', 'b.outChildCode=a.outChildCode')
|
|
|
|
- ->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code')
|
|
|
|
- ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode'], 'a.id' => array_column($param['list'], 'id')])
|
|
|
|
- ->column('a.*,b.wsm_code,c.addr,c.addrs_code,c.mobile,c.contactor_name', 'a.id');
|
|
|
|
- if (empty($info)) return json_show(1004, '退货工单不存在');
|
|
|
|
|
|
+ ->leftJoin('order_return b', 'b.returnCode=a.returnCode and b.is_del=0')
|
|
|
|
+ ->leftJoin('order_out_child c', 'c.outChildCode=a.outChildCode and c.is_del=0')
|
|
|
|
+ ->leftJoin('warehouse_info d', 'd.wsm_code=c.send_wsm_code')
|
|
|
|
+ ->leftJoin('warehouse_info e', 'e.wsm_code=a.return_wsm_code')
|
|
|
|
+ ->where(['is_del' => 0, 'returnCode' => $param['returnCode']])
|
|
|
|
+ ->column('a.id,a.returnCode,b.orderCode,c.outCode,a.order_out_child_status,a.outChildCode,d.supplierName send_supplierName,d.supplierNo send_supplierNo,d.name send_wsm_name,c.send_wsm_code,c.contactor_name send_contactor_name,c.send_num,a.return_num,e.supplierName return_supplierName,e.supplierNo return_supplierNo,e.name return_wsm_name,a.return_wsm_code,e.contactor_name return_contactor_name,a.status', 'a.id');
|
|
|
|
+// $info = Db::name('order_return_prepare')
|
|
|
|
+// ->alias('a')
|
|
|
|
+// ->leftJoin('order_out_child b', 'b.outChildCode=a.outChildCode')
|
|
|
|
+// ->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code')
|
|
|
|
+// ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode'], 'a.id' => array_column($param['list'], 'id')])
|
|
|
|
+// ->column('a.*,b.wsm_code,c.addr,c.addrs_code,c.mobile,c.contactor_name', 'a.id');
|
|
|
|
+ if (empty($info)) return json_show(1004, '退货工单设置信息不存在');
|
|
|
|
|
|
$val_child = Validate::rule([
|
|
$val_child = Validate::rule([
|
|
- 'id|退货工单id' => 'require|gt:0|max:999999999',
|
|
|
|
|
|
+ 'id|退货工单设置信息id' => 'require|gt:0|max:999999999',
|
|
'can_sell_num|销售仓入库数量' => 'require|number|egt:0|max:999999999999',
|
|
'can_sell_num|销售仓入库数量' => 'require|number|egt:0|max:999999999999',
|
|
'defective_num|次品仓入库数量' => 'require|number|egt:0|max:999999999999',
|
|
'defective_num|次品仓入库数量' => 'require|number|egt:0|max:999999999999',
|
|
'loss_num|丢失数量' => 'require|number|egt:0|max:999999999999',
|
|
'loss_num|丢失数量' => 'require|number|egt:0|max:999999999999',
|
|
@@ -216,55 +216,83 @@ class AfterChild extends Base
|
|
$insert = [];
|
|
$insert = [];
|
|
foreach ($param['list'] as $value) {
|
|
foreach ($param['list'] as $value) {
|
|
if ($val_child->check($value) == false) throw new Exception($val_child->getError());
|
|
if ($val_child->check($value) == false) throw new Exception($val_child->getError());
|
|
- if (!isset($info[$value['id']])) throw new Exception($value['id'] . '退货工单不存在');
|
|
|
|
- if ($info[$value['id']]['status'] != 1) throw new Exception($value['id'] . '退货工单状态有误');
|
|
|
|
|
|
+ if (!isset($info[$value['id']])) throw new Exception($value['id'] . '退货工单设置信息不存在');
|
|
|
|
+ if ($info[$value['id']]['status'] != 1) throw new Exception($value['id'] . '退货工单设置信息状态有误');
|
|
|
|
|
|
//退货工单
|
|
//退货工单
|
|
- Db::name('order_return_child')
|
|
|
|
- ->where(['is_del' => 0, 'id' => $value['id']])
|
|
|
|
- ->update([
|
|
|
|
|
|
+
|
|
|
|
+ if ($value['can_sell_num'] > 0) {
|
|
|
|
+ $insert[] = [
|
|
|
|
+ 'returnCode' => $param['returnCode'],
|
|
|
|
+ 'orderCode' => $info[$value['id']]['orderCode'],
|
|
|
|
+ 'outCode' => $info[$value['id']]['outCode'],
|
|
|
|
+ 'order_out_child_status' => $info[$value['id']]['order_out_child_status'],
|
|
|
|
+ 'outChildCode' => $info[$value['id']]['outChildCode'],
|
|
|
|
+ 'send_wsm_code' => $info[$value['id']]['send_wsm_code'],
|
|
|
|
+ 'send_num' => $info[$value['id']]['send_num'],
|
|
|
|
+ 'return_num' => $info[$value['id']]['return_num'],
|
|
|
|
+ 'return_wsm_code' => $info[$value['id']]['return_wsm_code'],
|
|
'can_sell_num' => $value['can_sell_num'],
|
|
'can_sell_num' => $value['can_sell_num'],
|
|
'defective_num' => $value['defective_num'],
|
|
'defective_num' => $value['defective_num'],
|
|
'loss_num' => $value['loss_num'],
|
|
'loss_num' => $value['loss_num'],
|
|
- 'remark' => $value['remark'] ?? '',
|
|
|
|
- 'updatetime' => $date,
|
|
|
|
|
|
+ 'apply_id' => $this->uid,
|
|
|
|
+ 'apply_name' => $this->uname,
|
|
'status' => 2,
|
|
'status' => 2,
|
|
- 'return_num_total' => $value['can_sell_num']
|
|
|
|
- ]);
|
|
|
|
-
|
|
|
|
- //发货工单数量减少
|
|
|
|
- Db::name('order_out_child')
|
|
|
|
- ->where(['is_del' => 0, 'outChildCode' => $info[$value['id']]['outChildCode']])
|
|
|
|
- ->dec('num', $info[$value['id']]['return_num'])
|
|
|
|
- ->update(['updatetime' => $date]);
|
|
|
|
-
|
|
|
|
- //如果次品仓入库数量大于0,另生成退货工单,以类型区分
|
|
|
|
- if ($value['defective_num'] > 0) {
|
|
|
|
- $temp = $info[$value['id']];
|
|
|
|
- unset($temp['wsm_code']);
|
|
|
|
- unset($temp['addr']);
|
|
|
|
- unset($temp['addrs_code']);
|
|
|
|
- unset($temp['mobile']);
|
|
|
|
- unset($temp['contactor_name']);
|
|
|
|
-
|
|
|
|
- $insert[] = array_merge($temp, [
|
|
|
|
- 'id' => null,
|
|
|
|
|
|
+ 'is_del' => 0,
|
|
|
|
+ 'remark' => $value['remark'],
|
|
'addtime' => $date,
|
|
'addtime' => $date,
|
|
'updatetime' => $date,
|
|
'updatetime' => $date,
|
|
- 'return_wsm_code' => Db::name('order_returninfo')->where('returnCode', $param['returnCode'])->value('return_wsm', ''),//取之前次品仓的编码
|
|
|
|
- 'type' => 2,
|
|
|
|
- 'return_num_total' => $value['defective_num'],
|
|
|
|
|
|
+ 'type' => 1,
|
|
|
|
+ 'return_num_total' => $value['can_sell_num'],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ //如果次品仓入库数量大于0,另生成退货工单,以类型区分
|
|
|
|
+ if ($value['defective_num'] > 0) {
|
|
|
|
+ $insert[] = [
|
|
|
|
+ 'returnCode' => $param['returnCode'],
|
|
|
|
+ 'orderCode' => $info[$value['id']]['orderCode'],
|
|
|
|
+ 'outCode' => $info[$value['id']]['outCode'],
|
|
|
|
+ 'order_out_child_status' => $info[$value['id']]['order_out_child_status'],
|
|
|
|
+ 'outChildCode' => $info[$value['id']]['outChildCode'],
|
|
|
|
+ 'send_wsm_code' => $info[$value['id']]['send_wsm_code'],
|
|
|
|
+ 'send_num' => $info[$value['id']]['send_num'],
|
|
|
|
+ 'return_num' => $info[$value['id']]['return_num'],
|
|
|
|
+ 'return_wsm_code' => $info[$value['id']]['return_wsm_code'],
|
|
'can_sell_num' => $value['can_sell_num'],
|
|
'can_sell_num' => $value['can_sell_num'],
|
|
'defective_num' => $value['defective_num'],
|
|
'defective_num' => $value['defective_num'],
|
|
'loss_num' => $value['loss_num'],
|
|
'loss_num' => $value['loss_num'],
|
|
- 'remark' => $value['remark'] ?? '',
|
|
|
|
|
|
+ 'apply_id' => $this->uid,
|
|
|
|
+ 'apply_name' => $this->uname,
|
|
'status' => 2,
|
|
'status' => 2,
|
|
- ]);
|
|
|
|
|
|
+ 'is_del' => 0,
|
|
|
|
+ 'remark' => $value['remark'],
|
|
|
|
+ 'addtime' => $date,
|
|
|
|
+ 'updatetime' => $date,
|
|
|
|
+ 'type' => 2,
|
|
|
|
+ 'return_num_total' => $value['defective_num'],
|
|
|
|
+ ];
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ if ($insert) Db::name('order_return_child')->insertAll($insert);
|
|
|
|
|
|
- if ($insert) Db::name('order_return_child')->insertAll($insert);
|
|
|
|
|
|
+// Db::name('order_return_child')
|
|
|
|
+// ->where(['is_del' => 0, 'id' => $value['id']])
|
|
|
|
+// ->update([
|
|
|
|
+// 'can_sell_num' => $value['can_sell_num'],
|
|
|
|
+// 'defective_num' => $value['defective_num'],
|
|
|
|
+// 'loss_num' => $value['loss_num'],
|
|
|
|
+// 'remark' => $value['remark'] ?? '',
|
|
|
|
+// 'updatetime' => $date,
|
|
|
|
+// 'status' => 2,
|
|
|
|
+// 'return_num_total' => $value['can_sell_num']
|
|
|
|
+// ]);
|
|
|
|
+
|
|
|
|
+ //发货工单数量减少
|
|
|
|
+ Db::name('order_out_child')
|
|
|
|
+ ->where(['is_del' => 0, 'outChildCode' => $info[$value['id']]['outChildCode']])
|
|
|
|
+ ->dec('num', $info[$value['id']]['return_num'])
|
|
|
|
+ ->update(['updatetime' => $date]);
|
|
|
|
+ }
|
|
|
|
|
|
$total = array_sum(array_column($param['list'], 'can_sell_num'));
|
|
$total = array_sum(array_column($param['list'], 'can_sell_num'));
|
|
|
|
|
|
@@ -560,6 +588,11 @@ class AfterChild extends Base
|
|
->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => 12])
|
|
->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => 12])
|
|
->update(['status' => 5, 'updatetime' => $date]);
|
|
->update(['status' => 5, 'updatetime' => $date]);
|
|
|
|
|
|
|
|
+ //售后退货工单设置信息维护
|
|
|
|
+ Db::name('order_return_prepare')
|
|
|
|
+ ->where(['is_del' => 0, 'status' => 1, 'id' => array_column($info, 'id')])
|
|
|
|
+ ->update(['updatetime' => $date, 'status' => 3]);
|
|
|
|
+
|
|
Db::commit();
|
|
Db::commit();
|
|
return json_show(0, '库管收货成功');
|
|
return json_show(0, '库管收货成功');
|
|
} catch (Exception $exception) {
|
|
} catch (Exception $exception) {
|
|
@@ -625,4 +658,54 @@ class AfterChild extends Base
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //获取 售后退货工单设置信息
|
|
|
|
+ public function getPreList()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ $param = $this->request->only(['page' => 1, 'size' => 10, 'returnCode' => '', 'status' => ''], 'post', 'trim');
|
|
|
|
+
|
|
|
|
+ $db = Db::name('order_return_prepare')
|
|
|
|
+ ->alias('a')
|
|
|
|
+ ->leftJoin('order_return b', 'b.returnCode=a.returnCode and b.is_del=0')
|
|
|
|
+ ->leftJoin('order_out_child c', 'c.outChildCode=a.outChildCode and c.is_del=0')
|
|
|
|
+ ->leftJoin('warehouse_info d', 'd.wsm_code=c.wsm_code')
|
|
|
|
+ ->leftJoin('warehouse_info e', 'e.wsm_code=a.return_wsm_code')
|
|
|
|
+ ->where('a.is_del', 0);
|
|
|
|
+
|
|
|
|
+ if ($param['returnCode'] != '') $db->whereLike('a.returnCode', '%' . $param['returnCode'] . '%');
|
|
|
|
+ if ($param['status'] !== '') $db->where('a.status', $param['status']);
|
|
|
|
+
|
|
|
|
+ $count = $db
|
|
|
|
+ ->count('a.id');
|
|
|
|
+
|
|
|
|
+ $list = $db
|
|
|
|
+ ->field(['a.id',
|
|
|
|
+ 'a.returnCode',
|
|
|
|
+ 'b.orderCode',
|
|
|
|
+ 'c.outCode',
|
|
|
|
+ 'a.order_out_child_status',
|
|
|
|
+ 'a.outChildCode',
|
|
|
|
+ 'd.supplierName send_supplierName',
|
|
|
|
+ 'd.supplierNo send_supplierNo',
|
|
|
|
+ 'd.name send_wsm_name',
|
|
|
|
+ 'c.wsm_code send_wsm_code',
|
|
|
|
+ 'd.contactor_name send_contactor_name',
|
|
|
|
+ 'c.num send_num',
|
|
|
|
+ 'a.return_num',
|
|
|
|
+ 'e.supplierName return_supplierName',
|
|
|
|
+ 'e.supplierNo return_supplierNo',
|
|
|
|
+ 'e.name return_wsm_name',
|
|
|
|
+ 'a.return_wsm_code',
|
|
|
|
+ 'e.contactor_name return_contactor_name',
|
|
|
|
+ 'a.status'])
|
|
|
|
+ ->order(['a.addtime' => 'desc', 'a.id' => 'desc'])
|
|
|
|
+ ->page($param['page'], $param['size'])
|
|
|
|
+ ->select()
|
|
|
|
+ ->toArray();
|
|
|
|
+
|
|
|
|
+ return json_show(0, '获取列表成功', ['count' => $count, 'list' => $list]);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|