|
@@ -1358,13 +1358,54 @@ class After extends Base
|
|
|
"before_status" => $old_info_status,
|
|
|
'holder_id' => $info['apply_id']
|
|
|
]);
|
|
|
+
|
|
|
+
|
|
|
+ //如果售后已完成,维护销售单、发货单和采购单
|
|
|
+ if ($info['status'] == 5) {
|
|
|
+ $sale['th_num'] += $info['error_num'];
|
|
|
+ if ($sale['th_num'] == $sale['send_num'] && $sale['wsend_num'] == 0) {
|
|
|
+ $sale['status'] = 3;
|
|
|
+ }
|
|
|
+ $sale['th_fee'] += round($info['error_num'] * $sale['sale_price'], 2);
|
|
|
+ $sale['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ Db::name("sale")->save($sale);
|
|
|
+
|
|
|
+ if ($info['error_num'] >= $out['send_num']) $out['status'] = 4;
|
|
|
+ $out['send_num'] -= $info['error_num'];
|
|
|
+ $out['error_num'] += $info['error_num'];
|
|
|
+ $out['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $upout = Db::name("order_out")->save($out);
|
|
|
+ if ($upout == false) throw new Exception('出库单数据更新失败');
|
|
|
+
|
|
|
+ //发货工单
|
|
|
+ Db::name('order_out_child')
|
|
|
+ ->where(['is_del' => 0, 'outCode' => $info["outCode"]])
|
|
|
+ ->dec('num', $info['error_num'])
|
|
|
+ ->update(['updatetime' => date("Y-m-d H:i:s")]);
|
|
|
+
|
|
|
+ //如果供应商承担,维护采购单
|
|
|
+ if ($info['is_th'] == 1) {
|
|
|
+ $cgdNo = Db::name('order_num')
|
|
|
+ ->where(['orderCode' => $info['orderCode']])
|
|
|
+ ->value('cgdNo', '');
|
|
|
+ if ($cgdNo != '') {
|
|
|
+ Db::name('purchease_order')
|
|
|
+ ->where(['is_del' => 0, 'cgdNo' => $cgdNo])
|
|
|
+ ->dec('th_num', $info['error_num'])
|
|
|
+ ->dec('th_fee', round($sale['sale_price'] * $info['error_num'], 2))
|
|
|
+ ->update(['updatetime' => date("Y-m-d H:i:s")]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
Db::commit();
|
|
|
return json_show(0, '退货成功');
|
|
|
} else throw new Exception('修改售后申请单状态失败');
|
|
|
|
|
|
} else throw new Exception('退货失败');
|
|
|
|
|
|
- //售后退货单数据
|
|
|
+ //售后退货单数据
|
|
|
// $thNo = makeNo("ST");
|
|
|
// $thdata = [
|
|
|
// "thNo" => $thNo,
|