add($data); return $ret; } /** * 修改中奖记录 */ public function saveTurntableUse($id, $data) { $w['id'] = $id; $ret = $this->where($w)->save($data); return $ret; } /* * 获取中奖记录列表 * param $merchant_id 商户ID * param $title 搜索字段 * param $turntable_id 活动ID * param $grant_type 发放方式1配送 2自提 3自动发放 * param $grant_status 发放状态1待配送 2已发放 * param $prize_type 奖品类型:1实物 2门店商品 3积分 4余额 5谢谢惠顾 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getWinList($merchant_id, $title, $turntable_id, $grant_type, $grant_status, $prize_type, $start_time, $end_time, $page, $page_size) { $where['a.merchant_id'] = $merchant_id; if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } if (!empty($grant_type)) { $where['a.delivery_type'] = $grant_type; } if (!empty($grant_status)) { $where['a.delivery_status'] = $grant_status; } if (!empty($prize_type)) { $where['a.prize_type'] = $prize_type; } if (!empty($start_time) and !empty($end_time)) { $where['a.add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { $map['a.username'] = array('like', '%' . $title . '%'); $map['a.phone'] = array('like', '%' . $title . '%'); $map['_logic'] = 'or'; $where['_complex'] = $map; } $list = $this->alias('a') ->join('ls_turntable as b on a.turntable_id=b.id', 'LEFT') ->join('ls_retail_store as c on a.store_id=c.id', 'LEFT') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->join('ls_retail_vip as e on a.user_id=e.id', 'LEFT') ->field('a.id,a.order_num,a.phone,a.add_time,a.delivery_type,a.delivery_status,a.receive_time,b.turntable_name,c.storetag,d.id as prize_id,d.prize_name,e.name,e.nickname') ->where($where) ->page($page, $page_size) ->order('a.add_time desc') ->select(); return $list; } /* * 获取中奖记录总数 * param $merchant_id 商户ID * param $title 搜索字段 * param $turntable_id 活动ID * param $grant_type 发放方式1配送 2自提 3自动发放 * param $grant_status 发放状态1待配送 2已发放 * param $prize_type 奖品类型:1实物 2门店商品 3积分 4余额 5谢谢惠顾 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getWinCount($merchant_id, $title, $turntable_id, $grant_type, $grant_status, $prize_type, $start_time, $end_time) { $where['a.merchant_id'] = $merchant_id; if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } if (!empty($grant_type)) { $where['a.delivery_type'] = $grant_type; } if (!empty($grant_status)) { $where['a.delivery_status'] = $grant_status; } if (!empty($prize_type)) { $where['a.prize_type'] = $prize_type; } if (!empty($start_time) and !empty($end_time)) { $where['a.add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { $map['a.username'] = array('like', '%' . $title . '%'); $map['a.phone'] = array('like', '%' . $title . '%'); $map['_logic'] = 'or'; $where['_complex'] = $map; } $list = $this->alias('a') ->join('ls_turntable as b on a.turntable_id=b.id', 'LEFT') ->join('ls_retail_store as c on a.store_id=c.id', 'LEFT') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.username,a.phone,a.add_time,a.delivery_type,a.delivery_status,a.receive_time,b.turntable_name,c.storetag,d.prize_name') ->where($where) ->count(); return $list; } /* * 获取门店中奖记录列表 * param $store_id 门店ID * param $merchant_id 商户ID * param $title 搜索字段 * param $turntable_id 活动ID * param $grant_type 发放方式1配送 2自提 3自动发放 * param $grant_status 发放状态1待配送 2已发放 * param $prize_type 奖品类型:1实物 2门店商品 3积分 4余额 5谢谢惠顾 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getWinRecordStoreList($store_id, $merchant_id, $title, $turntable_id, $grant_type, $grant_status, $prize_type, $start_time, $end_time, $page, $page_size) { $where['a.store_id'] = $store_id; if (!empty($merchant_id)) { $where['a.merchant_id'] = $merchant_id; } if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } if (!empty($grant_type)) { $where['a.delivery_type'] = $grant_type; } if (!empty($grant_status)) { $where['a.delivery_status'] = $grant_status; } if (!empty($prize_type)) { $where['a.prize_type'] = $prize_type; } if (!empty($start_time) and !empty($end_time)) { $where['a.add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { $map['a.username'] = array('like', '%' . $title . '%'); $map['a.phone'] = array('like', '%' . $title . '%'); $map['_logic'] = 'or'; $where['_complex'] = $map; } $list = $this->alias('a') ->join('ls_turntable as b on a.turntable_id=b.id', 'LEFT') ->join('ls_retail_store as c on a.store_id=c.id', 'LEFT') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.username,a.phone,a.add_time,a.delivery_type,a.delivery_status,a.receive_time,b.turntable_name,c.storetag,d.id as prize_id,d.prize_name') ->where($where) ->page($page, $page_size) ->order('a.add_time desc') ->select(); return $list; } /* * 获取门店中奖记录总数 * param $store_id 门店ID * param $merchant_id 商户ID * param $title 搜索字段 * param $turntable_id 活动ID * param $grant_type 发放方式1配送 2自提 3自动发放 * param $grant_status 发放状态1待配送 2已发放 * param $prize_type 奖品类型:1实物 2门店商品 3积分 4余额 5谢谢惠顾 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getWinRecordStoreCount($store_id, $merchant_id, $title, $turntable_id, $grant_type, $grant_status, $prize_type, $start_time, $end_time) { $where['a.store_id'] = $store_id; if (!empty($merchant_id)) { $where['a.merchant_id'] = $merchant_id; } if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } if (!empty($grant_type)) { $where['a.delivery_type'] = $grant_type; } if (!empty($grant_status)) { $where['a.delivery_status'] = $grant_status; } if (!empty($prize_type)) { $where['a.prize_type'] = $prize_type; } if (!empty($start_time) and !empty($end_time)) { $where['a.add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { $map['a.username'] = array('like', '%' . $title . '%'); $map['a.phone'] = array('like', '%' . $title . '%'); $map['_logic'] = 'or'; $where['_complex'] = $map; } $list = $this->alias('a') ->join('ls_turntable as b on a.turntable_id=b.id', 'LEFT') ->join('ls_retail_store as c on a.store_id=c.id', 'LEFT') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.username,a.phone,a.add_time,a.delivery_type,a.delivery_status,a.receive_time,b.turntable_name,c.storetag,d.prize_name') ->where($where) ->count(); return $list; } /* * 获取中奖记录详情名单列表 * param $merchant_id 商户ID * param $title 搜索字段 * param $turntable_id 活动ID * param $grant_status 发放状态1待配送 2已发放 * param $prize_type 奖品类型:1实物 2门店商品 3积分 4余额 5谢谢惠顾 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getWinDetail($merchant_id, $title, $turntable_id, $grant_status, $prize_type, $start_time, $end_time, $page, $page_size) { $where['a.merchant_id'] = $merchant_id; if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } if (!empty($grant_status)) { $where['a.delivery_status'] = $grant_status; } if (!empty($prize_type)) { $where['a.prize_type'] = $prize_type; } if (!empty($start_time) and !empty($end_time)) { $where['a.add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { $map['a.username'] = array('like', '%' . $title . '%'); $map['a.phone'] = array('like', '%' . $title . '%'); $map['_logic'] = 'or'; $where['_complex'] = $map; } $list = $this->alias('a') ->join('ls_turntable as b on a.turntable_id=b.id', 'LEFT') ->join('ls_retail_store as c on a.store_id=c.id', 'LEFT') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.username,a.phone,a.add_time,a.delivery_type,a.delivery_status,a.receive_time,b.turntable_name,c.storetag,d.prize_name') ->where($where) ->page($page, $page_size) ->select(); return $list; } /* * 获取中奖记录详情名单总数 * param $merchant_id 商户ID * param $title 搜索字段 * param $turntable_id 活动ID * param $grant_status 发放状态1待配送 2已发放 * param $prize_type 奖品类型:1实物 2门店商品 3积分 4余额 5谢谢惠顾 * param $start_time 开始时间 * param $end_time 结束时间 * param $page 当前页数 * param $page_size 每页记录数, * */ public function getWinDetailCount($merchant_id, $title, $turntable_id, $grant_status, $prize_type, $start_time, $end_time) { $where['a.merchant_id'] = $merchant_id; if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } if (!empty($grant_status)) { $where['a.delivery_status'] = $grant_status; } if (!empty($prize_type)) { $where['a.prize_type'] = $prize_type; } if (!empty($start_time) and !empty($end_time)) { $where['a.add_time'] = array('between', $start_time . ',' . $end_time); } if (!empty($title)) { $map['a.username'] = array('like', '%' . $title . '%'); $map['a.phone'] = array('like', '%' . $title . '%'); $map['_logic'] = 'or'; $where['_complex'] = $map; } $list = $this->alias('a') ->join('ls_turntable as b on a.turntable_id=b.id', 'LEFT') ->join('ls_retail_store as c on a.store_id=c.id', 'LEFT') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.username,a.phone,a.add_time,a.delivery_type,a.delivery_status,a.receive_time,b.turntable_name,c.storetag,d.prize_name') ->where($where) ->count(); return $list; } //小程序端 我的中奖记录 /* param $merchant_id 商户ID /* param $turntable_id 转盘ID * param $user_id 用户ID * param $page 当前页数 * param $page_size 每页记录数, * */ public function getTurntableWinList($merchant_id, $turntable_id, $user_id, $page, $page_size) { $where['a.user_id'] = $user_id; $where['a.prize_type'] = ['lt', 5];//过滤 谢谢惠顾 if (!empty($merchant_id)) { $where['a.merchant_id'] = $merchant_id; } if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } $list = $this->alias('a') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.status,a.add_time,a.delivery_type,d.id as prize_id,d.prize_name,d.type') ->where($where) ->page($page, $page_size) ->order('a.add_time desc') ->select(); return $list; } //小程序端 我的中奖记录总数 /* param $merchant_id 商户ID /* param $turntable_id 转盘ID /* param $merchant_id 商户ID * param $user_id 用户ID * */ public function getTurntableWinCount($merchant_id, $turntable_id, $user_id) { $where['a.user_id'] = $user_id; $where['a.prize_type'] = ['lt', 5];//过滤 谢谢惠顾 if (!empty($merchant_id)) { $where['a.merchant_id'] = $merchant_id; } if (!empty($turntable_id)) { $where['a.turntable_id'] = $turntable_id; } $list = $this->alias('a') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.status,a.add_time,d.id as prize_id,d.prize_name,d.type') ->where($where) ->order('a.add_time desc') ->count(); return $list; } //小程序端 查看实物奖品详情 /* param $win_id 中奖记录ID * param $user_id 用户ID * */ public function getPrizeDetail($win_id, $user_id) { $where['a.user_id'] = $user_id; $where['a.id'] = $win_id; $list = $this->alias('a') ->join('ls_turntable_prize as d on a.turntable_prize_id=d.id', 'LEFT') ->field('a.id,a.order_num,a.status,a.add_time,a.delivery_type,d.id as prize_id,d.prize_name,d.prize_img,d.grant_type') ->where($where) ->find(); return $list; } }