RefundOrder.php 25 KB

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