OrderProfitsharing.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\controller\admin\order;
  3. use app\common\repositories\store\order\StoreOrderProfitsharingRepository;
  4. use ln\basic\BaseController;
  5. use think\App;
  6. class OrderProfitsharing extends BaseController
  7. {
  8. protected $repository;
  9. public function __construct(App $app, StoreOrderProfitsharingRepository $repository)
  10. {
  11. parent::__construct($app);
  12. $this->repository = $repository;
  13. }
  14. public function getList()
  15. {
  16. $where = $this->request->params(['type', 'status', 'mer_id', 'keyword', 'profit_date', 'date']);
  17. $merId = $this->request->merId();
  18. if ($merId) {
  19. $where['mer_id'] = $merId;
  20. }
  21. [$page, $limit] = $this->getPage();
  22. return app('json')->success($this->repository->getList($where, $page, $limit, (bool)$merId));
  23. }
  24. public function again($id)
  25. {
  26. if (!$model = $this->repository->get((int)$id)) {
  27. return app('json')->fail('分账单不存在');
  28. }
  29. if ($model->status != -2) {
  30. return app('json')->fail('分账单状态操作,不能分账');
  31. }
  32. if ($this->repository->profitsharing($model)) {
  33. return app('json')->success('分账成功');
  34. }
  35. return app('json')->fail('分账失败');
  36. }
  37. }