| | |
| | | import com.yeshi.fanli.entity.integral.CodePublishRecord;
|
| | | import com.yeshi.fanli.entity.integral.IntegralExchange;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTask;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRank;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.exception.integral.IntegralExchangeException;
|
| | | import com.yeshi.fanli.exception.integral.IntegralGetException;
|
| | | import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | |
| | | import com.yeshi.fanli.service.inter.integral.IntegralDetailService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRankService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
|
| | |
| | |
|
| | | @Resource
|
| | | private IntegralExchangeRecordService integralExchangeRecordService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralTaskRankService integralTaskRankService;
|
| | |
|
| | | @Resource
|
| | | private CodePublishRecordService codePublishRecordService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralTaskService integralTaskService;
|
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | /**
|
| | | * 获取任务列表
|
| | |
| | | list = new ArrayList<IntegralTaskClassVO>();
|
| | | }
|
| | | long count = integralTaskClassService.countTaskClass();
|
| | | |
| | |
|
| | | // 用户签到
|
| | | Integer signState = 0;
|
| | | int signDays = 1;
|
| | | if (page == 1) {
|
| | | |
| | |
|
| | | // 签到
|
| | | try { |
| | | try {
|
| | | signState = integralTaskClassService.finishedDailySign(uid);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | UserInfoExtraVO extraVO = userInfoExtraService.getInfoExtraVOByUid(uid);
|
| | | if (extraVO == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户相关信息不存在"));
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "用户等级不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | // 签到日期信息
|
| | | DailySignVO dailySignVO = integralTaskClassService.getDailySignList(uid, userRank.getId());
|
| | | if (dailySignVO != null) {
|
| | | signDays = dailySignVO.getDays();
|
| | | }
|
| | | |
| | |
|
| | | boolean ejectSign = false;
|
| | | if (signState == 1) |
| | | if (signState == 1)
|
| | | ejectSign = true;
|
| | |
|
| | | data.put("signState", ejectSign);
|
| | |
| | | data.put("dailySign", dailySignVO);
|
| | | }
|
| | |
|
| | | |
| | | for (IntegralTaskClassVO taskClassVO : list) {
|
| | | String progress = taskClassVO.getProgress();
|
| | | if (StringUtil.isNullOrEmpty(progress))
|
| | | continue;
|
| | | |
| | |
|
| | | Integer taskNum = taskClassVO.getTaskNum();
|
| | | if (taskNum == null)
|
| | | continue;
|
| | |
| | |
|
| | | // 根据天数变化更改签到金额
|
| | | Integer num = integralTaskRecordService.getNowdaySignNum(uid, taskClassVO.getId());
|
| | | |
| | |
|
| | | String uniqueKeyTask = UniqueKeyEnum.dailySign.name() + num;
|
| | | IntegralTask integralTask = integralTaskService.getByCidAndUniqueKey(taskClassVO.getId(), uniqueKeyTask);
|
| | | IntegralTask integralTask = integralTaskService.getByCidAndUniqueKey(taskClassVO.getId(),
|
| | | uniqueKeyTask);
|
| | | Integer goldCoin = 0;
|
| | | if (integralTask != null) {
|
| | | goldCoin = integralTask.getGoldCoin();
|
| | |
| | | } else {
|
| | | taskClassVO.setLightUp(true);
|
| | | }
|
| | | |
| | |
|
| | | Integer dateType = 1; // 查询当日
|
| | | if (uniqueKey == UniqueKeyEnum.orderReward)
|
| | | dateType = null; // 查询历史
|
| | |
| | | countFinished = integralTaskRecordService.countFinished(uid, id, dateType);
|
| | | }
|
| | | progress = progress.replace("{已完成}", countFinished + "").replace("{总任务}", taskNum + "");
|
| | | |
| | |
|
| | | if (signState == 0 && uniqueKey == UniqueKeyEnum.dailySign) {
|
| | | progress = "未签到";
|
| | | taskClassVO.setBtnName("签到");
|
| | | } |
| | | }
|
| | | taskClassVO.setProgress(progress);
|
| | | }
|
| | | |
| | |
|
| | | data.put("count", count);
|
| | | data.put("list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | count = Integer.MAX_VALUE;
|
| | | }
|
| | | |
| | |
|
| | | List<IntegralTaskRecord> list = integralTaskRecordService.listNotReceived(count, uid);
|
| | | if (list == null) {
|
| | | list = new ArrayList<IntegralTaskRecord>();
|
| | |
| | | *
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param ids // 领取id
|
| | | * @param gids // 未领取id
|
| | | * @param ids
|
| | | * // 领取id
|
| | | * @param gids
|
| | | * // 未领取id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "receiveGoldCoin", method = RequestMethod.POST)
|
| | | public void receiveGoldCoin(AcceptData acceptData, Long uid, Integer type, String ids, String gids, PrintWriter out) {
|
| | | public void receiveGoldCoin(AcceptData acceptData, Long uid, Integer type, String ids, String gids,
|
| | | PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | // 全部领取
|
| | | if (type != null && type == 1) {
|
| | |
| | | data.put("goldCoin", goldCoin);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | // 部分领取
|
| | | Gson gson = new Gson();
|
| | | Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() {
|
| | |
| | | return;
|
| | | }
|
| | | Integer goldCoin = integralTaskRecordService.receiveGoldCoin(uid, idList);
|
| | | Set<Long> gidList = gson.fromJson(gids, new TypeToken<HashSet<Long>>() {}.getType());
|
| | | Set<Long> gidList = gson.fromJson(gids, new TypeToken<HashSet<Long>>() {
|
| | | }.getType());
|
| | | List<IntegralTaskRecord> list = null;
|
| | | if (gidList != null && gidList.size() > 0) {
|
| | | list = integralTaskRecordService.listNotReceivedExcludeId(5 - gidList.size(), uid, gidList);
|
| | | } else {
|
| | | list = integralTaskRecordService.listNotReceivedExcludeId(5, uid, null);
|
| | | }
|
| | | |
| | |
|
| | | if (list == null) {
|
| | | list = new ArrayList<IntegralTaskRecord>();
|
| | | }
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson2 = gsonBuilder.create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goldCoin", goldCoin);
|
| | | data.put("list", gson2.toJson(list));
|
| | |
| | | if (list == null)
|
| | | list = new ArrayList<IntegralExchange>();
|
| | |
|
| | | //Long count = integralExchangeService.countValid();
|
| | | // Long count = integralExchangeService.countValid();
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | |
| | | out.print(JsonUtil.loadFalseResult("用户尚未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(event)) {
|
| | | out.print(JsonUtil.loadFalseResult("事件为空"));
|
| | | return;
|
| | | }
|
| | | IntegralTaskRecord record = null;
|
| | | try {
|
| | | record = integralGetService.addEventStatistic(uid, event, null);
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (record == null) {
|
| | | out.print(JsonUtil.loadFalseResult("添加失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | || "scanTBCart".equalsIgnoreCase(event)) {
|
| | | JSONObject notify = new JSONObject();
|
| | | switch (event) {
|
| | | |
| | | case "recommendSearch":
|
| | | notify.put("name", "完成一次智能搜索");
|
| | | notify.put("score", "+20金币");
|
| | | break;
|
| | | case "scanGoods":
|
| | | notify.put("name", "完成一次商品浏览");
|
| | | notify.put("score", "+100金币");
|
| | | break;
|
| | | case "scanTBCart":
|
| | | notify.put("name", "完成一次购物车浏览");
|
| | | notify.put("score", "+300金币");
|
| | | break;
|
| | | }
|
| | |
|
| | | notify.put("score", String.format("+%s金币", record.getGoldCoin()));
|
| | | data.put("notify", notify);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | return gson;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 明细详情
|
| | | *
|
| | |
| | | * 年份
|
| | | * @param month
|
| | | * 月份
|
| | | * @param type 统计类型 0全部 1
|
| | | * @param type
|
| | | * 统计类型 0全部 1
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getDetails")
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "日期不完整"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Date date = null;
|
| | |
|
| | | if (year != null && month != null) {
|
| | |
| | | package com.yeshi.fanli.dao.mybatis.integral; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | |
| | | |
| | | /** |
| | | * 未领取金币 |
| | | * |
| | | * @param count |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<IntegralTaskRecord> listNotReceived(@Param("count") int count, @Param("uid") Long uid); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 未领取金币- 排除id |
| | | * |
| | | * @param count |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<IntegralTaskRecord> listNotReceivedExcludeId(@Param("count") int count, @Param("uid") Long uid, |
| | | @Param("list")Set<Long> idList); |
| | | |
| | | |
| | | @Param("list") Set<Long> idList); |
| | | |
| | | /** |
| | | * 总完成 |
| | | * |
| | | * @param uid |
| | | * @param dateType |
| | | * @return |
| | | */ |
| | | Integer getTotalGoldCoin(@Param("uid") Long uid, @Param("cid") Long cid, @Param("dateType")Integer dateType); |
| | | |
| | | Integer getTotalGoldCoin(@Param("uid") Long uid, @Param("cid") Long cid, @Param("dateType") Integer dateType); |
| | | |
| | | /** |
| | | * 统计完成数量 |
| | | * |
| | | * @param uid |
| | | * @param cid |
| | | * @param dateType |
| | | * @return |
| | | */ |
| | | Integer countFinished(@Param("uid") Long uid, @Param("cid") Long cid, @Param("dateType")Integer dateType); |
| | | |
| | | Integer countFinished(@Param("uid") Long uid, @Param("cid") Long cid, @Param("dateType") Integer dateType); |
| | | |
| | | /** |
| | | * 近7天签到情况 |
| | | * |
| | | * @param uid |
| | | * @param cid |
| | | * @param sortState 1倒序-创建时间 |
| | | * @param sortState |
| | | * 1倒序-创建时间 |
| | | * @return |
| | | */ |
| | | List<IntegralTaskRecord> listDaySignRecord(@Param("uid") Long uid, @Param("cid") Long cid); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 未领取金币 |
| | | * |
| | | * @param count |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | int countTotalGoldCoin(@Param("uid") Long uid); |
| | | |
| | | |
| | | /** |
| | | * 更新领取状态 |
| | | * |
| | | * @param uid |
| | | */ |
| | | void updateReceived(@Param("uid") Long uid); |
| | | |
| | | |
| | | /** |
| | | * 根据任务ID与时间段查询任务完成数量 |
| | | * |
| | | * @param taskId |
| | | * @param uid |
| | | * @param minTime |
| | | * @param maxTime |
| | | */ |
| | | int countGetCountByTaskIdAndDay(@Param("taskId") Long taskId,@Param("uid")Long uid, @Param("minTime") Date minTime, |
| | | @Param("maxTime") Date maxTime); |
| | | } |
| | | |
| | |
| | | */
|
| | | @Table("yeshi_ec_integral_task_record")
|
| | | public class IntegralTaskRecord implements Serializable {
|
| | |
|
| | | public static int STATE_WAITING_RECIEVE = 0;// 等待领取
|
| | | public static int STATE_ALREAD_RECIEVE = 1;// 已领取
|
| | | public static int STATE_INVALID = 2;// 失效
|
| | | /**
|
| | | *
|
| | | */
|
| | |
| | |
|
| | | @Column(name = "ir_cid")
|
| | | private Long cid;
|
| | | |
| | |
|
| | | @Column(name = "ir_task_id")
|
| | | private Long taskId;
|
| | |
|
| | |
| | |
|
| | | @Column(name = "ir_update_time")
|
| | | private Date updateTime;
|
| | | |
| | |
|
| | | @Expose
|
| | | private String taskName; // 任务名称
|
| | |
|
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.integral.IntegralTaskMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.integral.IntegralTask"> |
| | | <id column="it_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="it_name" property="name" jdbcType="VARCHAR"/> |
| | | <result column="it_unique_key" property="uniqueKey" jdbcType="VARCHAR"/> |
| | | <result column="it_explain" property="explain" jdbcType="VARCHAR"/> |
| | | <result column="it_gold_coin" property="goldCoin" jdbcType="INTEGER"/> |
| | | <result column="it_upper_limit" property="upperLimit" jdbcType="INTEGER"/> |
| | | <result column="it_double_num" property="doubleNum" jdbcType="INTEGER"/> |
| | | <result column="it_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="it_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="it_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <result column="it_frequency" property="frequency" typeHandler="com.yeshi.fanli.util.mybatishandler.integral.FrequencyEnumHandler"/> |
| | | |
| | | <association property="taskClass" column="it_cid" |
| | | select="com.yeshi.fanli.entity.dao.IntegralTaskClassMapper.selectByPrimaryKey"> |
| | | </association> |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap id="SimpleResultMap" type="com.yeshi.fanli.entity.integral.IntegralTask"> |
| | | <id column="it_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="it_name" property="name" jdbcType="VARCHAR"/> |
| | | <result column="it_unique_key" property="uniqueKey" jdbcType="VARCHAR"/> |
| | | <result column="it_explain" property="explain" jdbcType="VARCHAR"/> |
| | | <result column="it_gold_coin" property="goldCoin" jdbcType="INTEGER"/> |
| | | <result column="it_upper_limit" property="upperLimit" jdbcType="INTEGER"/> |
| | | <result column="it_double_num" property="doubleNum" jdbcType="INTEGER"/> |
| | | <result column="it_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="it_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="it_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <result column="it_frequency" property="frequency" typeHandler="com.yeshi.fanli.util.mybatishandler.integral.FrequencyEnumHandler"/> |
| | | |
| | | <association property="taskClass" column="it_cid" javaType="com.yeshi.fanli.entity.integral.IntegralTaskClass"> |
| | | <id column="it_cid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">it_id,it_cid,it_name,it_unique_key,it_explain,it_frequency,it_gold_coin,it_upper_limit,it_double_num,it_state,it_create_time,it_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_integral_task where it_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_integral_task where it_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.integral.IntegralTask" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_task (it_id,it_cid,it_name,it_unique_key,it_explain,it_frequency,it_gold_coin,it_upper_limit,it_double_num,it_state,it_create_time,it_update_time) values (#{id,jdbcType=BIGINT},#{taskClass.id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{uniqueKey,jdbcType=VARCHAR},#{explain,jdbcType=VARCHAR},#{frequency,jdbcType=VARCHAR},#{goldCoin,jdbcType=INTEGER},#{upperLimit,jdbcType=INTEGER},#{doubleNum,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTask" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_task |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">it_id,</if> |
| | | <if test="taskClass != null">it_cid,</if> |
| | | <if test="name != null">it_name,</if> |
| | | <if test="uniqueKey != null">it_unique_key,</if> |
| | | <if test="explain != null">it_explain,</if> |
| | | <if test="frequency != null">it_frequency,</if> |
| | | <if test="goldCoin != null">it_gold_coin,</if> |
| | | <if test="upperLimit != null">it_upper_limit,</if> |
| | | <if test="doubleNum != null">it_double_num,</if> |
| | | <if test="state != null">it_state,</if> |
| | | <if test="createTime != null">it_create_time,</if> |
| | | <if test="updateTime != null">it_update_time,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="taskClass != null">#{taskClass.id,jdbcType=BIGINT},</if> |
| | | <if test="name != null">#{name,jdbcType=VARCHAR},</if> |
| | | <if test="uniqueKey != null">#{uniqueKey,jdbcType=VARCHAR},</if> |
| | | <if test="explain != null">#{explain,jdbcType=VARCHAR},</if> |
| | | <if test="frequency != null">#{frequency,jdbcType=VARCHAR},</if> |
| | | <if test="goldCoin != null">#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="upperLimit != null">#{upperLimit,jdbcType=INTEGER},</if> |
| | | <if test="doubleNum != null">#{doubleNum,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.IntegralTask">update yeshi_ec_integral_task set it_cid = #{taskClass.id,jdbcType=BIGINT},it_name = #{name,jdbcType=VARCHAR},it_unique_key = #{uniqueKey,jdbcType=VARCHAR},it_explain = #{explain,jdbcType=VARCHAR},it_frequency = #{frequency,jdbcType=VARCHAR},it_gold_coin = #{goldCoin,jdbcType=INTEGER},it_upper_limit = #{upperLimit,jdbcType=INTEGER},it_double_num = #{doubleNum,jdbcType=INTEGER},it_state = #{state,jdbcType=INTEGER},it_create_time = #{createTime,jdbcType=TIMESTAMP},it_update_time = #{updateTime,jdbcType=TIMESTAMP} where it_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTask">update yeshi_ec_integral_task |
| | | <set> |
| | | <if test="taskClass != null">it_cid=#{taskClass.id,jdbcType=BIGINT},</if> |
| | | <if test="name != null">it_name=#{name,jdbcType=VARCHAR},</if> |
| | | <if test="uniqueKey != null">it_unique_key=#{uniqueKey,jdbcType=VARCHAR},</if> |
| | | <if test="explain != null">it_explain=#{explain,jdbcType=VARCHAR},</if> |
| | | <if test="frequency != null">it_frequency=#{frequency,jdbcType=VARCHAR},</if> |
| | | <if test="goldCoin != null">it_gold_coin=#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="upperLimit != null">it_upper_limit=#{upperLimit,jdbcType=INTEGER},</if> |
| | | <if test="doubleNum != null">it_double_num=#{doubleNum,jdbcType=INTEGER},</if> |
| | | <if test="state != null">it_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">it_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">it_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where it_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="listByCid" resultMap="SimpleResultMap"> |
| | | SELECT * FROM yeshi_ec_integral_task |
| | | WHERE it_state = 1 AND it_cid = #{cid} |
| | | </select> |
| | | |
| | | <select id="getByCidAndUniqueKey" resultMap="SimpleResultMap"> |
| | | SELECT * FROM yeshi_ec_integral_task |
| | | WHERE it_state = 1 AND it_cid = #{cid} AND it_unique_key = #{uniqueKey} |
| | | LIMIT 1 |
| | | </select> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.integral.IntegralTask"> |
| | | <id column="it_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="it_name" property="name" jdbcType="VARCHAR" /> |
| | | <result column="it_unique_key" property="uniqueKey" jdbcType="VARCHAR" /> |
| | | <result column="it_explain" property="explain" jdbcType="VARCHAR" /> |
| | | <result column="it_gold_coin" property="goldCoin" jdbcType="INTEGER" /> |
| | | <result column="it_upper_limit" property="upperLimit" jdbcType="INTEGER" /> |
| | | <result column="it_double_num" property="doubleNum" jdbcType="INTEGER" /> |
| | | <result column="it_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="it_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="it_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="it_frequency" property="frequency" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.integral.FrequencyEnumHandler" /> |
| | | |
| | | <association property="taskClass" column="it_cid" |
| | | select="com.yeshi.fanli.entity.dao.IntegralTaskClassMapper.selectByPrimaryKey"> |
| | | </association> |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap id="SimpleResultMap" type="com.yeshi.fanli.entity.integral.IntegralTask"> |
| | | <id column="it_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="it_name" property="name" jdbcType="VARCHAR" /> |
| | | <result column="it_unique_key" property="uniqueKey" jdbcType="VARCHAR" /> |
| | | <result column="it_explain" property="explain" jdbcType="VARCHAR" /> |
| | | <result column="it_gold_coin" property="goldCoin" jdbcType="INTEGER" /> |
| | | <result column="it_upper_limit" property="upperLimit" jdbcType="INTEGER" /> |
| | | <result column="it_double_num" property="doubleNum" jdbcType="INTEGER" /> |
| | | <result column="it_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="it_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="it_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="it_frequency" property="frequency" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.integral.FrequencyEnumHandler" /> |
| | | |
| | | <association property="taskClass" column="it_cid" |
| | | javaType="com.yeshi.fanli.entity.integral.IntegralTaskClass"> |
| | | <id column="it_cid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">it_id,it_cid,it_name,it_unique_key,it_explain,it_frequency,it_gold_coin,it_upper_limit,it_double_num,it_state,it_create_time,it_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_integral_task where it_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_integral_task where it_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.integral.IntegralTask" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_task |
| | | (it_id,it_cid,it_name,it_unique_key,it_explain,it_frequency,it_gold_coin,it_upper_limit,it_double_num,it_state,it_create_time,it_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{taskClass.id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{uniqueKey,jdbcType=VARCHAR},#{explain,jdbcType=VARCHAR},#{frequency,jdbcType=VARCHAR},#{goldCoin,jdbcType=INTEGER},#{upperLimit,jdbcType=INTEGER},#{doubleNum,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTask" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_integral_task |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">it_id,</if> |
| | | <if test="taskClass != null">it_cid,</if> |
| | | <if test="name != null">it_name,</if> |
| | | <if test="uniqueKey != null">it_unique_key,</if> |
| | | <if test="explain != null">it_explain,</if> |
| | | <if test="frequency != null">it_frequency,</if> |
| | | <if test="goldCoin != null">it_gold_coin,</if> |
| | | <if test="upperLimit != null">it_upper_limit,</if> |
| | | <if test="doubleNum != null">it_double_num,</if> |
| | | <if test="state != null">it_state,</if> |
| | | <if test="createTime != null">it_create_time,</if> |
| | | <if test="updateTime != null">it_update_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="taskClass != null">#{taskClass.id,jdbcType=BIGINT},</if> |
| | | <if test="name != null">#{name,jdbcType=VARCHAR},</if> |
| | | <if test="uniqueKey != null">#{uniqueKey,jdbcType=VARCHAR},</if> |
| | | <if test="explain != null">#{explain,jdbcType=VARCHAR},</if> |
| | | <if test="frequency != null">#{frequency,jdbcType=VARCHAR},</if> |
| | | <if test="goldCoin != null">#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="upperLimit != null">#{upperLimit,jdbcType=INTEGER},</if> |
| | | <if test="doubleNum != null">#{doubleNum,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.IntegralTask">update |
| | | yeshi_ec_integral_task set it_cid = |
| | | #{taskClass.id,jdbcType=BIGINT},it_name = |
| | | #{name,jdbcType=VARCHAR},it_unique_key = |
| | | #{uniqueKey,jdbcType=VARCHAR},it_explain = |
| | | #{explain,jdbcType=VARCHAR},it_frequency = |
| | | #{frequency,jdbcType=VARCHAR},it_gold_coin = |
| | | #{goldCoin,jdbcType=INTEGER},it_upper_limit = |
| | | #{upperLimit,jdbcType=INTEGER},it_double_num = |
| | | #{doubleNum,jdbcType=INTEGER},it_state = |
| | | #{state,jdbcType=INTEGER},it_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},it_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where it_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTask"> |
| | | update yeshi_ec_integral_task |
| | | <set> |
| | | <if test="taskClass != null">it_cid=#{taskClass.id,jdbcType=BIGINT},</if> |
| | | <if test="name != null">it_name=#{name,jdbcType=VARCHAR},</if> |
| | | <if test="uniqueKey != null">it_unique_key=#{uniqueKey,jdbcType=VARCHAR},</if> |
| | | <if test="explain != null">it_explain=#{explain,jdbcType=VARCHAR},</if> |
| | | <if test="frequency != null">it_frequency=#{frequency,jdbcType=VARCHAR},</if> |
| | | <if test="goldCoin != null">it_gold_coin=#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="upperLimit != null">it_upper_limit=#{upperLimit,jdbcType=INTEGER},</if> |
| | | <if test="doubleNum != null">it_double_num=#{doubleNum,jdbcType=INTEGER},</if> |
| | | <if test="state != null">it_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">it_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">it_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where it_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="listByCid" resultMap="SimpleResultMap"> |
| | | SELECT * FROM yeshi_ec_integral_task |
| | | WHERE it_state = 1 AND it_cid = #{cid} |
| | | </select> |
| | | |
| | | <select id="getByCidAndUniqueKey" resultMap="SimpleResultMap"> |
| | | SELECT * FROM yeshi_ec_integral_task |
| | | WHERE it_state = 1 |
| | | <if test="cid!=null"> |
| | | AND it_cid = #{cid} |
| | | </if> |
| | | AND it_unique_key = #{uniqueKey} |
| | | LIMIT 1 |
| | | </select> |
| | | </mapper> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.integral.IntegralTaskRecordMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.integral.IntegralTaskRecord"> |
| | | <id column="ir_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="ir_cid" property="cid" jdbcType="BIGINT"/> |
| | | <result column="ir_task_id" property="taskId" jdbcType="BIGINT"/> |
| | | <result column="ir_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="ir_gold_coin" property="goldCoin" jdbcType="INTEGER"/> |
| | | <result column="ir_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="ir_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="ir_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | |
| | | <result column="taskName" property="taskName" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">ir_id,ir_cid,ir_task_id,ir_uid,ir_gold_coin,ir_state,ir_create_time,ir_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_integral_task_record where ir_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_integral_task_record where ir_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_task_record (ir_id,ir_cid,ir_task_id,ir_uid,ir_gold_coin,ir_state,ir_create_time,ir_update_time) values (#{id,jdbcType=BIGINT},#{cid,jdbcType=BIGINT},#{taskId,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{goldCoin,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_task_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ir_id,</if> |
| | | <if test="cid != null">ir_cid,</if> |
| | | <if test="taskId != null">ir_task_id,</if> |
| | | <if test="uid != null">ir_uid,</if> |
| | | <if test="goldCoin != null">ir_gold_coin,</if> |
| | | <if test="state != null">ir_state,</if> |
| | | <if test="createTime != null">ir_create_time,</if> |
| | | <if test="updateTime != null">ir_update_time,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="cid != null">#{cid,jdbcType=BIGINT},</if> |
| | | <if test="taskId != null">#{taskId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="goldCoin != null">#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord">update yeshi_ec_integral_task_record set ir_cid = #{cid,jdbcType=BIGINT},ir_task_id = #{taskId,jdbcType=BIGINT},ir_uid = #{uid,jdbcType=BIGINT},ir_gold_coin = #{goldCoin,jdbcType=INTEGER},ir_state = #{state,jdbcType=INTEGER},ir_create_time = #{createTime,jdbcType=TIMESTAMP},ir_update_time = #{updateTime,jdbcType=TIMESTAMP} where ir_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord">update yeshi_ec_integral_task_record |
| | | <set> |
| | | <if test="cid != null">ir_cid=#{cid,jdbcType=BIGINT},</if> |
| | | <if test="taskId != null">ir_task_id=#{taskId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">ir_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="goldCoin != null">ir_gold_coin=#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="state != null">ir_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">ir_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">ir_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where ir_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <update id="updateReceived" parameterType="Long"> |
| | | UPDATE yeshi_ec_integral_task_record SET ir_state = 1,ir_update_time = NOW() |
| | | WHERE ir_state = 0 AND ir_uid = #{uid} |
| | | </update> |
| | | |
| | | |
| | | <select id="listNotReceived" resultMap="BaseResultMap"> |
| | | SELECT tc.`tc_name` AS taskName,d.* FROM yeshi_ec_integral_task_record d |
| | | LEFT JOIN `yeshi_ec_integral_task_class` tc ON tc.`tc_id` = d.`ir_cid` |
| | | WHERE d.`ir_uid` = #{uid} AND d.ir_state = 0 |
| | | ORDER BY d.ir_create_time |
| | | LIMIT #{count} |
| | | </select> |
| | | |
| | | <select id="listNotReceivedExcludeId" resultMap="BaseResultMap"> |
| | | SELECT tc.`tc_name` AS taskName,d.* FROM yeshi_ec_integral_task_record d |
| | | LEFT JOIN `yeshi_ec_integral_task_class` tc ON tc.`tc_id` = d.`ir_cid` |
| | | WHERE d.`ir_uid` = #{uid} AND d.ir_state = 0 |
| | | <if test="list != null"> |
| | | AND d.ir_id not in |
| | | <foreach collection="list" item="item" open="(" separator="," close=")"> |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | ORDER BY d.ir_create_time |
| | | LIMIT #{count} |
| | | </select> |
| | | |
| | | <select id="getTotalGoldCoin" resultType="Integer"> |
| | | SELECT IFNULL(SUM(tr.`ir_gold_coin`),0) FROM yeshi_ec_integral_task_record tr |
| | | WHERE tr.ir_uid = #{uid} AND tr.`ir_cid`=#{cid} <!-- tr.ir_state <![CDATA[<>]]>2 AND --> |
| | | <if test="dateType == 1"> |
| | | AND TO_DAYS(tr.ir_create_time) = TO_DAYS(NOW()) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="countFinished" resultType="Integer"> |
| | | SELECT IFNULL(COUNT(tr.`ir_id`),0) FROM yeshi_ec_integral_task_record tr |
| | | WHERE tr.ir_uid = #{uid} AND tr.`ir_cid`=#{cid} |
| | | <if test="dateType == 1"> |
| | | AND TO_DAYS(tr.ir_create_time) = TO_DAYS(NOW()) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="listDaySignRecord" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_integral_task_record d |
| | | WHERE d.`ir_uid` = #{uid} AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[<=]]> DATE(d.ir_create_time) |
| | | ORDER BY d.ir_create_time desc |
| | | </select> |
| | | |
| | | |
| | | <select id="countTotalGoldCoin" resultType="Integer"> |
| | | SELECT IFNULL(SUM(d.`ir_gold_coin`),0) FROM `yeshi_ec_integral_task_record` d |
| | | WHERE d.`ir_uid` = #{uid} AND d.`ir_state` = 0 |
| | | </select> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.integral.IntegralTaskRecord"> |
| | | <id column="ir_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="ir_cid" property="cid" jdbcType="BIGINT" /> |
| | | <result column="ir_task_id" property="taskId" jdbcType="BIGINT" /> |
| | | <result column="ir_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="ir_gold_coin" property="goldCoin" jdbcType="INTEGER" /> |
| | | <result column="ir_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="ir_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="ir_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | |
| | | <result column="taskName" property="taskName" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">ir_id,ir_cid,ir_task_id,ir_uid,ir_gold_coin,ir_state,ir_create_time,ir_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_integral_task_record where ir_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_integral_task_record where ir_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_integral_task_record |
| | | (ir_id,ir_cid,ir_task_id,ir_uid,ir_gold_coin,ir_state,ir_create_time,ir_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{cid,jdbcType=BIGINT},#{taskId,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{goldCoin,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_integral_task_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ir_id,</if> |
| | | <if test="cid != null">ir_cid,</if> |
| | | <if test="taskId != null">ir_task_id,</if> |
| | | <if test="uid != null">ir_uid,</if> |
| | | <if test="goldCoin != null">ir_gold_coin,</if> |
| | | <if test="state != null">ir_state,</if> |
| | | <if test="createTime != null">ir_create_time,</if> |
| | | <if test="updateTime != null">ir_update_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="cid != null">#{cid,jdbcType=BIGINT},</if> |
| | | <if test="taskId != null">#{taskId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="goldCoin != null">#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord">update |
| | | yeshi_ec_integral_task_record set ir_cid = |
| | | #{cid,jdbcType=BIGINT},ir_task_id = #{taskId,jdbcType=BIGINT},ir_uid = |
| | | #{uid,jdbcType=BIGINT},ir_gold_coin = |
| | | #{goldCoin,jdbcType=INTEGER},ir_state = |
| | | #{state,jdbcType=INTEGER},ir_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},ir_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where ir_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord"> |
| | | update yeshi_ec_integral_task_record |
| | | <set> |
| | | <if test="cid != null">ir_cid=#{cid,jdbcType=BIGINT},</if> |
| | | <if test="taskId != null">ir_task_id=#{taskId,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">ir_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="goldCoin != null">ir_gold_coin=#{goldCoin,jdbcType=INTEGER},</if> |
| | | <if test="state != null">ir_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">ir_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">ir_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where ir_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <update id="updateReceived" parameterType="Long"> |
| | | UPDATE |
| | | yeshi_ec_integral_task_record SET ir_state = 1,ir_update_time = NOW() |
| | | WHERE ir_state = 0 AND ir_uid = #{uid} |
| | | </update> |
| | | |
| | | |
| | | <select id="listNotReceived" resultMap="BaseResultMap"> |
| | | SELECT tc.`tc_name` AS |
| | | taskName,d.* FROM yeshi_ec_integral_task_record d |
| | | LEFT JOIN |
| | | `yeshi_ec_integral_task_class` tc ON tc.`tc_id` = d.`ir_cid` |
| | | WHERE |
| | | d.`ir_uid` = #{uid} AND d.ir_state = 0 |
| | | ORDER BY d.ir_create_time |
| | | LIMIT |
| | | #{count} |
| | | </select> |
| | | |
| | | <select id="listNotReceivedExcludeId" resultMap="BaseResultMap"> |
| | | SELECT tc.`tc_name` AS taskName,d.* FROM yeshi_ec_integral_task_record |
| | | d |
| | | LEFT JOIN `yeshi_ec_integral_task_class` tc ON tc.`tc_id` = |
| | | d.`ir_cid` |
| | | WHERE d.`ir_uid` = #{uid} AND d.ir_state = 0 |
| | | <if test="list != null"> |
| | | AND d.ir_id not in |
| | | <foreach collection="list" item="item" open="(" separator="," |
| | | close=")"> |
| | | ${item} |
| | | </foreach> |
| | | </if> |
| | | ORDER BY d.ir_create_time |
| | | LIMIT #{count} |
| | | </select> |
| | | |
| | | <select id="getTotalGoldCoin" resultType="Integer"> |
| | | SELECT IFNULL(SUM(tr.`ir_gold_coin`),0) FROM |
| | | yeshi_ec_integral_task_record tr |
| | | WHERE tr.ir_uid = #{uid} AND |
| | | tr.`ir_cid`=#{cid} <!-- tr.ir_state <![CDATA[<>]]>2 AND --> |
| | | <if test="dateType == 1"> |
| | | AND TO_DAYS(tr.ir_create_time) = TO_DAYS(NOW()) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="countFinished" resultType="Integer"> |
| | | SELECT IFNULL(COUNT(tr.`ir_id`),0) FROM yeshi_ec_integral_task_record |
| | | tr |
| | | WHERE tr.ir_uid = #{uid} AND tr.`ir_cid`=#{cid} |
| | | <if test="dateType == 1"> |
| | | AND TO_DAYS(tr.ir_create_time) = TO_DAYS(NOW()) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="listDaySignRecord" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_integral_task_record d |
| | | WHERE d.`ir_uid` = #{uid} |
| | | AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[<=]]> |
| | | DATE(d.ir_create_time) |
| | | ORDER BY d.ir_create_time desc |
| | | </select> |
| | | |
| | | |
| | | <select id="countTotalGoldCoin" resultType="Integer"> |
| | | SELECT |
| | | IFNULL(SUM(d.`ir_gold_coin`),0) FROM `yeshi_ec_integral_task_record` |
| | | d |
| | | WHERE d.`ir_uid` = #{uid} AND d.`ir_state` = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="countGetCountByTaskIdAndDay" resultType="Integer"> |
| | | SELECT count(*) FROM `yeshi_ec_integral_task_record` |
| | | d |
| | | WHERE |
| | | d.ir_task_id = #{taskId} |
| | | <if test="uid!=null"> |
| | | and ir_uid=#{uid} |
| | | </if> |
| | | |
| | | <if test="minTime!=null"> |
| | | and ir_create_time>=#{minTime} |
| | | </if> |
| | | |
| | | <if test="maxTime!=null"> |
| | | and #{maxTime}>ir_uid |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | package com.yeshi.fanli.service.impl.integral;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.entity.integral.IntegralTask;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTask.FrequencyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.exception.integral.IntegralGetException;
|
| | | import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskService;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service
|
| | | public class IntegralGetServiceImpl implements IntegralGetService {
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskService integralTaskService;
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskRecordService integralTaskRecordService;
|
| | |
|
| | | @Override
|
| | | public void addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException {
|
| | | switch (event) {
|
| | | case "recommendSearch":
|
| | | break;
|
| | | case "shareInvite":
|
| | | break;
|
| | | case "inShop":
|
| | | break;
|
| | | case "scanPush":
|
| | | break;
|
| | | case "scanGoods":
|
| | | break;
|
| | | case "scanHomeBanner":
|
| | | break;
|
| | | case "scanSpecial":
|
| | | break;
|
| | | case "scanTBCart":
|
| | | break;
|
| | | public IntegralTaskRecord addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException {
|
| | | Date nowDate = new Date();
|
| | | IntegralTask task = integralTaskService.getByCidAndUniqueKey(null, event);
|
| | | if (task == null)
|
| | | throw new IntegralGetException(1, "事件类型不存在");
|
| | | if (task.getFrequency() == FrequencyEnum.everyday) {
|
| | | int count = integralTaskRecordService.countGetCountByTaskIdAndDay(task.getId(), uid, nowDate);
|
| | | if (count >= task.getUpperLimit())
|
| | | throw new IntegralGetException(2, "事件触发达到上限");
|
| | | } else if (task.getFrequency() == FrequencyEnum.onlyOne) {
|
| | | int count = integralTaskRecordService.countGetCountByTaskIdAndDay(task.getId(), uid, null);
|
| | | if (count > 0)
|
| | | throw new IntegralGetException(2, "事件触发达到上限");
|
| | | }
|
| | |
|
| | | int goldCoin = task.getGoldCoin();
|
| | | if (task.getDoubleNum() != null && task.getDoubleNum() > 0)
|
| | | goldCoin = task.getDoubleNum() * goldCoin;
|
| | |
|
| | | IntegralTaskRecord record = new IntegralTaskRecord();
|
| | | record.setCid(task.getTaskClass().getId());
|
| | | record.setGoldCoin(goldCoin);
|
| | | record.setState(IntegralTaskRecord.STATE_WAITING_RECIEVE);
|
| | | record.setTaskId(task.getId());
|
| | | record.setUid(uid);
|
| | |
|
| | | try {
|
| | | return integralTaskRecordService.addRecord(record);
|
| | | } catch (IntegralTaskRecordException e) {
|
| | | throw new IntegralGetException(3, "添加记录失败");
|
| | | }
|
| | |
|
| | | // switch (event) {
|
| | | // case "recommendSearch":
|
| | | // break;
|
| | | // case "shareInvite":
|
| | | // break;
|
| | | // case "inShop":
|
| | | // break;
|
| | | // case "scanPush":
|
| | | // break;
|
| | | // case "scanGoods":
|
| | | // break;
|
| | | // case "scanHomeBanner":
|
| | | // break;
|
| | | // case "scanSpecial":
|
| | | // break;
|
| | | // case "scanTBCart":
|
| | | // break;
|
| | | // }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addRecommendSearch(Long uid) throws IntegralGetException {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | }
|
| | |
|
| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | @Service
|
| | | public class IntegralTaskRecordServiceImpl implements IntegralTaskRecordService {
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskRecordMapper integralTaskRecordMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | @Override
|
| | | public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) {
|
| | | return integralTaskRecordMapper.getTotalGoldCoin(uid, cid, dateType);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public Integer countFinished(long uid, Long cid, Integer dateType) {
|
| | | return integralTaskRecordMapper.countFinished(uid, cid, dateType);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void finishedTask(long uid, long cid, long taskId, int goldCoin) {
|
| | | IntegralTaskRecord taskRecord = new IntegralTaskRecord();
|
| | |
| | | taskRecord.setUpdateTime(new Date());
|
| | | integralTaskRecordMapper.insertSelective(taskRecord);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public boolean isToDaySign(long uid, Long cid) {
|
| | | Integer countFinished = integralTaskRecordMapper.countFinished(uid, cid, 1);
|
| | | if (countFinished != null && countFinished > 0) {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | Integer countFinished = integralTaskRecordMapper.countFinished(uid, cid, 1);
|
| | | if (countFinished != null && countFinished > 0) {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public Integer getNowdaySignNum(long uid, Long cid) {
|
| | | int num = 1;
|
| | |
| | | // 签到时间倒序查询近7天数据
|
| | | List<IntegralTaskRecord> list = integralTaskRecordMapper.listDaySignRecord(uid, cid);
|
| | | if (list != null && list.size() > 0) {
|
| | | Date today =new Date();
|
| | | for (IntegralTaskRecord record: list) {
|
| | | if (DateUtil.daysBetween2(record.getCreateTime(),today) == 0) {
|
| | | continue; |
| | | Date today = new Date();
|
| | | for (IntegralTaskRecord record : list) {
|
| | | if (DateUtil.daysBetween2(record.getCreateTime(), today) == 0) {
|
| | | continue;
|
| | | }
|
| | | |
| | | if (DateUtil.daysBetween2(record.getCreateTime(),today) != 1) {
|
| | |
|
| | | if (DateUtil.daysBetween2(record.getCreateTime(), today) != 1) {
|
| | | break; // 天数未连续
|
| | | }
|
| | | today = record.getCreateTime();
|
| | | num ++ ;
|
| | | num++;
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | |
| | |
|
| | | if (num > 7) {
|
| | | num = 1;
|
| | | }
|
| | | return num;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<Date> getSignDays(long uid, Long cid) {
|
| | | List<Date> listDate = new ArrayList<Date>();
|
| | |
| | | List<IntegralTaskRecord> list = integralTaskRecordMapper.listDaySignRecord(uid, cid);
|
| | | if (list != null && list.size() > 0) {
|
| | | Date date = new Date();
|
| | | for (IntegralTaskRecord record: list) {
|
| | | for (IntegralTaskRecord record : list) {
|
| | | Date createTime = record.getCreateTime();
|
| | | if (DateUtil.daysBetween2(createTime,date) > 1) {
|
| | | if (DateUtil.daysBetween2(createTime, date) > 1) {
|
| | | break; // 天数未连续
|
| | | }
|
| | | date = createTime;
|
| | |
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | |
| | |
|
| | | // 倒序
|
| | | Collections.reverse(listDate);
|
| | | Collections.reverse(listDate);
|
| | | return listDate;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<IntegralTaskRecord> listNotReceived(int count, long uid) {
|
| | | return integralTaskRecordMapper.listNotReceived(count, uid);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<IntegralTaskRecord> listNotReceivedExcludeId(int count, long uid, Set<Long> idList) {
|
| | | if (idList != null && idList.size() == 0) {
|
| | |
| | | }
|
| | | return integralTaskRecordMapper.listNotReceivedExcludeId(count, uid, idList);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException {
|
| | | public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException {
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null) |
| | | if (userInfoExtra == null)
|
| | | throw new IntegralTaskRecordException(1, "用户信息不全");
|
| | | |
| | |
|
| | | int totalGoldCoin = integralTaskRecordMapper.countTotalGoldCoin(uid);
|
| | | if (totalGoldCoin > 0) {
|
| | | integralTaskRecordMapper.updateReceived(uid);
|
| | | }
|
| | | |
| | |
|
| | | Integer goldCoin = userInfoExtra.getGoldCoin();
|
| | | if (goldCoin == null) |
| | | if (goldCoin == null)
|
| | | goldCoin = 0;
|
| | | |
| | |
|
| | | UserInfoExtra extra = new UserInfoExtra();
|
| | | extra.setId(userInfoExtra.getId());
|
| | | extra.setGoldCoin(goldCoin + totalGoldCoin);
|
| | |
| | | } catch (UserInfoExtraException e) {
|
| | | throw new IntegralTaskRecordException(1, "用户信息不全");
|
| | | }
|
| | | |
| | |
|
| | | return extra.getGoldCoin();
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException {
|
| | | if(idList == null || idList.size() == 0) {
|
| | | public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException {
|
| | | if (idList == null || idList.size() == 0) {
|
| | | throw new IntegralTaskRecordException(1, "id为空");
|
| | | }
|
| | | |
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null) {
|
| | | throw new IntegralTaskRecordException(1, "用户信息不全");
|
| | | }
|
| | | |
| | |
|
| | | Integer totalGoldCoin = 0;
|
| | | for (Long id: idList) {
|
| | | for (Long id : idList) {
|
| | | IntegralTaskRecord record = integralTaskRecordMapper.selectByPrimaryKey(id);
|
| | | if (record == null) |
| | | if (record == null)
|
| | | continue;
|
| | | |
| | |
|
| | | Long uid2 = record.getUid();
|
| | | if (uid2 == null || uid.longValue() != uid2.longValue())
|
| | | continue; // 用户id不符合
|
| | | |
| | |
|
| | | if (record.getState() != null && record.getState().intValue() == 1) {
|
| | | continue; // 已领取
|
| | | }
|
| | | |
| | |
|
| | | IntegralTaskRecord taskRecord = new IntegralTaskRecord();
|
| | | taskRecord.setId(record.getId());
|
| | | taskRecord.setState(1); // 已领取
|
| | | taskRecord.setUpdateTime(new Date());
|
| | | integralTaskRecordMapper.updateByPrimaryKeySelective(taskRecord);
|
| | | |
| | |
|
| | | totalGoldCoin += record.getGoldCoin();
|
| | | }
|
| | | |
| | |
|
| | | Integer goldCoin = userInfoExtra.getGoldCoin();
|
| | | if (goldCoin == null) |
| | | if (goldCoin == null)
|
| | | goldCoin = 0;
|
| | | |
| | |
|
| | | UserInfoExtra extra = new UserInfoExtra();
|
| | | extra.setId(userInfoExtra.getId());
|
| | | extra.setGoldCoin(goldCoin + totalGoldCoin);
|
| | |
| | | } catch (UserInfoExtraException e) {
|
| | | throw new IntegralTaskRecordException(1, "用户信息不全");
|
| | | }
|
| | | |
| | |
|
| | | return extra.getGoldCoin();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Integer countGetCountByTaskIdAndDay(Long taskId, Long uid, Date day) {
|
| | | if (day == null)
|
| | | return null;
|
| | | Date minTime = new Date(
|
| | | TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(day.getTime(), "yyyy-MM-dd"), "yyyy-MM-dd"));
|
| | | Date maxTime = new Date(minTime.getTime() + 1000 * 60 * 60 * 24L);
|
| | | return integralTaskRecordMapper.countGetCountByTaskIdAndDay(taskId, uid, minTime, maxTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public IntegralTaskRecord addRecord(IntegralTaskRecord record) throws IntegralTaskRecordException {
|
| | | if (record == null)
|
| | | throw new IntegralTaskRecordException(1, "记录为空");
|
| | |
|
| | | if (record.getCid() == null || record.getTaskId() == null || record.getGoldCoin() == null
|
| | | || record.getState() == null || record.getUid() == null)
|
| | | throw new IntegralTaskRecordException(2, "数据不完成");
|
| | |
|
| | | if (record.getCreateTime() == null)
|
| | | record.setCreateTime(new Date());
|
| | |
|
| | | if (record.getUpdateTime() == null)
|
| | | record.setUpdateTime(new Date());
|
| | | integralTaskRecordMapper.insertSelective(record);
|
| | | return record;
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.integral;
|
| | |
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.exception.integral.IntegralGetException;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | * 事件编码
|
| | | * @throws IntegralGetException
|
| | | */
|
| | | public void addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException;
|
| | | public IntegralTaskRecord addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException;
|
| | |
|
| | | /**
|
| | | * 从粘贴板推荐进入搜索结果
|
| | |
| | |
|
| | | public interface IntegralTaskRecordService {
|
| | |
|
| | | |
| | | /**
|
| | | * 待领取金币
|
| | | * |
| | | * @param count
|
| | | * @param uid
|
| | | * @return
|
| | |
| | |
|
| | | /**
|
| | | * 已领取金币
|
| | | * |
| | | * @param uid
|
| | | * @param dateType
|
| | | * @return
|
| | |
| | |
|
| | | /**
|
| | | * 完成任务数量
|
| | | * |
| | | * @param uid
|
| | | * @param cid
|
| | | * @param dateType
|
| | |
| | |
|
| | | /**
|
| | | * 今日是已签到
|
| | | * |
| | | * @param uid
|
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public boolean isToDaySign(long uid, Long cid);
|
| | |
|
| | |
|
| | | /**
|
| | | * 计算今日签到的天数
|
| | | * |
| | | * @param uid
|
| | | * @param cid
|
| | | * @return
|
| | |
| | |
|
| | | /**
|
| | | * 完成任务记录
|
| | | * |
| | | * @param uid
|
| | | * @param cid
|
| | | * @param taskId
|
| | |
| | |
|
| | | /**
|
| | | * 获取已连续签到次数
|
| | | * |
| | | * @param uid
|
| | | * @param cid
|
| | | * @return
|
| | | */
|
| | | public List<Date> getSignDays(long uid, Long cid);
|
| | |
|
| | | |
| | | /**
|
| | | * 领取金币
|
| | | * |
| | | * @param uid
|
| | | * @param idList
|
| | | * @throws IntegralTaskRecordException |
| | | * @throws IntegralTaskRecordException
|
| | | */
|
| | | public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException;
|
| | |
|
| | | /**
|
| | | * 返回领取列表
|
| | | * |
| | | * @param count
|
| | | * @param uid
|
| | | * @param idList
|
| | |
| | |
|
| | | /**
|
| | | * 领取所有
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | * @throws IntegralTaskRecordException
|
| | | */
|
| | | public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException;
|
| | |
|
| | | /**
|
| | | * 根据任务ID与日期获取任务完成数
|
| | | * |
| | | * @param taskId
|
| | | * @param day
|
| | | * @return
|
| | | */
|
| | | public Integer countGetCountByTaskIdAndDay(Long taskId, Long uid, Date day);
|
| | |
|
| | | /**
|
| | | * 添加获取记录
|
| | | * |
| | | * @param record
|
| | | */
|
| | | public IntegralTaskRecord addRecord(IntegralTaskRecord record) throws IntegralTaskRecordException;
|
| | |
|
| | | }
|