AfterChild.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Exception;
  4. use think\facade\Db;
  5. use think\facade\Validate;
  6. //退货工单
  7. class AfterChild extends Base
  8. {
  9. //退货工单列表
  10. public function getList()
  11. {
  12. $param = $this->request->only(['page' => 1, 'size' => 10, 'returnCode' => '', 'status' => '', 'orderCode' => '', 'outCode' => ''], 'post', 'trim');
  13. $where = [['a.is_del', '=', 0]];
  14. if ($param['returnCode'] != '') $where[] = ['a.returnCode', 'like', '%' . $param['returnCode'] . '%'];
  15. if ($param['status'] !== '') $where[] = ['a.status', '=', $param['status']];
  16. if ($param['orderCode'] != '') $where[] = ['a.orderCode', 'like', '%' . $param['orderCode'] . '%'];
  17. if ($param['outCode'] != '') $where[] = ['a.outCode', 'like', '%' . $param['outCode'] . '%'];
  18. $count = Db::name('order_return_child')
  19. ->alias('a')
  20. ->leftJoin('warehouse_info b', 'b.wsm_code=a.send_wsm_code')
  21. ->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code')
  22. ->leftJoin('order_return d','d.returnCode=a.returnCode and d.is_del=0')
  23. ->where($where)
  24. ->count('a.id');
  25. $list = Db::name('order_return_child')
  26. ->alias('a')
  27. ->field('a.id,a.returnCode,a.orderCode,a.outCode,a.order_out_child_status,a.outChildCode,b.supplierName send_supplierName,b.supplierNo send_supplierNo,b.name send_wsm_name,a.send_wsm_code,b.contactor_name send_contactor_name,a.send_num,a.return_num,c.supplierName return_supplierName,c.supplierNo return_supplierNo,c.name return_wsm_name,a.return_wsm_code,c.contactor_name return_contactor_name,a.status,d.companyNo,d.companyName,d.customer_code,d.customer_name')
  28. ->leftJoin('warehouse_info b', 'b.wsm_code=a.send_wsm_code')
  29. ->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code')
  30. ->leftJoin('order_return d','d.returnCode=a.returnCode and d.is_del=0')
  31. ->where($where)
  32. ->order(['a.addtime' => 'desc', 'a.id' => 'desc'])
  33. ->page($param['page'], $param['size'])
  34. ->select()
  35. ->toArray();
  36. return json_show(0, '获取列表成功', ['count' => $count, 'list' => $list]);
  37. }
  38. //设置退货工单
  39. public function setOrderReturnChild()
  40. {
  41. $param = $this->request->only(['returnCode', 'list'], 'post', 'trim');
  42. $val = Validate::rule([
  43. 'returnCode|售后申请单编码' => 'require',
  44. 'list|工单集合' => 'require|array|max:100',
  45. ]);
  46. if ($val->check($param) == false) return json_show(1004, $val->getError());
  47. $info = Db::name('order_return')
  48. ->where(['is_del' => 0, 'returnCode' => $param['returnCode']])
  49. ->findOrEmpty();
  50. if (empty($info)) return json_show(1004, '售后申请单不存在');
  51. if ($info['status'] != 11) return json_show(1004, '售后申请单状态错误');
  52. if ($info['is_receive'] != 1) return json_show(1004, '未收到货,无需设置退货工单');
  53. $order_out = Db::name('order_out')
  54. ->field('id,status order_out_status,orderCode')
  55. ->where(['is_del' => 0, 'outCode' => $info['outCode']])
  56. ->findOrEmpty();
  57. if (empty($order_out)) return json_show(1004, '未找到对应的发货单');
  58. $val_child = Validate::rule([
  59. 'outChildCode|发货工单号' => 'require',
  60. 'return_num|退货数量' => 'require|number|gt:0|max:999999999999',
  61. 'return_wsm_code|退货仓库编码' => 'require'
  62. ]);
  63. //发货工单详情
  64. $order_out_child = Db::name('order_out_child')
  65. ->where(['is_del' => 0, 'outCode' => $info['outCode'], 'outChildCode' => array_column($param['list'], 'outChildCode')])
  66. ->column('num,wsm_code,status', 'outChildCode');
  67. //所有仓库详情
  68. $wsm_info = Db::name('warehouse_info')
  69. ->where(['is_del' => 0, 'wsm_code' => array_unique(array_merge(array_column($order_out_child, 'wsm_code'), array_column($param['list'], 'return_wsm_code')))])
  70. ->column('id', 'wsm_code');
  71. if(array_sum(array_column($param['list'],'return_num')) != $info['error_num']) return json_show(1004,'数量错误');
  72. Db::startTrans();
  73. try {
  74. $insert = [];
  75. $date = date('Y-m-d H:i:s');
  76. foreach ($param['list'] as $value) {
  77. if ($val_child->check($value) == false) throw new Exception($val_child->getError());
  78. if (!isset($order_out_child[$value['outChildCode']])) throw new Exception($value['outChildCode'] . '发货工单不存在');
  79. if (!isset($wsm_info[$value['return_wsm_code']])) throw new Exception($value['return_wsm_code'] . '退货仓库不存在');
  80. $insert[] = [
  81. 'returnCode' => $param['returnCode'],
  82. 'orderCode' => $order_out['orderCode'],
  83. 'outCode' => $info['outCode'],
  84. 'order_out_child_status' => $order_out_child[$value['outChildCode']]['status'],
  85. 'outChildCode' => $value['outChildCode'],
  86. 'send_wsm_code' => $order_out_child[$value['outChildCode']]['wsm_code'],
  87. 'send_num' => $order_out_child[$value['outChildCode']]['num'],
  88. 'return_num' => $value['return_num'],
  89. 'return_wsm_code' => $value['return_wsm_code'],
  90. 'can_sell_num' => 0,
  91. 'defective_num' => 0,
  92. 'loss_num' => 0,
  93. 'apply_id' => $this->uid,
  94. 'apply_name' => $this->uname,
  95. 'status' => 1,
  96. 'is_del' => 0,
  97. 'remark' => '',
  98. 'addtime' => $date,
  99. 'updatetime' => $date,
  100. ];
  101. }
  102. if ($insert) Db::name('order_return_child')->insertAll($insert);
  103. Db::name('order_return')
  104. ->where(['is_del' => 0, 'id' => $info['id'], 'status' => 11])
  105. ->update(['status' => 4, 'updatetime' => $date]);
  106. Db::commit();
  107. return json_show(0, '设置退货工单成功');
  108. } catch (Exception $exception) {
  109. Db::rollback();
  110. return json_show(1004, $exception->getMessage());
  111. }
  112. }
  113. //库管收货
  114. public function deliveryOrderReturnChild()
  115. {
  116. $param = $this->request->only(['returnCode', 'list'], 'post', 'trim');
  117. $val = Validate::rule([
  118. 'returnCode|退货申请单号' => 'require',
  119. 'list|退货工单集合' => 'require|array|max:100',
  120. ]);
  121. if ($val->check($param) == false) return json_show(1004, $val->getError());
  122. $order_return = Db::name('order_return')
  123. ->alias('a')
  124. ->field('a.id,a.good_code,a.outCode,b.orderCode,c.is_stock,c.order_type,a.status')
  125. ->leftJoin('order_out b', 'b.outCode=a.outCode AND b.is_del=0')
  126. ->leftJoin('sale c', 'c.orderCode=b.orderCode AND c.is_del=0')
  127. ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode']])
  128. ->findOrEmpty();
  129. if (empty($order_return)) return json_show(1004, '售后申请单不存在');
  130. if ($order_return['status'] != 12) return json_show(1004, '售后申请单状态有误');
  131. $info = Db::name('order_return_child')
  132. ->alias('a')
  133. ->leftJoin('order_out_child b', 'b.outChildCode=a.outChildCode')
  134. ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode'], 'a.id' => array_column($param['list'], 'id')])
  135. ->column('a.id,a.return_wsm_code,a.outChildCode,b.wsm_code,a.status,a.return_num', 'a.id');
  136. if (empty($info)) return json_show(1004, '退货工单不存在');
  137. $val_child = Validate::rule([
  138. 'id|退货工单id' => 'require|gt:0|max:999999999',
  139. 'can_sell_num|销售仓入库数量' => 'require|number|egt:0|max:999999999999',
  140. 'defective_num|次品仓入库数量' => 'require|number|egt:0|max:999999999999',
  141. 'loss_num|丢失数量' => 'require|number|egt:0|max:999999999999',
  142. 'remark|备注' => 'max:255'
  143. ]);
  144. Db::startTrans();
  145. try {
  146. $date = date('Y-m-d H:i:s');
  147. foreach ($param['list'] as $value) {
  148. if ($val_child->check($value) == false) throw new Exception($val_child->getError());
  149. if (!isset($info[$value['id']])) throw new Exception($value['id'] . '退货工单不存在');
  150. if ($info[$value['id']]['status'] != 1) throw new Exception($value['id'] . '退货工单状态有误');
  151. //退货工单
  152. Db::name('order_return_child')
  153. ->where(['is_del' => 0, 'id' => $value['id']])
  154. ->update([
  155. 'can_sell_num' => $value['can_sell_num'],
  156. 'defective_num' => $value['defective_num'],
  157. 'loss_num' => $value['loss_num'],
  158. 'remark' => $value['remark'] ?? '',
  159. 'updatetime' => $date,
  160. 'status' => 2
  161. ]);
  162. //发货工单数量减少
  163. Db::name('order_out_child')
  164. ->where(['is_del' => 0, 'outChildCode' => $info[$value['id']]['outChildCode']])
  165. ->dec('num', $info[$value['id']]['return_num'])
  166. ->update(['updatetime' => $date]);
  167. }
  168. $total = array_sum(array_column($param['list'], 'can_sell_num'));
  169. if ($total > 0) {
  170. if ($order_return['is_stock'] != 1) {
  171. //根据转化表判断该非库存品是否转化为库存品
  172. $spuCode = Db::name('good_change_stock')
  173. ->where(['old_spuCode' => $order_return['good_code'], 'old_order_type' => $order_return['order_type']])
  174. ->value('spuCode', '');
  175. if ($spuCode == '') {
  176. //将非库存品转化为库存品
  177. $spuCode = makeNo('SKU');
  178. if ($order_return['order_type'] == 2) {
  179. $good = Db::name('good_basic')
  180. ->where('spuCode', $order_return['good_code'])
  181. ->findOrEmpty();
  182. if (!empty($good)) {
  183. Db::name('good_basic')->insert(array_merge($good, [
  184. 'id' => null,
  185. 'spuCode' => $spuCode,
  186. 'addtime' => $date,
  187. 'updatetime' => $date,
  188. ]));
  189. }
  190. } else {
  191. $good = Db::name('good_zixun')
  192. ->where([])
  193. ->findOrEmpty();
  194. if (!empty($good)) {
  195. Db::name('good_basic')->insert([
  196. 'spuCode' => $spuCode,
  197. 'good_code' => $good['good_code'],
  198. 'good_name' => $good['good_name'],
  199. 'cat_id' => $good['cat_id'],
  200. 'brand_id' => $good['brand_id'],
  201. 'companyNo' => $good['companyNo'],
  202. 'companyName' => $good['companyName'],
  203. 'good_unit' => $good['good_unit'],
  204. 'good_type' => $good['good_type'],
  205. 'moq' => $good['moq'],
  206. 'is_exclusive' => 0,
  207. 'customized' => $good['customized'],
  208. 'tax' => $good['tax'],
  209. 'supplierNo' => $good['supplierNo'],
  210. 'supplierName' => $good['supplierName'],
  211. 'is_auth' => $good['is_auth'],
  212. 'auth_img' => $good['auth_img'],
  213. 'is_stock' => 1,
  214. 'after_sales' => '',
  215. 'craft_desc' => $good['craft_desc'],
  216. 'good_remark' => $good['good_remark'],
  217. 'good_size' => '',
  218. 'weight' => $good['weight'],
  219. 'packing_way' => '',
  220. 'packing_size' => '',
  221. 'packing_spec' => '',
  222. 'packing_list' => '',
  223. 'packing_weight' => 0,
  224. 'good_bar' => '',
  225. 'supply_area' => $good['supply_area'],
  226. 'delivery_place' => '',
  227. 'origin_place' => '',
  228. 'delivery_day' => '',
  229. 'lead_time' => '',
  230. 'sample_day' => '',
  231. 'sample_fee' => '',
  232. 'good_img' => $good['good_img'],
  233. 'good_thumb_img' => $good['good_thumb_img'],
  234. 'good_info_img' => $good['good_info_img'],
  235. 'cert_fee' => 0,
  236. 'packing_fee' => 0,
  237. 'cost_fee' => 0,
  238. 'mark_fee' => 0,
  239. 'demo_fee' => 0,
  240. 'open_fee' => 0,
  241. 'noble_metal' => $good['noble_metal'],
  242. 'noble_weight' => 0,
  243. 'is_gold_price' => $good['is_gold_price'],
  244. 'cgd_gold_price' => 0,
  245. 'market_price' => 0,
  246. 'nake_price' => 0,
  247. 'is_step' => 0,
  248. 'is_online' => 0,
  249. 'status' => 0,
  250. 'createrid' => $good['createrid'],
  251. 'creater' => $good['creater'],
  252. 'field_change' => '',
  253. 'is_del' => 0,
  254. 'addtime' => $date,
  255. 'updatetime' => $date,
  256. 'is_diff' => 0,
  257. 'config' => '',
  258. 'other_config' => '',
  259. 'stock_moq' => 0,
  260. 'is_support_barter' => 1,
  261. 'chargerid' => $good['createrid'],
  262. 'charger' => $good['creater'],
  263. 'is_support_stock' => 1
  264. ]);
  265. }
  266. }
  267. if (!empty($good)) {
  268. //关联表增数据
  269. Db::name('good_change_stock')
  270. ->insert([
  271. 'old_spuCode' => $order_return['good_code'],
  272. 'old_order_type' => $order_return['order_type'],
  273. 'spuCode' => $spuCode,
  274. 'addtime' => $date,
  275. 'updatetime' => $date,
  276. ]);
  277. } else throw new Exception('未找到对应的商品数据');
  278. }
  279. //新增bn记录,维护旧有bn记录
  280. $child_bns = Db::name('child_bn')
  281. ->field('id,num,origin_price')
  282. ->where(['orderCode' => $order_return['orderCode'], 'outCode' => $order_return['outCode']])
  283. ->order(['num' => 'desc', 'id' => 'asc'])
  284. ->cursor();
  285. $origin_price = $j = 0;
  286. foreach ($child_bns as $child_bn) {
  287. if ($origin_price === 0) $origin_price = $child_bn['origin_price'];
  288. Db::name('child_bn')
  289. ->where(['id' => $child_bn['id']])
  290. ->dec('num', ($child_bn['num'] >= $total) ? $total : $child_bn['num'])
  291. ->update(['updatetime' => $date]);
  292. $total = ($child_bn['num'] >= $total) ? 0 : ($total - $child_bn['num']);
  293. if ($total == 0) break;
  294. }
  295. foreach ($param['list'] as $value) {
  296. if ($value['can_sell_num'] > 0) {
  297. $stockid = Db::name('good_stock')
  298. ->insertGetId([
  299. 'project_code' => '',
  300. 'spuCode' => $spuCode,
  301. 'wsm_code' => $info[$value['id']]['return_wsm_code'],
  302. 'wait_in_stock' => 0,
  303. 'wait_out_stock' => 0,
  304. 'usable_stock' => $value['can_sell_num'],
  305. 'intra_stock' => 0,
  306. 'total_stock' => $value['can_sell_num'],
  307. 'status' => 1,
  308. 'is_del' => 0,
  309. 'warn_stock' => 0,
  310. 'addtime' => $date,
  311. 'updatetime' => $date,
  312. ]);
  313. Db::name('good_stock_info')
  314. ->insert([
  315. 'stockid' => $stockid,
  316. 'bnCode' => substr(makeNo("BN"), 0, -2) . str_pad($j++, 2, '0', STR_PAD_LEFT),
  317. 'total_num' => $value['can_sell_num'],
  318. 'used_num' => 0,
  319. 'balance_num' => $value['can_sell_num'],
  320. 'origin_price' => $origin_price,
  321. 'addtime' => $date,
  322. 'updatetime' => $date,
  323. ]);
  324. }
  325. }
  326. } else {
  327. //库存品,直接维护stock和info
  328. $stockids = Db::name('good_stock')
  329. ->where(['is_del' => 0, 'spuCode' => $order_return['good_code'], 'wsm_code' => array_column($info, 'return_wsm_code')])
  330. ->column('id', 'wsm_code');
  331. foreach ($param['list'] as $value) {
  332. //定义了stockid,维护bn
  333. if (isset($stockids[$info[$value['id']]['return_wsm_code']])) {
  334. $good_stock_info = Db::name('good_stock_info')
  335. ->where(['stockid' => $stockids[$info[$value['id']]['return_wsm_code']]])
  336. ->findOrEmpty();
  337. if (empty($good_stock_info)) {
  338. //从child_bn查询bn号并维护,新建到good_stock_info中
  339. $child_bns = Db::name('child_bn')
  340. ->field('id,num,bnCode,origin_price')
  341. ->where(['orderCode' => $order_return['orderCode'], 'outCode' => $order_return['outCode'], 'childCode' => $info[$value['id']]['outChildCode']])
  342. ->order(['num' => 'desc', 'id' => 'asc'])
  343. ->cursor();
  344. $total = $value['can_sell_num'];
  345. foreach ($child_bns as $child_bn) {
  346. Db::name('child_bn')
  347. ->where(['id' => $child_bn['id']])
  348. ->dec('num', ($child_bn['num'] >= $total) ? $total : $child_bn['num'])
  349. ->update(['updatetime' => $date]);
  350. Db::name('good_stock_info')
  351. ->insert([
  352. 'stockid' => $stockids[$info[$value['id']]['return_wsm_code']],
  353. 'bnCode' => $child_bn['bnCode'],
  354. 'total_num' => ($child_bn['num'] >= $total) ? $total : $child_bn['num'],
  355. 'used_num' => 0,
  356. 'balance_num' => ($child_bn['num'] >= $total) ? $total : $child_bn['num'],
  357. 'origin_price' => $child_bn['origin_price'],
  358. 'addtime' => $date,
  359. 'updatetime' => $date,
  360. ]);
  361. $total = ($child_bn['num'] >= $total) ? 0 : ($total - $child_bn['num']);
  362. if ($total == 0) break;
  363. }
  364. } else {
  365. //维护记录
  366. Db::name('good_stock_info')
  367. ->where(['id' => $good_stock_info['id']])
  368. ->inc('balance_num', $value['can_sell_num'])//可用数量增加
  369. ->dec('used_num', $value['can_sell_num'])//已用数量减少
  370. ->update(['updatetime' => $date]);
  371. }
  372. } else {
  373. //新建good_stock和good_stock_info
  374. $stockid = Db::name('good_stock')
  375. ->insertGetId([
  376. 'project_code' => '',
  377. 'spuCode' => $order_return['good_code'],
  378. 'wsm_code' => $value['return_wsm_code'],
  379. 'wait_in_stock' => 0,
  380. 'wait_out_stock' => 0,
  381. 'usable_stock' => $value['can_sell_num'],
  382. 'intra_stock' => 0,
  383. 'total_stock' => $value['can_sell_num'],
  384. 'status' => 1,
  385. 'is_del' => 0,
  386. 'warn_stock' => 0,
  387. 'addtime' => $date,
  388. 'updatetime' => $date,
  389. ]);
  390. //从child_bn查询bn号并维护,新建到good_stock_info中
  391. $child_bns = Db::name('child_bn')
  392. ->field('id,num,bnCode,origin_price')
  393. ->where(['orderCode' => $order_return['orderCode'], 'outCode' => $order_return['outCode'], 'childCode' => $info[$value['id']]['outChildCode']])
  394. ->order(['num' => 'desc', 'id' => 'asc'])
  395. ->cursor();
  396. $total = $value['can_sell_num'];
  397. foreach ($child_bns as $child_bn) {
  398. Db::name('child_bn')
  399. ->where(['id' => $child_bn['id']])
  400. ->dec('num', ($child_bn['num'] >= $total) ? $total : $child_bn['num'])
  401. ->update(['updatetime' => $date]);
  402. Db::name('good_stock_info')
  403. ->insert([
  404. 'stockid' => $stockid,
  405. 'bnCode' => $child_bn['bnCode'],
  406. 'total_num' => ($child_bn['num'] >= $total) ? $total : $child_bn['num'],
  407. 'used_num' => 0,
  408. 'balance_num' => ($child_bn['num'] >= $total) ? $total : $child_bn['num'],
  409. 'origin_price' => $child_bn['origin_price'],
  410. 'addtime' => $date,
  411. 'updatetime' => $date,
  412. ]);
  413. $total = ($child_bn['num'] >= $total) ? 0 : ($total - $child_bn['num']);
  414. if ($total == 0) break;
  415. }
  416. }
  417. }
  418. //维护商品层面的库存数
  419. Db::name('good')
  420. ->where(['is_del' => 0, 'spuCode' => $order_return['good_code']])
  421. ->inc('usable_stock', array_sum(array_column($info, 'return_num')) - array_sum(array_column($param['list'], 'loss_num')))
  422. ->update(['updatetime' => $date]);
  423. }
  424. }
  425. //售后申请单状态维护
  426. Db::name('order_return')
  427. ->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => 12])
  428. ->update(['status' => 5, 'updatetime' => $date]);
  429. Db::commit();
  430. return json_show(0, '库管收货成功');
  431. } catch (Exception $exception) {
  432. Db::rollback();
  433. return json_show(1004, $exception->getMessage());
  434. }
  435. }
  436. //更新退货工单标记
  437. public function setRecord()
  438. {
  439. $param = $this->request->only(['id', 'record'], 'post', 'trim');
  440. $val = Validate::rule([
  441. 'id|退货工单id' => 'require|number|gt:0',
  442. 'record|标记内容' => 'require',
  443. ]);
  444. if ($val->check($param) == false) return json_show(1004, $val->getError());
  445. $temp = Db::name('order_return_child')
  446. ->field('id')
  447. ->where(['is_del' => 0, 'id' => $param['id']])
  448. ->findOrEmpty();
  449. if (empty($temp)) return json_show(1004, '该退货工单不存在');
  450. $rs = Db::name('order_return_child')
  451. ->where(['is_del' => 0, 'id' => $param['id']])
  452. ->update(['record' => $param['record'], 'updatetime' => date('Y-m-d H:i:s')]);
  453. return $rs ? json_show(0, '更新退货工单标记内容成功') : json_show(1004, '更新退货工单标记内容失败');
  454. }
  455. //详情
  456. public function info()
  457. {
  458. $param = $this->request->only(['id'], 'post', 'trim');
  459. $val = Validate::rule([
  460. 'id|退货工单id' => 'require|number|gt:0',
  461. ]);
  462. if ($val->check($param) == false) return json_show(1004, $val->getError());
  463. $info = Db::name('order_return_child')
  464. ->alias('a')
  465. ->field('a.*,b.supplierName send_supplierName,b.supplierNo send_supplierNo,b.name send_wsm_name,c.supplierName return_supplierName,c.supplierNo return_supplierNo,c.name return_wsm_name,d.companyNo,d.companyName,d.customer_code,d.customer_name')
  466. ->leftJoin('warehouse_info b', 'b.wsm_code=a.send_wsm_code')
  467. ->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code')
  468. ->leftJoin('order_return d','d.returnCode=a.returnCode and d.is_del=0')
  469. ->where(['a.is_del' => 0, 'a.id' => $param['id']])
  470. ->findOrEmpty();
  471. if (empty($info)) return json_show(1004, '该退货工单不存在');
  472. return empty($info) ? json_show(1004, '该退货工单不存在') : json_show(0, '获取退货工单详情成功', $info);
  473. }
  474. }