|
@@ -90,7 +90,7 @@ class After extends Base
|
|
|
} else {
|
|
|
$goon = Db::name('good_platform')
|
|
|
->alias('a')
|
|
|
- ->field("b.creater,b.createrid,b.supplierNo")
|
|
|
+ ->field("b.creater,b.createrid,b.supplierNo,b.supplierName")
|
|
|
->join('good b', 'b.spuCode=a.spuCode', 'left')
|
|
|
->where(['a.skuCode' => $oder['skuCode']])
|
|
|
->findOrEmpty();
|
|
@@ -109,7 +109,7 @@ class After extends Base
|
|
|
// if (!isset($supplier['code']) || $supplier['code'] != 0) return json_show($supplier['code'], $supplier['message'], $supplier['data']);
|
|
|
$supplier = $supplier['data'];
|
|
|
|
|
|
- $names = $userCommon->handle('getCodeAndName', ['code' => [$oder['customer_code'], $oder['supplierNo']]]);
|
|
|
+// $names = $userCommon->handle('getCodeAndName', ['code' => [$oder['customer_code'], $oder['supplierNo']]]);
|
|
|
|
|
|
// $supplier =Db::name("supplier")->where(["code"=>$goon['supplierNo']])->find();
|
|
|
// if($supplier==false){
|
|
@@ -157,11 +157,11 @@ class After extends Base
|
|
|
"good_code" => $oder['good_code'],
|
|
|
"good_name" => $oder['good_name'],
|
|
|
"customer_code" => $oder['customer_code'],
|
|
|
- "customer_name" => $names['data'][$oder['customer_code']] ?? '',
|
|
|
+ "customer_name" =>$oder['customerName'],
|
|
|
"apply_id" => $rm,
|
|
|
"apply_name" => $ri,
|
|
|
'supplierNo' => $goon['supplierNo'],
|
|
|
- 'supplierName' => $supplier['name'],
|
|
|
+ 'supplierName' => $goon['supplierName'],
|
|
|
"cgder" => $wsm['contactor_name'] ?? '',
|
|
|
"cgderid" => $wsm['contactor'] ?? 0,
|
|
|
"person" => $supplier['person'] ?? '',
|
|
@@ -177,7 +177,7 @@ class After extends Base
|
|
|
"except_code" => $param['except_code'],
|
|
|
"order_type" => $orderout['order_type'],
|
|
|
'companyNo' => $oder['supplierNo'],
|
|
|
- 'companyName' => $names['data'][$oder['supplierNo']] ?? '',
|
|
|
+ 'companyName' => $oder['supplierName'],
|
|
|
"status" => 1,
|
|
|
"is_del" => 0,
|
|
|
"addtime" => date("Y-m-d H:i:s"),
|
|
@@ -213,13 +213,13 @@ class After extends Base
|
|
|
$process = ["order_code" => $returnCode, "order_id" => $create, "order_status" => $in['status'], "order_type" => 'SHD', "before_status" => 0, 'holder_id' => $in['apply_id']];
|
|
|
ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
|
|
|
Db::commit();
|
|
|
- return app_show(0, "售后申请单新建成功", ["returnCode" => $returnCode]);
|
|
|
+ return json_show(0, "售后申请单新建成功", ["returnCode" => $returnCode]);
|
|
|
}
|
|
|
Db::rollback();
|
|
|
return error_show(1005, "售后申请单新建失败");
|
|
|
- } catch (Exception $e) {
|
|
|
+ } catch (Exception $exception) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1005, $e->getMessage());
|
|
|
+ return json_show(1005, $exception->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -384,6 +384,8 @@ class After extends Base
|
|
|
// $info['supplierNo'] = $goon['supplierNo'];
|
|
|
|
|
|
$int = isset($goon['cat_id']) && $goon['cat_id'] != 0 ? made($goon['cat_id']) : [];
|
|
|
+ $info['can'] = $int;
|
|
|
+
|
|
|
$addcode = '';
|
|
|
if ($info['addr_code'] != "") {
|
|
|
list($a, $b, $c) = explode(",", $info['addr_code']);
|
|
@@ -401,27 +403,27 @@ class After extends Base
|
|
|
->alias("a")
|
|
|
// ->leftJoin("supplier b", "a.supplierNo=b.code")
|
|
|
->where(["a.wsm_code" => $info['return_wsm']])
|
|
|
- ->field("a.name as wsm_name,a.wsm_code,a.contactor_name,a.position,a.mobile,a.addrs_code,a.addr,a.companyNo,a.supplierNo")
|
|
|
+// ->field("a.name as wsm_name,a.wsm_code,a.contactor_name,a.position,a.mobile,a.addrs_code,a.addr,a.companyNo,a.supplierNo")
|
|
|
->find();
|
|
|
|
|
|
}
|
|
|
|
|
|
- $userCommon = \app\admin\common\User::getIns();
|
|
|
- $names = $userCommon->handle('getCodeAndName', ['code' => [
|
|
|
- $wsmcode['supplierNo'] ?? '',
|
|
|
- $wsmcode['companyNo'] ?? '',
|
|
|
-// $info['customer_code'],
|
|
|
-// $info['companyNo'],
|
|
|
-// $info['supplierNo'],
|
|
|
- ]]);
|
|
|
+// $userCommon = \app\admin\common\User::getIns();
|
|
|
+// $names = $userCommon->handle('getCodeAndName', ['code' => [
|
|
|
+// $wsmcode['supplierNo'] ?? '',
|
|
|
+// $wsmcode['companyNo'] ?? '',
|
|
|
+//// $info['customer_code'],
|
|
|
+//// $info['companyNo'],
|
|
|
+//// $info['supplierNo'],
|
|
|
+// ]]);
|
|
|
|
|
|
if ($info['return_wsm'] != '') {
|
|
|
$info['wsm_supplierNo'] = $wsmcode['supplierNo'] ?? "";
|
|
|
- $info['wsm_supplier'] = $names['data'][$wsmcode['supplierNo']] ?? '';//isset($wsmcode['name']) ? $wsmcode['name'] : "";
|
|
|
- $info['wsm_customer_name'] = $names['data'][$wsmcode['companyNo']] ?? '';//isset($customer['company']) ? trim($customer['company']) : '';
|
|
|
+ $info['wsm_supplier'] = $wsmcode['supplierName'];//isset($wsmcode['name']) ? $wsmcode['name'] : "";
|
|
|
+ $info['wsm_customer_name'] = $wsmcode['companyName'];//isset($customer['company']) ? trim($customer['company']) : '';
|
|
|
$info['wsm_customer_code'] = $wsmcode['companyNo'] ?? "";//isset($customer['companyNo']) ? trim($customer['companyNo']) : '';
|
|
|
$info['wsm_code'] = isset($wsmcode['wsm_code']) ? $wsmcode['wsm_code'] : "";
|
|
|
- $info['wsm_name'] = isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name'] : "";
|
|
|
+ $info['wsm_name'] = isset($wsmcode['name']) ? $wsmcode['name'] : "";
|
|
|
}
|
|
|
|
|
|
// $customer = [];
|
|
@@ -433,8 +435,6 @@ class After extends Base
|
|
|
// $info['companyName'] = $names['data'][$info['companyNo']] ?? '';
|
|
|
// $info['supplierName'] = $names['data'][$info['supplierNo']] ?? '';
|
|
|
|
|
|
- $info['can'] = $int;
|
|
|
-
|
|
|
//仓库的联系人、职位、电话、省市区和地址
|
|
|
isset($wsmcode['contactor_name']) ? $info['contactor'] = $wsmcode['contactor_name'] : '';//联系人
|
|
|
isset($wsmcode['mobile']) ? $info['mobile'] = $wsmcode['mobile'] : '';//电话
|
|
@@ -446,14 +446,15 @@ class After extends Base
|
|
|
// $info['addr'] = $wsmcode['addr'];//地址
|
|
|
$info['spuCode'] = $orderinfo['good_code'];
|
|
|
$info['skuCode'] = $orderinfo['skuCode'];
|
|
|
- $info['return_tag'] = $info['return_tag'] == 0 ? "" : $info['return_tag'];//地址
|
|
|
- $info['is_th'] = $info['is_th'] == 0 ? "" : $info['is_th'];//地址
|
|
|
+ $info['return_tag'] = $info['return_tag'] == 0 ? "" : $info['return_tag'];
|
|
|
+ $info['is_th'] = $info['is_th'] == 0 ? "" : $info['is_th'];
|
|
|
|
|
|
return app_show(0, "获取成功", $info);
|
|
|
}
|
|
|
|
|
|
//售后申请单 审核
|
|
|
- //申请单状态:1待业务审核,2待采购审核,3待设置仓库(该节点废除),4待客户退货,5售后已完成,6业务已驳回,7采购已驳回(该节点废除),8申请已取消,9供应商审核,10业务公司修改待供应商确认
|
|
|
+ //申请单状态:1待业务审核,2待采购审核,3待设置仓库(该节点废除),4待客户退货(已收到货才有),5售后已完成,6业务已驳回,7采购已驳回(该节点废除),8申请已取消,9供应商审核,10业务公司修改待供应商确认
|
|
|
+ //11待设置退货工单(已收到货才有),12待库管收货(已收到货才有)
|
|
|
public function status()
|
|
|
{
|
|
|
try {
|
|
@@ -500,7 +501,9 @@ class After extends Base
|
|
|
if (in_array($param['status'], [6, 9]) == false) throw new Exception('选项错误');
|
|
|
break;
|
|
|
case 9:
|
|
|
- if (in_array($param['status'], [2, 4, 5]) == false) throw new Exception('选项错误');
|
|
|
+ if ((($info['is_receive'] == 1) && (in_array($param['status'], [2, 4]) == false) || (($info['is_receive'] == 0) && (in_array($param['status'], [2, 5]) == false)))) throw new Exception('选项错误');
|
|
|
+
|
|
|
+// if (in_array($param['status'], [2, 4, 5]) == false) throw new Exception('选项错误');
|
|
|
// if ($this->level != 3) throw new Exception('当前状态下只能由供应商账号操作');
|
|
|
if ($param['status'] == 4) {
|
|
|
if ($param['contactor'] == '') throw new Exception('收货人不能为空');
|
|
@@ -510,22 +513,13 @@ class After extends Base
|
|
|
}
|
|
|
break;
|
|
|
case 2:
|
|
|
- if (in_array($param['status'], [10, 4, 5]) == false) throw new Exception('选项错误');
|
|
|
- if ($param['status'] == 4) {
|
|
|
- if ($param['wsm_code'] == '') throw new Exception('请填写退回仓库');
|
|
|
- else {
|
|
|
- $ware = Db::name('warehouse_info')
|
|
|
- ->field('contactor_name contactor,mobile,addr,addrs_code addr_code')
|
|
|
- ->where(['wsm_code' => $param['wsm_code'], 'is_del' => 0])
|
|
|
- ->findOrEmpty();
|
|
|
- if (empty($ware)) throw new Exception('该仓库不存在');
|
|
|
- else $param = array_merge($param, $ware);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ if ((($info['is_receive'] == 1) && (in_array($param['status'], [10, 11]) == false) || (($info['is_receive'] == 0) && (in_array($param['status'], [10, 5]) == false)))) throw new Exception('选项错误');
|
|
|
|
|
|
break;
|
|
|
case 10:
|
|
|
- if (in_array($param['status'], [2, 4, 5]) == false) throw new Exception('选项错误');
|
|
|
+ if ((($info['is_receive'] == 1) && (in_array($param['status'], [2, 4]) == false) || (($info['is_receive'] == 0) && (in_array($param['status'], [2, 5]) == false)))) throw new Exception('选项错误');
|
|
|
+
|
|
|
if ($param['status'] == 4) {
|
|
|
if ($param['contactor'] == '') throw new Exception('收货人不能为空');
|
|
|
if ($param['mobile'] == '') throw new Exception('联系电话不能为空');
|
|
@@ -573,7 +567,7 @@ class After extends Base
|
|
|
|
|
|
//判断 退回供应商 or 退回业务公司
|
|
|
if ($info['status'] == 9) {
|
|
|
- if ($param['status'] == 4) $info['return_tag'] = 1;
|
|
|
+ if (in_array($param['status'],[4,5])) $info['return_tag'] = 1;
|
|
|
else $info['return_tag'] = 2;
|
|
|
}
|
|
|
|
|
@@ -1317,8 +1311,17 @@ class After extends Base
|
|
|
->update($returninfo);
|
|
|
|
|
|
if ($up) {
|
|
|
+
|
|
|
+ //查看是否有退货工单
|
|
|
+ $temp = Db::name('order_return_child')
|
|
|
+ ->field('id')
|
|
|
+ ->where(['is_del' => 0, 'returnCode' => $bkcode])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if (empty($temp)) $info['status'] = 5;//没有退货工单,更新到status5,售后申请已结束
|
|
|
+ else $info['status'] = 12;//存在退货工单,要更新到status12(待库管收货)
|
|
|
+
|
|
|
$old_info_status = $info['status'];
|
|
|
- $info['status'] = 5;
|
|
|
+// $info['status'] = 5;
|
|
|
$info['updatetime'] = date("y-m-d H:i:s");
|
|
|
$ro = Db::name("order_return")->save($info);
|
|
|
if ($ro) {
|
|
@@ -1341,281 +1344,281 @@ class After extends Base
|
|
|
]);
|
|
|
|
|
|
//售后退货单数据
|
|
|
- $thNo = makeNo("ST");
|
|
|
- $thdata = [
|
|
|
- "thNo" => $thNo,
|
|
|
- "orderCode" => $out["orderCode"],
|
|
|
- "outCode" => $out["outCode"],
|
|
|
- "order_type" => $info["order_type"],
|
|
|
- "returnCode" => $info["returnCode"],
|
|
|
- "good_code" => $info["good_code"],
|
|
|
- "good_name" => $info["good_name"],
|
|
|
- "return_wsm" => $returninfo["return_wsm"],
|
|
|
- "total_fee" => round($sale['sale_price'] * $info["error_num"], 2),
|
|
|
- "good_price" => $sale['sale_price'],
|
|
|
- "platform_id" => $sale['platform_id'],
|
|
|
- "return_msg" => $info["error_msg"],
|
|
|
- "return_num" => $info["error_num"],
|
|
|
- "normal_num" => 0,
|
|
|
- "received_num" => 0,
|
|
|
- "apply_id" => $info['apply_id'],
|
|
|
- "apply_name" => $info['apply_name'],
|
|
|
- "cgder" => $info['cgder'],
|
|
|
- "cgderid" => $info['cgderid'],
|
|
|
- "person" => $info['person'],
|
|
|
- "person_id" => $info['person_id'],
|
|
|
- "contactor" => $returninfo["contactor"],
|
|
|
- "mobile" => $returninfo["mobile"],
|
|
|
- "addr" => $returninfo["addr"],
|
|
|
- "addr_code" => $returninfo["addr_code"],
|
|
|
- "return_code" => $info["error_code"],
|
|
|
- "post_fee" => $returninfo["post_fee"],
|
|
|
- "post_code" => $returninfo["post_code"],
|
|
|
- "post_company" => $returninfo["post_company"],
|
|
|
- "customer_code" => $info["customer_code"],
|
|
|
- "customer_name" => $info["customer_name"],
|
|
|
- "status" => $info['return_tag'] == 1 ? 4 : 1, //return_tag==1退回供应商,status:4完成退货,1待验收
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s"),
|
|
|
- 'supplierNo' => $info['supplierNo'],
|
|
|
- 'supplierName' => $info['supplierName'],
|
|
|
- 'companyNo' => $info['companyNo'],
|
|
|
- 'companyName' => $info['companyName'],
|
|
|
- ];
|
|
|
- $sav = Db::name("order_back")->insert($thdata, true);
|
|
|
- if ($sav) {
|
|
|
-
|
|
|
- //修改状态,添加待办
|
|
|
- ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
- "order_code" => $thdata['thNo'],//销售单code
|
|
|
- "status" => $thdata['status'],//这里的status是之前的值
|
|
|
- "action_remark" => '',//备注
|
|
|
- "action_type" => "create"//新建create,编辑edit,更改状态status
|
|
|
- ], "CKTHD", $thdata['status'], $thdata);
|
|
|
-
|
|
|
-
|
|
|
- //售后退货单,供应商不同意退货,退回到业务公司仓的时候,要把待办数据推给供应商负责人和库管人员
|
|
|
- if ($thdata['status'] == 1) {
|
|
|
-
|
|
|
- //31库管人员,41库管-张凯旋
|
|
|
- $uids = Db::name('user_role')
|
|
|
- ->where(['is_del' => 0, 'roleid' => [31, 41], 'status' => 1])
|
|
|
- ->column('uid');
|
|
|
-
|
|
|
- ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
- "order_type" => 'CKTHD',
|
|
|
- "order_code" => $thdata['thNo'],//销售单code
|
|
|
- "order_id" => $sav,
|
|
|
- "order_status" => $thdata['status'],
|
|
|
- "before_status" => 0,
|
|
|
- 'handle_user_list' => implode(',', array_merge($uids, [$sale['cgderid']])),
|
|
|
- ]);
|
|
|
- } else {
|
|
|
- ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
- "order_type" => 'CKTHD',
|
|
|
- "order_code" => $thdata['thNo'],//销售单code
|
|
|
- "order_id" => $sav,
|
|
|
- "order_status" => $thdata['status'],
|
|
|
- "before_status" => 0
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //维护台账记录
|
|
|
-// Db::name('standing_book')
|
|
|
-// ->where(['returnCode' => $bkcode])
|
|
|
-// ->update([
|
|
|
-// 'thNo' => $thNo,
|
|
|
-// 'updatetime' => date("Y-m-d H:i:s")
|
|
|
-// ]);
|
|
|
- Db::execute("UPDATE `wsm_standing_book` SET `thNo`=CONCAT(IFNULL(`thNo`,''),',{$thNo}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE FIND_IN_SET('{$bkcode}',`returnCode`)");//这里的returnCode可能有多个
|
|
|
- // 库存品退货 不退商品 需要计算成本
|
|
|
-// if($info['except_code']==1){
|
|
|
-// $sabebn =Db::name("sale_info")->where(["orderCode"=>$info['orderCode']])->select()->toArray();
|
|
|
-// if(!empty($sabebn)){
|
|
|
-// $total_num =$info["error_num"];
|
|
|
-// foreach ($sabebn as $ve){
|
|
|
+// $thNo = makeNo("ST");
|
|
|
+// $thdata = [
|
|
|
+// "thNo" => $thNo,
|
|
|
+// "orderCode" => $out["orderCode"],
|
|
|
+// "outCode" => $out["outCode"],
|
|
|
+// "order_type" => $info["order_type"],
|
|
|
+// "returnCode" => $info["returnCode"],
|
|
|
+// "good_code" => $info["good_code"],
|
|
|
+// "good_name" => $info["good_name"],
|
|
|
+// "return_wsm" => $returninfo["return_wsm"],
|
|
|
+// "total_fee" => round($sale['sale_price'] * $info["error_num"], 2),
|
|
|
+// "good_price" => $sale['sale_price'],
|
|
|
+// "platform_id" => $sale['platform_id'],
|
|
|
+// "return_msg" => $info["error_msg"],
|
|
|
+// "return_num" => $info["error_num"],
|
|
|
+// "normal_num" => 0,
|
|
|
+// "received_num" => 0,
|
|
|
+// "apply_id" => $info['apply_id'],
|
|
|
+// "apply_name" => $info['apply_name'],
|
|
|
+// "cgder" => $info['cgder'],
|
|
|
+// "cgderid" => $info['cgderid'],
|
|
|
+// "person" => $info['person'],
|
|
|
+// "person_id" => $info['person_id'],
|
|
|
+// "contactor" => $returninfo["contactor"],
|
|
|
+// "mobile" => $returninfo["mobile"],
|
|
|
+// "addr" => $returninfo["addr"],
|
|
|
+// "addr_code" => $returninfo["addr_code"],
|
|
|
+// "return_code" => $info["error_code"],
|
|
|
+// "post_fee" => $returninfo["post_fee"],
|
|
|
+// "post_code" => $returninfo["post_code"],
|
|
|
+// "post_company" => $returninfo["post_company"],
|
|
|
+// "customer_code" => $info["customer_code"],
|
|
|
+// "customer_name" => $info["customer_name"],
|
|
|
+// "status" => $info['return_tag'] == 1 ? 4 : 1, //return_tag==1退回供应商,status:4完成退货,1待验收
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
+// "updatetime" => date("Y-m-d H:i:s"),
|
|
|
+// 'supplierNo' => $info['supplierNo'],
|
|
|
+// 'supplierName' => $info['supplierName'],
|
|
|
+// 'companyNo' => $info['companyNo'],
|
|
|
+// 'companyName' => $info['companyName'],
|
|
|
+// ];
|
|
|
+// $sav = Db::name("order_back")->insert($thdata, true);
|
|
|
+// if ($sav) {
|
|
|
+//
|
|
|
+// //修改状态,添加待办
|
|
|
+// ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+// "order_code" => $thdata['thNo'],//销售单code
|
|
|
+// "status" => $thdata['status'],//这里的status是之前的值
|
|
|
+// "action_remark" => '',//备注
|
|
|
+// "action_type" => "create"//新建create,编辑edit,更改状态status
|
|
|
+// ], "CKTHD", $thdata['status'], $thdata);
|
|
|
+//
|
|
|
//
|
|
|
-// $tempnum=0;
|
|
|
-// if ($total_num==0) break;
|
|
|
-// if($total_num>=$ve['num']){
|
|
|
-// $tempnum = $ve['num'];
|
|
|
-// $total_num-=$ve['num'];
|
|
|
-// $ve['num']=0;
|
|
|
-// }else{
|
|
|
-// $tempnum = $total_num;
|
|
|
-// $ve['num']-=$total_num;
|
|
|
-// $total_num=0;
|
|
|
-// }
|
|
|
-// $bnin=GoodStockInfo::ReturnAdd($stockid,$ve['bnCode'],$tempnum,$ve['stockid']);
|
|
|
-// if($bnin==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
-// }
|
|
|
-// $up=Db::name("sale_info")->save($ve);
|
|
|
-// if($up==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
-// }
|
|
|
-// $bnin=GoodStockInfo::ReturnBn($info['returnCode'],$ve['id'],$tempnum);
|
|
|
-// if($bnin==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
-// }
|
|
|
-// }
|
|
|
+// //售后退货单,供应商不同意退货,退回到业务公司仓的时候,要把待办数据推给供应商负责人和库管人员
|
|
|
+// if ($thdata['status'] == 1) {
|
|
|
+//
|
|
|
+// //31库管人员,41库管-张凯旋
|
|
|
+// $uids = Db::name('user_role')
|
|
|
+// ->where(['is_del' => 0, 'roleid' => [31, 41], 'status' => 1])
|
|
|
+// ->column('uid');
|
|
|
+//
|
|
|
+// ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+// "order_type" => 'CKTHD',
|
|
|
+// "order_code" => $thdata['thNo'],//销售单code
|
|
|
+// "order_id" => $sav,
|
|
|
+// "order_status" => $thdata['status'],
|
|
|
+// "before_status" => 0,
|
|
|
+// 'handle_user_list' => implode(',', array_merge($uids, [$sale['cgderid']])),
|
|
|
+// ]);
|
|
|
+// } else {
|
|
|
+// ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+// "order_type" => 'CKTHD',
|
|
|
+// "order_code" => $thdata['thNo'],//销售单code
|
|
|
+// "order_id" => $sav,
|
|
|
+// "order_status" => $thdata['status'],
|
|
|
+// "before_status" => 0
|
|
|
+// ]);
|
|
|
// }
|
|
|
-// }else{
|
|
|
//
|
|
|
-// }
|
|
|
-
|
|
|
- //退回供应商的时候,处理库存
|
|
|
- if ($info['return_tag'] == 1) {
|
|
|
- $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");
|
|
|
- $uap = Db::name("sale")->save($sale);
|
|
|
-
|
|
|
- if ($uap == false) throw new Exception('销售单订单更新失败');
|
|
|
-// if($uap==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005,'销售单订单更新失败');
|
|
|
+//
|
|
|
+// //维护台账记录
|
|
|
+//// Db::name('standing_book')
|
|
|
+//// ->where(['returnCode' => $bkcode])
|
|
|
+//// ->update([
|
|
|
+//// 'thNo' => $thNo,
|
|
|
+//// 'updatetime' => date("Y-m-d H:i:s")
|
|
|
+//// ]);
|
|
|
+// Db::execute("UPDATE `wsm_standing_book` SET `thNo`=CONCAT(IFNULL(`thNo`,''),',{$thNo}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE FIND_IN_SET('{$bkcode}',`returnCode`)");//这里的returnCode可能有多个
|
|
|
+// // 库存品退货 不退商品 需要计算成本
|
|
|
+//// if($info['except_code']==1){
|
|
|
+//// $sabebn =Db::name("sale_info")->where(["orderCode"=>$info['orderCode']])->select()->toArray();
|
|
|
+//// if(!empty($sabebn)){
|
|
|
+//// $total_num =$info["error_num"];
|
|
|
+//// foreach ($sabebn as $ve){
|
|
|
+////
|
|
|
+//// $tempnum=0;
|
|
|
+//// if ($total_num==0) break;
|
|
|
+//// if($total_num>=$ve['num']){
|
|
|
+//// $tempnum = $ve['num'];
|
|
|
+//// $total_num-=$ve['num'];
|
|
|
+//// $ve['num']=0;
|
|
|
+//// }else{
|
|
|
+//// $tempnum = $total_num;
|
|
|
+//// $ve['num']-=$total_num;
|
|
|
+//// $total_num=0;
|
|
|
+//// }
|
|
|
+//// $bnin=GoodStockInfo::ReturnAdd($stockid,$ve['bnCode'],$tempnum,$ve['stockid']);
|
|
|
+//// if($bnin==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
+//// }
|
|
|
+//// $up=Db::name("sale_info")->save($ve);
|
|
|
+//// if($up==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
+//// }
|
|
|
+//// $bnin=GoodStockInfo::ReturnBn($info['returnCode'],$ve['id'],$tempnum);
|
|
|
+//// if($bnin==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+//// }else{
|
|
|
+////
|
|
|
+//// }
|
|
|
+//
|
|
|
+// //退回供应商的时候,处理库存
|
|
|
+// if ($info['return_tag'] == 1) {
|
|
|
+// $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");
|
|
|
+// $uap = Db::name("sale")->save($sale);
|
|
|
+//
|
|
|
+// if ($uap == false) throw new Exception('销售单订单更新失败');
|
|
|
+//// if($uap==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005,'销售单订单更新失败');
|
|
|
+//// }
|
|
|
+// if ($sale['is_stock'] == 0) {
|
|
|
+// $ordernum = Db::name("order_num")
|
|
|
+// ->where(['orderCode' => $info['orderCode']])
|
|
|
+// ->find();
|
|
|
+// if ($ordernum == false) throw new Exception('未找到关联采购单1');
|
|
|
+//// if($ordernum==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005,'未找到关联采购单');
|
|
|
+//// }
|
|
|
+// $ordernum['send_num'] -= $info['error_num'];
|
|
|
+// $orderup = Db::name("order_num")->save($ordernum);
|
|
|
+//
|
|
|
+// if ($orderup == false) throw new Exception('关联数据更新失败');
|
|
|
+//
|
|
|
+//// if($orderup==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005,'关联数据更新失败');
|
|
|
+//// }
|
|
|
+// $cgd = Db::name("purchease_order")
|
|
|
+// ->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])
|
|
|
+// ->findOrEmpty();
|
|
|
+// if (empty($cgd)) throw new Exception('未找到采购单数据');
|
|
|
+//// if($cgd==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005,'未找到采购单数据');
|
|
|
+//// }
|
|
|
+// $cgd['th_num'] += $info['error_num'];
|
|
|
+// if ($cgd['th_num'] == $cgd['send_num'] && $cgd['wsend_num'] == 0) {
|
|
|
+// $cgd['status'] = 4;
|
|
|
+// }
|
|
|
+// $cgd['th_fee'] += round($info['error_num'] * $cgd['good_price'], 2);
|
|
|
+// $cgd['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $cgdup = Db::name("purchease_order")->save($cgd);
|
|
|
+//
|
|
|
+// if ($cgdup == false) throw new Exception('采购单数据更新失败');
|
|
|
+//// if($cgdup==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005,'采购单数据更新失败');
|
|
|
+//// }
|
|
|
// }
|
|
|
- if ($sale['is_stock'] == 0) {
|
|
|
- $ordernum = Db::name("order_num")
|
|
|
- ->where(['orderCode' => $info['orderCode']])
|
|
|
- ->find();
|
|
|
- if ($ordernum == false) throw new Exception('未找到关联采购单1');
|
|
|
-// if($ordernum==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005,'未找到关联采购单');
|
|
|
-// }
|
|
|
- $ordernum['send_num'] -= $info['error_num'];
|
|
|
- $orderup = Db::name("order_num")->save($ordernum);
|
|
|
-
|
|
|
- if ($orderup == false) throw new Exception('关联数据更新失败');
|
|
|
-
|
|
|
-// if($orderup==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005,'关联数据更新失败');
|
|
|
-// }
|
|
|
- $cgd = Db::name("purchease_order")
|
|
|
- ->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])
|
|
|
- ->findOrEmpty();
|
|
|
- if (empty($cgd)) throw new Exception('未找到采购单数据');
|
|
|
-// if($cgd==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005,'未找到采购单数据');
|
|
|
-// }
|
|
|
- $cgd['th_num'] += $info['error_num'];
|
|
|
- if ($cgd['th_num'] == $cgd['send_num'] && $cgd['wsend_num'] == 0) {
|
|
|
- $cgd['status'] = 4;
|
|
|
- }
|
|
|
- $cgd['th_fee'] += round($info['error_num'] * $cgd['good_price'], 2);
|
|
|
- $cgd['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $cgdup = Db::name("purchease_order")->save($cgd);
|
|
|
-
|
|
|
- if ($cgdup == false) throw new Exception('采购单数据更新失败');
|
|
|
-// if($cgdup==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005,'采购单数据更新失败');
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
- $sabebn = Db::name("sale_info")
|
|
|
- ->where([["orderCode", "=", $info['orderCode']], ["num", ">", 0]])
|
|
|
- ->select()
|
|
|
- ->toArray();
|
|
|
- if (!empty($sabebn)) {
|
|
|
- $total_num = $info["error_num"];
|
|
|
- foreach ($sabebn as $ve) {
|
|
|
- $tempnum = 0;
|
|
|
- if ($total_num == 0) break;
|
|
|
- if ($total_num >= $ve['num']) {
|
|
|
- $tempnum = $ve['num'];
|
|
|
- $total_num -= $ve['num'];
|
|
|
- $ve['th_num'] += $ve['num'];
|
|
|
- $ve['num'] = 0;
|
|
|
- } else {
|
|
|
- $tempnum = $total_num;
|
|
|
- $ve['num'] -= $total_num;
|
|
|
- $ve['th_num'] += $total_num;
|
|
|
- $total_num = 0;
|
|
|
- }
|
|
|
-
|
|
|
- if ($info['except_code'] == 1) {
|
|
|
-// if($sale['is_stock']==1){
|
|
|
-// $bnin=GoodStockInfo::AddBn($ve['stockid'],$ve['bnCode'],$tempnum);
|
|
|
-// if($bnin==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
-// }
|
|
|
-// }
|
|
|
- $up = Db::name("sale_info")->save($ve);
|
|
|
-
|
|
|
- if ($up == false) throw new Exception('可售商品Bn库存数入库失败');
|
|
|
-// if($up==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
- $bnin = GoodStockInfo::ReturnBn($info['returnCode'], $ve['id'], $tempnum);
|
|
|
- if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
|
|
|
-// if($bnin==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
-// }
|
|
|
- }
|
|
|
- }
|
|
|
- if ($info['error_num'] >= $out['send_num']) {
|
|
|
- $out['status'] = 4;
|
|
|
- $out['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $upout = Db::name("order_out")->save($out);
|
|
|
- if ($upout == false) throw new Exception('出库单数据更新失败');
|
|
|
-// if($upout==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1005,'出库单数据更新失败');
|
|
|
+//
|
|
|
+// $sabebn = Db::name("sale_info")
|
|
|
+// ->where([["orderCode", "=", $info['orderCode']], ["num", ">", 0]])
|
|
|
+// ->select()
|
|
|
+// ->toArray();
|
|
|
+// if (!empty($sabebn)) {
|
|
|
+// $total_num = $info["error_num"];
|
|
|
+// foreach ($sabebn as $ve) {
|
|
|
+// $tempnum = 0;
|
|
|
+// if ($total_num == 0) break;
|
|
|
+// if ($total_num >= $ve['num']) {
|
|
|
+// $tempnum = $ve['num'];
|
|
|
+// $total_num -= $ve['num'];
|
|
|
+// $ve['th_num'] += $ve['num'];
|
|
|
+// $ve['num'] = 0;
|
|
|
+// } else {
|
|
|
+// $tempnum = $total_num;
|
|
|
+// $ve['num'] -= $total_num;
|
|
|
+// $ve['th_num'] += $total_num;
|
|
|
+// $total_num = 0;
|
|
|
// }
|
|
|
- }
|
|
|
- $data = [
|
|
|
- "orderCode" => $info['orderCode'],
|
|
|
- "th_type" => 3,
|
|
|
- "th_num" => $info['error_num'],
|
|
|
- "th_fee" => round($sale['sale_price'] * $info["error_num"], 2),
|
|
|
- "thCode" => $thNo,
|
|
|
- "spuCode" => $sale['good_code'],
|
|
|
- "good_name" => $sale['good_name'],
|
|
|
- "cat_id" => $sale['cat_id'],
|
|
|
- "apply_id" => $info['apply_id'],
|
|
|
- "apply_name" => $info['apply_name'],
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "status" => 1,
|
|
|
- "is_del" => 0
|
|
|
- ];
|
|
|
- $inse = Db::name("th_data")->insert($data);
|
|
|
- if ($inse == false) throw new Exception('退货单更新失败');
|
|
|
-
|
|
|
-
|
|
|
-// if($inse==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1004,"退货单更新失败");
|
|
|
+//
|
|
|
+// if ($info['except_code'] == 1) {
|
|
|
+//// if($sale['is_stock']==1){
|
|
|
+//// $bnin=GoodStockInfo::AddBn($ve['stockid'],$ve['bnCode'],$tempnum);
|
|
|
+//// if($bnin==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+// $up = Db::name("sale_info")->save($ve);
|
|
|
+//
|
|
|
+// if ($up == false) throw new Exception('可售商品Bn库存数入库失败');
|
|
|
+//// if($up==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
+//// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// $bnin = GoodStockInfo::ReturnBn($info['returnCode'], $ve['id'], $tempnum);
|
|
|
+// if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
|
|
|
+//// if($bnin==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005, '可售商品Bn库存数入库失败');
|
|
|
+//// }
|
|
|
+// }
|
|
|
// }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- Db::commit();
|
|
|
- return app_show(0, "退货单新建成功", ["thNo" => $thNo]);
|
|
|
- }
|
|
|
+// if ($info['error_num'] >= $out['send_num']) {
|
|
|
+// $out['status'] = 4;
|
|
|
+// $out['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $upout = Db::name("order_out")->save($out);
|
|
|
+// if ($upout == false) throw new Exception('出库单数据更新失败');
|
|
|
+//// if($upout==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1005,'出库单数据更新失败');
|
|
|
+//// }
|
|
|
+// }
|
|
|
+// $data = [
|
|
|
+// "orderCode" => $info['orderCode'],
|
|
|
+// "th_type" => 3,
|
|
|
+// "th_num" => $info['error_num'],
|
|
|
+// "th_fee" => round($sale['sale_price'] * $info["error_num"], 2),
|
|
|
+// "thCode" => $thNo,
|
|
|
+// "spuCode" => $sale['good_code'],
|
|
|
+// "good_name" => $sale['good_name'],
|
|
|
+// "cat_id" => $sale['cat_id'],
|
|
|
+// "apply_id" => $info['apply_id'],
|
|
|
+// "apply_name" => $info['apply_name'],
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
+// "status" => 1,
|
|
|
+// "is_del" => 0
|
|
|
+// ];
|
|
|
+// $inse = Db::name("th_data")->insert($data);
|
|
|
+// if ($inse == false) throw new Exception('退货单创建失败');
|
|
|
+//
|
|
|
+//
|
|
|
+//// if($inse==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return error_show(1004,"退货单更新失败");
|
|
|
+//// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// Db::commit();
|
|
|
+// return app_show(0, "退货单新建成功", ["thNo" => $thNo]);
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
- Db::rollback();
|
|
|
- return error_show(1004, '退货失败');
|
|
|
+ Db::commit();
|
|
|
+ return json_show(0, '退货成功');
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1004, $e->getMessage());
|
|
|
+ return json_show(1004, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1636,11 +1639,11 @@ class After extends Base
|
|
|
->field('id,status,apply_id')
|
|
|
->where([
|
|
|
['returnCode', '=', $data['returnCode']],
|
|
|
- ['is_del', '=', 0],
|
|
|
- ['status', '<>', 8]
|
|
|
+ ['is_del', '=', 0]
|
|
|
])->findOrEmpty();
|
|
|
|
|
|
- if (!$rs) throw new Exception('该售后单记录不存在');
|
|
|
+ if (empty($rs)) throw new Exception('该售后单记录不存在');
|
|
|
+ if (in_array($rs['status'], [4, 12, 5, 8])) throw new Exception('不允许取消');
|
|
|
|
|
|
//修改记录
|
|
|
$res = Db::name('order_return')->where(['id' => $rs['id']])->update(['status' => 8, 'updatetime' => date('Y-m-d H:i:s')]);
|