admin
2019-08-21 f1a2d46aaa612253afba7b1d61ad04a2f0ef7eed
金币获得客户端事件添加
9个文件已修改
394 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralTaskRecordMapper.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/integral/IntegralTaskRecord.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralTaskMapper.xml 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralTaskRecordMapper.xml 109 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java 84 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralGetService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralTaskRecordService.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -34,11 +34,10 @@
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;
@@ -46,6 +45,7 @@
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;
@@ -99,6 +99,9 @@
    
    @Resource
    private IntegralTaskService integralTaskService;
    @Resource
    private IntegralGetService integralGetService;
    /**
     * 获取任务列表
@@ -178,7 +181,6 @@
                data.put("dailySign", dailySignVO);
            }
            for (IntegralTaskClassVO taskClassVO : list) {
                String progress = taskClassVO.getProgress();
                if (StringUtil.isNullOrEmpty(progress))
@@ -202,7 +204,8 @@
                    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();
@@ -281,12 +284,15 @@
     * 
     * @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;
@@ -311,7 +317,8 @@
                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);
@@ -515,27 +522,33 @@
            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;
        }
        JSONObject data = new JSONObject();
        if ("recommendSearch".equalsIgnoreCase(event) || "scanGoods".equalsIgnoreCase(event)
                || "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));
@@ -607,7 +620,6 @@
        return gson;
    }
    /**
     * 明细详情
     * 
@@ -619,7 +631,8 @@
     *            年份
     * @param month
     *            月份
     *  @param type  统计类型  0全部  1
     * @param type
     *            统计类型 0全部 1
     * @param out
     */
    @RequestMapping(value = "getDetails")
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralTaskRecordMapper.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.dao.mybatis.integral;
import java.util.Date;
import java.util.List;
import java.util.Set;
@@ -12,15 +13,16 @@
    /**
     * 未领取金币
     *
     * @param count
     * @param uid
     * @return
     */
    List<IntegralTaskRecord> listNotReceived(@Param("count") int count, @Param("uid") Long uid);
    
    /**
     * 未领取金币- 排除id
     *
     * @param count
     * @param uid
     * @return
@@ -28,9 +30,9 @@
    List<IntegralTaskRecord> listNotReceivedExcludeId(@Param("count") int count, @Param("uid") Long uid,
            @Param("list")Set<Long> idList);
    
    /**
     * 总完成
     *
     * @param uid
     * @param dateType
     * @return
@@ -39,6 +41,7 @@
    
    /**
     * 统计完成数量
     *
     * @param uid
     * @param cid
     * @param dateType
@@ -48,16 +51,18 @@
    
    /**
     * 近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
@@ -66,9 +71,19 @@
    
    /**
     * 更新领取状态
     *
     * @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);
}
fanli/src/main/java/com/yeshi/fanli/entity/integral/IntegralTaskRecord.java
@@ -20,6 +20,10 @@
 */
@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;// 失效
    /**
     * 
     */
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralTaskMapper.xml
@@ -13,7 +13,8 @@
    <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"/>
        <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">
@@ -32,20 +33,34 @@
    <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"/>
        <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">
        <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}
    <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
    <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>
@@ -59,7 +74,8 @@
      <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>
        values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="taskClass != null">#{taskClass.id,jdbcType=BIGINT},</if>
@@ -75,8 +91,22 @@
      <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
    <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>
@@ -89,7 +119,8 @@
      <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}
        </set>
        where it_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="listByCid" resultMap="SimpleResultMap">
@@ -99,7 +130,11 @@
  
   <select id="getByCidAndUniqueKey" resultMap="SimpleResultMap">
      SELECT * FROM yeshi_ec_integral_task 
     WHERE it_state = 1 AND it_cid = #{cid}  AND it_unique_key = #{uniqueKey}
        WHERE it_state = 1
        <if test="cid!=null">
            AND it_cid = #{cid}
        </if>
        AND it_unique_key = #{uniqueKey}
     LIMIT 1
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralTaskRecordMapper.xml
@@ -2,7 +2,8 @@
<!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">
    <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"/>
@@ -14,13 +15,27 @@
    
    <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}
    <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
    <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>
@@ -30,7 +45,8 @@
      <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>
        values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="cid != null">#{cid,jdbcType=BIGINT},</if>
@@ -42,8 +58,17 @@
      <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
    <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>
@@ -52,31 +77,40 @@
      <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}
        </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()
        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
        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}
        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`
        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=")">
            <foreach collection="list" item="item" open="(" separator=","
                close=")">
                 ${item}
             </foreach>
         </if>
@@ -85,15 +119,18 @@
  </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 -->
        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
        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())
@@ -102,13 +139,37 @@
  
  <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)
        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
        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>
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java
@@ -1,40 +1,86 @@
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
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java
@@ -20,6 +20,8 @@
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 {
@@ -92,7 +94,6 @@
        return num;
    }
    
    @Override
    public List<Date> getSignDays(long uid, Long cid) {
        List<Date> listDate = new ArrayList<Date>();
@@ -124,7 +125,6 @@
        return integralTaskRecordMapper.listNotReceived(count, uid);
    }
    
    @Override
    public List<IntegralTaskRecord> listNotReceivedExcludeId(int count, long uid, Set<Long> idList) {
        if (idList != null && idList.size() == 0) {
@@ -132,7 +132,6 @@
        }
        return integralTaskRecordMapper.listNotReceivedExcludeId(count, uid, idList);
    }
    
    @Override
    @Transactional
@@ -161,8 +160,6 @@
        
        return extra.getGoldCoin();
    }
    
    @Override
    @Transactional
@@ -214,5 +211,32 @@
        
        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;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralGetService.java
@@ -1,5 +1,6 @@
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;
@@ -22,7 +23,7 @@
     *            事件编码
     * @throws IntegralGetException
     */
    public void addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException;
    public IntegralTaskRecord addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException;
    /**
     * 从粘贴板推荐进入搜索结果
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralTaskRecordService.java
@@ -9,9 +9,9 @@
public interface IntegralTaskRecordService {
    /**
     * 待领取金币
     *
     * @param count
     * @param uid
     * @return
@@ -20,6 +20,7 @@
    /**
     * 已领取金币
     *
     * @param uid
     * @param dateType
     * @return
@@ -28,6 +29,7 @@
    /**
     * 完成任务数量
     *
     * @param uid
     * @param cid
     * @param dateType
@@ -37,15 +39,16 @@
    /**
     * 今日是已签到
     *
     * @param uid
     * @param cid
     * @return
     */
    public boolean isToDaySign(long uid, Long cid);
    /**
     * 计算今日签到的天数
     *
     * @param uid
     * @param cid
     * @return
@@ -54,6 +57,7 @@
    /**
     * 完成任务记录
     *
     * @param uid
     * @param cid
     * @param taskId
@@ -63,15 +67,16 @@
    /**
     * 获取已连续签到次数
     *
     * @param uid
     * @param cid
     * @return
     */
    public List<Date> getSignDays(long uid, Long cid);
    /**
     * 领取金币
     *
     * @param uid
     * @param idList
     * @throws IntegralTaskRecordException 
@@ -80,6 +85,7 @@
    /**
     * 返回领取列表
     *
     * @param count
     * @param uid
     * @param idList
@@ -89,10 +95,27 @@
    /**
     * 领取所有
     *
     * @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;
}