|
@@ -873,40 +873,40 @@ class Reorder extends Base
|
|
|
$ste = ["order_code" => $code, "status" => $temp, "action_remark" => '', "action_type" => "status"];
|
|
|
ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], $ste, "XSTHD", $status, $info);
|
|
|
if ($status == 4) {
|
|
|
- if ($info['is_addr'] == 1) {
|
|
|
- if (isset($addr) && !empty($addr)) {
|
|
|
- foreach ($addr as $value) {
|
|
|
- $addrinfo = Db::name("order_addr")
|
|
|
- ->where(['id' => $value['addrid'], "is_del" => 0])
|
|
|
- ->findOrEmpty();
|
|
|
- if (empty($addrinfo)) throw new Exception("地址数据未找到");
|
|
|
-
|
|
|
- if ($addrinfo['receipt_quantity'] < $value['return_num']) throw new Exception("地址发货数量不足");
|
|
|
-
|
|
|
- $addrinfo['receipt_quantity'] -= $value['return_num'];
|
|
|
- $addrinfo['is_del'] = $addrinfo['receipt_quantity'] <= 0 ? 1 : 0;
|
|
|
- $addrinfo['updatetime'] = $date;
|
|
|
- $addrup = Db::name("order_addr")->save($addrinfo);
|
|
|
- if ($addrup == false) throw new Exception('地址发货数量更新失败');
|
|
|
-
|
|
|
- if ($value['outCode'] != "") {
|
|
|
- $out = Db::name("order_out")->where(["outCode" => $value['outCode']])->findOrEmpty();
|
|
|
- if (empty($out)) throw new Exception('地址发货单数据未找到');
|
|
|
-
|
|
|
- if ($out['status'] >= 2) throw new Exception('地址发货单已发货');
|
|
|
-
|
|
|
- if ($out['send_num'] < $value['return_num']) throw new Exception('地址发货单发货数量不足');
|
|
|
-
|
|
|
- $out['send_num'] -= $value['return_num'];
|
|
|
- $out['is_del'] = $out['send_num'] <= 0 ? 1 : 0;
|
|
|
- $out['updatetime'] = $date;
|
|
|
- $outup = Db::name("order_out")->save($out);
|
|
|
- if ($outup == false) throw new Exception('地址发货单更新失败');
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// if ($info['is_addr'] == 1) {
|
|
|
+// if (isset($addr) && !empty($addr)) {
|
|
|
+// foreach ($addr as $value) {
|
|
|
+// $addrinfo = Db::name("order_addr")
|
|
|
+// ->where(['id' => $value['addrid'], "is_del" => 0])
|
|
|
+// ->findOrEmpty();
|
|
|
+// if (empty($addrinfo)) throw new Exception("地址数据未找到");
|
|
|
+//
|
|
|
+// if ($addrinfo['receipt_quantity'] < $value['return_num']) throw new Exception("地址发货数量不足");
|
|
|
+//
|
|
|
+// $addrinfo['receipt_quantity'] -= $value['return_num'];
|
|
|
+// $addrinfo['is_del'] = $addrinfo['receipt_quantity'] <= 0 ? 1 : 0;
|
|
|
+// $addrinfo['updatetime'] = $date;
|
|
|
+// $addrup = Db::name("order_addr")->save($addrinfo);
|
|
|
+// if ($addrup == false) throw new Exception('地址发货数量更新失败');
|
|
|
+//
|
|
|
+// if ($value['outCode'] != "") {
|
|
|
+// $out = Db::name("order_out")->where(["outCode" => $value['outCode']])->findOrEmpty();
|
|
|
+// if (empty($out)) throw new Exception('地址发货单数据未找到');
|
|
|
+//
|
|
|
+// if ($out['status'] >= 2) throw new Exception('地址发货单已发货');
|
|
|
+//
|
|
|
+// if ($out['send_num'] < $value['return_num']) throw new Exception('地址发货单发货数量不足');
|
|
|
+//
|
|
|
+// $out['send_num'] -= $value['return_num'];
|
|
|
+// $out['is_del'] = $out['send_num'] <= 0 ? 1 : 0;
|
|
|
+// $out['updatetime'] = $date;
|
|
|
+// $outup = Db::name("order_out")->save($out);
|
|
|
+// if ($outup == false) throw new Exception('地址发货单更新失败');
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
if ($orderinfo['wsend_num'] < $info['num']) throw new Exception('销售单未发货数量不足退货');
|
|
|
|
|
@@ -1453,7 +1453,6 @@ class Reorder extends Base
|
|
|
// }
|
|
|
$userCommon = \app\admin\common\User::getIns();
|
|
|
$tmp = $userCommon->handle('sInfo', ['code' => $goon['supplierNo']]);
|
|
|
- if (!isset($tmp['code']) || $tmp['code'] != 0) return json_show($tmp['code'], $tmp['message'], $tmp['data']);
|
|
|
$supplier = $tmp['data'];
|
|
|
if (empty($supplier)) return json_show(1005, "未找到商品供应商数据");
|
|
|
|
|
@@ -1523,72 +1522,72 @@ class Reorder extends Base
|
|
|
ProcessOrder::AddProcess(["id" => $this->uid, "nickname" => $this->uname], $process);
|
|
|
//维护台账信息
|
|
|
Db::execute("UPDATE `wsm_standing_book` SET `returnGoodCode`=CONCAT(IFNULL(`returnGoodCode`,''),',{$returnCode}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE `orderCode`='{$orderCode}'");
|
|
|
- if (count($addr) != 0) {
|
|
|
- $inf = [];
|
|
|
- foreach ($addr as $val) {
|
|
|
- if ($val['receipt_quantity'] == 0) continue;//当退货数量为0时,跳过
|
|
|
-
|
|
|
- $temp = [];
|
|
|
- $send = Db::name('order_out')->where([["addrid", "=", $val['id']]])->find();
|
|
|
- if ($send == false) throw new Exception("地址发货单未找到");
|
|
|
-
|
|
|
- if ($send['status'] >= 2) throw new Exception("地址已发货");
|
|
|
-
|
|
|
-
|
|
|
- if ($order['is_stock'] == 1) {
|
|
|
-
|
|
|
- $val['is_del'] = 1;
|
|
|
- $val['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $addrup = Db::name("order_addr")->save($val);
|
|
|
- if ($addrup == false) throw new Exception("地址更新失败");
|
|
|
-
|
|
|
-
|
|
|
- $send['is_del'] = 1;
|
|
|
- $send['remark'] = '全退';
|
|
|
- $send['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $outup = Db::name("order_out")->save($send);
|
|
|
- if ($outup == false) throw new Exception("地址发货单更新失败");
|
|
|
-
|
|
|
-
|
|
|
- //处理发货申请单流程
|
|
|
- ProcessOrder::AddProcess(["id" => $this->uid, "nickname" => $this->uname], [
|
|
|
- "order_type" => 'CKD',
|
|
|
- "order_code" => $send["outCode"],//出库单号
|
|
|
- "order_id" => $send["id"],
|
|
|
- "order_status" => 4,//全部退货
|
|
|
- "before_status" => $send['status'],
|
|
|
- 'holder_id=' => $send['apply_id']
|
|
|
- ]);
|
|
|
-// $ordersend = Db::name("order_send")->where(["outCode" => $send['outCode']])->find();
|
|
|
-// if($ordersend==false){
|
|
|
-// Db::rollback();
|
|
|
-// return json_show(1004, "发货单关联数据未找到");
|
|
|
-// }
|
|
|
-// $ordersend['status'] = 0;
|
|
|
-// $ordersend['updatetime'] = date("Y-m-d H:i:s");
|
|
|
-// $sendip = Db::name("order_send")->save($ordersend);
|
|
|
-// if ($sendip == false) {
|
|
|
-// Db::rollback();
|
|
|
-// return json_show(1004, "发货单更新失败");
|
|
|
-// }
|
|
|
- }
|
|
|
- $temp['returnCode'] = $returnCode;
|
|
|
- $temp['orderCode'] = $orderCode;
|
|
|
- $temp['outCode'] = isset($send['outCode']) ? $send['outCode'] : "";
|
|
|
- $temp['addrid'] = $val['id'];
|
|
|
- $temp['send_num'] = $val['receipt_quantity'];
|
|
|
- $temp['return_num'] = $val['receipt_quantity'];
|
|
|
- $temp['is_del'] = 0;
|
|
|
- $temp['addtime'] = date("Y-m-d H:i:s");
|
|
|
- $temp['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $inf[] = $temp;
|
|
|
- }
|
|
|
- $inadd = Db::name("sale_returnaddr")->insertAll($inf);
|
|
|
- if ($inadd == 0) throw new Exception("退货单新建失败");
|
|
|
-
|
|
|
- }
|
|
|
+// if (count($addr) != 0) {
|
|
|
+// $inf = [];
|
|
|
+// foreach ($addr as $val) {
|
|
|
+// if ($val['receipt_quantity'] == 0) continue;//当退货数量为0时,跳过
|
|
|
+//
|
|
|
+// $temp = [];
|
|
|
+// $send = Db::name('order_out')->where([["addrid", "=", $val['id']]])->find();
|
|
|
+// if ($send == false) throw new Exception("地址发货单未找到");
|
|
|
+//
|
|
|
+// if ($send['status'] >= 2) throw new Exception("地址已发货");
|
|
|
+//
|
|
|
+//
|
|
|
+// if ($order['is_stock'] == 1) {
|
|
|
+//
|
|
|
+// $val['is_del'] = 1;
|
|
|
+// $val['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $addrup = Db::name("order_addr")->save($val);
|
|
|
+// if ($addrup == false) throw new Exception("地址更新失败");
|
|
|
+//
|
|
|
+//
|
|
|
+// $send['is_del'] = 1;
|
|
|
+// $send['remark'] = '全退';
|
|
|
+// $send['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $outup = Db::name("order_out")->save($send);
|
|
|
+// if ($outup == false) throw new Exception("地址发货单更新失败");
|
|
|
+//
|
|
|
+//
|
|
|
+// //处理发货申请单流程
|
|
|
+// ProcessOrder::AddProcess(["id" => $this->uid, "nickname" => $this->uname], [
|
|
|
+// "order_type" => 'CKD',
|
|
|
+// "order_code" => $send["outCode"],//出库单号
|
|
|
+// "order_id" => $send["id"],
|
|
|
+// "order_status" => 4,//全部退货
|
|
|
+// "before_status" => $send['status'],
|
|
|
+// 'holder_id=' => $send['apply_id']
|
|
|
+// ]);
|
|
|
+//// $ordersend = Db::name("order_send")->where(["outCode" => $send['outCode']])->find();
|
|
|
+//// if($ordersend==false){
|
|
|
+//// Db::rollback();
|
|
|
+//// return json_show(1004, "发货单关联数据未找到");
|
|
|
+//// }
|
|
|
+//// $ordersend['status'] = 0;
|
|
|
+//// $ordersend['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+//// $sendip = Db::name("order_send")->save($ordersend);
|
|
|
+//// if ($sendip == false) {
|
|
|
+//// Db::rollback();
|
|
|
+//// return json_show(1004, "发货单更新失败");
|
|
|
+//// }
|
|
|
+// }
|
|
|
+// $temp['returnCode'] = $returnCode;
|
|
|
+// $temp['orderCode'] = $orderCode;
|
|
|
+// $temp['outCode'] = isset($send['outCode']) ? $send['outCode'] : "";
|
|
|
+// $temp['addrid'] = $val['id'];
|
|
|
+// $temp['send_num'] = $val['receipt_quantity'];
|
|
|
+// $temp['return_num'] = $val['receipt_quantity'];
|
|
|
+// $temp['is_del'] = 0;
|
|
|
+// $temp['addtime'] = date("Y-m-d H:i:s");
|
|
|
+// $temp['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $inf[] = $temp;
|
|
|
+// }
|
|
|
+// $inadd = Db::name("sale_returnaddr")->insertAll($inf);
|
|
|
+// if ($inadd == 0) throw new Exception("退货单新建失败");
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
- if ($order['is_stock'] == 1) {
|
|
|
+ if ($in['status'] == 4 && $order['is_stock'] == 1) {
|
|
|
$lor = $order['status'];
|
|
|
$thnum = $order['wsend_num'];
|
|
|
$order['send_num'] += $thnum;
|
|
@@ -1617,67 +1616,67 @@ class Reorder extends Base
|
|
|
'holder_id=' => $order['apply_id']
|
|
|
]);
|
|
|
|
|
|
- $saleinfo = Db::name("sale_info")->where([["orderCode", "=", $orderCode], ["num", ">", 0]])->select()->toArray();
|
|
|
- if (empty($saleinfo)) {
|
|
|
- $ordernum = Db::name("order_num")->where(['orderCode' => $orderCode])->findOrEmpty();
|
|
|
- if (empty($ordernum)) throw new Exception('未找到关联采购单');
|
|
|
-
|
|
|
- $cgd = Db::name("purchease_order")->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])->findOrEmpty();
|
|
|
- if (empty($cgd)) throw new Exception('未找到采购单数据');
|
|
|
-
|
|
|
- $bn = makeNo("BN");
|
|
|
- $stock = Db::name("good_stock")->where(["spuCode" => $order['good_code'], 'wsm_code' => $cgd['wsm_code'], "is_del" => 0, "status" => 1])->find();
|
|
|
- if ($stock == false) throw new Exception('商品库存数据未找到');
|
|
|
-
|
|
|
- $stock['usable_stock'] += $thnum;
|
|
|
- $stock['wait_out_stock'] -= $thnum;
|
|
|
- $stock['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $st_up = Db::name("good_stock")->save($stock);
|
|
|
- if ($st_up == false) throw new Exception('可售商品入库失败');
|
|
|
-
|
|
|
- $yp = GoodStockInfo::AddBn($stock['id'], $bn, $thnum, $cgd['good_price']);
|
|
|
- if ($yp == false) throw new Exception('商品批次退货入库失败');
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- $tempnum = $thnum;
|
|
|
- foreach ($saleinfo as $va) {
|
|
|
- if ($tempnum == 0) break;
|
|
|
- $stock = Db::name("good_stock")->where(["spuCode" => $order['good_code'], 'id' => $va['stockid']])->findOrEmpty();
|
|
|
- if ($stock == false) throw new Exception('商品库存数据未找到');
|
|
|
-
|
|
|
- if ($va['num'] >= $tempnum) {
|
|
|
- $tnm = $tempnum;
|
|
|
- $va['num'] -= $tempnum;
|
|
|
- $va['th_num'] += $tempnum;
|
|
|
- $tempnum = 0;
|
|
|
- } else {
|
|
|
- $tnm = $va['num'];
|
|
|
- $tempnum -= $va['num'];
|
|
|
- $va['th_num'] += $va['num'];
|
|
|
- $va['num'] = 0;
|
|
|
- }
|
|
|
- $stock['usable_stock'] += $tnm;
|
|
|
- $stock['wait_out_stock'] -= $tnm;
|
|
|
- $stock['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $st_up = Db::name("good_stock")->save($stock);
|
|
|
- if ($st_up == false) throw new Exception('可售商品入库失败');
|
|
|
-
|
|
|
- $ps = GoodStockInfo::AddBn($va['stockid'], $va['bnCode'], $tnm);
|
|
|
- if ($ps == false) throw new Exception('商品批次退货入库失败');
|
|
|
-
|
|
|
- $ret = GoodStockInfo::ReturnBn($returnCode, $va['id'], $tnm);
|
|
|
- if ($ret == false) throw new Exception('商品批次退货入库失败');
|
|
|
-
|
|
|
- $va['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $sal = Db::name("sale_info")->save($va);
|
|
|
- if ($sal == false) throw new Exception('商品批次退货入库失败');
|
|
|
-
|
|
|
- $good_data[] = ['good_log_code' => $returnCode, "stock_id" => $va['stockid'], "type" => 1, 'stock' => $tnm, "stock_name" => "usable_stock"];
|
|
|
- $good_data[] = ['good_log_code' => $returnCode, "stock_id" => $va['stockid'], "type" => 2, 'stock' => $tnm, "stock_name" => "wait_out_stock"];
|
|
|
- GoodLog::LogAdd(['id' => $this->uid, 'nickname' => $this->uname], $good_data, 'XSTHD');
|
|
|
- }
|
|
|
- }
|
|
|
+// $saleinfo = Db::name("sale_info")->where([["orderCode", "=", $orderCode], ["num", ">", 0]])->select()->toArray();
|
|
|
+// if (empty($saleinfo)) {
|
|
|
+// $ordernum = Db::name("order_num")->where(['orderCode' => $orderCode])->findOrEmpty();
|
|
|
+// if (empty($ordernum)) throw new Exception('未找到关联采购单');
|
|
|
+//
|
|
|
+// $cgd = Db::name("purchease_order")->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])->findOrEmpty();
|
|
|
+// if (empty($cgd)) throw new Exception('未找到采购单数据');
|
|
|
+//
|
|
|
+// $bn = makeNo("BN");
|
|
|
+// $stock = Db::name("good_stock")->where(["spuCode" => $order['good_code'], 'wsm_code' => $cgd['wsm_code'], "is_del" => 0, "status" => 1])->find();
|
|
|
+// if ($stock == false) throw new Exception('商品库存数据未找到');
|
|
|
+//
|
|
|
+// $stock['usable_stock'] += $thnum;
|
|
|
+// $stock['wait_out_stock'] -= $thnum;
|
|
|
+// $stock['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $st_up = Db::name("good_stock")->save($stock);
|
|
|
+// if ($st_up == false) throw new Exception('可售商品入库失败');
|
|
|
+//
|
|
|
+// $yp = GoodStockInfo::AddBn($stock['id'], $bn, $thnum, $cgd['good_price']);
|
|
|
+// if ($yp == false) throw new Exception('商品批次退货入库失败');
|
|
|
+//
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// $tempnum = $thnum;
|
|
|
+// foreach ($saleinfo as $va) {
|
|
|
+// if ($tempnum == 0) break;
|
|
|
+// $stock = Db::name("good_stock")->where(["spuCode" => $order['good_code'], 'id' => $va['stockid']])->findOrEmpty();
|
|
|
+// if ($stock == false) throw new Exception('商品库存数据未找到');
|
|
|
+//
|
|
|
+// if ($va['num'] >= $tempnum) {
|
|
|
+// $tnm = $tempnum;
|
|
|
+// $va['num'] -= $tempnum;
|
|
|
+// $va['th_num'] += $tempnum;
|
|
|
+// $tempnum = 0;
|
|
|
+// } else {
|
|
|
+// $tnm = $va['num'];
|
|
|
+// $tempnum -= $va['num'];
|
|
|
+// $va['th_num'] += $va['num'];
|
|
|
+// $va['num'] = 0;
|
|
|
+// }
|
|
|
+// $stock['usable_stock'] += $tnm;
|
|
|
+// $stock['wait_out_stock'] -= $tnm;
|
|
|
+// $stock['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $st_up = Db::name("good_stock")->save($stock);
|
|
|
+// if ($st_up == false) throw new Exception('可售商品入库失败');
|
|
|
+//
|
|
|
+// $ps = GoodStockInfo::AddBn($va['stockid'], $va['bnCode'], $tnm);
|
|
|
+// if ($ps == false) throw new Exception('商品批次退货入库失败');
|
|
|
+//
|
|
|
+// $ret = GoodStockInfo::ReturnBn($returnCode, $va['id'], $tnm);
|
|
|
+// if ($ret == false) throw new Exception('商品批次退货入库失败');
|
|
|
+//
|
|
|
+// $va['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $sal = Db::name("sale_info")->save($va);
|
|
|
+// if ($sal == false) throw new Exception('商品批次退货入库失败');
|
|
|
+//
|
|
|
+// $good_data[] = ['good_log_code' => $returnCode, "stock_id" => $va['stockid'], "type" => 1, 'stock' => $tnm, "stock_name" => "usable_stock"];
|
|
|
+// $good_data[] = ['good_log_code' => $returnCode, "stock_id" => $va['stockid'], "type" => 2, 'stock' => $tnm, "stock_name" => "wait_out_stock"];
|
|
|
+// GoodLog::LogAdd(['id' => $this->uid, 'nickname' => $this->uname], $good_data, 'XSTHD');
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
// $data=[
|
|
|
// "orderCode"=>$orderCode,
|