| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace addons\Community\api\modules\v1\controllers;
- use addons\Community\common\service\CommissionService;
- use api\controllers\OnAuthController;
- use Yii;
- class CommissionController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = [];
- public function actionIndex()
- {
- // 是否需要校验验证码
- $data = Yii::$app->request->get();
- $valid = Yii::$app->services->validate->validate($data, [
- [['page', 'limit'], 'integer'],
- [['date'], 'string']
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $data['user_id'] = $this->user_id; // 自提点管理人
- $ret = (new CommissionService())->page($this->mall_id, $data, true);
- if (!empty($ret['list'])) {
- foreach ($ret['list'] as &$item) {
- $item['commission'] = bcdiv($item['commission'], 100, 2);
- $item['intro'] = "订单:{$item['order']['order_no']},成功自提获得佣金奖励。";
- unset($item['order']);
- }
- }
- if (!empty($ret['commission'])) {
- $ret['commission'] = bcdiv($ret['commission'], 100, 2);
- }
- if (!empty($ret['today_commission'])) {
- $ret['today_commission'] = bcdiv($ret['today_commission'], 100, 2);
- }
- return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
- }
- }
|