* @version : HUOSDK 8.0 */ namespace huo\model\integral; use huo\model\common\CommonModel; class IntegralActivityModel extends CommonModel { protected $name = 'itg_act'; // 开启自动写入时间戳字段 protected $autoWriteTimestamp = true; /** * 基础查询 * * @param $query */ protected function base($query) { $query->where('delete_time', 0) ->where('is_delete', 2); } /** * 添加积分活动 * * @param $data * * @return bool|mixed */ public function addIa($data) { if (empty($data)) { return false; } if ($_obj = self::create($data, true)) { return $_obj->id; } else { return false; } } /** * 获取积分活动 * * @param array $where * * @return array|false|\PDOStatement|string|\think\Collection */ public function getIas($where = []) { $_field = 'id,ia_code,ia_name,icon,ia_desc,integral,link_table,start_time,end_time,limit_agent,list_order,limit_cnt,type'; $_data = $this->where($where)->order('list_order desc, id asc')->column($_field, 'id'); return $_data; } /** * 更新积分活动 * * @param array $ia_data * @param int $ia_id * * @return bool */ public function updateIa($ia_data, $ia_id) { $_map['id'] = $ia_id; $_data = $ia_data; $_rs = self::update($_data, $_map, true); if (false == $_rs) { return false; } else { return true; } } }