CommissionController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace addons\BossThree\api\modules\v1\controllers;
  3. use addons\BossThree\common\models\BossThree;
  4. use common\enums\StatusEnum;
  5. use common\models\user\UserLevel;
  6. use Yii;
  7. use api\controllers\OnAuthController;
  8. use common\models\common\MallSetting;
  9. use Exception;
  10. /**
  11. * 佣金控制器-前端访问
  12. *
  13. * Class CommissionController
  14. * @package addons\SelfMall\api\modules\v1\controllers
  15. */
  16. class CommissionController extends OnAuthController
  17. {
  18. public $modelClass = '';
  19. /**
  20. * 不用进行登录验证的方法
  21. *
  22. * 例如: ['index', 'update', 'create', 'view', 'delete']
  23. * 默认全部需要验证
  24. *
  25. * @var array
  26. */
  27. protected $authOptional = [];
  28. /**
  29. * 佣金明细
  30. *
  31. * @return string
  32. */
  33. public function actionList()
  34. {
  35. }
  36. /**
  37. * 佣金统计接口
  38. * @return mixed|void
  39. */
  40. public function actionTotal()
  41. {
  42. try{
  43. $boss = BossThree::findOne(['mall_id' => $this->mall_id,'user_id' => $this->user['id'],'status' => StatusEnum::ENABLED]);
  44. $user_level = UserLevel::getUserLevelOne(['mall_id' => $this->mall_id,'level' => $this->user['level']],[],true);
  45. $return = [
  46. 'nickname' => $this->user['nickname'],
  47. 'username' => $this->user['username'],
  48. 'avatar_url' => $this->user['avatar_url'],
  49. 'mobile' => $this->user['mobile'],
  50. 'level_name' => $user_level['name'] ?: MallSetting::getDefaultLevelName($this->mall_id),
  51. 'settle_commission' => $boss->commission,
  52. 'total_commission' => $boss->total_commission,
  53. 'frozen_commission' => 0
  54. ];
  55. return $this->success('success',$return);
  56. }catch(Exception $e){
  57. return $this->error($e->getMessage());
  58. }
  59. }
  60. }