After.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\ProcessOrder;
  5. use think\App;
  6. use think\Exception;
  7. use think\facade\Db;
  8. use think\facade\Validate;
  9. //售后
  10. class After extends \app\BaseController
  11. {
  12. public $post=[];
  13. public function __construct(App $app)
  14. {
  15. parent::__construct($app);
  16. $this->post =$this->request->post();
  17. }
  18. public function create(){
  19. $outCode = isset($this->post['outCode']) &&$this->post['outCode']!=''?trim($this->post['outCode']) :"";
  20. if($outCode==''){
  21. return error_show(1004,"参数outCode 不能为空");
  22. }
  23. $orderout= Db::name("order_out")->where(["outCode"=>$outCode])->find();
  24. if(empty($orderout)){
  25. return error_show(1005,"未找到订单数据");
  26. }
  27. $oder= Db::name("sale")->where(["orderCode"=>$orderout['orderCode'],"is_del"=>0])->find();
  28. if(empty($oder)){
  29. return error_show(1005,"未找到订单数据");
  30. }
  31. $errorCode = isset($this->post['errorCode']) &&$this->post['errorCode']!=''?trim($this->post['errorCode']) :"";
  32. if($outCode==''){
  33. return error_show(1004,"参数errorCode 不能为空");
  34. }
  35. $error =Db::name('result_info')->where(["result_code"=>$errorCode,"is_del"=>0])->find();
  36. if(empty($error)){
  37. return error_show(1005,"未找到退货原因数据");
  38. }
  39. $remark =isset($this->post['remark']) &&$this->post['remark']!=''?trim($this->post['remark']) :"";
  40. $is_receive =isset($this->post['is_receive']) &&$this->post['is_receive']!==''?intval($this->post['is_receive'])
  41. :"";
  42. if($is_receive===""){
  43. return error_show(1004,"参数 is_receive 不能为空");
  44. }
  45. if($is_receive==0){
  46. $num=$orderout['send_num'];
  47. }else{
  48. $num =isset($this->post['num']) &&$this->post['num']!=''?intval($this->post['num']) :"";
  49. if($num==""){
  50. return error_show(1004,"参数 num 不能为空或零");
  51. }
  52. }
  53. $except_code =isset($this->post['except_code']) &&$this->post['except_code']!=''?trim($this->post['except_code']) :"";
  54. $img = isset($this->post['img']) &&$this->post['img']!=''?trim($this->post['img']) :"";
  55. $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
  56. if($token==''){
  57. return error_show(105,"参数token不能为空");
  58. }
  59. $user =GetUserInfo($token);
  60. if(empty($user)||$user['code']!=0){
  61. return error_show(102,"申请人数据不存在");
  62. }
  63. $rm= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  64. $ri= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  65. $returnCode=makeNo("RS");
  66. Db::startTrans();
  67. try{
  68. $in = [
  69. "returnCode"=>$returnCode,
  70. "outCode"=>$outCode,
  71. "orderCode"=> $oder['orderCode'],
  72. "good_code"=>$oder['good_code'],
  73. "good_name"=>$oder['good_name'],
  74. "customer_code"=>$oder['customer_code'],
  75. "apply_id"=>$rm,
  76. "apply_name"=>$ri,
  77. 'total_num'=>$orderout['send_num'],
  78. "error_code"=>$errorCode,
  79. "error_num"=>$num,
  80. "error_img"=>$img,
  81. "error_msg"=>$error['result'],
  82. "error_remark"=>$remark,
  83. "is_receive"=>$is_receive,
  84. "remark"=>'',
  85. "except_code"=>$except_code,
  86. "order_type"=>$orderout['order_type'],
  87. "status"=>1,
  88. "is_del"=>0,
  89. "addtime"=>date("Y-m-d H:i:s"),
  90. "updatetime"=>date("Y-m-d H:i:s")
  91. ];
  92. $create = Db::name("order_return")->insert($in,true);
  93. $orde = ["order_code"=>$returnCode,"status"=>$in['status'],"action_remark"=>'',"action_type"=>"create"];
  94. ActionLog::logAdd($this->post['token'],$orde,$orderout['order_type']==1?'SHD':"ZXSHD",0,$orde);
  95. if($create>0){
  96. $process=["order_code"=>$returnCode,"order_id"=>$create,"order_status"=>0,"order_type"=>'SHD'];
  97. ProcessOrder::AddProcess($token,$process);
  98. Db::commit();
  99. return app_show(0,"售后申请单新建成功",["returnCode"=>$returnCode]);
  100. }
  101. Db::rollback();
  102. return error_show(1005,"售后申请单新建失败");
  103. }catch (\Exception $e){
  104. Db::rollback();
  105. return error_show(1005,$e->getMessage());
  106. }
  107. }
  108. public function list(){
  109. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
  110. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
  111. $where =[['a.is_del',"=",0]];
  112. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  113. if($bkcode!=""){
  114. $where[]=['a.returnCode',"like", "%{$bkcode}%"];
  115. }
  116. $out = isset($this->post['outCode']) && $this->post['outCode']!="" ? trim($this->post['outCode']):"";
  117. if($out!=""){
  118. $where[]=['a.outCode',"like", "%{$out}%"];
  119. }
  120. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  121. if($status!==""){
  122. $where[]=['a.status',"=", $status];
  123. }
  124. $order_type = isset($this->post['order_type']) && $this->post['order_type']!=="" ? intval($this->post['order_type']):"";
  125. if($order_type!==""){
  126. $where[]=['a.order_type',"=", $order_type];
  127. }
  128. $orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode'])
  129. :"";
  130. if($orderCode!=""){
  131. $where[]=['a.orderCode',"like", "%{$orderCode}%"];
  132. }
  133. $good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code'])
  134. :"";
  135. if($good_code!=""){
  136. $where[]=['a.good_code',"like", "%{$good_code}%"];
  137. }
  138. $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name'])
  139. :"";
  140. if($good_name!=""){
  141. $where[]=['a.good_name',"like", "%{$good_name}%"];
  142. }
  143. $customer_code = isset($this->post['customer_code']) && $this->post['customer_code']!="" ? trim($this->post['customer_code'])
  144. :"";
  145. if($customer_code!=""){
  146. $where[]=['a.customer_code',"like", "%{$customer_code}%"];
  147. }
  148. $except_code = isset($this->post['except_code']) && $this->post['except_code']!="" ? trim($this->post['except_code']):"";
  149. if($except_code!=""){
  150. $where[]=['a.except_code',"=", $except_code];
  151. }
  152. $apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name'])
  153. :"";
  154. if($apply_name!=""){
  155. $where[]=['a.apply_name',"like", "%{$apply_name}%"];
  156. }
  157. $start =isset($this->post['start'])&&$this->post['start']!='' ? $this->post['start']:"";
  158. if($start!==""){
  159. $where[]=['a.addtime',">=", $start];
  160. }
  161. $end =isset($this->post['end'])&&$this->post['end']!='' ? $this->post['end']:"";
  162. if($end!==""){
  163. $where[]=['a.addtime',"<=", $end];
  164. }
  165. $count=Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")->where
  166. ($where)->count();
  167. $total = ceil($count/$size);
  168. $page = $total>=$page ? $page :$total;
  169. $list =Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")->where($where)
  170. ->field("a.*,b.return_wsm,b.contactor,b.mobile,b.addr,b.addr_code,b.post_code,b.post_company,b.post_fee,b.gys_remark")->page($page,$size)
  171. ->order("addtime desc")->select();
  172. $data=[];
  173. foreach ($list as $value){
  174. $customer = Db::name("customer_info")->where(["companyNo"=>$value['customer_code']])->find();
  175. $value['customer_name'] = isset($customer['companyName']) ?trim($customer['companyName']):'';
  176. $data[]=$value;
  177. }
  178. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  179. }
  180. /**
  181. * @return \think\response\Json|void
  182. * @throws \think\db\exception\DataNotFoundException
  183. * @throws \think\db\exception\DbException
  184. * @throws \think\db\exception\ModelNotFoundException
  185. */
  186. public function info()
  187. {
  188. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode'] != "" ? trim($this->post['returnCode']) : "";
  189. if ($bkcode == "") {
  190. return error_show(1005, "参数returnCode 不能为空");
  191. }
  192. $info = Db::name("order_return")->alias("a")->leftJoin("order_returninfo b", "a.returnCode=b.returnCode")
  193. ->field("a.*,b.return_wsm,b.contactor,b.mobile,b.addr,b.addr_code,b.post_code,b.post_company,b.post_fee,b.gys_remark")
  194. ->where(['a.returnCode' => $bkcode])->find();
  195. if (empty($info)) {
  196. return error_show(1005, "未找到售后数据");
  197. }
  198. $orderinfo = Db::name("sale")->where(["orderCode" => $info["orderCode"]])->find();
  199. $info['origin_price'] = $orderinfo['origin_price'];
  200. $info['order_type'] = $orderinfo['order_type'];
  201. $info['sale_price'] = $orderinfo['sale_price'];
  202. $info['total_price'] = sprintf("%1\$.2f", $orderinfo['sale_price'] * $info['error_num']);
  203. if ($orderinfo['order_type'] == 3 || $orderinfo['order_type'] == 4) {
  204. $goon = Db::name("good_zixun")->where(["spuCode" => $orderinfo['good_code'], "is_del" => 0])->find();
  205. } else {
  206. $goon = Db::name('good_platform')->alias('a')->join('good b', 'b.spuCode=a.spuCode', 'left')
  207. ->where(['a.skuCode' => $orderinfo['skuCode']])->find();
  208. }
  209. if (empty($goon)) {
  210. return error_show(1003, "未找到商品数据");
  211. }
  212. $int = isset($goon['cat_id']) && $goon['cat_id'] != 0 ? made($goon['cat_id']) : [];
  213. $addcode = '';
  214. if ($info['addr_code'] != "") {
  215. list($a, $b, $c) = explode(",", $info['addr_code']);
  216. $addcode = json_encode(["provice_code" => $a, "city_code" => $b, "area_code" => $c]);
  217. }
  218. $info["addr_cn"]=GetAddr($addcode);
  219. // $info["addr_code"]=json_decode($addcode,true);
  220. $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  221. $info['out_num'] = isset($out['send_num'])?$out['send_num']:'';
  222. // $customer = Db::name("customer_info")->where(["companyNo"=>$info['customer_code']])->find();
  223. if($info['return_wsm']!=''){
  224. $wsmcode = Db::name("warehouse_info")
  225. ->alias("a")
  226. ->leftJoin("supplier b","a.supplierNo=b.code")
  227. ->where(["a.wsm_code"=>$info['return_wsm']])
  228. ->field("a.name as wsm_name,b.name,b.code,a.wsm_code,a.contactor_name,a.position,a.mobile,a.addrs_code,a.addr,a.companyNo")
  229. ->find();
  230. }
  231. $info['wsm_code'] =isset($wsmcode['wsm_code']) ? $wsmcode['wsm_code']:"";
  232. $info['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  233. $info['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  234. $info['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  235. $customer = Db::name("business")->field('id,company,companyNo')->where(["companyNo"=>$wsmcode['companyNo']])->find();
  236. $info['customer_name'] = isset($customer['company']) ?trim($customer['company']):'';
  237. $info['customer_code'] = isset($customer['companyNo']) ?trim($customer['companyNo']):'';
  238. $info['can']=$int;
  239. //仓库的联系人、职位、电话、省市区和地址
  240. isset($wsmcode['contactor_name'])? $info['contactor'] =$wsmcode['contactor_name']:'';//联系人
  241. isset($wsmcode['mobile'])? $info['mobile'] =$wsmcode['mobile']:'';//联系人
  242. isset($wsmcode['addrs_code'])? $info['addr_code'] =$wsmcode['addrs_code']:'';//联系人
  243. isset($wsmcode['addr'])? $info['addr'] =$wsmcode['addr']:'';//联系人
  244. isset($wsmcode['contactor_name'])? $info['contactor'] =$wsmcode['contactor_name']:'';//联系人
  245. // $info['position'] = $wsmcode['position'];//职位
  246. // $info['mobile'] = $wsmcode['mobile'];//电话
  247. // $info['addrs_code'] = json_decode($wsmcode['addrs_code'], true);//省市区编码
  248. // $info['addr'] = $wsmcode['addr'];//地址
  249. $info['spuCode'] = $orderinfo['good_code'];//地址
  250. $info['skuCode'] = $orderinfo['skuCode'];//地址
  251. return app_show(0,"获取成功",$info);
  252. }
  253. public function status(){
  254. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  255. if($bkcode==""){
  256. return error_show(1005,"参数returnCode 不能为空");
  257. }
  258. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  259. if(empty($info)){
  260. return error_show(1005,"未找到售后数据");
  261. }
  262. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status'])
  263. :"";
  264. if($status===""){
  265. return error_show(1005,"参数status 不能为空");
  266. }
  267. $orde= Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  268. if($orde==false){
  269. return error_show(1005,"未找到出库单数据");
  270. }
  271. $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
  272. if($remark!=''){
  273. $info['remark'] =$remark;
  274. }
  275. if($status==3 && $info['is_receive']==1){
  276. $post =isset($this->post['is_post'])&&$this->post['is_post']!==""? intval($this->post['is_post']):"";
  277. if($post===""){
  278. return error_show(1005,"参数is_post不能为空");
  279. }
  280. $info['is_post']=$post;
  281. $return_tag =isset($this->post['return_tag'])&&$this->post['return_tag']!==""? intval($this->post['return_tag']):"";
  282. if($return_tag===""){
  283. return error_show(1005,"参数return_tag不能为空");
  284. }
  285. $info['return_tag']=$return_tag;
  286. $is_th =isset($this->post['is_th'])&&$this->post['is_th']!==""? intval($this->post['is_th']):"0";
  287. $info['is_th']=$is_th;
  288. }
  289. // $status = $info['order_status']==1&&$info['order_type']==1 && $status==1?4:$status;
  290. Db::startTrans();
  291. try{
  292. $var=$info['status'];
  293. $info['status']=$status;
  294. $info['updatetime']=date("Y-m-d H:i:s");
  295. $up =Db::name("order_return")->save($info);
  296. if($up){
  297. $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  298. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD", $info['status'],$this->post);
  299. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$status,"order_type"=>$info['order_type']==1?'SHD':"ZXSHD"];
  300. ProcessOrder::AddProcess($this->post['token'],$process);
  301. Db::commit();
  302. return app_show(0,"更新成功");
  303. }else{
  304. Db::rollback();
  305. return error_show(1004,"更新失败");
  306. }
  307. }catch (\Exception $e){
  308. Db::rollback();
  309. return error_show(1004,$e->getMessage());
  310. }
  311. }
  312. public function setWsm(){
  313. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  314. if($bkcode==""){
  315. return error_show(1005,"参数returnCode 不能为空");
  316. }
  317. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  318. if(empty($info)){
  319. return error_show(1005,"未找到售后数据");
  320. }
  321. if($info['status']!=3){
  322. return error_show(1005,"采购主管未审核无法设置退回仓库");
  323. }
  324. $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']) :"";
  325. if($info['return_tag']==2) {
  326. if($wsm_code==""){
  327. return error_show(1005,"参数 wsm_code 不能为空");
  328. }
  329. $warehouse =Db::name("warehouse_info")->where(["wsm_code"=>$wsm_code])->find();
  330. if($warehouse==false){
  331. return error_show(1005,"仓库数据未找到");
  332. }
  333. $wareaddr =Db::name("warehouse_addr")->where(["wsm_code"=>$wsm_code,"is_del"=>0,"status"=>1])->find();
  334. }
  335. $addrcode=isset($this->post['addr_code'])&&$this->post['addr_code']!=""?$this->post['addr_code']:"";
  336. if($addrcode==""){
  337. return error_show(1005,"参数 addr_code 不能为空");
  338. }
  339. $addr=isset($this->post['addr'])&&$this->post['addr']!=""?trim($this->post['addr']):"";
  340. if($addr==""){
  341. return error_show(1005,"参数 addr 不能为空");
  342. }
  343. $mobile=isset($this->post['mobile'])&&$this->post['mobile']!=""?trim($this->post['mobile']):"";
  344. if($mobile==""){
  345. return error_show(1005,"参数 mobile 不能为空");
  346. }
  347. $contactor=isset($this->post['contactor'])&&$this->post['contactor']!=""?trim($this->post['contactor']):"";
  348. if($contactor==""){
  349. return error_show(1005,"参数 contactor 不能为空");
  350. }
  351. $returninfo=[
  352. "returnCode"=>$bkcode,
  353. "return_wsm"=>$wsm_code,
  354. "contactor"=>$contactor,
  355. "mobile"=>$mobile ,
  356. "addr"=>$addr,
  357. "addr_code"=>$addrcode,
  358. "addtime"=>date("Y-m-d H:i:s")
  359. ];
  360. Db::startTrans();
  361. try {
  362. $in=Db::name("order_returninfo")->insert($returninfo);
  363. if($in){
  364. if($info['return_tag']==2 &&$wareaddr==false) {
  365. $addrs =[
  366. "wsm_code"=>$wsm_code,
  367. "wsm_type"=>1,
  368. "wsm_name"=>$contactor,
  369. "wsm_addr"=>$addr,
  370. "addr_code"=>$addrcode,
  371. "wsm_mobile"=>$mobile,
  372. "status"=>'1',
  373. "is_del"=>'0',
  374. "addtime"=>date("Y-m-d H:i:s"),
  375. "updatetime"=>date("Y-m-d H:i:s")
  376. ];
  377. $wareaddr =Db::name("warehouse_addr")->insert($addrs);
  378. if($wareaddr==false){
  379. Db::rollback();
  380. return app_show(1004,"退货仓库地址录入失败");
  381. }
  382. }
  383. $info['status']=4;
  384. $info["updatetime"]=date("Y-m-d H:i:s");
  385. $up =Db::name("order_return")->save($info);
  386. if($up){
  387. Db::commit();
  388. return app_show(0,"退货仓库设置成功");
  389. }
  390. }
  391. Db::rollback();
  392. return error_show(1004,"设置失败");
  393. }catch (\Exception $e){
  394. Db::rollback();
  395. return error_show(1004,$e->getMessage());
  396. }
  397. }
  398. /**
  399. * @return \think\response\Json|void
  400. * @throws \think\db\exception\DataNotFoundException
  401. * @throws \think\db\exception\DbException
  402. * @throws \think\db\exception\ModelNotFoundException
  403. */
  404. public function postfeed(){
  405. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  406. if($bkcode==""){
  407. return error_show(1005,"参数returnCode 不能为空");
  408. }
  409. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  410. if(empty($info)){
  411. return error_show(1005,"未找到售后数据");
  412. }
  413. $contactor = isset($this->post['contactor']) && $this->post['contactor']!="" ? trim($this->post['contactor']) :"";
  414. $mobile = isset($this->post['mobile']) && $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  415. $addr = isset($this->post['addr']) && $this->post['addr']!="" ? trim($this->post['addr']):"";
  416. $addr_code = isset($this->post['addr_code']) && $this->post['addr_code']!=""&&!empty($this->post['addr_code']) ?
  417. $this->post['addr_code']:"";
  418. $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
  419. if($wsm_code==""){
  420. return error_show(1005,"参数 wsm_code不能为空");
  421. }
  422. if($info['is_th']==0&&$info['order_type']==1) {
  423. $wsm = Db::name("warehouse_info")->where(["wsm_code" => $wsm_code])->find();
  424. if (empty($wsm)) {
  425. return error_show(1005, "未找到仓库数据");
  426. }
  427. $sm = Db::name("warehouse_addr")->where(["wsm_code" => $wsm_code,"is_del"=>0])->find();
  428. $contactor==""?(isset($sm['wsm_name']) ? $contactor=$sm['wsm_name']:""):"";
  429. $sm['wsm_name'] =isset($sm['wsm_name']) ? $sm['wsm_name']:"";
  430. $mobile==""?(isset($sm['wsm_mobile']) ? $mobile=$sm['wsm_mobile']:""):"";
  431. $sm['wsm_mobile'] =isset($sm['wsm_mobile']) ? $sm['wsm_mobile']:"";
  432. $addr==""?(isset($sm['wsm_addr']) ? $addr=$sm['wsm_addr']:""):"";
  433. $sm['wsm_addr'] =isset($sm['wsm_addr']) ? $sm['wsm_addr']:"";
  434. $addr_code==""?(isset($sm['addr_code']) ? $addr=$sm['addr_code']:""):"";
  435. $sm['addr_code'] =isset($sm['addr_code']) ? $sm['addr_code']:"";
  436. }
  437. $remark = isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  438. if($info['is_th']==1 && $info['order_type']==1){
  439. if($contactor==''){
  440. return error_show(1005,"参数 contactor 不能为空");
  441. }
  442. if($mobile==''){
  443. return error_show(1005,"参数 mobile 不能为空");
  444. }
  445. if($addr==''){
  446. return error_show(1005,"参数 addr 不能为空");
  447. }
  448. if($addr_code==''){
  449. return error_show(1005,"参数 addr_code 不能为空");
  450. }
  451. if($addr_code!==''&&is_array($addr_code)){
  452. $addrs=[];
  453. $addrs['provice_code'] = $addr_code[0];
  454. $addrs['city_code'] = $addr_code[1];
  455. $addrs['area_code'] = $addr_code[2];
  456. $addr_code = json_encode($addrs);
  457. }
  458. }
  459. Db::startTrans();
  460. try{
  461. $var=$info['status'];
  462. $info['status']=$info['order_type']==1?3:4;
  463. $info['remark']=$remark;
  464. $info['updatetime']=date("Y-m-d H:i:s");
  465. $up =Db::name("order_return")->save($info);
  466. if($up){
  467. // var_dump($contactor);
  468. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  469. if(empty($returninfo)){
  470. $returninfo=[
  471. "returnCode"=>$bkcode,
  472. "return_wsm"=>$wsm_code,
  473. "contactor"=>$contactor,
  474. "mobile"=>$mobile ,
  475. "addr"=>$addr,
  476. "addr_code"=>$addr_code,
  477. "addtime"=>date("Y-m-d H:i:s")
  478. ];
  479. }else{
  480. $returninfo['return_wsm'] = $wsm_code;
  481. //if($info['is_th']==1 && $info['order_type']==1) {
  482. $contactor !==""? $returninfo['contactor'] = $contactor:"";
  483. $mobile!==""?$returninfo['mobile'] = $mobile:"";
  484. $addr!==""? $returninfo['addr'] = $addr:"";
  485. $addr_code!==""?$returninfo['addr_code'] = $addr_code:"";
  486. // }
  487. }
  488. // var_dump($contactor);
  489. // var_dump($returninfo);
  490. $in=Db::name("order_returninfo")->save($returninfo);
  491. if($in){
  492. $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  493. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD",$info['status'],$order);
  494. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>$info['order_type']==1?'SHD':"ZXSHD"];
  495. ProcessOrder::AddProcess($this->post['token'],$process);
  496. Db::commit();
  497. return app_show(0,"更新成功");
  498. }
  499. }
  500. Db::rollback();
  501. return error_show(1004,"更新失败");
  502. }catch (\Exception $e){
  503. Db::rollback();
  504. return error_show(1004,$e->getMessage());
  505. }
  506. }
  507. /**
  508. * @return \think\response\Json|void
  509. * @throws \think\db\exception\DataNotFoundException
  510. * @throws \think\db\exception\DbException
  511. * @throws \think\db\exception\ModelNotFoundException
  512. */
  513. public function addpost(){
  514. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  515. if($bkcode==""){
  516. return error_show(1005,"参数returnCode 不能为空");
  517. }
  518. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  519. if(empty($info)){
  520. return error_show(1005,"未找到售后数据");
  521. }
  522. $return_info = Db::name("order_returninfo")->where(['returnCode'=>$bkcode])->find();
  523. if(empty($return_info)){
  524. $return_info=[
  525. "returnCode"=>$bkcode,
  526. "return_wsm"=>'',
  527. "contactor"=>'',
  528. "mobile"=>'',
  529. "addr"=>'',
  530. "addr_code"=>'',
  531. "addtime"=>date("Y-m-d H:i:s"),
  532. "post_company"=>'',
  533. "post_code"=>'',
  534. "post_fee"=>'',
  535. ];
  536. }
  537. $post_own = isset($this->post['own']) &&$this->post['own']!='' ? trim($this->post['own']):"";
  538. if($post_own==''){
  539. return error_show(1005,"参数own不能为空");
  540. }
  541. $info['post_own'] = $post_own;
  542. $post_company = isset($this->post['company'])&&$this->post['company']!='' ? trim($this->post['company']):"";
  543. if($post_company==''){
  544. return error_show(1005,"参数company不能为空");
  545. }
  546. $return_info['post_company'] = $post_company;
  547. $post_code = isset($this->post['post_code'])&&$this->post['post_code']!='' ? trim($this->post['post_code']):"";
  548. if($post_code==''){
  549. return error_show(1005,"参数post_code不能为空");
  550. }
  551. $return_info['post_code'] = $post_code;
  552. $fee= isset($this->post['post_fee'])&&$this->post['post_fee']!=='' ? round($this->post['post_fee'],2):"";
  553. if($fee===''){
  554. return error_show(1005,"参数post_fee不能为空");
  555. }
  556. $return_info['post_fee'] = $fee;
  557. Db::startTrans();
  558. try{
  559. $str=$info['status'];
  560. $info['status']=$info['order_type']==1?4:5;
  561. $info['updatetime']=date("Y-m-d H:i:s");
  562. $up =Db::name("order_return")->save($info);
  563. if($up){
  564. $order = ["order_code"=>$info['orderCode'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
  565. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD",$info['status'],$order);
  566. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>$info['order_type']==1?'SHD':"ZXSHD"];
  567. ProcessOrder::AddProcess($this->post['token'],$process);
  568. $in=Db::name("order_returninfo")->save($return_info);
  569. if($in){
  570. $data=[
  571. 'thNo'=>makeNo("ST"),
  572. "orderCode"=>$info['orderCode'],
  573. "order_type"=>$info['order_type'],
  574. "outCode"=>$info['outCode'],
  575. "returnCode"=>$info['returnCode'],
  576. "good_code"=>$info['good_code'],
  577. "good_name"=>$info['good_name'],
  578. "return_wsm"=>$return_info['return_wsm'],
  579. "return_num"=>$info['error_num'],
  580. "contactor"=>$return_info['contactor'],
  581. "mobile"=>$return_info['mobile'],
  582. "addr"=>$return_info['addr'],
  583. "addr_code"=>$return_info['addr_code'],
  584. "return_code"=>$info['error_code'],
  585. "return_msg"=>$info['error_msg'],
  586. "post_fee"=>$return_info['post_fee'],
  587. "post_code"=>$return_info['post_code'],
  588. "post_company"=>$return_info['post_company'],
  589. "customer_code"=>$info['customer_code'],
  590. "addtime"=>date("Y-m-d H:i:s"),
  591. "updatetime"=>date("Y-m-d H:i:s")
  592. ];
  593. $back =Db::name("order_back")->insert($data,true);
  594. if($back>0){
  595. $order = ["order_code"=>$data['thNo'],"status"=>0,"action_remark"=>'',"action_type"=>"create"];
  596. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD", 0,$data);
  597. $process=["order_code"=>$data['thNo'],"order_id"=>$back,"order_status"=>0,"order_type"=>$info['order_type']==1?'CKTHD':"ZXCKTHD"];
  598. ProcessOrder::AddProcess($this->post['token'],$process);
  599. Db::commit();
  600. return app_show(0,"更新成功");
  601. }
  602. }
  603. }
  604. Db::rollback();
  605. return error_show(1004,"更新失败");
  606. }catch (\Exception $e){
  607. Db::rollback();
  608. return error_show(1004,$e->getMessage());
  609. }
  610. }
  611. /**
  612. * @return \think\response\Json|void
  613. * @throws \think\db\exception\DataNotFoundException
  614. * @throws \think\db\exception\DbException
  615. * @throws \think\db\exception\ModelNotFoundException
  616. */
  617. public function GysFeed(){
  618. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  619. if($bkcode==""){
  620. return error_show(1005,"参数returnCode 不能为空");
  621. }
  622. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  623. if(empty($info)){
  624. return error_show(1005,"未找到售后数据");
  625. }
  626. $isth = isset($this->post['is_th']) && $this->post['is_th']!="" ? intval($this->post['is_th']):"0";
  627. $contactor = isset($this->post['contactor']) && $this->post['contactor']!="" ? trim($this->post['contactor'])
  628. :"";
  629. $mobile = isset($this->post['mobile']) && $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  630. $addr = isset($this->post['addr']) && $this->post['addr']!="" ? trim($this->post['addr']):"";
  631. $addr_code = isset($this->post['addr_code']) && $this->post['addr_code']!=""&&!empty($this->post['addr_code']) ? $this->post['addr_code']:"";
  632. $remark = isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  633. if($isth==1){
  634. if($contactor==''){
  635. return error_show(1005,"参数 contactor 不能为空");
  636. }
  637. if($mobile==''){
  638. return error_show(1005,"参数 mobile 不能为空");
  639. }
  640. if($addr==''){
  641. return error_show(1005,"参数 addr 不能为空");
  642. }
  643. // var_dump(isset($this->post['addr_code']) , $this->post['addr_code']!="",!empty($addr_code));
  644. if($addr_code==''){
  645. return error_show(1005,"参数 addr_code 不能为空");
  646. }
  647. if(is_array($addr_code)){
  648. $addrs=[];
  649. $addrs['provice_code'] = $addr_code[0];
  650. $addrs['city_code'] = $addr_code[1];
  651. $addrs['area_code'] = $addr_code[2];
  652. $addr_code = json_encode($addrs);
  653. }
  654. }
  655. $orde= Db::name("order_out")->where(["outCode"=>$info['outCode'],"is_del"=>0])->find();
  656. if(empty($orde)){
  657. return error_show(1005,"未找到出库单数据");
  658. }
  659. Db::startTrans();
  660. try{
  661. $stat=$info['status'];
  662. $info['status']=$info['order_status']==1?5:3;
  663. $info['is_th']=$isth;
  664. $info['updatetime']=date("Y-m-d H:i:s");
  665. $up =Db::name("order_return")->save($info);
  666. if($up){
  667. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  668. if(empty($returninfo)){
  669. $returninfo=[
  670. "returnCode"=>$bkcode,
  671. "return_wsm"=>'',
  672. "contactor"=>$contactor,
  673. "mobile"=>$mobile ,
  674. "addr"=>$addr,
  675. "addr_code"=>$addr_code,
  676. "gys_remark"=>$remark,
  677. "addtime"=>date("Y-m-d H:i:s")
  678. ];
  679. }else{
  680. $returninfo['return_wsm'] = '';
  681. $returninfo['contactor'] = $contactor;
  682. $returninfo['mobile'] = $mobile;
  683. $returninfo['addr'] = $addr;
  684. $returninfo['gys_remark'] = $remark;
  685. $returninfo['addr_code'] = $addr_code;
  686. }
  687. $in=Db::name("order_returninfo")->save($returninfo);
  688. if($in){
  689. if( $info['order_status']==1&&$info['order_type']==2){
  690. $orderout= Db::name("order_out")->where($orde)->save(['status'=>3,"updatetime"=>date("Y-m-d H:i:s")]);
  691. $order = ["order_code"=>$orde['outCode'],"status"=>$orde['status'],"action_remark"=>'',"action_type"=>"edit"];
  692. ActionLog::logAdd($this->post['token'],$order,$orde['order_type']==1?'CKD':"ZXCKD", 3,
  693. ['status'=>3,"updatetime"=>date("Y-m-d H:i:s")]);
  694. $process=["order_code"=>$orde['outCode'],"order_id"=>$orde['id'],"order_status"=>3,
  695. "order_type"=>$orde['order_type']==1?'CKD':"ZXCKD"];
  696. ProcessOrder::AddProcess($this->post['token'],$process);
  697. if($orderout){
  698. Db::commit();
  699. return app_show(0,"更新成功");
  700. }else{
  701. Db::rollback();
  702. return error_show(1004,"更新失败");
  703. }
  704. }
  705. $order = ["order_code"=>$info['returnCode'],"status"=>$stat,"action_remark"=>'',"action_type"=>"edit"];
  706. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'CKTHD':"ZXCKTHD",3,$order);
  707. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>$info['order_type']==1?'CKTHD':"ZXCKTHD"];
  708. ProcessOrder::AddProcess($this->post['token'],$process);
  709. Db::commit();
  710. return app_show(0,"更新成功");
  711. }
  712. }
  713. Db::rollback();
  714. return error_show(1004,"更新失败");
  715. }catch (\Exception $e){
  716. Db::rollback();
  717. return error_show(1004,$e->getMessage());
  718. }
  719. }
  720. public function GetWsm(){
  721. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  722. if($bkcode==""){
  723. return error_show(1005,"参数returnCode 不能为空");
  724. }
  725. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  726. if(empty($info)){
  727. return error_show(1005,"未找到售后数据");
  728. }
  729. $list=[];
  730. if($info['is_th']==1){
  731. if($info["order_type"]==1){
  732. $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  733. if(empty($out)){
  734. return error_show(1005,"未找到出库单数据");
  735. }
  736. $ware = Db::name("warehouse_info")->alias("a")->leftJoin("warehouse_addr b","a.wsm_code=b.wsm_code and b.status=1 and b.is_del=0")
  737. ->where(["a.status"=>1,"wsm_type"=>1,"a.is_del"=>0,"a.supplierNo"=>$out['wsm_code']])->field("a.wsm_code,a.name,b.wsm_name,b.wsm_mobile,b.wsm_addr,b.addr_code")->find();
  738. if(empty($ware)){
  739. return error_show(1005,"未找到仓库数据");
  740. }
  741. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  742. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  743. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  744. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  745. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  746. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  747. $temp['addr_cn'] =GetAddr( $ware['addr_code']);
  748. $list[]=$temp;
  749. }else {
  750. $returninfo = Db::name("order_returninfo")->where(["returnCode" => $bkcode])->find();
  751. if (empty($returninfo)) {
  752. return error_show(1005, "未找到供应商仓库数据");
  753. }
  754. $data = [];
  755. $data['wsm_code'] = isset($returninfo['return_wsm']) && $returninfo['return_wsm'] != "" ? $returninfo['return_wsm'] : "-";
  756. $data['wsm_name'] = '供应商仓';
  757. $data['supplier_name'] = '供应商';
  758. $data['contactor'] = $returninfo['contactor'];
  759. $data['mobile'] = $returninfo['mobile'];
  760. $data['addr'] = $returninfo['addr'];
  761. $data['addr_cn'] =GetAddr( $returninfo['addr_code']);
  762. $data['addr_code'] = $returninfo['addr_code'];
  763. $list[] = $data;
  764. }
  765. }
  766. $supplier = Db::name("supplier")->where(["is_platform"=>1,"status"=>1,"is_del"=>0])->column("code,name");
  767. if(empty($supplier)){
  768. return error_show(1005,"未找到供应商仓库数据");
  769. }
  770. foreach ($supplier as $value){
  771. $temp=[];
  772. $ware = Db::name("warehouse_info")->alias("a")->leftJoin("warehouse_addr b","a.wsm_code=b.wsm_code and b.status=1 and b.is_del=0")
  773. ->where(["a.wsm_type"=>1,"a.status"=>1,"a.is_del"=>0,"a.supplierNo"=>$value['code']])->field("a.wsm_code,a.name,b.wsm_name,b.wsm_mobile,b.wsm_addr,b.addr_code")->find();
  774. if(empty($ware)){
  775. continue;
  776. }
  777. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  778. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  779. $temp['supplier_name']=$value['name'];
  780. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  781. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  782. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  783. $temp['addr_cn'] =GetAddr($ware['addr_code']);
  784. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  785. $list[]=$temp;
  786. }
  787. return app_show(0,"获取成功",$list);
  788. }
  789. public function setdelivery(){
  790. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  791. if($bkcode==""){
  792. return error_show(1005,"参数returnCode 不能为空");
  793. }
  794. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  795. if(empty($info)){
  796. return error_show(1005,"未找到售后数据");
  797. }
  798. if(($info['is_receive']==0&&$info['status']!=3)||($info['is_receive']==1&&$info['status']!=4) ){
  799. return error_show(1005,"售后单流程状态有误");
  800. }
  801. $out=Db::name("order_out")->where(["outCode"=>$info["outCode"]])->find();
  802. $is_th = isset($this->post['is_th'])&&$this->post['is_th']!=="" ? intval($this->post['is_th']):"";
  803. if($is_th===""){
  804. return error_show(1005,"参数is_th不能为空");
  805. }
  806. $company=isset($this->post['company'])&&$this->post['company']!=""?trim($this->post['company']):"";
  807. $post_code=isset($this->post['post_code'])&&$this->post['post_code']!=""?trim($this->post['post_code']):"";
  808. $post_fee=isset($this->post['post_fee'])&&$this->post['post_fee']!==""?floatval($this->post['post_fee']):"";
  809. if($is_th==1){
  810. if($company==""){
  811. return error_show(1005,"参数company不能为空");
  812. }
  813. if($post_code==""){
  814. return error_show(1005,"参数post_code不能为空");
  815. }
  816. if($post_fee===""){
  817. return error_show(1005,"参数post_fee不能为空");
  818. }
  819. }
  820. Db::startTrans();
  821. try {
  822. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  823. if($returninfo==false){
  824. $returninfo=[
  825. "returnCode"=>$bkcode,
  826. "return_wsm"=>"",
  827. "contactor"=>"",
  828. "mobile"=>"",
  829. "addr"=>"",
  830. "addr_code"=>"",
  831. "post_code"=>$post_code,
  832. "post_company"=>$company,
  833. "post_fee"=>$post_fee,
  834. "gys_remark"=>"",
  835. "addtime"=>date("Y-m-d H:i:s")
  836. ];
  837. }else{
  838. $returninfo['post_fee']=$post_fee;
  839. $returninfo['post_company']=$company;
  840. $returninfo['post_code']=$post_code;
  841. }
  842. $up =Db::name("order_returninfo")->save($returninfo);
  843. if($up){
  844. $info['status']=5;
  845. $info['updatetime']=date("y-m-d H:i:s");
  846. $ro =Db::name("order_return")->save($info);
  847. if($ro){
  848. $thNo =makeNo("ST");
  849. $thdata=[
  850. "thNo"=>$thNo,
  851. "orderCode"=>$out["orderCode"],
  852. "outCode"=>$out["outCode"],
  853. "order_type"=>$info["order_type"],
  854. "returnCode"=>$info["returnCode"],
  855. "good_code"=>$info["good_code"],
  856. "good_name"=>$info["good_name"],
  857. "return_wsm"=>$returninfo["return_wsm"],
  858. // "defective_wsm"=>'',
  859. "return_msg"=>$info["error_msg"],
  860. "return_num"=>$info["total_num"],
  861. "normal_num"=>0,
  862. "received_num"=>0,
  863. // "defective_num"=>0,
  864. // "loss_num"=>0,
  865. "contactor"=>$returninfo["contactor"],
  866. "mobile"=>$returninfo["mobile"],
  867. "addr"=>$returninfo["addr"],
  868. "addr_code"=>$returninfo["addr_code"],
  869. "return_code"=>$info["error_code"],
  870. "post_fee"=>$returninfo["post_fee"],
  871. "post_code"=>$returninfo["post_code"],
  872. "post_company"=>$returninfo["post_company"],
  873. "customer_code"=>$info["customer_code"],
  874. "status"=>1,
  875. "addtime"=>date("Y-m-d H:i:s"),
  876. "updatetime"=>date("Y-m-d H:i:s")
  877. ];
  878. $sav= Db::name("order_back")->insert($thdata);
  879. if($sav){
  880. Db::commit();
  881. return app_show(0,"退货单新建成功",["thNo"=>$thNo]);
  882. }
  883. }
  884. }
  885. Db::rollback();
  886. return error_show(1004,'退货失败');
  887. }catch (\Exception $e){
  888. Db::rollback();
  889. return error_show(1004,$e->getMessage());
  890. }
  891. }
  892. //取消售后
  893. public function Cancel()
  894. {
  895. //接收参数
  896. $data = $this->request->only(['token', 'returnCode'], 'post', 'trim');
  897. $val = Validate::rule(['returnCode|售后单编号' => 'require']);
  898. if (!$val->check($data)) return error_show(1005, $val->getError());
  899. Db::startTrans();
  900. try {
  901. $rs = Db::name('order_return')->field('id,status')->where([['returnCode', '=', $data['returnCode']], ['is_del', '=', 0], ['status', '<>', 8]])->find();
  902. if (!$rs) throw new Exception('该售后单记录不存在');
  903. //修改记录
  904. $res = Db::name('order_return')->where(['id' => $rs['id']])->update(['status' => 8, 'updatetime' => date('Y-m-d H:i:s')]);
  905. if (!$res) throw new Exception('该售后单记录修改失败');
  906. //记录日志
  907. ActionLog::logAdd($data['token'], ["order_code" => $data['returnCode'], "status" => 8, "action_remark" => '', "action_type" => "cancel"], 'SHD', 8, $this->post);
  908. ProcessOrder::AddProcess($this->post['token'], ["order_code" => $data['returnCode'], "order_id" => $rs['id'], "order_status" => 8, "order_type" => 'SHD']);
  909. //提交
  910. Db::commit();
  911. return app_show(0, "取消成功");
  912. } catch (\Exception $e) {
  913. Db::rollback();
  914. return error_show(1004, $e->getMessage());
  915. }
  916. }
  917. }