'记录编号', 'goods_name' => '商品名称', 'item_spec_value_str' => '商品规格', 'nickname' => '发起用户', 'help_num' => '帮砍次数', 'current_price' => '当前价格', 'status_desc' => '砍价状态', 'create_time' => '发起时间', ]; } /** * @notes 导出表名 * @return string * @author Tab * @date 2021/9/24 17:50 */ public function setFileName(): string { return '活动记录'; } /** * @notes 设置搜索 * @return array * @author Tab * @date 2021/9/24 17:30 */ public function setSearch(): array { return [ '=' => ['status'], 'between_time' => 'create_time' ]; } /** * @notes 附加搜索 * @author Tab * @date 2021/9/24 15:54 */ public function attachSearch() { $this->searchWhere[] = ['bi.activity_id', '=', $this->params['id']]; } /** * @notes 列表 * @return array * @author Tab * @date 2021/9/24 17:50 */ public function lists() : array { // $this->attachSearch(); $field = [ 'bi.id', 'bi.sn', 'bi.goods_snapshot', 'bi.bargain_snapshot', 'bi.help_num', 'bi.current_price', 'bi.status', 'bi.status' => 'status_desc', 'bi.create_time', 'u.avatar', 'u.nickname', ]; $lists = BargainInitiate::alias('bi') ->leftJoin('user u', 'u.id = bi.user_id') ->withSearch(['goods_info', 'user_info', 'activity_info'], $this->params) ->field($field) ->order('bi.create_time', 'desc') ->where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); foreach ($lists as &$item) { $item['goods_snapshot']['goods_image'] = FileService::getFileUrl($item['goods_snapshot']['goods_image']); $item['avatar'] = FileService::getFileUrl($item['avatar']); $item['goods_name'] = $item['goods_snapshot']['goods_name']; $item['item_spec_value_str'] = $item['goods_snapshot']['item_spec_value_str']; } return $lists; } /** * @notes 记录数 * @return int * @author Tab * @date 2021/9/24 17:51 */ public function count() : int { // $this->attachSearch(); $count = BargainInitiate::alias('bi') ->leftJoin('user u', 'u.id = bi.user_id') ->withSearch(['goods_info', 'user_info'], $this->params) ->where($this->searchWhere) ->count(); return $count; } }