|
@@ -7,7 +7,7 @@ use app\admin\model\DataGroup as DataGroupModel;
|
|
use app\admin\model\GoodLog;
|
|
use app\admin\model\GoodLog;
|
|
use app\admin\model\GoodStockInfo;
|
|
use app\admin\model\GoodStockInfo;
|
|
use app\admin\model\ProcessOrder;
|
|
use app\admin\model\ProcessOrder;
|
|
-use think\App;
|
|
|
|
|
|
+use app\admin\model\ThData;use think\App;
|
|
use think\Exception;
|
|
use think\Exception;
|
|
use think\facade\Db;
|
|
use think\facade\Db;
|
|
use think\facade\Validate;
|
|
use think\facade\Validate;
|
|
@@ -505,7 +505,7 @@ class After extends Base
|
|
//9供应商审核,
|
|
//9供应商审核,
|
|
//10业务公司修改待供应商确认
|
|
//10业务公司修改待供应商确认
|
|
//11待设置退货工单(已收到货才有),
|
|
//11待设置退货工单(已收到货才有),
|
|
- //12待库管收货(已收到货才有)
|
|
|
|
|
|
+ //12待库管收货(已收到货才有),
|
|
public function status()
|
|
public function status()
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
@@ -724,29 +724,7 @@ class After extends Base
|
|
$order = ["order_code" => $info['returnCode'], "status" => $var, "action_remark" => '', "action_type" => "edit"];
|
|
$order = ["order_code" => $info['returnCode'], "status" => $var, "action_remark" => '', "action_type" => "edit"];
|
|
ActionLog::logAdd($action_log_user, $order, "SHD", $info['status'], $this->post);
|
|
ActionLog::logAdd($action_log_user, $order, "SHD", $info['status'], $this->post);
|
|
|
|
|
|
-// switch ($param['status']) {
|
|
|
|
-// //待采购审核
|
|
|
|
-// case 2:
|
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
|
|
|
|
-// break;
|
|
|
|
-//
|
|
|
|
-// //待设置仓库
|
|
|
|
-// case 3:
|
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'], 'holder_id' => $info['cgderid']];
|
|
|
|
-// break;
|
|
|
|
-//
|
|
|
|
-// //待客户退货
|
|
|
|
-// case 4:
|
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'], 'holder_id' => $info['apply_id']];
|
|
|
|
-// break;
|
|
|
|
-//
|
|
|
|
-// default:
|
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'holder_id' => $info['apply_id']];
|
|
|
|
-// }
|
|
|
|
-// if (in_array($param['status'], [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
|
|
|
|
-// elseif ($param['status'] == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
|
|
|
|
-// else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
|
|
|
|
- $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
|
|
|
|
|
|
+ $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
|
|
|
|
|
|
ProcessOrder::AddProcess($action_log_user, $process);
|
|
ProcessOrder::AddProcess($action_log_user, $process);
|
|
Db::commit();
|
|
Db::commit();
|
|
@@ -1312,25 +1290,6 @@ class After extends Base
|
|
->where(["outCode" => $info["outCode"], "is_del" => 0])
|
|
->where(["outCode" => $info["outCode"], "is_del" => 0])
|
|
->findOrEmpty();
|
|
->findOrEmpty();
|
|
if (empty($out)) return error_show(1005, "未找到发货单数据");
|
|
if (empty($out)) return error_show(1005, "未找到发货单数据");
|
|
-
|
|
|
|
-// $is_th = isset($this->post['is_th'])&&$this->post['is_th']!=="" ? intval($this->post['is_th']):"";
|
|
|
|
-// if($is_th===""){
|
|
|
|
-// return error_show(1005,"参数is_th不能为空");
|
|
|
|
-// }
|
|
|
|
-// $company=isset($this->post['company'])&&$this->post['company']!=""?trim($this->post['company']):"";
|
|
|
|
-// $post_code=isset($this->post['post_code'])&&$this->post['post_code']!=""?trim($this->post['post_code']):"";
|
|
|
|
-// $post_fee=isset($this->post['post_fee'])&&$this->post['post_fee']!==""?floatval($this->post['post_fee']):"";
|
|
|
|
-// if($is_th==1){
|
|
|
|
-// if($company==""){
|
|
|
|
-// return error_show(1005,"参数company不能为空");
|
|
|
|
-// }
|
|
|
|
-// if($post_code==""){
|
|
|
|
-// return error_show(1005,"参数post_code不能为空");
|
|
|
|
-// }
|
|
|
|
-// if($post_fee===""){
|
|
|
|
-// return error_show(1005,"参数post_fee不能为空");
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
$sale = Db::name('sale')
|
|
$sale = Db::name('sale')
|
|
->where(['orderCode' => $info['orderCode'], "is_del" => 0])
|
|
->where(['orderCode' => $info['orderCode'], "is_del" => 0])
|
|
->findOrEmpty();
|
|
->findOrEmpty();
|
|
@@ -1406,9 +1365,7 @@ class After extends Base
|
|
//如果售后已完成,维护销售单、发货单和采购单
|
|
//如果售后已完成,维护销售单、发货单和采购单
|
|
if ($info['status'] == 5) {
|
|
if ($info['status'] == 5) {
|
|
$sale['th_num'] += $info['error_num'];
|
|
$sale['th_num'] += $info['error_num'];
|
|
-// if ($sale['th_num'] == $sale['send_num'] && $sale['wsend_num'] == 0) $sale['status'] = 3;
|
|
|
|
if ($sale['th_num'] == $sale['good_num']) $sale['status'] = 3;
|
|
if ($sale['th_num'] == $sale['good_num']) $sale['status'] = 3;
|
|
-
|
|
|
|
$sale['th_fee'] += round($info['error_num'] * $sale['sale_price'], 2);
|
|
$sale['th_fee'] += round($info['error_num'] * $sale['sale_price'], 2);
|
|
$sale['updatetime'] = date("Y-m-d H:i:s");
|
|
$sale['updatetime'] = date("Y-m-d H:i:s");
|
|
Db::name("sale")->save($sale);
|
|
Db::name("sale")->save($sale);
|
|
@@ -1419,14 +1376,6 @@ class After extends Base
|
|
$out['updatetime'] = date("Y-m-d H:i:s");
|
|
$out['updatetime'] = date("Y-m-d H:i:s");
|
|
$upout = Db::name("order_out")->save($out);
|
|
$upout = Db::name("order_out")->save($out);
|
|
if ($upout == false) throw new Exception('出库单数据更新失败');
|
|
if ($upout == false) throw new Exception('出库单数据更新失败');
|
|
-
|
|
|
|
- //发货工单,有可能会有多个,要按照顺序扣减发货数
|
|
|
|
-// Db::name('order_out_child')
|
|
|
|
-// ->data(['updatetime' => date("Y-m-d H:i:s")])
|
|
|
|
-// ->where(['is_del' => 0, 'outCode' => $info["outCode"]])
|
|
|
|
-// ->dec('num', $info['error_num'])
|
|
|
|
-// ->update();
|
|
|
|
-
|
|
|
|
$error_num = $info['error_num'];
|
|
$error_num = $info['error_num'];
|
|
$tmp_ooc = Db::name('order_out_child')
|
|
$tmp_ooc = Db::name('order_out_child')
|
|
->where(['is_del' => 0, 'outCode' => $info["outCode"]])
|
|
->where(['is_del' => 0, 'outCode' => $info["outCode"]])
|
|
@@ -1452,8 +1401,8 @@ class After extends Base
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- //如果供应商承担,维护采购单
|
|
|
|
- if ($info['return_tag'] == 1) {
|
|
|
|
|
|
+ //如果供应商承担,维护采购单 todo:: 新逻辑 无论供应商是否同意退货采购单都要减退回
|
|
|
|
+// if ($info['return_tag'] == 1) {
|
|
$cgd_info = Db::name('order_num')
|
|
$cgd_info = Db::name('order_num')
|
|
->alias('a')
|
|
->alias('a')
|
|
->field('a.id,b.id cgd_id,b.good_price')
|
|
->field('a.id,b.id cgd_id,b.good_price')
|
|
@@ -1469,305 +1418,37 @@ class After extends Base
|
|
->update();
|
|
->update();
|
|
if($up==false) throw new Exception('采购单更新失败');
|
|
if($up==false) throw new Exception('采购单更新失败');
|
|
}
|
|
}
|
|
- }
|
|
|
|
- $data = [
|
|
|
|
- "orderCode" => $info['orderCode'],
|
|
|
|
- "th_type" => 2,
|
|
|
|
- "th_num" => $info['error_num'],
|
|
|
|
- "th_fee" => round($info['error_num'] * $sale['sale_price'], 2),
|
|
|
|
- "thCode" => $info['returnCode'],
|
|
|
|
- "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" => $info['updatetime'],
|
|
|
|
- "status" => 1,
|
|
|
|
- "is_del" => 0
|
|
|
|
- ];
|
|
|
|
- $inse = Db::name("th_data")->insert($data);
|
|
|
|
- if ($inse == false) throw new Exception('退回单更新失败');
|
|
|
|
|
|
+// }
|
|
|
|
+//todo::供应商不同意退货 生成转库存数据
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Db::commit();
|
|
Db::commit();
|
|
|
|
+ if($info["status"]==5){
|
|
|
|
+ $data = [
|
|
|
|
+ 'orderCode' => $info['orderCode'],
|
|
|
|
+ 'th_type' => 2,
|
|
|
|
+ 'th_num' => $info['error_num'],
|
|
|
|
+ 'th_fee' => round($info['error_num'] * $sale['sale_price'], 2),
|
|
|
|
+ 'thCode' => $info['returnCode'],
|
|
|
|
+ 'spuCode' => $sale['good_code'],
|
|
|
|
+ 'good_name' => $sale['good_name'],
|
|
|
|
+ 'sale_price' => $sale['sale_price'],
|
|
|
|
+ 'cgd_price' => $cgd_info['good_price'],
|
|
|
|
+ 'cat_id' => $sale['cat_id'],
|
|
|
|
+ 'apply_id' => $info['apply_id'],
|
|
|
|
+ 'apply_name' => $info['apply_name'],
|
|
|
|
+ 'addtime' => $info['updatetime'],
|
|
|
|
+ 'status' => 1,
|
|
|
|
+ 'is_del' => 0
|
|
|
|
+ ];
|
|
|
|
+ event('thdata',$data);
|
|
|
|
+ }
|
|
return json_show(0, '退货成功');
|
|
return json_show(0, '退货成功');
|
|
} else throw new Exception('修改售后申请单状态失败');
|
|
} else throw new Exception('修改售后申请单状态失败');
|
|
|
|
|
|
} else throw new Exception('退货失败');
|
|
} else throw new Exception('退货失败');
|
|
|
|
|
|
- //售后退货单数据
|
|
|
|
-// $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){
|
|
|
|
-////
|
|
|
|
-//// $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,'采购单数据更新失败');
|
|
|
|
-//// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// $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,'出库单数据更新失败');
|
|
|
|
-//// }
|
|
|
|
-// }
|
|
|
|
-// $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::commit();
|
|
|
|
-// return json_show(0, '退货成功');
|
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return json_show(1004, $e->getMessage());
|
|
return json_show(1004, $e->getMessage());
|