request; if ($retuest->isAjax) { if ($retuest->isPost) { // 检查提交的参数 $params = $retuest->post(); $res = Yii::$app->services->validate->validate($params,[ [['page','limit'], 'integer'], [['keyword'], 'string'] ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $commonission_type = LevelEnum::getCommissionType();// 分红类型 $compute_period = LevelEnum::getComputePeriod();// 分红周期 $where = []; $where[] = ['=', 'mall_id', $this->mall_id]; // 根据用户昵称搜索 if (isset($params['keyword'])) { $where[] = ['=', 'user_id', $params['keyword']]; // $user_id = User::find()->select('id')->where(['mall_id' => $this->mall_id,'mobile' => $params['keyword'],'status' => StatusEnum::ENABLED])->asArray()->scalar(); // if ($user_id) $where[] = ['=', 'user_id', $user_id]; } $where[] = ['=', 'status', StatusEnum::ENABLED]; $order = 'id desc'; $with = ['user']; $params = array('where' => $where, 'order' => $order, 'with' => $with, 'limit' => $params['limit']); $list = AddonsBossCommissionLog::listPage($params, false, true); if (empty($list)) $this->error('获取失败'); foreach ($list['list'] as &$item) { $item['start_time'] = date("Y-m-d", strtotime($item['start_time'])); $item['end_time'] = date("Y-m-d", strtotime($item['end_time'])); } $this->success('获取成功', compact('list', 'commonission_type', 'compute_period')); } } return $this->render($this->action->id); } /** * 分红明细 * @Author: lun * @DateTime: 2021/11/5 0005 16:58 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|string|void */ public function actionRewardLog() { $retuest = Yii::$app->request; if ($retuest->isAjax) { if ($retuest->isPost) { // 检查提交的参数 $params = $retuest->post(); $res = Yii::$app->services->validate->validate($params,[ [['id','type','start_time','end_time','commission_id'], 'required'], [['id','type','commission_id'], 'integer'], [['start_time','end_time'], 'string'] ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); // 获取股东等级 $boss_level_list = AddonsBossLevel::getBossLevel([['mall_id' => $this->mall_id]], [],true,'level,name'); $boss_level_arr = array_column($boss_level_list, null,'level'); $settlement_method = LevelEnum::getSettlementMethod();// 结算方式 $compute_type = LevelEnum::getComputeType();// 佣金计算方式 // 获取用户信息 $user = User::find()->select('nickname,avatar_url')->where(['mall_id' => $this->mall_id,'id' => $params['id']])->asArray()->one(); if($params['type'] == 4){ $settlement_config = AddonsBossCommissionLog::find()->select('settlement_config')->where(['id' => $params['commission_id']])->column(); $where = []; $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['between', 'date', str_replace('-','',$params['start_time']), str_replace('-','',$params['end_time'])]; $where[] = ['=', 'status', StatusEnum::ENABLED]; $order = 'id desc'; $params = array('where' => $where, 'order' => $order, 'limit' => $params['limit']); $list = AddonsBossRewardOrderLog::listPage($params, false, true); foreach($list['list'] as &$item){ $item['type'] = 4; $item['settlement_config'] = $settlement_config; $settlement_config_array = \yii\helpers\Json::decode($settlement_config[0]); $item['settle_price'] = bcdiv($item['amounts']*$settlement_config_array['weight_turnover_ratio']*$settlement_config_array['weight_level_ratio'],10000,2); } }else{ $where = []; $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['=', 'user_id', $params['id']]; $where[] = ['=', 'type', $params['type']]; $where[] = ['between', 'date', str_replace('-','',$params['start_time']), str_replace('-','',$params['end_time'])]; $where[] = ['=', 'is_settlement', StatusEnum::ENABLED]; $where[] = ['=', 'status', StatusEnum::ENABLED]; $order = 'created_at desc'; $params = array('where' => $where, 'order' => $order, 'limit' => $params['limit']); $list = AddonsBossRewardLog::listPage($params, false, true); } $this->success('获取成功', compact('list','boss_level_arr', 'user', 'settlement_method' ,'compute_type')); } } return $this->render($this->action->id); } }