ShareProfits.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\controller\admin\profits;
  3. use app\common\repositories\profits\ProfitsRepository;
  4. use app\controller\admin\BaseController;
  5. use app\entity\admin\request\profits\PartnerProfitsRequestEntity;
  6. use app\entity\admin\response\profits\ZeroUserProfitResponseEntity;
  7. use app\validate\admin\profits\PartnerProfitsValidate;
  8. class ShareProfits extends BaseController
  9. {
  10. /**
  11. * @var
  12. */
  13. private $repository;
  14. public function __construct(ProfitsRepository $repository)
  15. {
  16. parent::__construct();
  17. $this->repository = $repository;
  18. }
  19. /**
  20. * @param PartnerProfitsValidate $validate
  21. * @return mixed
  22. * @throws \think\db\exception\DataNotFoundException
  23. * @throws \think\db\exception\DbException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * 合伙人分红接口
  26. */
  27. public function partnerProfits(PartnerProfitsValidate $validate)
  28. {
  29. $validationResult = $this->validateRequest($validate, PartnerProfitsRequestEntity::class);
  30. $res = $this->repository->getZeroUser($validationResult->toArray());
  31. // $res = $this->repository->profits($validationResult->toArray());
  32. if (is_string($res)) {
  33. $response = ZeroUserProfitResponseEntity::error($res);
  34. return app('json')->fail($response->toResponseArray());
  35. }
  36. $response = ZeroUserProfitResponseEntity::success();
  37. return app('json')->success($response->toResponseArray());
  38. }
  39. }