|
@@ -11,6 +11,7 @@ import java.util.Random;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import org.apache.commons.io.filefilter.FalseFileFilter;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -53,9 +54,10 @@ public class PrizeController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/luckDraw")
|
|
|
- public void luckDraw(Integer userId, HttpServletResponse response)
|
|
|
+ public void luckDraw(@RequestParam(required = false) Integer userId, HttpServletResponse response)
|
|
|
throws Exception, KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ userId = new Random().nextInt(6)+1;//测试用
|
|
|
Integer count = -1;
|
|
|
PrizeRecord prizeRecord = new PrizeRecord();
|
|
|
User user = usermapper.selectByPrimaryKey(userId);
|
|
@@ -66,35 +68,52 @@ public class PrizeController {
|
|
|
UserPrizeCountExample uExp = new UserPrizeCountExample();
|
|
|
Integer luckDrawCount = UserPrizeCountMapper.selectCountByTodayByUid(userId);
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
- if (luckDrawCount == 0) {
|
|
|
- // 直接抽奖
|
|
|
- count = getLuckDraw(prizeRecord, count);
|
|
|
- // 添加抽奖记录
|
|
|
- UserPrizeCount userPrizeCount = new UserPrizeCount();
|
|
|
- userPrizeCount.setUserId(userId);
|
|
|
- UserPrizeCountMapper.insert(userPrizeCount);
|
|
|
- map.put("prizeLevel", count);
|
|
|
+ // 模拟无限次数抽奖
|
|
|
+ // 测试必定中奖账号
|
|
|
+ if ("o1L3L5vwFkGSUMpec3uwRgsI6A-M".equals(user.getVoucherId())) {
|
|
|
+ Prize prize = prizeMapper.selectByPrimaryKey(1);
|
|
|
+ // UserPrizeCount userPrizeCount = new UserPrizeCount();
|
|
|
+ // userPrizeCount.setUserId(userId);
|
|
|
+ // UserPrizeCountMapper.insert(userPrizeCount);
|
|
|
+ map.put("prizeLevel", 0);
|
|
|
map.put("prizeRecord", prizeRecord);
|
|
|
+ map.put("prize", prize);
|
|
|
msg.data = map;
|
|
|
- } else if (luckDrawCount == 1) {
|
|
|
- int opportunityCount = prizeOpportunityMapper.selectCountByToday(userId);
|
|
|
- if (opportunityCount > 0) {
|
|
|
- // 直接抽奖
|
|
|
- count = getLuckDraw(prizeRecord, count);
|
|
|
- // 添加抽奖记录
|
|
|
- UserPrizeCount userPrizeCount = new UserPrizeCount();
|
|
|
- userPrizeCount.setUserId(userId);
|
|
|
- UserPrizeCountMapper.insert(userPrizeCount);
|
|
|
- map.put("prizeLevel", count);
|
|
|
- map.put("prizeRecord", prizeRecord);
|
|
|
- msg.data = map;
|
|
|
- }else{
|
|
|
- msg.setError("抽奖次数已达上限,去分享即可获得抽奖机会");
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- msg.setError("抽奖次数已达上限");
|
|
|
+ response.setContentType("application/json");
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ response.getWriter().println(msg.toJSONStr());
|
|
|
+ return;
|
|
|
}
|
|
|
+ // if (luckDrawCount == 0) {
|
|
|
+ // 直接抽奖
|
|
|
+ count = getLuckDraw(prizeRecord, count);
|
|
|
+ // 添加抽奖记录
|
|
|
+ UserPrizeCount userPrizeCount = new UserPrizeCount();
|
|
|
+ userPrizeCount.setUserId(userId);
|
|
|
+ UserPrizeCountMapper.insert(userPrizeCount);
|
|
|
+ map.put("prizeLevel", count);
|
|
|
+ map.put("prizeRecord", prizeRecord);
|
|
|
+ msg.data = map;
|
|
|
+ // } else if (luckDrawCount == 1) {
|
|
|
+ // int opportunityCount =
|
|
|
+ // prizeOpportunityMapper.selectCountByToday(userId);
|
|
|
+ // if (opportunityCount > 0) {
|
|
|
+ // // 直接抽奖
|
|
|
+ // count = getLuckDraw(prizeRecord, count);
|
|
|
+ // // 添加抽奖记录
|
|
|
+ // UserPrizeCount userPrizeCount = new UserPrizeCount();
|
|
|
+ // userPrizeCount.setUserId(userId);
|
|
|
+ // UserPrizeCountMapper.insert(userPrizeCount);
|
|
|
+ // map.put("prizeLevel", count);
|
|
|
+ // map.put("prizeRecord", prizeRecord);
|
|
|
+ // msg.data = map;
|
|
|
+ // }else{
|
|
|
+ // msg.setError("抽奖次数已达上限,去分享即可获得抽奖机会");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } else {
|
|
|
+ // msg.setError("抽奖次数已达上限");
|
|
|
+ // }
|
|
|
response.setContentType("application/json");
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
response.getWriter().println(msg.toJSONStr());
|
|
@@ -108,43 +127,25 @@ public class PrizeController {
|
|
|
if (prize == null) {
|
|
|
count = -1;
|
|
|
} else {
|
|
|
- if (prize.getPrizeLevel() == 0 && prize.getIsSelected() == 0) {
|
|
|
- count = 0;
|
|
|
- // prize.setIsSelected(1);
|
|
|
- // prizeMapper.updateByPrimaryKeySelective(prize);
|
|
|
- prizeRecord.setPrizeId(prize.getPrizeLevel());
|
|
|
- prizeRecord.setPrize(prize.getName());
|
|
|
- prizeRecordMapper.insert(prizeRecord);
|
|
|
- } else if (prize.getPrizeLevel() == 1 && prize.getIsSelected() == 0) {
|
|
|
- count = 1;
|
|
|
- // prize.setIsSelected(1);
|
|
|
- // prizeMapper.updateByPrimaryKeySelective(prize);
|
|
|
- prizeRecord.setPrizeId(prize.getPrizeLevel());
|
|
|
- prizeRecord.setPrize(prize.getName());
|
|
|
- prizeRecordMapper.insert(prizeRecord);
|
|
|
- } else if (prize.getPrizeLevel() == 2 && prize.getIsSelected() == 0) {
|
|
|
- count = 2;
|
|
|
- // prize.setIsSelected(1);
|
|
|
- // prizeMapper.updateByPrimaryKeySelective(prize);
|
|
|
- prizeRecord.setPrizeId(prize.getPrizeLevel());
|
|
|
- prizeRecord.setPrize(prize.getName());
|
|
|
- prizeRecordMapper.insert(prizeRecord);
|
|
|
- } else if (prize.getPrizeLevel() == 3 && prize.getIsSelected() == 0) {
|
|
|
- count = 3;
|
|
|
- // prize.setIsSelected(1);
|
|
|
- // prizeMapper.updateByPrimaryKeySelective(prize);
|
|
|
- prizeRecord.setPrizeId(prize.getPrizeLevel());
|
|
|
- prizeRecord.setPrize(prize.getName());
|
|
|
- prizeRecordMapper.insert(prizeRecord);
|
|
|
- } else if (prize.getPrizeLevel() == 4 && prize.getIsSelected() == 0) {
|
|
|
- count = 4;
|
|
|
+ if (prize.getPrizeLevel() == 5 || prize.getIsSelected() == 1) {
|
|
|
+ count = -1;
|
|
|
+ } else {
|
|
|
+ if (prize.getPrizeLevel() == 0 && prize.getIsSelected() == 0) {
|
|
|
+ count = 0;
|
|
|
+ } else if (prize.getPrizeLevel() == 1 && prize.getIsSelected() == 0) {
|
|
|
+ count = 1;
|
|
|
+ } else if (prize.getPrizeLevel() == 2 && prize.getIsSelected() == 0) {
|
|
|
+ count = 2;
|
|
|
+ } else if (prize.getPrizeLevel() == 3 && prize.getIsSelected() == 0) {
|
|
|
+ count = 3;
|
|
|
+ } else if (prize.getPrizeLevel() == 4 && prize.getIsSelected() == 0) {
|
|
|
+ count = 4;
|
|
|
+ }
|
|
|
// prize.setIsSelected(1);
|
|
|
// prizeMapper.updateByPrimaryKeySelective(prize);
|
|
|
prizeRecord.setPrizeId(prize.getPrizeLevel());
|
|
|
prizeRecord.setPrize(prize.getName());
|
|
|
prizeRecordMapper.insert(prizeRecord);
|
|
|
- } else {
|
|
|
- count = -1;
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
@@ -165,7 +166,7 @@ public class PrizeController {
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
response.getWriter().println(msg.toJSONStr());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 小游戏抽奖列表后台查看
|
|
|
*
|
|
@@ -220,24 +221,24 @@ public class PrizeController {
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
response.getWriter().println(msg.toJSONStr());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * 查看个人获奖信息
|
|
|
- *
|
|
|
- * 传递的参数:
|
|
|
- * userId:用户id message:寄语
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @RequestMapping("/getluckDrawByUserId")
|
|
|
- public void getluckDrawByUserId(Integer UserId,HttpServletResponse response) throws IOException{
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
- PrizeRecordExample exp = new PrizeRecordExample();
|
|
|
- exp.createCriteria().andUidEqualTo(UserId);
|
|
|
+ * 查看个人获奖信息
|
|
|
+ *
|
|
|
+ * 传递的参数: userId:用户id message:寄语
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @RequestMapping("/getluckDrawByUserId")
|
|
|
+ public void getluckDrawByUserId(Integer UserId, HttpServletResponse response) throws IOException {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ PrizeRecordExample exp = new PrizeRecordExample();
|
|
|
+ exp.createCriteria().andUidEqualTo(UserId);
|
|
|
List<PrizeRecord> list = prizeRecordMapper.selectByExample(exp);
|
|
|
msg.data = list;
|
|
|
response.setContentType("application/json");
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
response.getWriter().println(msg.toJSONStr());
|
|
|
- }
|
|
|
+ }
|
|
|
}
|