request->isGet) { $res = SalesCompany::findOne(['user_id'=>$this->user->id]); if(!$res){ throw new \Exception('您还未绑定销售公司'); } $param = \Yii::$app->request->get(); $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['=', 'user_id', $this->user->id]; $params['where'] = $where; $params['order'] = ' created_at desc'; $params['select'] = 'id,user_id,created_at,desc,money'; $data = CommissionLog::listPage($params, false); if(!empty($data['list'])){ foreach($data['list'] as &$list){ $list['created_at'] = date('Y-m-d H:i:s',$list['created_at']); $list['type'] = 1; } } $data['total_money'] = 0; $data['today_money'] = 0; $data['rate_money'] = 0; $commissionLog = CommissionLog::find()->select('sum(money) as money,sum(total_money) as total_money')->where(['user_id'=>$this->user->id,'mall_id'=>$this->mall_id])->asArray()->one(); if($commissionLog){ $data['total_money'] = $commissionLog['money'] ?? 0; $data['rate_money'] = $commissionLog['total_money'] - $commissionLog['money'] ?? 0; } $start_time = strtotime(date('Y-m-d 00:00:00',time())); $end_time = $start_time + 24 * 60 * 60; $commissionLog = CommissionLog::find() ->select('sum(money) as money') ->where(['user_id'=>$this->user->id,'mall_id'=>$this->mall_id]) ->andWhere(['>=','created_at',$start_time]) ->andWhere(['<','created_at',$end_time]) ->asArray() ->one(); if($commissionLog){ $data['today_money'] = $commissionLog['money'] ?? 0; } $user = User::findOne(['id'=>$this->user->id]); $data['user'] = [ 'nickname' => $user->nickname, 'id' => $user->id, 'avatar_url' => $user->avatar_url, ]; return $this->success('操作成功', $data); }else{ throw new \Exception("请求方法错误!"); } }catch(\Exception $e){ return $this->error($e->getMessage()); } } }