OrderProfitsharing.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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\admin\order;
  12. use app\common\repositories\store\ExcelRepository;
  13. use app\common\repositories\store\order\StoreOrderProfitsharingRepository;
  14. use crmeb\basic\BaseController;
  15. use crmeb\services\ExcelService;
  16. use think\App;
  17. class OrderProfitsharing extends BaseController
  18. {
  19. protected $repository;
  20. public function __construct(App $app, StoreOrderProfitsharingRepository $repository)
  21. {
  22. parent::__construct($app);
  23. $this->repository = $repository;
  24. }
  25. public function getList()
  26. {
  27. $where = $this->request->params(['type', 'status', 'mer_id', 'keyword', 'profit_date', 'date']);
  28. $merId = $this->request->merId();
  29. if ($merId) {
  30. $where['mer_id'] = $merId;
  31. }
  32. [$page, $limit] = $this->getPage();
  33. return app('json')->success($this->repository->getList($where, $page, $limit, (bool)$merId));
  34. }
  35. public function again($id)
  36. {
  37. if (!$model = $this->repository->get((int)$id)) {
  38. return app('json')->fail('分账单不存在');
  39. }
  40. if ($model->status != -2) {
  41. return app('json')->fail('分账单状态操作,不能分账');
  42. }
  43. if ($this->repository->profitsharing($model)) {
  44. return app('json')->success('分账成功');
  45. }
  46. return app('json')->fail('分账失败');
  47. }
  48. public function export()
  49. {
  50. $where = $this->request->params(['type', 'status', 'mer_id', 'keyword', 'profit_date', 'date']);
  51. $merId = $this->request->merId();
  52. if ($merId) {
  53. $where['mer_id'] = $merId;
  54. }
  55. [$page, $limit] = $this->getPage();
  56. $data = app()->make(ExcelService::class)->profitsharing($where,$page,$limit);
  57. return app('json')->success($data);
  58. }
  59. }