Authored by zhouxiang

10.28会员日

@@ -14,3 +14,6 @@ controller/target/ @@ -14,3 +14,6 @@ controller/target/
14 *.class 14 *.class
15 other/ 15 other/
16 target/ 16 target/
  17 +*.name
  18 +queue/.idea/compiler.xml
  19 +queue/.idea/
  1 +package com.yoho.activity.common.bo;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * Created by zhouxiang on 2016/10/29.
  7 + */
  8 +public class DrawPrizeBo {
  9 +
  10 + private Integer prizeType;
  11 +
  12 + private Integer prizeValue;
  13 +
  14 + private Integer drawResult;
  15 +
  16 + public DrawPrizeBo(Integer prizeType, Integer prizeValue, Integer drawResult) {
  17 + this.prizeType = prizeType;
  18 + this.prizeValue = prizeValue;
  19 + this.drawResult = drawResult;
  20 + }
  21 +
  22 + public Integer getPrizeType() {
  23 + return prizeType;
  24 + }
  25 +
  26 + public void setPrizeType(Integer prizeType) {
  27 + this.prizeType = prizeType;
  28 + }
  29 +
  30 + public Integer getPrizeValue() {
  31 + return prizeValue;
  32 + }
  33 +
  34 + public void setPrizeValue(Integer prizeValue) {
  35 + this.prizeValue = prizeValue;
  36 + }
  37 +
  38 + public Integer getDrawResult() {
  39 + return drawResult;
  40 + }
  41 +
  42 + public void setDrawResult(Integer drawResult) {
  43 + this.drawResult = drawResult;
  44 + }
  45 +
  46 + @Override
  47 + public String toString() {
  48 + return "DrawPrizeBo{" +
  49 + "prizeType=" + prizeType +
  50 + ", prizeValue=" + prizeValue +
  51 + ", drawResult=" + drawResult +
  52 + '}';
  53 + }
  54 +}
