After.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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']==1){
  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. if($addr_code!==''&&is_array($addr_code)){
  269. $addrs=[];
  270. $addrs['provice_code'] = $addr_code[0];
  271. $addrs['city_code'] = $addr_code[1];
  272. $addrs['area_code'] = $addr_code[2];
  273. $addr_code = json_encode($addrs);
  274. }
  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. if($info['is_th']==1 && $info['order_type']==1) {
  298. $returninfo['contactor'] = $contactor;
  299. $returninfo['mobile'] = $mobile;
  300. $returninfo['addr'] = $addr;
  301. $returninfo['addr_code'] = $addr_code;
  302. }
  303. }
  304. $in=Db::name("order_returninfo")->save($returninfo);
  305. if($in){
  306. $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  307. ActionLog::logAdd($this->post['token'],$order,"AFTER",$info['status'],$order);
  308. Db::commit();
  309. return app_show(0,"更新成功");
  310. }
  311. }
  312. Db::rollback();
  313. return error_show(1004,"更新失败");
  314. }catch (\Exception $e){
  315. Db::rollback();
  316. return error_show(1004,$e->getMessage());
  317. }
  318. }
  319. /**
  320. * @return \think\response\Json|void
  321. * @throws \think\db\exception\DataNotFoundException
  322. * @throws \think\db\exception\DbException
  323. * @throws \think\db\exception\ModelNotFoundException
  324. */
  325. public function addpost(){
  326. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  327. if($bkcode==""){
  328. return error_show(1005,"参数returnCode 不能为空");
  329. }
  330. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  331. if(empty($info)){
  332. return error_show(1005,"未找到售后数据");
  333. }
  334. $return_info = Db::name("order_returninfo")->where(['returnCode'=>$bkcode])->find();
  335. if(empty($return_info)){
  336. $return_info=[
  337. "returnCode"=>$bkcode,
  338. "return_wsm"=>'',
  339. "contactor"=>'',
  340. "mobile"=>'',
  341. "addr"=>'',
  342. "addr_code"=>'',
  343. "addtime"=>date("Y-m-d H:i:s"),
  344. "post_company"=>'',
  345. "post_code"=>'',
  346. "post_fee"=>'',
  347. ];
  348. }
  349. $post_own = isset($this->post['own']) &&$this->post['own']!='' ? trim($this->post['own']):"";
  350. if($post_own==''){
  351. return error_show(1005,"参数own不能为空");
  352. }
  353. $info['post_own'] = $post_own;
  354. $post_company = isset($this->post['company'])&&$this->post['company']!='' ? trim($this->post['company']):"";
  355. if($post_company==''){
  356. return error_show(1005,"参数company不能为空");
  357. }
  358. $return_info['post_company'] = $post_company;
  359. $post_code = isset($this->post['post_code'])&&$this->post['post_code']!='' ? trim($this->post['post_code']):"";
  360. if($post_code==''){
  361. return error_show(1005,"参数post_code不能为空");
  362. }
  363. $return_info['post_code'] = $post_code;
  364. $fee= isset($this->post['post_fee'])&&$this->post['post_fee']!=='' ? round($this->post['post_fee'],2):"";
  365. if($fee===''){
  366. return error_show(1005,"参数post_fee不能为空");
  367. }
  368. $return_info['post_fee'] = $fee;
  369. Db::startTrans();
  370. try{
  371. $str=$info['status'];
  372. $info['status']=$info['order_type']==1?4:5;
  373. $info['updatetime']=date("Y-m-d H:i:s");
  374. $up =Db::name("order_return")->save($info);
  375. if($up){
  376. $order = ["order_code"=>$info['orderCode'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
  377. ActionLog::logAdd($this->post['token'],$order,"zxd",$info['status'],$order);
  378. $in=Db::name("order_returninfo")->save($return_info);
  379. if($in){
  380. $data=[
  381. 'thNo'=>makeNo("TH"),
  382. "orderCode"=>$info['orderCode'],
  383. "order_type"=>$info['order_type'],
  384. "outCode"=>$info['outCode'],
  385. "returnCode"=>$info['returnCode'],
  386. "good_code"=>$info['good_code'],
  387. "good_name"=>$info['good_name'],
  388. "return_wsm"=>$return_info['return_wsm'],
  389. "return_num"=>$info['error_num'],
  390. "contactor"=>$return_info['contactor'],
  391. "mobile"=>$return_info['mobile'],
  392. "addr"=>$return_info['addr'],
  393. "addr_code"=>$return_info['addr_code'],
  394. "return_code"=>$info['error_code'],
  395. "return_msg"=>$info['error_msg'],
  396. "post_fee"=>$return_info['post_fee'],
  397. "post_code"=>$return_info['post_code'],
  398. "post_company"=>$return_info['post_company'],
  399. "customer_code"=>$info['customer_code'],
  400. "addtime"=>date("Y-m-d H:i:s"),
  401. "updatetime"=>date("Y-m-d H:i:s")
  402. ];
  403. $back =Db::name("order_back")->insert($data);
  404. if($back){
  405. $order = ["order_code"=>$info['orderCode'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
  406. ActionLog::logAdd($this->post['token'],$order,"zxd", $info['status'],$order);
  407. Db::commit();
  408. return app_show(0,"更新成功");
  409. }
  410. }
  411. }
  412. Db::rollback();
  413. return error_show(1004,"更新失败");
  414. }catch (\Exception $e){
  415. Db::rollback();
  416. return error_show(1004,$e->getMessage());
  417. }
  418. }
  419. /**
  420. * @return \think\response\Json|void
  421. * @throws \think\db\exception\DataNotFoundException
  422. * @throws \think\db\exception\DbException
  423. * @throws \think\db\exception\ModelNotFoundException
  424. */
  425. public function GysFeed(){
  426. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  427. if($bkcode==""){
  428. return error_show(1005,"参数returnCode 不能为空");
  429. }
  430. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  431. if(empty($info)){
  432. return error_show(1005,"未找到售后数据");
  433. }
  434. $isth = isset($this->post['is_th']) && $this->post['is_th']!="" ? intval($this->post['is_th']):"0";
  435. $contactor = isset($this->post['contactor']) && $this->post['contactor']!="" ? trim($this->post['contactor'])
  436. :"";
  437. $mobile = isset($this->post['mobile']) && $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  438. $addr = isset($this->post['addr']) && $this->post['addr']!="" ? trim($this->post['addr']):"";
  439. $addr_code = isset($this->post['addr_code']) && $this->post['addr_code']!=""&&!empty($this->post['addr_code']) ? $this->post['addr_code']:"";
  440. $remark = isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  441. if($isth==1){
  442. if($contactor==''){
  443. return error_show(1005,"参数 contactor 不能为空");
  444. }
  445. if($mobile==''){
  446. return error_show(1005,"参数 mobile 不能为空");
  447. }
  448. if($addr==''){
  449. return error_show(1005,"参数 addr 不能为空");
  450. }
  451. // var_dump(isset($this->post['addr_code']) , $this->post['addr_code']!="",!empty($addr_code));
  452. if($addr_code==''){
  453. return error_show(1005,"参数 addr_code 不能为空");
  454. }
  455. if(is_array($addr_code)){
  456. $addrs=[];
  457. $addrs['provice_code'] = $addr_code[0];
  458. $addrs['city_code'] = $addr_code[1];
  459. $addrs['area_code'] = $addr_code[2];
  460. $addr_code = json_encode($addrs);
  461. }
  462. }
  463. Db::startTrans();
  464. try{
  465. $stat=$info['status'];
  466. $info['status']=3;
  467. $info['is_th']=$isth;
  468. $info['updatetime']=date("Y-m-d H:i:s");
  469. $up =Db::name("order_return")->save($info);
  470. if($up){
  471. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  472. if(empty($returninfo)){
  473. $returninfo=[
  474. "returnCode"=>$bkcode,
  475. "return_wsm"=>'',
  476. "contactor"=>$contactor,
  477. "mobile"=>$mobile ,
  478. "addr"=>$addr,
  479. "addr_code"=>$addr_code,
  480. "gys_remark"=>$remark,
  481. "addtime"=>date("Y-m-d H:i:s")
  482. ];
  483. }else{
  484. $returninfo['return_wsm'] = '';
  485. $returninfo['contactor'] = $contactor;
  486. $returninfo['mobile'] = $mobile;
  487. $returninfo['addr'] = $addr;
  488. $returninfo['gys_remark'] = $remark;
  489. $returninfo['addr_code'] = $addr_code;
  490. }
  491. $in=Db::name("order_returninfo")->save($returninfo);
  492. if($in){
  493. $order = ["order_code"=>$info['orderCode'],"status"=>$stat,"action_remark"=>'',"action_type"=>"edit"];
  494. ActionLog::logAdd($this->post['token'],$order,"zxd",3,$order);
  495. Db::commit();
  496. return app_show(0,"更新成功");
  497. }
  498. }
  499. Db::rollback();
  500. return error_show(1004,"更新失败");
  501. }catch (\Exception $e){
  502. Db::rollback();
  503. return error_show(1004,$e->getMessage());
  504. }
  505. }
  506. public function GetWsm(){
  507. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  508. if($bkcode==""){
  509. return error_show(1005,"参数returnCode 不能为空");
  510. }
  511. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  512. if(empty($info)){
  513. return error_show(1005,"未找到售后数据");
  514. }
  515. $list=[];
  516. if($info['is_th']==1){
  517. if($info["order_type"]==1){
  518. $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  519. if(empty($out)){
  520. return error_show(1005,"未找到出库单数据");
  521. }
  522. $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")
  523. ->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();
  524. if(empty($ware)){
  525. return error_show(1005,"未找到仓库数据");
  526. }
  527. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  528. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  529. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  530. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  531. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  532. $temp['addr_cn'] =GetAddr( $ware['addr_code']);
  533. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  534. $list[]=$temp;
  535. }else {
  536. $returninfo = Db::name("order_returninfo")->where(["returnCode" => $bkcode])->find();
  537. if (empty($returninfo)) {
  538. return error_show(1005, "未找到供应商仓库数据");
  539. }
  540. $data = [];
  541. $data['wsm_code'] = isset($returninfo['return_wsm']) && $returninfo['return_wsm'] != "" ? $returninfo['return_wsm'] : "-";
  542. $data['wsm_name'] = '供应商仓';
  543. $data['supplier_name'] = '供应商';
  544. $data['contactor'] = $returninfo['contactor'];
  545. $data['mobile'] = $returninfo['mobile'];
  546. $data['addr'] = $returninfo['addr'];
  547. $data['addr_cn'] =GetAddr( $returninfo['addr_code']);
  548. $data['addr_code'] = $returninfo['addr_code'];
  549. $list[] = $data;
  550. }
  551. }
  552. $supplier = Db::name("supplier")->where(["is_platform"=>1,"status"=>1,"is_del"=>0])->column("code,name");
  553. if(empty($supplier)){
  554. return error_show(1005,"未找到供应商仓库数据");
  555. }
  556. foreach ($supplier as $value){
  557. $temp=[];
  558. $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")
  559. ->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();
  560. if(empty($ware)){
  561. continue;
  562. }
  563. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  564. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  565. $temp['supplier_name']=$value['name'];
  566. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  567. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  568. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  569. $temp['addr_cn'] =GetAddr($ware['addr_code']);
  570. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  571. $list[]=$temp;
  572. }
  573. return app_show(0,"获取成功",$list);
  574. }
  575. }