RefundOrder.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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\admin\order;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\store\order\StoreOrderStatusRepository;
  14. use app\common\repositories\store\order\StoreRefundOrderRepository as repository;
  15. use crmeb\services\ExcelService;
  16. use think\App;
  17. /**
  18. * 退款
  19. */
  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. /**
  29. * 列表
  30. * @param $id
  31. * @return \think\response\Json
  32. * @author Qinii
  33. */
  34. public function lst($id)
  35. {
  36. [$page, $limit] = $this->getPage();
  37. $where = $this->request->params(['date','nickname','uid','phone','real_name']);
  38. $where['mer_id'] = $id;
  39. $where['status'] = 3;
  40. return app('json')->success($this->repository->getAdminList($where, $page, $limit));
  41. }
  42. public function detail($id)
  43. {
  44. return app('json')->success($this->repository->getOne($id));
  45. }
  46. public function log($id)
  47. {
  48. list($page, $limit) = $this->getPage();
  49. $where = $this->request->params(['date', 'user_type']);
  50. $where['id'] = $id;
  51. $where['type'] = StoreOrderStatusRepository::TYPE_REFUND;
  52. $data = app()->make(StoreOrderStatusRepository::class)->search($where, $page, $limit);
  53. return app('json')->success($data);
  54. }
  55. /**
  56. * 备注
  57. * @param $id
  58. * @return \think\response\Json
  59. * @author Qinii
  60. */
  61. public function markForm($id)
  62. {
  63. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  64. return app('json')->fail('数据不存在');
  65. return app('json')->success(formToData($this->repository->adminMarkForm($id)));
  66. }
  67. /**
  68. * 备注
  69. * @param $id
  70. * @return \think\response\Json
  71. * @author Qinii
  72. */
  73. public function mark($id)
  74. {
  75. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  76. return app('json')->fail('数据不存在');
  77. $data = $this->request->params(['admin_mark']);
  78. $this->repository->update($id, $data);
  79. return app('json')->success('备注成功');
  80. }
  81. /**
  82. * 列表
  83. * @return \think\response\Json
  84. * @author Qinii
  85. */
  86. public function getAllList()
  87. {
  88. [$page, $limit] = $this->getPage();
  89. $where = $this->request->params(['refund_order_sn', 'status', 'refund_type', 'date', 'mer_id', 'order_sn', 'is_trader','uid','phone','real_name','nickname']);
  90. return app('json')->success($this->repository->getAllList($where, $page, $limit));
  91. }
  92. /**
  93. * 根据和解单ID获取和解记录列表
  94. *
  95. * 本函数用于根据提供的和解单ID,检索和解记录列表。它首先确定分页信息,然后构建查询条件,
  96. * 最后调用仓库层的方法获取和解记录,并以JSON格式返回结果。
  97. *
  98. * @param int $id 和解单的唯一标识符
  99. * @return \Illuminate\Http\JsonResponse 返回包含和解记录列表的JSON响应
  100. */
  101. public function reList($id)
  102. {
  103. // 获取当前请求的分页信息
  104. [$page, $limit] = $this->getPage();
  105. // 定义查询条件,筛选和解单ID和类型为1的记录
  106. $where = ['reconciliation_id' => $id, 'type' => 1];
  107. // 调用仓库层的reconList方法获取和解记录,并返回成功的JSON响应
  108. return app('json')->success($this->repository->reconList($where, $page, $limit));
  109. }
  110. /**
  111. * 导出
  112. * @return \think\response\Json
  113. * @author Qinii
  114. */
  115. public function excel()
  116. {
  117. $where = $this->request->params(['refund_order_sn', 'status', 'refund_type', 'date', 'order_sn', 'id', 'mer_id']);
  118. [$page, $limit] = $this->getPage();
  119. $data = app()->make(ExcelService::class)->refundOrder($where, $page, $limit);
  120. return app('json')->success($data);
  121. }
  122. /**
  123. * 平台审核退款单
  124. * @param $id
  125. * @return \think\response\Json
  126. * @throws \think\db\exception\DataNotFoundException
  127. * @throws \think\db\exception\DbException
  128. * @throws \think\db\exception\ModelNotFoundException
  129. */
  130. public function approve($id)
  131. {
  132. $data = $this->request->params(['status','platform_mark']);
  133. $this->repository->approve($id,$data);
  134. return app('json')->success('操作成功');
  135. }
  136. }