params['change_object'] ?? CoachAccountLogEnum::MONEY; $where[] = ['AL.change_object','=',$changeObject]; if (isset($this->params['user_info']) && $this->params['user_info'] != '') { $where[] = ['C.sn|C.mobile|C.name','like','%'.$this->params['user_info'].'%']; } if (isset($this->params['change_type']) && $this->params['change_type'] != '') { $where[] = ['AL.change_type','=',$this->params['change_type']]; } // 开始时间 if(isset($this->params['start_time']) && $this->params['start_time'] != '') { $where[] = ['AL.create_time', '>=', strtotime($this->params['start_time'])]; } // 结束时间 if(isset($this->params['end_time']) && $this->params['end_time'] != '') { $where[] = ['AL.create_time', '<=', strtotime($this->params['end_time'])]; } if (isset($this->params['order_sn']) && $this->params['order_sn'] != '') { $where[] = ['AL.association_sn','=',$this->params['order_sn']]; } return $where; } /** * @notes 账户流水记录列表 * @return array * @author ljj * @date 2022/12/2 5:32 下午 */ public function lists(): array { $lists = CoachAccountLog::alias('AL') ->join('coach C', 'C.id = AL.coach_id') ->field('AL.id,C.sn as user_sn,C.name,C.mobile,AL.change_amount,AL.left_amount,AL.action,AL.change_type,AL.association_sn,AL.create_time') ->append(['change_type_desc']) ->where(self::where()) ->limit($this->limitOffset,$this->limitLength) ->order('AL.id','desc') ->select() ->toArray(); return $lists; } /** * @notes 账户流水记录数量 * @return int * @author ljj * @date 2022/12/2 5:32 下午 */ public function count(): int { return CoachAccountLog::alias('AL') ->join('coach C', 'C.id = AL.coach_id') ->where(self::where()) ->count(); } /** * @notes 导出字段 * @return string[] * @author ljj * @date 2023/4/12 2:40 下午 */ public function setExcelFields(): array { return [ // '数据库字段名(支持别名) => 'Excel表字段名' 'user_sn' => '用户编号', 'nickname' => '用户昵称', 'change_amount' => '变动金额', 'left_amount' => '剩余金额', 'change_type_desc' => '变动类型', 'association_sn' => '来源单号', 'create_time' => '记录时间', ]; } /** * @notes 导出表名 * @return string * @author ljj * @date 2023/4/12 2:40 下午 */ public function setFileName(): string { return '账户流水记录列表'; } }