After.php 26 KB

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