OrderProfitsharing.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 app\common\repositories\store\order\StoreOrderProfitsharingRepository;
  13. use crmeb\basic\BaseController;
  14. use crmeb\services\ExcelService;
  15. use think\App;
  16. /**
  17. * 分账
  18. */
  19. class OrderProfitsharing extends BaseController
  20. {
  21. protected $repository;
  22. public function __construct(App $app, StoreOrderProfitsharingRepository $repository)
  23. {
  24. parent::__construct($app);
  25. $this->repository = $repository;
  26. }
  27. /**
  28. * 分账列表
  29. * @return \think\response\Json
  30. * @author Qinii
  31. */
  32. public function getList()
  33. {
  34. $where = $this->request->params(['type', 'status', 'mer_id', 'keyword', 'profit_date', 'date']);
  35. $merId = $this->request->merId();
  36. if ($merId) {
  37. $where['mer_id'] = $merId;
  38. }
  39. [$page, $limit] = $this->getPage();
  40. return app('json')->success($this->repository->getList($where, $page, $limit, (bool)$merId));
  41. }
  42. /**
  43. * 重新发起分账
  44. * @param $id
  45. * @return \think\response\Json
  46. * @author Qinii
  47. */
  48. public function again($id)
  49. {
  50. if (!$model = $this->repository->get((int)$id)) {
  51. return app('json')->fail('分账单不存在');
  52. }
  53. if ($model->status != -2) {
  54. return app('json')->fail('分账单状态操作,不能分账');
  55. }
  56. if ($this->repository->profitsharing($model)) {
  57. return app('json')->success('分账成功');
  58. }
  59. return app('json')->fail('分账失败');
  60. }
  61. /**
  62. * 导出
  63. * @return \think\response\Json
  64. * @author Qinii
  65. */
  66. public function export()
  67. {
  68. $where = $this->request->params(['type', 'status', 'mer_id', 'keyword', 'profit_date', 'date']);
  69. $merId = $this->request->merId();
  70. if ($merId) {
  71. $where['mer_id'] = $merId;
  72. }
  73. [$page, $limit] = $this->getPage();
  74. $data = app()->make(ExcelService::class)->profitsharing($where, $page, $limit);
  75. return app('json')->success($data);
  76. }
  77. }