AfterChild.php 28 KB

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