@@ -18,11 +18,11 @@ public interface IUserdayPrizeLogDAO { @@ -18,11 +18,11 @@ public interface IUserdayPrizeLogDAO {
18 18
19 int updateByPrimaryKey(UserdayPrizeLog record); 19 int updateByPrimaryKey(UserdayPrizeLog record);
20 20
21 - UserdayPrizeLog selectByUidForLeaveWords(Integer uid); 21 + UserdayPrizeLog selectByUidForLeaveWords(@Param("uid") Integer uid,@Param("winningDate") int winningDate);
22 22
23 int insertLog(UserdayPrizeLog userdayPrizeLog); 23 int insertLog(UserdayPrizeLog userdayPrizeLog);
24 24
25 - List<UserdayPrizeLog> selectByUidAndPrizeType(@Param("uid") int uid, @Param("prizeType") int prizeType); 25 + List<UserdayPrizeLog> selectByUidAndPrizeType(@Param("uid") int uid, @Param("drawType") int drawType,@Param("winningDate") int winningDate);
26 26
27 - int selectNumByPrizeType(@Param("prizeType") int prize_type); 27 + int selectNumByPrizeType(@Param("drawType") int draw_type);
28 } 28 }
@@ -12,6 +12,9 @@ public class UserdayPrizeLog extends BaseModel { @@ -12,6 +12,9 @@ public class UserdayPrizeLog extends BaseModel {
12 12
13 private Integer uid; 13 private Integer uid;
14 14
  15 + //抽奖类型
  16 + private Integer drawType;
  17 +
15 // 奖品类型:1-有货币,2-优惠券 18 // 奖品类型:1-有货币,2-优惠券
16 private Integer prizeType; 19 private Integer prizeType;
17 20
@@ -32,6 +35,23 @@ public class UserdayPrizeLog extends BaseModel { @@ -32,6 +35,23 @@ public class UserdayPrizeLog extends BaseModel {
32 this.createTime = createTime; 35 this.createTime = createTime;
33 } 36 }
34 37
  38 + public UserdayPrizeLog(Integer uid, Integer drawType, Integer prizeType, Integer prizeValue, Integer winningDate, Integer createTime) {
  39 + this.uid = uid;
  40 + this.drawType = drawType;
  41 + this.prizeType = prizeType;
  42 + this.prizeValue = prizeValue;
  43 + this.winningDate = winningDate;
  44 + this.createTime = createTime;
  45 + }
  46 +
  47 + public Integer getDrawType() {
  48 + return drawType;
  49 + }
  50 +
  51 + public void setDrawType(Integer drawType) {
  52 + this.drawType = drawType;
  53 + }
  54 +
35 public Integer getId() { 55 public Integer getId() {
36 return id; 56 return id;
37 } 57 }
@@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
5 <id column="id" property="id" jdbcType="INTEGER" /> 5 <id column="id" property="id" jdbcType="INTEGER" />
6 <result column="uid" property="uid" jdbcType="INTEGER" /> 6 <result column="uid" property="uid" jdbcType="INTEGER" />
7 <result column="prize_type" property="prizeType" jdbcType="INTEGER" /> 7 <result column="prize_type" property="prizeType" jdbcType="INTEGER" />
  8 + <result column="draw_type" property="drawType" jdbcType="INTEGER" />
8 <result column="prize_value" property="prizeValue" jdbcType="INTEGER" /> 9 <result column="prize_value" property="prizeValue" jdbcType="INTEGER" />
9 <result column="winning_date" property="winningDate" jdbcType="INTEGER" /> 10 <result column="winning_date" property="winningDate" jdbcType="INTEGER" />
10 <result column="create_time" property="createTime" jdbcType="INTEGER" /> 11 <result column="create_time" property="createTime" jdbcType="INTEGER" />
11 </resultMap> 12 </resultMap>
12 <sql id="Base_Column_List"> 13 <sql id="Base_Column_List">
13 - id, uid, prize_type, prize_value, winning_date, create_time 14 + id, uid, prize_type, prize_value, winning_date, create_time,draw_type
14 </sql> 15 </sql>
15 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer"> 16 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
16 select 17 select
@@ -108,25 +109,26 @@ @@ -108,25 +109,26 @@
108 select 109 select
109 <include refid="Base_Column_List" /> 110 <include refid="Base_Column_List" />
110 from userday_prize_log 111 from userday_prize_log
111 - where uid = #{uid,jdbcType=INTEGER} and prize_type = 2 and winning_date = UNIX_TIMESTAMP(CURRENT_DATE()) limit 1 112 + where uid = #{uid,jdbcType=INTEGER} and draw_type = 2 and winning_date = #{winningDate,jdbcType=INTEGER} limit 1
112 </select> 113 </select>
113 <select id="selectByUidAndPrizeType" resultMap="BaseResultMap"> 114 <select id="selectByUidAndPrizeType" resultMap="BaseResultMap">
114 select 115 select
115 <include refid="Base_Column_List" /> 116 <include refid="Base_Column_List" />
116 from userday_prize_log 117 from userday_prize_log
117 - where uid = #{uid,jdbcType=INTEGER} and prize_type = #{prizeType,jdbcType=INTEGER} and winning_date = UNIX_TIMESTAMP(CURRENT_DATE()) 118 + where uid = #{uid,jdbcType=INTEGER} and draw_type = #{drawType,jdbcType=INTEGER} and winning_date = #{winningDate,jdbcType=INTEGER}
118 ORDER BY create_time DESC 119 ORDER BY create_time DESC
119 </select> 120 </select>
120 <select id="selectNumByPrizeType" resultType="java.lang.Integer"> 121 <select id="selectNumByPrizeType" resultType="java.lang.Integer">
121 - select IFNULL(COUNT(DISTINCT uid), 0) from userday_prize_log where prize_type = #{prizeType,jdbcType=INTEGER} 122 + select IFNULL(COUNT(DISTINCT uid), 0) from userday_prize_log where draw_type = #{drawType,jdbcType=INTEGER}
122 </select> 123 </select>
123 124
124 <insert id="insertLog" parameterType="com.yoho.userday.dal.model.UserdayPrizeLog"> 125 <insert id="insertLog" parameterType="com.yoho.userday.dal.model.UserdayPrizeLog">
125 insert into userday_prize_log (uid, prize_type, 126 insert into userday_prize_log (uid, prize_type,
126 - prize_value, winning_date, create_time 127 + prize_value, winning_date, create_time,draw_type
127 ) 128 )
128 values (#{uid,jdbcType=INTEGER}, #{prizeType,jdbcType=INTEGER}, 129 values (#{uid,jdbcType=INTEGER}, #{prizeType,jdbcType=INTEGER},
129 - #{prizeValue,jdbcType=INTEGER}, UNIX_TIMESTAMP(CURRENT_DATE()), #{createTime,jdbcType=INTEGER} 130 + #{prizeValue,jdbcType=INTEGER}, #{winningDate,jdbcType=INTEGER},
  131 + #{createTime,jdbcType=INTEGER}, #{drawType,jdbcType=INTEGER}
130 ) 132 )
131 </insert> 133 </insert>
132 </mapper> 134 </mapper>
1 package com.yoho.activity.service; 1 package com.yoho.activity.service;
2 2
  3 +import com.yoho.activity.common.bo.DrawPrizeBo;
3 import com.yoho.userday.dal.model.UserdayPrizeLog; 4 import com.yoho.userday.dal.model.UserdayPrizeLog;
4 5
5 import java.util.List; 6 import java.util.List;
@@ -9,7 +10,7 @@ import java.util.List; @@ -9,7 +10,7 @@ import java.util.List;
9 */ 10 */
10 public interface IUserdayDrawPrizeService { 11 public interface IUserdayDrawPrizeService {
11 12
12 - int drawPrize(int uid) throws Exception; 13 + DrawPrizeBo drawPrize(int uid) throws Exception;
13 14
14 boolean existsPrizeLog(List<UserdayPrizeLog> userdayPrizeLogList); 15 boolean existsPrizeLog(List<UserdayPrizeLog> userdayPrizeLogList);
15 } 16 }
  1 +package com.yoho.activity.service.impl;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.yoho.activity.common.bo.DrawPrizeBo;
  5 +import com.yoho.activity.common.helper.SendCouponHelper;
  6 +import com.yoho.activity.service.IUserdayDrawPrizeService;
  7 +import com.yoho.error.exception.ServiceException;
  8 +import com.yoho.userday.dal.model.UserdayPrizeLog;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.beans.factory.annotation.Value;
  13 +import org.springframework.stereotype.Service;
  14 +import org.springframework.util.StringUtils;
  15 +
  16 +import javax.annotation.Resource;
  17 +import java.util.List;
  18 +import java.util.Map;
  19 +import java.util.Random;
  20 +
  21 +/**
  22 + * 会员日,抽奖
  23 + */
  24 +@Service
  25 +public class UserdayDrawCouponOrCoinServiceImpl implements IUserdayDrawPrizeService {
  26 +
  27 + private static final Logger log = LoggerFactory.getLogger(UserdayDrawCouponOrCoinServiceImpl.class);
  28 +
  29 + @Autowired
  30 + private SendCouponHelper sendCouponHelper;
  31 +
  32 + @Resource(name = "couponMap")
  33 + private Map<Integer,Integer> couponMap;
  34 +
  35 + @Override
  36 + public DrawPrizeBo drawPrize(int uid) throws Exception {
  37 + log.info("enter drawPrize. param uid={}", uid);
  38 +
  39 + // (1)校验uid
  40 + if (1 > uid) {
  41 + throw new ServiceException(401, "参数不合法");
  42 + }
  43 +
  44 + //获取中奖返回对象
  45 + DrawPrizeBo drawPrizeBo = getDrawPrize();
  46 + log.info("drawPrize: draw prize complete. drawPrizeBo {}", drawPrizeBo);
  47 + // 发送有货币
  48 + if (1 == drawPrizeBo.getPrizeType().intValue()) {
  49 + Boolean isSuccess = sendCouponHelper.sendYOHOBi(uid, drawPrizeBo.getPrizeValue(), 6);
  50 + if(!isSuccess){
  51 + //设置为未中奖
  52 + drawPrizeBo.setDrawResult(0);
  53 + drawPrizeBo.setPrizeType(0);
  54 + drawPrizeBo.setPrizeValue(0);
  55 + }
  56 + return drawPrizeBo;
  57 + }
  58 + // 发送优惠券
  59 + if (2 == drawPrizeBo.getPrizeType().intValue()) {
  60 + String couponCode = sendCouponHelper.sendCoupon(drawPrizeBo.getPrizeValue().toString(), uid);
  61 + if(StringUtils.isEmpty(couponCode)){
  62 + //设置为未中奖
  63 + drawPrizeBo.setDrawResult(0);
  64 + drawPrizeBo.setPrizeType(0);
  65 + drawPrizeBo.setPrizeValue(0);
  66 + }
  67 + return drawPrizeBo;
  68 + }
  69 + // (4)返回
  70 + return drawPrizeBo;
  71 + }
  72 +
  73 + @Override
  74 + public boolean existsPrizeLog(List<UserdayPrizeLog> userdayPrizeLogList) {
  75 + log.debug("enter existsPrizeLog.");
  76 +
  77 + // 返回
  78 + if (null != userdayPrizeLogList && 0 < userdayPrizeLogList.size()) {
  79 + return true;
  80 + }
  81 + return false;
  82 + }
  83 +
  84 + /**
  85 + * 抽奖
  86 + * @return
  87 + */
  88 + private DrawPrizeBo getDrawPrize() {
  89 + int random = new Random().nextInt(100);
  90 + //100有货币(15%)
  91 + if (random > 84) {
  92 + return new DrawPrizeBo(1,100,1);
  93 + }
  94 + //200有货币(4%)
  95 + if(random > 80){
  96 + return new DrawPrizeBo(1,200,2);
  97 + }
  98 + //500有货币(1%)
  99 + if(random > 79){
  100 + return new DrawPrizeBo(1,500,3);
  101 + }
  102 + //10元优惠券(40%)
  103 + if(random > 39){
  104 + return new DrawPrizeBo(2,couponMap.get(10),4);
  105 + }
  106 + //299-40优惠券(35%)
  107 + if(random > 4){
  108 + return new DrawPrizeBo(2,couponMap.get(40),5);
  109 + }
  110 + //499-70优惠券(5%)
  111 + return new DrawPrizeBo(2,couponMap.get(70),6);
  112 + }
  113 +}
1 package com.yoho.activity.service.impl; 1 package com.yoho.activity.service.impl;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
  4 +import com.yoho.activity.common.bo.DrawPrizeBo;
4 import com.yoho.activity.common.helper.SendCouponHelper; 5 import com.yoho.activity.common.helper.SendCouponHelper;
5 import com.yoho.activity.service.IUserdayDrawPrizeService; 6 import com.yoho.activity.service.IUserdayDrawPrizeService;
6 import com.yoho.error.exception.ServiceException; 7 import com.yoho.error.exception.ServiceException;
@@ -29,7 +30,7 @@ public class UserdayDrawCouponServiceImpl implements IUserdayDrawPrizeService { @@ -29,7 +30,7 @@ public class UserdayDrawCouponServiceImpl implements IUserdayDrawPrizeService {
29 private String prizeConpon; 30 private String prizeConpon;
30 31
31 @Override 32 @Override
32 - public int drawPrize(int uid) throws Exception { 33 + public DrawPrizeBo drawPrize(int uid) throws Exception {
33 log.info("enter drawPrize. param uid={}", uid); 34 log.info("enter drawPrize. param uid={}", uid);
34 35
35 // (1)校验uid 36 // (1)校验uid
@@ -54,9 +55,7 @@ public class UserdayDrawCouponServiceImpl implements IUserdayDrawPrizeService { @@ -54,9 +55,7 @@ public class UserdayDrawCouponServiceImpl implements IUserdayDrawPrizeService {
54 } 55 }
55 56
56 // (4)返回 57 // (4)返回
57 - return couponId;  
58 -  
59 - 58 + return new DrawPrizeBo(1,couponId,couponId);
60 } 59 }
61 60
62 @Override 61 @Override
1 package com.yoho.activity.service.impl; 1 package com.yoho.activity.service.impl;
2 2
  3 +import com.yoho.activity.common.bo.DrawPrizeBo;
3 import com.yoho.activity.common.helper.SendCouponHelper; 4 import com.yoho.activity.common.helper.SendCouponHelper;
4 import com.yoho.activity.service.IUserdayDrawPrizeService; 5 import com.yoho.activity.service.IUserdayDrawPrizeService;
5 import com.yoho.core.rest.client.ServiceCaller; 6 import com.yoho.core.rest.client.ServiceCaller;
@@ -29,7 +30,7 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService @@ -29,7 +30,7 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService
29 ServiceCaller serviceCaller; 30 ServiceCaller serviceCaller;
30 31
31 @Override 32 @Override
32 - public int drawPrize(int uid) throws Exception { 33 + public DrawPrizeBo drawPrize(int uid) throws Exception {
33 log.info("enter drawPrize. param uid={}", uid); 34 log.info("enter drawPrize. param uid={}", uid);
34 35
35 // (1)校验uid 36 // (1)校验uid
@@ -70,7 +71,7 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService @@ -70,7 +71,7 @@ public class UserdayDrawYohoCoinServiceImpl implements IUserdayDrawPrizeService
70 } 71 }
71 72
72 // (6)返回 73 // (6)返回
73 - return yohoCoinNum; 74 + return new DrawPrizeBo(1,yohoCoinNum,yohoCoinNum);
74 } 75 }
75 76
76 @Override 77 @Override
1 package com.yoho.activity.service.impl; 1 package com.yoho.activity.service.impl;
2 2
3 -import java.util.ArrayList;  
4 -import java.util.List;  
5 -import java.util.Map; 3 +import java.util.*;
6 4
7 import javax.annotation.Resource; 5 import javax.annotation.Resource;
8 6
  7 +import com.yoho.activity.common.bo.DrawPrizeBo;
9 import com.yoho.activity.common.redis.CacheKeyEnum; 8 import com.yoho.activity.common.redis.CacheKeyEnum;
10 import com.yoho.activity.common.redis.RedisValueCache; 9 import com.yoho.activity.common.redis.RedisValueCache;
11 import org.apache.commons.collections.CollectionUtils; 10 import org.apache.commons.collections.CollectionUtils;
@@ -14,7 +13,6 @@ import org.slf4j.LoggerFactory; @@ -14,7 +13,6 @@ import org.slf4j.LoggerFactory;
14 import org.springframework.beans.BeanUtils; 13 import org.springframework.beans.BeanUtils;
15 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.beans.factory.annotation.Value; 15 import org.springframework.beans.factory.annotation.Value;
17 -import org.springframework.stereotype.Service;  
18 16
19 import com.yoho.activity.common.utils.DateUtils; 17 import com.yoho.activity.common.utils.DateUtils;
20 import com.yoho.activity.service.IUserdayDrawPrizeService; 18 import com.yoho.activity.service.IUserdayDrawPrizeService;
@@ -28,7 +26,6 @@ import com.yoho.userday.dal.model.UserdayPrizeLog; @@ -28,7 +26,6 @@ import com.yoho.userday.dal.model.UserdayPrizeLog;
28 /** 26 /**
29 * 会员日,中奖记录 27 * 会员日,中奖记录
30 */ 28 */
31 -@Service  
32 public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService { 29 public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
33 30
34 private static final Logger log = LoggerFactory.getLogger(UserdayPrizeLogServiceImpl.class); 31 private static final Logger log = LoggerFactory.getLogger(UserdayPrizeLogServiceImpl.class);
@@ -43,6 +40,8 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService { @@ -43,6 +40,8 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
43 @Value("${userday.open.day}") 40 @Value("${userday.open.day}")
44 String userdayOpenDay; 41 String userdayOpenDay;
45 42
  43 + private Map<Integer,String> errMsg;
  44 +
46 @Override 45 @Override
47 public UserdayPrizeLog queryPrizeLogForLeaveWords(int uid) throws Exception { 46 public UserdayPrizeLog queryPrizeLogForLeaveWords(int uid) throws Exception {
48 log.info("enter queryPrizeLogForLeaveWords. param uid={}", uid); 47 log.info("enter queryPrizeLogForLeaveWords. param uid={}", uid);
@@ -52,18 +51,18 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService { @@ -52,18 +51,18 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
52 throw new ServiceException(401, "参数不合法"); 51 throw new ServiceException(401, "参数不合法");
53 } 52 }
54 53
55 - return userdayPrizeLogDAO.selectByUidForLeaveWords(uid); 54 + return userdayPrizeLogDAO.selectByUidForLeaveWords(uid,getTodyTime());
56 } 55 }
57 56
58 @Override 57 @Override
59 - public int addPrizeLog(int uid, int prize_type) throws Exception {  
60 - log.info("enter addPrizeLog. param uid={}, prize_type={}", uid, prize_type); 58 + public int addPrizeLog(int uid, int draw_type) throws Exception {
  59 + log.info("enter addPrizeLog. param uid={}, prize_type={}", uid, draw_type);
61 60
62 // (1)校验uid, prize_type 61 // (1)校验uid, prize_type
63 - if (1 > uid || 1 > prize_type) { 62 + if (1 > uid || 1 > draw_type) {
64 throw new ServiceException(401, "参数不合法"); 63 throw new ServiceException(401, "参数不合法");
65 } 64 }
66 - IUserdayDrawPrizeService userdayDrawPrizeService = userdayDrawPrizeServiceMap.get(prize_type); 65 + IUserdayDrawPrizeService userdayDrawPrizeService = userdayDrawPrizeServiceMap.get(draw_type);
67 if (null == userdayDrawPrizeService) { 66 if (null == userdayDrawPrizeService) {
68 throw new ServiceException(401, "参数不合法"); 67 throw new ServiceException(401, "参数不合法");
69 } 68 }
@@ -74,22 +73,23 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService { @@ -74,22 +73,23 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
74 throw new ServiceException(403, "非会员日,不允许抽奖"); 73 throw new ServiceException(403, "非会员日,不允许抽奖");
75 } 74 }
76 75
77 - // (3)是否参加过疯狂大转盘  
78 - if (2 == prize_type) {  
79 - List<UserdayPrizeLog> userdayPrizeLogList = userdayPrizeLogDAO.selectByUidAndPrizeType(uid, prize_type); 76 + // (3)是否参加过疯狂大转盘 或 3学生专享优惠抽奖
  77 + if (2 == draw_type || 3 == draw_type) {
  78 + List<UserdayPrizeLog> userdayPrizeLogList = userdayPrizeLogDAO.selectByUidAndPrizeType(uid, draw_type,getTodyTime());
80 if (null != userdayPrizeLogList && 0 < userdayPrizeLogList.size()) { 79 if (null != userdayPrizeLogList && 0 < userdayPrizeLogList.size()) {
81 - throw new ServiceException(406, "您今天已经参加过疯狂大转盘"); 80 + throw new ServiceException(406, errMsg.get(draw_type));
82 } 81 }
83 } 82 }
84 83
85 - // (4)获取奖品值  
86 - int prize_value = userdayDrawPrizeService.drawPrize(uid); 84 + // (4)获取奖品返回对象
  85 + DrawPrizeBo drawPrize = userdayDrawPrizeService.drawPrize(uid);
87 86
88 // (5)保存抽奖日志 87 // (5)保存抽奖日志
89 - UserdayPrizeLog userdayPrizeLog = new UserdayPrizeLog(uid, prize_type, prize_value, DateUtil.currentTimeSeconds()); 88 + UserdayPrizeLog userdayPrizeLog = new UserdayPrizeLog(uid, draw_type,drawPrize.getPrizeType(),
  89 + drawPrize.getPrizeValue(),getTodyTime(), DateUtil.currentTimeSeconds());
90 userdayPrizeLogDAO.insertLog(userdayPrizeLog); 90 userdayPrizeLogDAO.insertLog(userdayPrizeLog);
91 91
92 - return prize_value; 92 + return drawPrize.getDrawResult();
93 } 93 }
94 94
95 @Override 95 @Override
@@ -106,7 +106,7 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService { @@ -106,7 +106,7 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
106 } 106 }
107 107
108 // (2)查询当天中奖日志 108 // (2)查询当天中奖日志
109 - List<UserdayPrizeLog> userdayPrizeLogList = userdayPrizeLogDAO.selectByUidAndPrizeType(uid, prize_type); 109 + List<UserdayPrizeLog> userdayPrizeLogList = userdayPrizeLogDAO.selectByUidAndPrizeType(uid, prize_type,getTodyTime());
110 110
111 // (3)返回 111 // (3)返回
112 return userdayDrawPrizeService.existsPrizeLog(userdayPrizeLogList); 112 return userdayDrawPrizeService.existsPrizeLog(userdayPrizeLogList);
@@ -122,7 +122,7 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService { @@ -122,7 +122,7 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
122 } 122 }
123 123
124 // (2)查询当天中奖日志 124 // (2)查询当天中奖日志
125 - List<UserdayPrizeLog> userdayPrizeLogList = userdayPrizeLogDAO.selectByUidAndPrizeType(uid, prize_type); 125 + List<UserdayPrizeLog> userdayPrizeLogList = userdayPrizeLogDAO.selectByUidAndPrizeType(uid, prize_type,getTodyTime());
126 if (CollectionUtils.isEmpty(userdayPrizeLogList)) { 126 if (CollectionUtils.isEmpty(userdayPrizeLogList)) {
127 return null; 127 return null;
128 } 128 }
@@ -140,11 +140,24 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService { @@ -140,11 +140,24 @@ public class UserdayPrizeLogServiceImpl implements IUserdayPrizeLogService {
140 } 140 }
141 141
142 @Override 142 @Override
143 - public int queryPrizeLogNum(int prize_type) {  
144 - log.info("enter queryPrizeLogNum. param prize_type={}", prize_type);  
145 - int realNum = userdayPrizeLogDAO.selectNumByPrizeType(prize_type); 143 + public int queryPrizeLogNum(int draw_type) {
  144 + log.info("enter queryPrizeLogNum. param draw_type={}", draw_type);
  145 + int realNum = userdayPrizeLogDAO.selectNumByPrizeType(draw_type);
146 Integer virtualNum = redisValueCache.get(CacheKeyEnum.USERDAY_DRAWPRIZENUM, "", Integer.class); 146 Integer virtualNum = redisValueCache.get(CacheKeyEnum.USERDAY_DRAWPRIZENUM, "", Integer.class);
147 return realNum + (null == virtualNum ? 0 : virtualNum); 147 return realNum + (null == virtualNum ? 0 : virtualNum);
148 } 148 }
149 149
  150 + public void setErrMsg(Map<Integer, String> errMsg) {
  151 + this.errMsg = errMsg;
  152 + }
  153 +
  154 + /**
  155 + * 获取当天时间
  156 + * @return
  157 + */
  158 + private int getTodyTime(){
  159 + long current=System.currentTimeMillis();//当前时间毫秒数
  160 + long zero = current / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();
  161 + return (int) (zero/1000);
  162 + }
