StoreRefundOrder.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\server;
  12. use app\common\repositories\store\order\StoreRefundOrderRepository;
  13. use crmeb\basic\BaseController;
  14. use think\App;
  15. class StoreRefundOrder extends BaseController
  16. {
  17. protected $merId;
  18. protected $repository;
  19. protected $service_id;
  20. public function __construct(App $app, StoreRefundOrderRepository $repository)
  21. {
  22. parent::__construct($app);
  23. $this->repository = $repository;
  24. $this->merId = $this->request->route('merId');
  25. $this->service_id = $this->request->serviceInfo()->service_id;
  26. }
  27. public function lst()
  28. {
  29. [$page, $limit] = $this->getPage();
  30. $where = $this->request->params(['order_type','delivery_id']);
  31. $where['mer_id'] = $this->merId;
  32. return app('json')->success($this->repository->getListByService($where,$page,$limit));
  33. }
  34. public function detail($id)
  35. {
  36. $data = $this->repository->getWhere([$this->repository->getPk() => $id,'mer_id' => $this->merId],'*',['order','refundProduct.product','user']);
  37. return app('json')->success($data);
  38. }
  39. public function getRefundPrice($id)
  40. {
  41. return app('json')->success($this->repository->serverRefundDetail($id,$this->merId));
  42. }
  43. public function express($id)
  44. {
  45. $data['refund'] = $this->repository->getWhere(['refund_order_id' => $id,'mer_id'=> $this->merId,'status' =>2],'*', ['refundProduct.product']);
  46. if(!$data['refund'])
  47. return app('json')->fail('订单信息或状态错误');
  48. $data['express'] = $this->repository->express($id);
  49. return app('json')->success($data);
  50. }
  51. public function switchStatus($id)
  52. {
  53. if(!$this->repository->getStatusExists($this->merId,$id))
  54. return app('json')->fail('信息或状态错误');
  55. $status = ($this->request->param('status') == 1) ? 1 : -1;
  56. event('refund.status',compact('id','status'));
  57. if($status == 1){
  58. $data = $this->request->params(['mer_delivery_user','mer_delivery_address','phone']);
  59. if ($data['phone'] && isPhone($data['phone']))
  60. return app('json')->fail('请输入正确的手机号');
  61. $data['status'] = $status;
  62. $this->repository->agree($id,$data,$this->service_id);
  63. }else{
  64. $fail_message = $this->request->param('fail_message','');
  65. if($status == -1 && empty($fail_message))
  66. return app('json')->fail('未通过必须填写');
  67. $data['status'] = $status;
  68. $data['fail_message'] = $fail_message;
  69. $this->repository->refuse($id,$data);
  70. }
  71. return app('json')->success('审核成功');
  72. }
  73. public function refundPrice($id)
  74. {
  75. if(!$this->repository->getRefundPriceExists($this->merId,$id))
  76. return app('json')->fail('信息或状态错误');
  77. $this->repository->adminRefund($id,$this->service_id);
  78. return app('json')->success('退款成功');
  79. }
  80. public function mark($id){
  81. if(!$this->repository->getExistsById($this->merId,$id))
  82. return app('json')->fail('数据不存在');
  83. $this->repository->update($id,['mer_mark' => $this->request->param('mer_mark','')]);
  84. return app('json')->success('备注成功');
  85. }
  86. }