After.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use think\App;
  5. use think\facade\Db;
  6. class After extends \app\BaseController
  7. {
  8. public $post=[];
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. $this->post =$this->request->post();
  13. }
  14. public function create(){
  15. $outCode = isset($this->post['outCode']) &&$this->post['outCode']!=''?trim($this->post['outCode']) :"";
  16. if($outCode==''){
  17. return error_show(1004,"参数outCode 不能为空");
  18. }
  19. $order= Db::name("order_out")->where(["outCode"=>$outCode])->find();
  20. if(empty($order)){
  21. return error_show(1005,"未找到订单数据");
  22. }
  23. $order= Db::name("sale")->where(["orderCode"=>$order['orderCode'],"is_del"=>0])->find();
  24. if(empty($order)){
  25. return error_show(1005,"未找到订单数据");
  26. }
  27. $errorCode = isset($this->post['errorCode']) &&$this->post['errorCode']!=''?trim($this->post['errorCode']) :"";
  28. if($outCode==''){
  29. return error_show(1004,"参数errorCode 不能为空");
  30. }
  31. $error =Db::name('result_info')->where(["result_code"=>$errorCode,"is_del"=>0])->find();
  32. if(empty($error)){
  33. return error_show(1005,"未找到退货原因数据");
  34. }
  35. $num =isset($this->post['num']) &&$this->post['num']!=''?intval($this->post['num']) :"";
  36. if($num==""){
  37. return error_show(1004,"参数 num 不能为空或零");
  38. }
  39. $order_type =isset($this->post['order_type']) &&$this->post['order_type']!=''?intval($this->post['order_type']) :"";
  40. // if($order_type==""){
  41. // return error_show(1004,"参数 order_type 不能为空或零");
  42. // }
  43. $remark =isset($this->post['remark']) &&$this->post['remark']!=''?trim($this->post['remark']) :"";
  44. $except_code =isset($this->post['except_code']) &&$this->post['except_code']!=''?trim($this->post['except_code']) :"";
  45. $img = isset($this->post['img']) &&$this->post['img']!=''?trim($this->post['img']) :"";
  46. $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
  47. if($token==''){
  48. return error_show(1005,"参数token不能为空");
  49. }
  50. $user =GetUserInfo($token);
  51. if(empty($user)||$user['code']!=0){
  52. return error_show(1002,"申请人数据不存在");
  53. }
  54. $rm= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  55. $ri= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  56. $returnCode=makeNo("RXS");
  57. Db::startTrans();
  58. try{
  59. $in = [
  60. "returnCode"=>$returnCode,
  61. "outCode"=>$outCode,
  62. "orderCode"=> $order['orderCode'],
  63. "good_code"=>$order['good_code'],
  64. "good_name"=>$order['good_name'],
  65. "customer_code"=>$order['customer_code'],
  66. "apply_id"=>$rm,
  67. "apply_name"=>$ri,
  68. 'total_num'=>$order['send_num'],
  69. "error_code"=>$errorCode,
  70. "error_num"=>$num,
  71. "error_img"=>$img,
  72. "error_msg"=>$error['result'],
  73. "error_remark"=>$remark,
  74. "remark"=>'',
  75. "except_code"=>$except_code,
  76. "order_type"=>$order['order_type'],
  77. "status"=>0,
  78. "is_del"=>0,
  79. "addtime"=>date("Y-m-d H:i:s"),
  80. "updatetime"=>date("Y-m-d H:i:s")
  81. ];
  82. $create = Db::name("order_return")->insert($in);
  83. $orde = ["order_code"=>$returnCode,"status"=>$in['status'],"action_remark"=>'',"action_type"=>"create"];
  84. ActionLog::logAdd($this->post['token'],$orde,'zxd',0,$orde);
  85. if($create){
  86. Db::commit();
  87. return app_show(0,"售后申请单新建成功");
  88. }
  89. Db::rollback();
  90. return error_show(1005,"售后申请单新建失败");
  91. }catch (\Exception $e){
  92. Db::rollback();
  93. return error_show(1005,$e->getMessage());
  94. }
  95. }
  96. public function list(){
  97. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
  98. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
  99. $where =[['a.is_del',"=",0]];
  100. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  101. if($bkcode!=""){
  102. $where[]=['a.returnCode',"like", "%{$bkcode}%"];
  103. }
  104. $out = isset($this->post['outCode']) && $this->post['outCode']!="" ? trim($this->post['outCode']):"";
  105. if($out!=""){
  106. $where[]=['a.outCode',"like", "%{$out}%"];
  107. }
  108. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  109. if($status!==""){
  110. $where[]=['a.status',"=", $status];
  111. }
  112. $order_type = isset($this->post['order_type']) && $this->post['order_type']!=="" ? intval($this->post['order_type']):"";
  113. if($order_type!==""){
  114. $where[]=['a.order_type',"=", $order_type];
  115. }
  116. $orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode'])
  117. :"";
  118. if($orderCode!=""){
  119. $where[]=['a.orderCode',"like", "%{$orderCode}%"];
  120. }
  121. $good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code'])
  122. :"";
  123. if($good_code!=""){
  124. $where[]=['a.good_code',"like", "%{$good_code}%"];
  125. }
  126. $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name'])
  127. :"";
  128. if($good_name!=""){
  129. $where[]=['a.good_name',"like", "%{$good_name}%"];
  130. }
  131. $customer_code = isset($this->post['customer_code']) && $this->post['customer_code']!="" ? trim($this->post['customer_code'])
  132. :"";
  133. if($customer_code!=""){
  134. $where[]=['a.customer_code',"like", "%{$customer_code}%"];
  135. }
  136. $except_code = isset($this->post['except_code']) && $this->post['except_code']!="" ? trim($this->post['except_code']):"";
  137. if($except_code!=""){
  138. $where[]=['a.except_code',"=", $except_code];
  139. }
  140. $apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name'])
  141. :"";
  142. if($apply_name!=""){
  143. $where[]=['a.apply_name',"like", "%{$apply_name}%"];
  144. }
  145. $start =isset($this->post['start'])&&$this->post['start']!='' ? $this->post['start']:"";
  146. if($start!==""){
  147. $where[]=['a.addtime',">=", $start];
  148. }
  149. $end =isset($this->post['end'])&&$this->post['end']!='' ? $this->post['end']:"";
  150. if($end!==""){
  151. $where[]=['a.addtime',"<=", $end];
  152. }
  153. $count=Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")->where
  154. ($where)->count();
  155. $total = ceil($count/$size);
  156. $page = $total>=$page ? $page :$total;
  157. $list =Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")->where($where)
  158. ->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)
  159. ->order("addtime desc")->select();
  160. $data=[];
  161. foreach ($list as $value){
  162. $customer = Db::name("customer_info")->where(["companyNo"=>$value['customer_code']])->find();
  163. $value['customer_name'] = isset($customer['companyName']) ?trim($customer['companyName']):'';
  164. $data[]=$value;
  165. }
  166. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  167. }
  168. /**
  169. * @return \think\response\Json|void
  170. * @throws \think\db\exception\DataNotFoundException
  171. * @throws \think\db\exception\DbException
  172. * @throws \think\db\exception\ModelNotFoundException
  173. */
  174. public function info(){
  175. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  176. if($bkcode==""){
  177. return error_show(1005,"参数returnCode 不能为空");
  178. }
  179. $info = Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")
  180. ->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")
  181. ->where(['a.returnCode'=>$bkcode])->find();
  182. if(empty($info)){
  183. return error_show(1005,"未找到售后数据");
  184. }
  185. $info["addr_cn"]=GetAddr($info['addr_code']);
  186. $info["addr_code"]=json_decode($info['addr_code'],true);
  187. $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  188. $info['out_num'] = isset($out['send_num'])?$out['send_num']:'';
  189. $customer = Db::name("customer_info")->where(["companyNo"=>$info['customer_code']])->find();
  190. $info['customer_name'] = isset($customer['companyName']) ?trim($customer['companyName']):'';
  191. return app_show(0,"获取成功",$info);
  192. }
  193. public function status(){
  194. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  195. if($bkcode==""){
  196. return error_show(1005,"参数returnCode 不能为空");
  197. }
  198. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  199. if(empty($info)){
  200. return error_show(1005,"未找到售后数据");
  201. }
  202. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status'])
  203. :"";
  204. if($status===""){
  205. return error_show(1005,"参数status 不能为空");
  206. }
  207. $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
  208. if($remark!=''){
  209. $info['remark'] =$remark;
  210. }
  211. $var=$info['status'];
  212. $info['status']=$status;
  213. $info['updatetime']=date("Y-m-d H:i:s");
  214. $up =Db::name("order_return")->save($info);
  215. if($up){
  216. $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  217. ActionLog::logAdd($this->post['token'],$order,"zxd", $info['status'],$this->post);
  218. return app_show(0,"更新成功");
  219. }else{
  220. return error_show(1004,"更新失败");
  221. }
  222. }
  223. /**
  224. * @return \think\response\Json|void
  225. * @throws \think\db\exception\DataNotFoundException
  226. * @throws \think\db\exception\DbException
  227. * @throws \think\db\exception\ModelNotFoundException
  228. */
  229. public function postfeed(){
  230. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  231. if($bkcode==""){
  232. return error_show(1005,"参数returnCode 不能为空");
  233. }
  234. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  235. if(empty($info)){
  236. return error_show(1005,"未找到售后数据");
  237. }
  238. $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
  239. if($wsm_code==""){
  240. return error_show(1005,"参数 wsm_code不能为空");
  241. }
  242. if($info['is_th']==0&&$info['order_type']==1) {
  243. $wsm = Db::name("warehouse_info")->where(["wsm_code" => $wsm_code])->find();
  244. if (empty($wsm)) {
  245. return error_show(1005, "未找到仓库数据");
  246. }
  247. }
  248. $contactor = isset($this->post['contactor']) && $this->post['contactor']!="" ? trim($this->post['contactor'])
  249. :"";
  250. $mobile = isset($this->post['mobile']) && $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  251. $addr = isset($this->post['addr']) && $this->post['addr']!="" ? trim($this->post['addr']):"";
  252. $addr_code = isset($this->post['addr_code']) && $this->post['addr_code']!=""&&!empty($this->post['addr_code']) ?
  253. $this->post['addr_code']:"";
  254. $remark = isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  255. if($info['is_th']==1 && $info['order_type']==2){
  256. if($contactor==''){
  257. return error_show(1005,"参数 contactor 不能为空");
  258. }
  259. if($mobile==''){
  260. return error_show(1005,"参数 mobile 不能为空");
  261. }
  262. if($addr==''){
  263. return error_show(1005,"参数 addr 不能为空");
  264. }
  265. if($addr_code==''){
  266. return error_show(1005,"参数 addr_code 不能为空");
  267. }
  268. }
  269. if($addr_code!==''&&is_array($addr_code)){
  270. $addrs=[];
  271. $addrs['provice_code'] = $addr_code[0];
  272. $addrs['city_code'] = $addr_code[1];
  273. $addrs['area_code'] = $addr_code[2];
  274. $addr_code = json_encode($addrs);
  275. }
  276. Db::startTrans();
  277. try{
  278. $var=$info['status'];
  279. $info['status']=$info['order_type']==1?3:4;
  280. $info['remark']=$remark;
  281. $info['updatetime']=date("Y-m-d H:i:s");
  282. $up =Db::name("order_return")->save($info);
  283. if($up){
  284. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  285. if(empty($returninfo)){
  286. $returninfo=[
  287. "returnCode"=>$bkcode,
  288. "return_wsm"=>$wsm_code,
  289. "contactor"=>$contactor,
  290. "mobile"=>$mobile ,
  291. "addr"=>$addr,
  292. "addr_code"=>$addr_code,
  293. "addtime"=>date("Y-m-d H:i:s")
  294. ];
  295. }else{
  296. $returninfo['return_wsm'] = $wsm_code;
  297. $returninfo['contactor'] = $contactor;
  298. $returninfo['mobile'] = $mobile;
  299. $returninfo['addr'] = $addr;
  300. $returninfo['addr_code'] = $addr_code;
  301. }
  302. $in=Db::name("order_returninfo")->save($returninfo);
  303. if($in){
  304. $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  305. ActionLog::logAdd($this->post['token'],$order,$info['status'],$order);
  306. Db::commit();
  307. return app_show(0,"更新成功");
  308. }
  309. }
  310. Db::rollback();
  311. return error_show(1004,"更新失败");
  312. }catch (\Exception $e){
  313. Db::rollback();
  314. return error_show(1004,$e->getMessage());
  315. }
  316. }
  317. /**
  318. * @return \think\response\Json|void
  319. * @throws \think\db\exception\DataNotFoundException
  320. * @throws \think\db\exception\DbException
  321. * @throws \think\db\exception\ModelNotFoundException
  322. */
  323. public function addpost(){
  324. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  325. if($bkcode==""){
  326. return error_show(1005,"参数returnCode 不能为空");
  327. }
  328. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  329. if(empty($info)){
  330. return error_show(1005,"未找到售后数据");
  331. }
  332. $return_info = Db::name("order_returninfo")->where(['returnCode'=>$bkcode])->find();
  333. if(empty($return_info)){
  334. $return_info=[
  335. "returnCode"=>$bkcode,
  336. "return_wsm"=>'',
  337. "contactor"=>'',
  338. "mobile"=>'',
  339. "addr"=>'',
  340. "addr_code"=>'',
  341. "addtime"=>date("Y-m-d H:i:s"),
  342. "post_company"=>'',
  343. "post_code"=>'',
  344. "post_fee"=>'',
  345. ];
  346. }
  347. $post_own = isset($this->post['own']) &&$this->post['own']!='' ? trim($this->post['own']):"";
  348. if($post_own==''){
  349. return error_show(1005,"参数own不能为空");
  350. }
  351. $info['post_own'] = $post_own;
  352. $post_company = isset($this->post['company'])&&$this->post['company']!='' ? trim($this->post['company']):"";
  353. if($post_company==''){
  354. return error_show(1005,"参数company不能为空");
  355. }
  356. $return_info['post_company'] = $post_company;
  357. $post_code = isset($this->post['post_code'])&&$this->post['post_code']!='' ? trim($this->post['post_code']):"";
  358. if($post_code==''){
  359. return error_show(1005,"参数post_code不能为空");
  360. }
  361. $return_info['post_code'] = $post_code;
  362. $fee= isset($this->post['post_fee'])&&$this->post['post_fee']!=='' ? round($this->post['post_fee'],2):"";
  363. if($fee===''){
  364. return error_show(1005,"参数post_fee不能为空");
  365. }
  366. $return_info['post_fee'] = $fee;
  367. Db::startTrans();
  368. try{
  369. $str=$info['status'];
  370. $info['status']=$info['order_type']==1?4:5;
  371. $info['updatetime']=date("Y-m-d H:i:s");
  372. $up =Db::name("order_return")->save($info);
  373. if($up){
  374. $order = ["order_code"=>$info['orderCode'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
  375. ActionLog::logAdd($this->post['token'],$order,"zxd",$info['status'],$order);
  376. $in=Db::name("order_returninfo")->save($return_info);
  377. if($in){
  378. $data=[
  379. 'thNo'=>makeNo("TH"),
  380. "orderCode"=>$info['orderCode'],
  381. "order_type"=>$info['order_type'],
  382. "outCode"=>$info['outCode'],
  383. "returnCode"=>$info['returnCode'],
  384. "good_code"=>$info['good_code'],
  385. "good_name"=>$info['good_name'],
  386. "return_wsm"=>$return_info['return_wsm'],
  387. "return_num"=>$info['error_num'],
  388. "contactor"=>$return_info['contactor'],
  389. "mobile"=>$return_info['mobile'],
  390. "addr"=>$return_info['addr'],
  391. "addr_code"=>$return_info['addr_code'],
  392. "return_code"=>$info['error_code'],
  393. "return_msg"=>$info['error_msg'],
  394. "post_fee"=>$return_info['post_fee'],
  395. "post_code"=>$return_info['post_code'],
  396. "post_company"=>$return_info['post_company'],
  397. "customer_code"=>$info['customer_code'],
  398. "addtime"=>date("Y-m-d H:i:s"),
  399. "updatetime"=>date("Y-m-d H:i:s")
  400. ];
  401. $back =Db::name("order_back")->insert($data);
  402. if($back){
  403. $order = ["order_code"=>$info['orderCode'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
  404. ActionLog::logAdd($this->post['token'],$order,"zxd", $info['status'],$order);
  405. Db::commit();
  406. return app_show(0,"更新成功");
  407. }
  408. }
  409. }
  410. Db::rollback();
  411. return error_show(1004,"更新失败");
  412. }catch (\Exception $e){
  413. Db::rollback();
  414. return error_show(1004,$e->getMessage());
  415. }
  416. }
  417. /**
  418. * @return \think\response\Json|void
  419. * @throws \think\db\exception\DataNotFoundException
  420. * @throws \think\db\exception\DbException
  421. * @throws \think\db\exception\ModelNotFoundException
  422. */
  423. public function GysFeed(){
  424. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  425. if($bkcode==""){
  426. return error_show(1005,"参数returnCode 不能为空");
  427. }
  428. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  429. if(empty($info)){
  430. return error_show(1005,"未找到售后数据");
  431. }
  432. $isth = isset($this->post['is_th']) && $this->post['is_th']!="" ? intval($this->post['is_th']):"0";
  433. $contactor = isset($this->post['contactor']) && $this->post['contactor']!="" ? trim($this->post['contactor'])
  434. :"";
  435. $mobile = isset($this->post['mobile']) && $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  436. $addr = isset($this->post['addr']) && $this->post['addr']!="" ? trim($this->post['addr']):"";
  437. $addr_code = isset($this->post['addr_code']) && $this->post['addr_code']!=""&&!empty($this->post['addr_code']) ? $this->post['addr_code']:"";
  438. $remark = isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  439. if($isth==1){
  440. if($contactor==''){
  441. return error_show(1005,"参数 contactor 不能为空");
  442. }
  443. if($mobile==''){
  444. return error_show(1005,"参数 mobile 不能为空");
  445. }
  446. if($addr==''){
  447. return error_show(1005,"参数 addr 不能为空");
  448. }
  449. // var_dump(isset($this->post['addr_code']) , $this->post['addr_code']!="",!empty($addr_code));
  450. if($addr_code==''){
  451. return error_show(1005,"参数 addr_code 不能为空");
  452. }
  453. if(is_array($addr_code)){
  454. $addrs=[];
  455. $addrs['provice_code'] = $addr_code[0];
  456. $addrs['city_code'] = $addr_code[1];
  457. $addrs['area_code'] = $addr_code[2];
  458. $addr_code = json_encode($addrs);
  459. }
  460. }
  461. Db::startTrans();
  462. try{
  463. $stat=$info['status'];
  464. $info['status']=3;
  465. $info['is_th']=$isth;
  466. $info['updatetime']=date("Y-m-d H:i:s");
  467. $up =Db::name("order_return")->save($info);
  468. if($up){
  469. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  470. if(empty($returninfo)){
  471. $returninfo=[
  472. "returnCode"=>$bkcode,
  473. "return_wsm"=>'',
  474. "contactor"=>$contactor,
  475. "mobile"=>$mobile ,
  476. "addr"=>$addr,
  477. "addr_code"=>$addr_code,
  478. "gys_remark"=>$remark,
  479. "addtime"=>date("Y-m-d H:i:s")
  480. ];
  481. }else{
  482. $returninfo['return_wsm'] = '';
  483. $returninfo['contactor'] = $contactor;
  484. $returninfo['mobile'] = $mobile;
  485. $returninfo['addr'] = $addr;
  486. $returninfo['gys_remark'] = $remark;
  487. $returninfo['addr_code'] = $addr_code;
  488. }
  489. $in=Db::name("order_returninfo")->save($returninfo);
  490. if($in){
  491. $order = ["order_code"=>$info['orderCode'],"status"=>$stat,"action_remark"=>'',"action_type"=>"edit"];
  492. ActionLog::logAdd($this->post['token'],$order,"zxd",3,$order);
  493. Db::commit();
  494. return app_show(0,"更新成功");
  495. }
  496. }
  497. Db::rollback();
  498. return error_show(1004,"更新失败");
  499. }catch (\Exception $e){
  500. Db::rollback();
  501. return error_show(1004,$e->getMessage());
  502. }
  503. }
  504. public function GetWsm(){
  505. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  506. if($bkcode==""){
  507. return error_show(1005,"参数returnCode 不能为空");
  508. }
  509. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  510. if(empty($info)){
  511. return error_show(1005,"未找到售后数据");
  512. }
  513. $list=[];
  514. if($info['is_th']==1){
  515. if($info["order_type"]==1){
  516. $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  517. if(empty($out)){
  518. return error_show(1005,"未找到出库单数据");
  519. }
  520. $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")
  521. ->where(["a.status"=>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();
  522. if(empty($ware)){
  523. return error_show(1005,"未找到仓库数据");
  524. }
  525. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  526. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  527. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  528. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  529. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  530. $temp['addr_cn'] =GetAddr( $ware['addr_code']);
  531. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  532. $list[]=$temp;
  533. }else {
  534. $returninfo = Db::name("order_returninfo")->where(["returnCode" => $bkcode])->find();
  535. if (empty($returninfo)) {
  536. return error_show(1005, "未找到供应商仓库数据");
  537. }
  538. $data = [];
  539. $data['wsm_code'] = isset($returninfo['return_wsm']) && $returninfo['return_wsm'] != "-" ? $returninfo['return_wsm'] : "-";
  540. $data['wsm_name'] = '供应商仓';
  541. $data['supplier_name'] = '供应商';
  542. $data['contactor'] = $returninfo['contactor'];
  543. $data['mobile'] = $returninfo['mobile'];
  544. $data['addr'] = $returninfo['addr'];
  545. $data['addr_cn'] =GetAddr( $returninfo['addr_code']);
  546. $data['addr_code'] = $returninfo['addr_code'];
  547. $list[] = $data;
  548. }
  549. }else{
  550. $supplier = Db::name("supplier")->where(["is_platform"=>1,"status"=>1,"is_del"=>0])->column("code,name");
  551. if(empty($supplier)){
  552. return error_show(1005,"未找到供应商仓库数据");
  553. }
  554. foreach ($supplier as $value){
  555. $temp=[];
  556. $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")
  557. ->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();
  558. if(empty($ware)){
  559. continue;
  560. }
  561. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  562. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  563. $temp['supplier_name']=$value['name'];
  564. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  565. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  566. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  567. $temp['addr_cn'] =GetAddr($ware['addr_code']);
  568. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  569. $list[]=$temp;
  570. }
  571. }
  572. return app_show(0,"获取成功",$list);
  573. }
  574. }