RefundOrder.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author Qinii
  6. * @day 2020-06-12
  7. *
  8. *
  9. */
  10. namespace app\controller\merchant\store\order;
  11. use app\common\repositories\store\order\MerchantReconciliationRepository;
  12. use app\common\repositories\store\order\StoreRefundStatusRepository;
  13. use app\services\ThirdParty\AlibabaAgent\OrderService;
  14. use think\App;
  15. use crmeb\basic\BaseController;
  16. use app\common\repositories\store\order\StoreRefundOrderRepository as repository;
  17. use think\facade\Db;
  18. class RefundOrder extends BaseController
  19. {
  20. /**
  21. * @var repository
  22. */
  23. protected $repository;
  24. /**
  25. * Order constructor.
  26. * @param App $app
  27. * @param repository $repository
  28. */
  29. public function __construct(App $app, repository $repository)
  30. {
  31. parent::__construct($app);
  32. $this->repository = $repository;
  33. }
  34. /**
  35. * @return mixed
  36. * @author Qinii
  37. * @day 2020-06-12
  38. */
  39. public function lst()
  40. {
  41. list($page,$limit) = $this->getPage();
  42. $where = $this->request->params(['refund_order_sn','refund_type','date','order_sn']);
  43. $status = $this->request->param('status');
  44. $where['mer_id'] = $this->request->merId();
  45. return app('json')->success($this->repository->getList($where,$page,$limit,$status));
  46. }
  47. /**
  48. * @param $id
  49. * @return mixed
  50. * @author Qinii
  51. * @day 2020-06-12
  52. */
  53. public function detail($id)
  54. {
  55. if(!$this->repository->getExistsById($this->request->merId(),$id))
  56. return app('json')->fail('数据不存在');
  57. $data=$this->repository->getOne($id);
  58. return app('json')->success($data);
  59. }
  60. /**
  61. * @param $id
  62. * @return mixed
  63. * @author Qinii
  64. * @day 2020-06-12
  65. */
  66. public function switchStatus($id)
  67. {
  68. if(!$this->repository->getStatusExists($this->request->merId(),$id))
  69. return app('json')->fail('信息或状态错误');
  70. $status=-1;
  71. if($this->request->param('status') == 1){
  72. $status=1;
  73. }else if($this->request->param('status') == 2){
  74. $status=2;
  75. }
  76. // $status = ($this->request->param('status') == 1) ? 1 : -1;
  77. if($status == 1 || $status == 2){
  78. $refund_order=$this->repository->get($id);
  79. if($status==2){
  80. $part_refund_message = $this->request->param('part_refund_message','');
  81. $refund_price =(float) $this->request->param('part_refund_price',0);
  82. if($refund_price<0.01){
  83. return app('json')->fail('退款金额不能小于0.01');
  84. }
  85. $pay_price=Db::name('store_order')->where('order_id',$refund_order['order_id'])->value('pay_price');
  86. if($refund_order && $refund_price > $pay_price){
  87. return app('json')->fail('退款金额不能大于用户支付金额');
  88. }
  89. if($part_refund_message==''){
  90. return app('json')->fail('请填写商家备注');
  91. }
  92. $this->repository->update($id,['refund_type'=>1,'refund_price'=>$refund_price,'part_refund_price'=>$refund_price,'part_refund_message' => $part_refund_message,'part_refund_time'=>date('Y-m-d H:i:s')]);
  93. }
  94. $douduo = $this -> repository -> douduofund($id,true);
  95. if($douduo['code'] < 0){
  96. return app('json')->fail($douduo['message']);
  97. }
  98. if($douduo['code'] == 2){
  99. return app('json')->success($douduo['message']);
  100. }
  101. // $data = $this->request->params(['mer_delivery_user','mer_delivery_address','phone']);
  102. $data['mer_delivery_user']=$this->request->param('mer_refund_user','');
  103. $data['mer_delivery_address']=$this->request->param('mer_refund_address','');
  104. $data['phone']=$this->request->param('set_phone','');
  105. if($refund_order['refund_type']==2 && $status == 1 && ($data['mer_delivery_user']=='' || $data['mer_delivery_address']=='' || $data['phone']=='')){
  106. return app('json')->fail('请输入收货人信息');
  107. }
  108. $data['status'] = $status;
  109. $this->repository->agree($id,$data,$this->request->adminId(),1);
  110. // 获取订单金额
  111. $store_order_info = Db::name('store_order')
  112. ->where('order_id', $refund_order['order_id'])
  113. ->find();
  114. $group_order_map = Db::name('store_group_order')
  115. ->where('group_order_id', $store_order_info['group_order_id'])
  116. ->field('uid,pay_price,hf_pay_id,fzone_paytype')
  117. ->find();
  118. $make = '商贸区';
  119. if ($store_order_info['mer_id'] == 439) {
  120. $make = '精彩生活区';
  121. } else if ($store_order_info['mer_id'] == 496) {
  122. $make = '会员专区';
  123. } else if ($store_order_info['mer_id'] == 491) {
  124. $make = '复购区';
  125. }
  126. // 如果是组合支付 现金 + 积分 则需要把积分退回
  127. // 参考 app\controller\api\Notify.php -- 745 $array_fzone_paytype['type']=='b2'
  128. $array_fzone_paytype = json_decode($group_order_map['fzone_paytype'], true);
  129. if (!empty($array_fzone_paytype)) {
  130. if ($array_fzone_paytype['type'] == 'b1') {
  131. // VR+积分 {"checked":true,"note":"VR+积分","other":210.0,"price":970.0,"total":0.0,"type":"b1","vr":"47557.5"}
  132. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
  133. $vrpri += $array_fzone_paytype['price'];
  134. Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
  135. Db::name("user_sign_vr")->insert([
  136. 'uid' => $store_order_info['uid'],
  137. 'number' => $array_fzone_paytype['price'],
  138. 'mark' => "{$make}商品申请退款退回VR",
  139. 'desc' => "VR",
  140. 'order_type' => 0,
  141. 'order_id' => $store_order_info['order_id'],
  142. 'surplus' => $vrpri,
  143. 'type' => 1,
  144. 'addtime' => time()
  145. ]);
  146. // {"checked":true,"note":"VR+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
  147. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('score');
  148. $vrpri += $array_fzone_paytype['other'];
  149. Db::name("user")->where("uid", $group_order_map['uid'])->update(['score' => $vrpri]);
  150. $data = [
  151. "uid" => $store_order_info['uid'],
  152. "reward_socre" => $array_fzone_paytype['other'],
  153. "addtime" => time(),
  154. "status" => 1,
  155. "order_id" => $store_order_info['order_id'],
  156. "mark" => "{$make}商品申请退款退回积分",
  157. "surplus" => $vrpri,
  158. "pm" => 1,
  159. "source_type" => 3
  160. ];
  161. Db::name("user_sign_score")->insert($data);//添加积分记录
  162. } else if ($array_fzone_paytype['type'] == 'b2') {
  163. // {"checked":true,"note":"现金+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
  164. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('score');
  165. $vrpri += $array_fzone_paytype['other'];
  166. Db::name("user")->where("uid", $group_order_map['uid'])->update(['score' => $vrpri]);
  167. $data = [
  168. "uid" => $store_order_info['uid'],
  169. "reward_socre" => $array_fzone_paytype['other'],
  170. "addtime" => time(),
  171. "status" => 1,
  172. "order_id" => $store_order_info['order_id'],
  173. "mark" => "{$make}商品申请退款退回积分",
  174. "surplus" => $vrpri,
  175. "pm" => 1,
  176. "source_type" => 3
  177. ];
  178. Db::name("user_sign_score")->insert($data);//添加积分记录
  179. } else if ($array_fzone_paytype['type'] == 'b3') {
  180. // VR+积分 {"checked":true,"note":"VR+积分","other":210.0,"price":970.0,"total":0.0,"type":"b1","vr":"47557.5"}
  181. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
  182. $vrpri += $array_fzone_paytype['price'];
  183. Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
  184. Db::name("user_sign_vr")->insert([
  185. 'uid' => $store_order_info['uid'],
  186. 'number' => $array_fzone_paytype['price'],
  187. 'mark' => "{$make}商品申请退款退回VR",
  188. 'desc' => "VR",
  189. 'order_type' => 0,
  190. 'order_id' => $store_order_info['order_id'],
  191. 'surplus' => $vrpri,
  192. 'type' => 1,
  193. 'addtime' => time()
  194. ]);
  195. // {"checked":true,"note":"VR+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
  196. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('jingdou');
  197. $vrpri += $array_fzone_paytype['other'];
  198. Db::name("user")->where("uid", $group_order_map['uid'])->update(['jingdou' => $vrpri]);
  199. Db::name('user_sign_jingdou')->insert([
  200. 'uid' => $store_order_info['uid'],
  201. 'number' => $array_fzone_paytype['other'],
  202. 'status' => 1,
  203. 'mark' => "{$make}商品申请退款退回京豆",
  204. 'addtime' => time(),
  205. 'surplus' => $vrpri,
  206. 'settlement_time' => date('Y-m-d H:i:s'),
  207. 'type' => 1,
  208. 'order_type' => 0,
  209. 'order_id' => $store_order_info['order_id']
  210. ]);
  211. } else if ($array_fzone_paytype['type'] == 'b4') {
  212. // {"checked":true,"note":"现金+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
  213. $jingdoupri = Db::name("user")->where("uid", $group_order_map['uid'])->value('jingdou');
  214. $jingdoupri += $array_fzone_paytype['other'];
  215. Db::name("user")->where("uid", $group_order_map['uid'])->update(['jingdou' => $jingdoupri]);
  216. Db::name('user_sign_jingdou')->insert([
  217. 'uid' => $store_order_info['uid'],
  218. 'number' => $array_fzone_paytype['other'],
  219. 'status' => 1,
  220. 'mark' => "{$make}商品申请退款退回京豆",
  221. 'addtime' => time(),
  222. 'surplus' => $jingdoupri,
  223. 'settlement_time' => date('Y-m-d H:i:s'),
  224. 'type' => 1,
  225. 'order_type' => 0,
  226. 'order_id' => $store_order_info['order_id']
  227. ]);
  228. } else if ($array_fzone_paytype['type'] == 'b5') {
  229. // {"checked":true,"note":"VR","other":0.0,"price":1.0,"total":0.0,"type":"b5","vr":"10"}
  230. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
  231. $vrpri += $array_fzone_paytype['price'];
  232. Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
  233. Db::name("user_sign_vr")->insert([
  234. 'uid' => $store_order_info['uid'],
  235. 'number' => $array_fzone_paytype['price'],
  236. 'mark' => "{$make}商品申请退款退回VR",
  237. 'desc' => "VR",
  238. 'order_type' => 0,
  239. 'order_id' => $store_order_info['order_id'],
  240. 'surplus' => $vrpri,
  241. 'type' => 1,
  242. 'addtime' => time()
  243. ]);
  244. } else if ($array_fzone_paytype['type'] == 'a3') {
  245. // {"checked":true,"note":"现金+VR","other":1.5,"price":8.5,"total":0.0,"type":"a3","vr":"48799.82"}
  246. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
  247. $vrpri += $array_fzone_paytype['other'];
  248. Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
  249. //VR入账
  250. $insertdata = [
  251. 'uid'=> $store_order_info['uid'],
  252. 'number' => $array_fzone_paytype['other'],
  253. 'surplus' => $vrpri,
  254. 'mark' => "{$make}商品申请退款退回VR",
  255. 'order_id'=> $store_order_info['order_id'],
  256. 'type' => 2,
  257. 'addtime' => time(),
  258. 'settlement_time'=> date('Y-m-d H:i:s', time())
  259. ];
  260. Db::name('user_sign_vr')->insert($insertdata);
  261. } else if ($array_fzone_paytype['type'] == 'c1') {
  262. // {"checked":true,"note":"复购金","other":1.5,"price":8.5,"total":0.0,"type":"c1","vr":"48799.82"}
  263. $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('fugou');
  264. $vrpri += $array_fzone_paytype['price'];
  265. Db::name("user")->where("uid", $group_order_map['uid'])->update(['fugou' => $vrpri]);
  266. //支出账号存到log日志
  267. $log_data = [
  268. 'uid' => $store_order_info['uid'],
  269. 'number' => $array_fzone_paytype['price'],
  270. 'mark' => "复购区商品申请退款退回复购金:" . $array_fzone_paytype['price'],
  271. 'desc' => "复购金",
  272. 'order_id' => $store_order_info['order_id'],
  273. 'surplus' => $vrpri,
  274. 'order_type' => 0,
  275. 'type' => 1,
  276. 'addtime' => time()
  277. ];
  278. Db::name("user_sign_fugou")->insert($log_data);
  279. }
  280. }
  281. // 取消 订单所发放的福利
  282. $this->repository->cancelOrderBonus($id);
  283. }else{
  284. $fail_message = $this->request->param('fail_message','');
  285. if($status == -1 && empty($fail_message)){
  286. return app('json')->fail('未通过必须填写');
  287. }
  288. if($fail_message==''){
  289. return app('json')->fail('未通过必须填写');
  290. }
  291. $data['status'] = $status;
  292. $data['fail_message'] = $fail_message;
  293. $this->repository->refuse($id,$data);
  294. $this->repository->set_consult(2,$id);//协商记录
  295. }
  296. return app('json')->success('审核成功');
  297. }
  298. public function switchStatusjhm($id)
  299. {
  300. $this->repository->agreejhm($id);
  301. return app('json')->success('审核成功');
  302. }
  303. public function switchStatusnf($id)
  304. {
  305. $res = $this->repository->agreenf($id);
  306. return app('json')->success($res);
  307. }
  308. public function switchStatusqds($id)
  309. {
  310. $res = $this->repository->agreeqds($id);
  311. return app('json')->success($res);
  312. }
  313. /**
  314. * TODO 收货后确定退款
  315. * @param $id
  316. * @return mixed
  317. * @author Qinii
  318. * @day 2020-06-12
  319. */
  320. public function refundPrice($id)
  321. {
  322. if(!$this->repository->getRefundPriceExists($this->request->merId(),$id))
  323. return app('json')->fail('信息或状态错误');
  324. if($this->request->param('status') == 2){
  325. $part_refund_message = $this->request->param('part_refund_message','');
  326. $refund_price =(float) $this->request->param('part_refund_price',0);
  327. if($refund_price<0.01){
  328. return app('json')->fail('退款金额不能小于0.01');
  329. }
  330. $refund_order=$this->repository->get($id);
  331. $pay_price=Db::name('store_order')->where('order_id',$refund_order['order_id'])->value('pay_price');
  332. if($refund_price > $pay_price){
  333. return app('json')->fail('退款金额不能大于用户支付金额');
  334. }
  335. if($part_refund_message==''){
  336. return app('json')->fail('请填写商家备注');
  337. }
  338. $this->repository->update($id,['refund_price'=>$refund_price,'part_refund_price'=>$refund_price,'part_refund_message' => $part_refund_message,'part_refund_time'=>date('Y-m-d H:i:s')]);
  339. }else if($this->request->param('status') == -1){
  340. $fail_message = $this->request->param('fail_message','');
  341. if(empty($fail_message))
  342. return app('json')->fail('请输入拒绝原因');
  343. $data['status'] = -1;
  344. $data['fail_message'] = $fail_message;
  345. $this->repository->refuse($id,$data);
  346. $this->repository->set_consult(7,$id);//协商记录
  347. return app('json')->success('拒绝成功');
  348. }
  349. $this->repository->set_consult(5,$id);//协商记录
  350. $this->repository->adminRefund($id,$this->request->adminId());
  351. return app('json')->success('退款成功');
  352. }
  353. /**
  354. * TODO
  355. * @param $id
  356. * @return mixed
  357. * @author Qinii
  358. * @day 2020-06-12
  359. */
  360. public function switchStatusForm($id)
  361. {
  362. if(!$this->repository->getStatusExists($this->request->merId(),$id))
  363. return app('json')->fail('信息或状态错误');
  364. // $douduo = $this -> repository -> douduofund($id,false);
  365. // if($douduo['code'] < 0){
  366. // return app('json')->fail($douduo['message']);
  367. // }
  368. // if($douduo['code'] == 2){
  369. // return app('json')->success($douduo['message']);
  370. // }
  371. return app('json')->success(formToData($this->repository->statusForm($id)));
  372. }
  373. /**
  374. * TODO
  375. * @param $id
  376. * @return mixed
  377. * @author Qinii
  378. * @day 2020-06-18
  379. */
  380. public function delete($id)
  381. {
  382. if(!$this->repository->getUserDelExists($this->request->merId(),$id))
  383. return app('json')->fail('信息或状态错误');
  384. $this->repository->update($id,['is_system_del' => 1]);
  385. return app('json')->success('删除成功');
  386. }
  387. /**
  388. * TODO
  389. * @param $id
  390. * @return mixed
  391. * @author Qinii
  392. * @day 2020-06-18
  393. */
  394. public function markForm($id)
  395. {
  396. if(!$this->repository->getExistsById($this->request->merId(),$id))
  397. return app('json')->fail('数据不存在');
  398. return app('json')->success(formToData($this->repository->markForm($id)));
  399. }
  400. /**
  401. * TODO
  402. * @param $id
  403. * @return mixed
  404. * @author Qinii
  405. * @day 2020-06-18
  406. */
  407. public function mark($id)
  408. {
  409. if(!$this->repository->getExistsById($this->request->merId(),$id))
  410. return app('json')->fail('数据不存在');
  411. $this->repository->update($id,['mer_mark' => $this->request->param('mer_mark','')]);
  412. return app('json')->success('备注成功');
  413. }
  414. public function log($id)
  415. {
  416. list($page,$limit) = $this->getPage();
  417. $make = app()->make(StoreRefundStatusRepository::class);
  418. return app('json')->success($make->search($id,$page,$limit));
  419. }
  420. public function reList($id)
  421. {
  422. [$page,$limit] = $this->getPage();
  423. $make = app()->make(MerchantReconciliationRepository::class);
  424. if(!$make->getWhereCount(['mer_id' => $this->request->merId(),'reconciliation_id' => $id]))
  425. return app('json')->fail('数据不存在');
  426. $where = ['reconciliation_id' => $id,'type' => 1];
  427. return app('json')->success($this->repository->reconList($where,$page,$limit));
  428. }
  429. /**
  430. * TODO 快递查询
  431. * @param $id
  432. * @return mixed
  433. * @author Qinii
  434. * @day 2020-06-25
  435. */
  436. public function express($id)
  437. {
  438. // if(!$this->repository->getWhereCount(['refund_order_id' => $id,'status' =>2]))
  439. // return app('json')->fail('订单信息或状态错误');
  440. return app('json')->success($this->repository->express($id));
  441. }
  442. public function refundReasonList()
  443. {
  444. $orderId = request()->param('alibaba_order_id');
  445. if (empty($orderId)) {
  446. return app('json')->fail('订单号不能为空');
  447. }
  448. $orderService = new OrderService();
  449. $params = ['orderId' => $orderId];
  450. $result = $orderService->getRefundReasonList($params);
  451. if ($result === false) {
  452. return app('json')->fail('获取退款原因失败');
  453. }
  454. return app('json')->success($result);
  455. }
  456. public function submitAli()
  457. {
  458. $data = $this->request->params([
  459. 'orderId',
  460. 'orderEntryIds',
  461. 'disputeRequest',
  462. 'description',
  463. 'applyPayment',
  464. 'applyCarriage',
  465. 'applyReasonId',
  466. 'goodsStatus',
  467. 'refund_order_id',
  468. ]);
  469. // 参数校验(所有参数均为必填)
  470. $requiredFields = ['orderId', 'orderEntryIds', 'disputeRequest', 'description', 'applyPayment', 'applyCarriage', 'applyReasonId', 'goodsStatus'];
  471. foreach ($requiredFields as $field) {
  472. if (!isset($data[$field])) {
  473. return app('json')->fail('缺少必填参数: ' . $field);
  474. }
  475. }
  476. $orderService = new OrderService();
  477. // 构建1688接口参数(前端 disputeRequest 映射为 1688 接口的 disputeReasonId)
  478. $params = [
  479. 'orderId' => (string)$data['orderId'],
  480. 'orderEntryIds' => $data['orderEntryIds'],
  481. 'disputeReasonId' => (string)$data['disputeRequest'],
  482. 'description' => (string)$data['description'],
  483. 'applyPayment' => (string)$data['applyPayment'] * 100,
  484. 'applyCarriage' => (string)$data['applyCarriage'] * 100,
  485. 'applyReasonId' => (string)$data['applyReasonId'],
  486. 'goodsStatus' => (string)$data['goodsStatus'],
  487. ];
  488. // 调用1688 API提交售后申请
  489. $result = $orderService->createRefund($params);
  490. // 记录到 store_refund_alibaba 表(不管成功与否都保存原始数据)
  491. $insertData = [
  492. 'refund_order_id' => (int)($data['refund_order_id'] ?? 0),
  493. 'alibaba_order_id' => (string)$data['orderId'],
  494. 'order_entry_ids' => $data['orderEntryIds'],
  495. 'dispute_reason_id' => (string)$data['disputeRequest'],
  496. 'description' => (string)$data['description'],
  497. 'goods_status' => (string)$data['goodsStatus'],
  498. 'apply_payment' => (string)$data['applyPayment'],
  499. 'apply_carriage' => (string)$data['applyCarriage'],
  500. 'result_data' => json_encode($result['rawData'] ?? [], JSON_UNESCAPED_UNICODE),
  501. ];
  502. if ($result['success']) {
  503. // 提交成功
  504. $insertData['status'] = 1;
  505. $insertData['alibaba_refund_id'] = $result['refundId'] ?? '';
  506. $insertData['alibaba_status'] = $result['status'] ?? '';
  507. Db::name('store_refund_alibaba')->insert($insertData);
  508. // 更新退款单的 after_sn 字段为1688售后单ID
  509. if (!empty($data['refund_order_id']) && !empty($result['refundId'])) {
  510. Db::name('store_refund_order')
  511. ->where('refund_order_id', (int)$data['refund_order_id'])
  512. ->update(['after_sn' => $result['refundId']]);
  513. }
  514. return app('json')->success([
  515. 'alibaba_refund_id' => $result['refundId'] ?? '',
  516. 'alibaba_status' => $result['status'] ?? '',
  517. ], '提交1688售后申请成功');
  518. } else {
  519. // 提交失败
  520. $insertData['status'] = 2;
  521. $insertData['fail_message'] = $result['status'] ?? '1688接口调用失败';
  522. Db::name('store_refund_alibaba')->insert($insertData);
  523. return app('json')->fail($result['status'] ?? '提交1688售后申请失败');
  524. }
  525. }
  526. }