150 } 163 }
@@ -47,8 +47,24 @@ @@ -47,8 +47,24 @@
47 value-type="com.yoho.activity.service.IUserdayDrawPrizeService"> 47 value-type="com.yoho.activity.service.IUserdayDrawPrizeService">
48 <entry key="1" value-ref="userdayDrawYohoCoinServiceImpl"></entry> 48 <entry key="1" value-ref="userdayDrawYohoCoinServiceImpl"></entry>
49 <entry key="2" value-ref="userdayDrawCouponServiceImpl"></entry> 49 <entry key="2" value-ref="userdayDrawCouponServiceImpl"></entry>
  50 + <entry key="3" value-ref="userdayDrawCouponOrCoinServiceImpl"></entry>
50 </util:map> 51 </util:map>
51 52
  53 + <util:map id="couponMap" key-type="java.lang.Integer" value-type="java.lang.Integer">
  54 + <entry key="10" value="14144"/>
  55 + <entry key="40" value="14146"/>
  56 + <entry key="70" value="14148"/>
  57 + </util:map>
  58 +
  59 + <bean id="userdayPrizeLogServiceImpl" class="com.yoho.activity.service.impl.UserdayPrizeLogServiceImpl">
  60 + <property name="errMsg">
  61 + <map>
  62 + <entry key="2" value="您今天已经参加过疯狂大转盘"/>
  63 + <entry key="3" value="抱歉您的抽奖次数已用完,更多抽奖机会请关注下个会员日"/>
  64 + </map>
  65 + </property>
  66 + </bean>
  67 +
52 <mvc:interceptors> 68 <mvc:interceptors>
53 <ref bean="securityInterceptor" /> 69 <ref bean="securityInterceptor" />
54 <ref bean="threadProfileInterceptor" /> 70 <ref bean="threadProfileInterceptor" />
@@ -73,5 +73,5 @@ rabbit_password=yoho @@ -73,5 +73,5 @@ rabbit_password=yoho
73 73
74 74
75 userday.coupon={"20":"14146", "10":"14144"} 75 userday.coupon={"20":"14146", "10":"14144"}
76 -userday.open.day=18 76 +userday.open.day=28
77 userday.drawPrizeNum.redisSwitch=true 77 userday.drawPrizeNum.redisSwitch=true