After.php 25 KB

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