RefundOrder.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\merchant\store\order;
  12. use app\common\repositories\store\order\MerchantReconciliationRepository;
  13. use app\common\repositories\store\order\StoreRefundStatusRepository;
  14. use think\App;
  15. use crmeb\basic\BaseController;
  16. use app\common\repositories\store\order\StoreRefundOrderRepository as repository;
  17. class RefundOrder extends BaseController
  18. {
  19. /**
  20. * @var repository
  21. */
  22. protected $repository;
  23. /**
  24. * Order constructor.
  25. * @param App $app
  26. * @param repository $repository
  27. */
  28. public function __construct(App $app, repository $repository)
  29. {
  30. parent::__construct($app);
  31. $this->repository = $repository;
  32. }
  33. /**
  34. * @return mixed
  35. * @author Qinii
  36. * @day 2020-06-12
  37. */
  38. public function lst()
  39. {
  40. list($page,$limit) = $this->getPage();
  41. $where = $this->request->params(['refund_order_sn','status','refund_type','date','order_sn','id']);
  42. $where['mer_id'] = $this->request->merId();
  43. return app('json')->success($this->repository->getList($where,$page,$limit));
  44. }
  45. /**
  46. * @param $id
  47. * @return mixed
  48. * @author Qinii
  49. * @day 2020-06-12
  50. */
  51. public function detail($id)
  52. {
  53. if(!$this->repository->getExistsById($this->request->merId(),$id))
  54. return app('json')->fail('数据不存在');
  55. return app('json')->success($this->repository->getOne($id));
  56. }
  57. /**
  58. * @param $id
  59. * @return mixed
  60. * @author Qinii
  61. * @day 2020-06-12
  62. */
  63. public function switchStatus($id)
  64. {
  65. if(!$this->repository->getStatusExists($this->request->merId(),$id))
  66. return app('json')->fail('信息或状态错误');
  67. $status = ($this->request->param('status') == 1) ? 1 : -1;
  68. if($status == 1){
  69. $data = $this->request->params(['mer_delivery_user','mer_delivery_address','phone']);
  70. $data['status'] = $status;
  71. $this->repository->agree($id,$data,$this->request->adminId());
  72. }else{
  73. $fail_message = $this->request->param('fail_message','');
  74. if($status == -1 && empty($fail_message))
  75. return app('json')->fail('未通过必须填写');
  76. $data['status'] = $status;
  77. $data['fail_message'] = $fail_message;
  78. $this->repository->refuse($id,$data);
  79. }
  80. return app('json')->success('审核成功');
  81. }
  82. /**
  83. * TODO 收货后确定退款
  84. * @param $id
  85. * @return mixed
  86. * @author Qinii
  87. * @day 2020-06-12
  88. */
  89. public function refundPrice($id)
  90. {
  91. if(!$this->repository->getRefundPriceExists($this->request->merId(),$id))
  92. return app('json')->fail('信息或状态错误');
  93. $this->repository->adminRefund($id,$this->request->adminId());
  94. return app('json')->success('退款成功');
  95. }
  96. /**
  97. * TODO
  98. * @param $id
  99. * @return mixed
  100. * @author Qinii
  101. * @day 2020-06-12
  102. */
  103. public function switchStatusForm($id)
  104. {
  105. if(!$this->repository->getStatusExists($this->request->merId(),$id))
  106. return app('json')->fail('信息或状态错误');
  107. return app('json')->success(formToData($this->repository->statusForm($id)));
  108. }
  109. /**
  110. * TODO
  111. * @param $id
  112. * @return mixed
  113. * @author Qinii
  114. * @day 2020-06-18
  115. */
  116. public function delete($id)
  117. {
  118. if(!$this->repository->getUserDelExists($this->request->merId(),$id))
  119. return app('json')->fail('信息或状态错误');
  120. $this->repository->update($id,['is_system_del' => 1]);
  121. return app('json')->success('删除成功');
  122. }
  123. /**
  124. * TODO
  125. * @param $id
  126. * @return mixed
  127. * @author Qinii
  128. * @day 2020-06-18
  129. */
  130. public function markForm($id)
  131. {
  132. if(!$this->repository->getExistsById($this->request->merId(),$id))
  133. return app('json')->fail('数据不存在');
  134. return app('json')->success(formToData($this->repository->markForm($id)));
  135. }
  136. /**
  137. * TODO
  138. * @param $id
  139. * @return mixed
  140. * @author Qinii
  141. * @day 2020-06-18
  142. */
  143. public function mark($id)
  144. {
  145. if(!$this->repository->getExistsById($this->request->merId(),$id))
  146. return app('json')->fail('数据不存在');
  147. $this->repository->update($id,['mer_mark' => $this->request->param('mer_mark','')]);
  148. return app('json')->success('备注成功');
  149. }
  150. public function log($id)
  151. {
  152. list($page,$limit) = $this->getPage();
  153. $make = app()->make(StoreRefundStatusRepository::class);
  154. return app('json')->success($make->search($id,$page,$limit));
  155. }
  156. public function reList($id)
  157. {
  158. [$page,$limit] = $this->getPage();
  159. $make = app()->make(MerchantReconciliationRepository::class);
  160. if(!$make->getWhereCount(['mer_id' => $this->request->merId(),'reconciliation_id' => $id]))
  161. return app('json')->fail('数据不存在');
  162. $where = ['reconciliation_id' => $id,'type' => 1];
  163. return app('json')->success($this->repository->reconList($where,$page,$limit));
  164. }
  165. /**
  166. * TODO 快递查询
  167. * @param $id
  168. * @return mixed
  169. * @author Qinii
  170. * @day 2020-06-25
  171. */
  172. public function express($id)
  173. {
  174. if(!$this->repository->getWhereCount(['refund_order_id' => $id,'status' =>2]))
  175. return app('json')->fail('订单信息或状态错误');
  176. return app('json')->success($this->repository->express($id));
  177. }
  178. }