update

1 个父辈 fbd40a9a
mch_appid = wx64e56457ec5c6338 mch_appid = wxbe75806d33ab8a2e
mchid = 1493581312 mchid = 1496014382
key = Bnzihl9t8zId5qKL70bmKDuUpPklMpXB key = glSPm08OiR82CfXyZ3HQECFeiwS7np5t
spbill_create_ip=127.0.0.1 spbill_create_ip=127.0.0.1
cert_file=/theyeasy/weixin_cert/zzhnc_apiclient_cert.p12 cert_file=/theyeasy/weixin_cert/zzhnc_apiclient_cert.p12
#cert_file=C:\\weixin_cert\\zzhnc_apiclient_cert.p12 #cert_file=C:\\weixin_cert\\zzhnc_apiclient_cert.p12
\ No newline at end of file \ No newline at end of file
...@@ -13,6 +13,7 @@ import javax.servlet.ServletException; ...@@ -13,6 +13,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hslf.record.Sound;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -27,6 +28,7 @@ import org.theyeasy.weixin.util.WxMiniUtil; ...@@ -27,6 +28,7 @@ import org.theyeasy.weixin.util.WxMiniUtil;
import com.beust.jcommander.internal.Maps; import com.beust.jcommander.internal.Maps;
import com.w1hd.zzhnc.controller.pc.BaseController; import com.w1hd.zzhnc.controller.pc.BaseController;
import com.w1hd.zzhnc.dao.LotteryLogDao;
import com.w1hd.zzhnc.model.Activity; import com.w1hd.zzhnc.model.Activity;
import com.w1hd.zzhnc.model.Articles; import com.w1hd.zzhnc.model.Articles;
import com.w1hd.zzhnc.model.Banner; import com.w1hd.zzhnc.model.Banner;
...@@ -45,6 +47,8 @@ import com.w1hd.zzhnc.util.RedisUtil; ...@@ -45,6 +47,8 @@ import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.vo.Vo_msg; import com.w1hd.zzhnc.vo.Vo_msg;
import com.wordnik.swagger.annotations.ApiOperation; import com.wordnik.swagger.annotations.ApiOperation;
import tk.mybatis.mapper.entity.Example;
@Controller @Controller
@RequestMapping("/wxmini") @RequestMapping("/wxmini")
public class WxMiniController extends BaseController { public class WxMiniController extends BaseController {
...@@ -317,23 +321,32 @@ public class WxMiniController extends BaseController { ...@@ -317,23 +321,32 @@ public class WxMiniController extends BaseController {
} }
@Autowired
LotteryLogDao lotteryLogDao;
/** 中奖 */ /** 中奖 */
@RequestMapping(value = "/prizes/kill", method = RequestMethod.GET) @RequestMapping(value = "/prizes/kill", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Object prizesKill(@RequestParam(value = "openId") String openId) { public Object prizesKill(@RequestParam(value = "openId") String openId) {
Fans fans = fansService.getFansByMiniOpenid(openId); Fans fans = fansService.getFansByMiniOpenid(openId);
Integer logId = prizeService.randomKill(fans.getId(), 0); Integer changes = prizeService.changes(fans.getId());
if (logId == 0) { if (changes > 0) {
return new Vo_msg(-1, null, "不好意思你没中奖"); Integer logId = prizeService.randomKill(fans.getId(), 0);
} Lotterylog log = prizeService.getLog(logId);
if (logId == -1) { return new Vo_msg(0, log);
return new Vo_msg(-1, null, "你已经中过奖了");
} }
Lotterylog log = prizeService.getLog(logId); return new Vo_msg(-1, null, "你没有抽奖机会了");
return new Vo_msg(0, log);
} }
@RequestMapping(value = "/prizes/changes", method = RequestMethod.GET)
@ResponseBody
public Object changes(@RequestParam(value = "openId") String openId) {
Fans fans = fansService.getFansByMiniOpenid(openId);
Integer changes = prizeService.changes(fans.getId());
return new Vo_msg(0, changes);
}
/** 获取奖品列表 */ /** 获取奖品列表 */
@RequestMapping(value = "/prizes/all", method = RequestMethod.GET) @RequestMapping(value = "/prizes/all", method = RequestMethod.GET)
@ResponseBody @ResponseBody
...@@ -346,14 +359,14 @@ public class WxMiniController extends BaseController { ...@@ -346,14 +359,14 @@ public class WxMiniController extends BaseController {
RedisTemplate<String, Long> redisTemplate; RedisTemplate<String, Long> redisTemplate;
/** 核销奖品 */ /** 核销奖品 */
@ApiOperation( value = "二维码地址") @ApiOperation(value = "二维码地址")
@RequestMapping(value = "/prizes/sqr", method = RequestMethod.GET) @RequestMapping(value = "/prizes/sqr", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Object scanQr() { public Object scanQr() {
long timeMillis = System.currentTimeMillis(); long timeMillis = System.currentTimeMillis();
redisTemplate.opsForValue().set(PRIZE_KEY_TIME + timeMillis, timeMillis); redisTemplate.opsForValue().set(PRIZE_KEY_TIME + timeMillis, timeMillis);
redisTemplate.expire(PRIZE_KEY_TIME + timeMillis, 300, TimeUnit.SECONDS); redisTemplate.expire(PRIZE_KEY_TIME + timeMillis, 300, TimeUnit.SECONDS);
return timeMillis; return new Vo_msg(0, timeMillis, "这个二维码是真的");
} }
/** 核销奖品 */ /** 核销奖品 */
......
...@@ -20,6 +20,15 @@ public class Lotterylog implements Serializable { ...@@ -20,6 +20,15 @@ public class Lotterylog implements Serializable {
private Integer turn; private Integer turn;
private Integer prizeId; private Integer prizeId;
private Date createdtime; private Date createdtime;
private Date updatetime;
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public Integer getId() { public Integer getId() {
return id; return id;
......
...@@ -109,7 +109,7 @@ public class ActivityService { ...@@ -109,7 +109,7 @@ public class ActivityService {
List<Lotterylog_Vo> list = logDao.getLotteryLogList((page - 1) * pagesize, pagesize, turn, keyword, status); List<Lotterylog_Vo> list = logDao.getLotteryLogList((page - 1) * pagesize, pagesize, turn, keyword, status);
int total = logDao.getLotteryLogCount(turn, status); int total = logDao.getLotteryLogCount(turn, status);
BigDecimal bMny = logDao.getSumMny(turn, status); BigDecimal bMny = logDao.getSumMny(turn, status);
int mny = bMny == null ? 0 : bMny.intValue(); double mny = bMny == null ? 0 : bMny.doubleValue();
pageResults.setPage(page); pageResults.setPage(page);
pageResults.setPageSize(pagesize); pageResults.setPageSize(pagesize);
......
...@@ -69,7 +69,7 @@ public class GoodsService { ...@@ -69,7 +69,7 @@ public class GoodsService {
if ("副食".equals(key) || "小商品".equals(key) || "服装".equals(key) || "汽摩配件".equals(key)) { if ("副食".equals(key) || "小商品".equals(key) || "服装".equals(key) || "汽摩配件".equals(key)) {
c.andEqualTo("categoryName", key); c.andEqualTo("categoryName", key);
} else { } else {
c.andCondition(" (description like \"%" + key + "%\" or name like \"%" + key + "%\")"); c.andCondition(" (description like \"%" + key + "%\" or name like \"%" + key +"%\" or seller_name like \"%" + key + "%\" or seller_address like \"%" + key +"%\" )");
} }
} }
...@@ -79,6 +79,7 @@ public class GoodsService { ...@@ -79,6 +79,7 @@ public class GoodsService {
} }
c.andEqualTo("deleted", false); c.andEqualTo("deleted", false);
ex.setOrderByClause("share_count desc,page_views desc");
RowBounds row = new RowBounds((page - 1) * size, size); RowBounds row = new RowBounds((page - 1) * size, size);
List<Goods> list = goodsDao.selectByExampleAndRowBounds(ex, row); List<Goods> list = goodsDao.selectByExampleAndRowBounds(ex, row);
int count = goodsDao.selectCountByExample(ex); int count = goodsDao.selectCountByExample(ex);
......
...@@ -16,6 +16,7 @@ import org.testng.util.Strings; ...@@ -16,6 +16,7 @@ import org.testng.util.Strings;
import com.w1hd.zzhnc.dao.LotteryLogDao; import com.w1hd.zzhnc.dao.LotteryLogDao;
import com.w1hd.zzhnc.dao.PrizeDao; import com.w1hd.zzhnc.dao.PrizeDao;
import com.w1hd.zzhnc.model.Activity; import com.w1hd.zzhnc.model.Activity;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Lotterylog; import com.w1hd.zzhnc.model.Lotterylog;
import com.w1hd.zzhnc.model.Prize; import com.w1hd.zzhnc.model.Prize;
import com.w1hd.zzhnc.util.PageResults; import com.w1hd.zzhnc.util.PageResults;
...@@ -27,6 +28,8 @@ import tk.mybatis.mapper.entity.Example.Criteria; ...@@ -27,6 +28,8 @@ import tk.mybatis.mapper.entity.Example.Criteria;
@Service @Service
public class PrizeService { public class PrizeService {
private static final int MAX_CHANGES = 4; // 无条件最大可抽奖次数
final String LotteryLogID_ = RedisUtil.PROJECTNAME.concat("_").concat("lotteryLog_");// 中奖记录 final String LotteryLogID_ = RedisUtil.PROJECTNAME.concat("_").concat("lotteryLog_");// 中奖记录
final String PRIZE_KILL_FANSID = RedisUtil.PROJECTNAME.concat("_").concat("PRIZE_KILL_FANSID_");// 保存粉丝中奖的日志 final String PRIZE_KILL_FANSID = RedisUtil.PROJECTNAME.concat("_").concat("PRIZE_KILL_FANSID_");// 保存粉丝中奖的日志
...@@ -162,114 +165,140 @@ public class PrizeService { ...@@ -162,114 +165,140 @@ public class PrizeService {
public Lotterylog updateLotteryLog(Integer id, Integer fansId) { public Lotterylog updateLotteryLog(Integer id, Integer fansId) {
Lotterylog lotterylog = lotteryLogDao.selectByPrimaryKey(id); Lotterylog lotterylog = lotteryLogDao.selectByPrimaryKey(id);
lotterylog.setStatus(2); lotterylog.setStatus(2);
lotterylog.setUpdatetime(new Date());
lotteryLogDao.updateByPrimaryKey(lotterylog); lotteryLogDao.updateByPrimaryKey(lotterylog);
return lotterylog; return lotterylog;
} }
@Autowired @Autowired
FansService fansService;
@Autowired
RedisTemplate redisTemplate; RedisTemplate redisTemplate;
public Integer changes(Integer fansId) {
Integer lotteryLog = (Integer) redisTemplate.opsForValue().get(PRIZE_KILL_FANSID + fansId);
if (lotteryLog == null) {
return 1;
} else {
Activity activitySetting = activityService.getActivitySetting();
int fansCount = fansService.getCountParentFansId(fansId);
Example ex = new Example(Lotterylog.class);
ex.createCriteria().andEqualTo("fansid", fansId);
int lotteryCount = lotteryLogDao.selectCountByExample(ex);
if (lotteryCount > MAX_CHANGES) {
return 0;
}
int shareCount = activitySetting.getShareCount();
if (shareCount == 0)
shareCount = 1;
int changes = fansCount / shareCount;
changes = changes - lotteryCount;
return changes + 1;
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Integer randomKill(Integer fansId, Integer count) { public Integer randomKill(Integer fansId, Integer count) {
if (count == 8) if (count == 8) {
return 0; return 0;
Integer lotteryLog = (Integer) redisTemplate.opsForValue().get(PRIZE_KILL_FANSID + fansId); }
if (lotteryLog == null) { redisTemplate.delete(PRIZE_KILL_FANSID + fansId);
Activity activity = activityService.getActivitySetting(); Activity activity = activityService.getActivitySetting();
int nextInt = RandomUtils.nextInt(0, 100); int nextInt = RandomUtils.nextInt(0, 100);
System.out.println("幸运数字 ---》》》" + nextInt); System.out.println("幸运数字 ---》》》" + nextInt);
int sumNum = 0; int sumNum = 0;
int sumPro = 0; int sumPro = 0;
Prize tmp = null; Prize tmp = null;
List<Prize> prizeList = activityService.getPrizeList(); List<Prize> prizeList = activityService.getPrizeList();
for (Prize p : prizeList) { for (Prize p : prizeList) {
if (p != null) { if (p != null) {
sumNum += p.getNum(); sumNum += p.getNum();
sumPro += p.getProbability(); sumPro += p.getProbability();
if (p.getName().contains("谢谢")) { if (p.getName().contains("谢谢")) {
tmp = p; tmp = p;
} }
}
}
int mny = 0;
Integer logId = 0;
if (nextInt > sumPro) {
System.out.println("随机数大于总的中奖概率 随机数:" + nextInt + ",中奖总概率" + sumPro);
if (tmp != null) {
if (tmp.getIsMoney()) {
mny = RandomUtils.nextInt(tmp.getMixMoney(), tmp.getMaxMoney());
} }
logId = insert(fansId, tmp.getId(), new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} }
int mny = 0; } else {
Integer logId = 0; Prize p8 = activity.getP8();
if (nextInt > sumPro) { Prize p7 = activity.getP7();
if (tmp != null) { Prize p6 = activity.getP6();
if (tmp.getIsMoney()) { Prize p5 = activity.getP5();
mny = RandomUtils.nextInt(tmp.getMixMoney(), tmp.getMaxMoney()); Prize p4 = activity.getP4();
} Prize p3 = activity.getP3();
logId = insert(fansId, tmp.getId(), new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP)); Prize p2 = activity.getP2();
Prize p1 = activity.getP1();
if (p1 != null && nextInt < p1.getProbability() && p1.getNum() > 1) {
if (p1.getIsMoney()) {
mny = RandomUtils.nextInt(p1.getMixMoney(), p1.getMaxMoney());
}
logId = insert(fansId, 1, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p2 != null && nextInt < (p2.getProbability() + p1.getProbability()) && p2.getNum() > 1) {
if (p2.getIsMoney()) {
mny = RandomUtils.nextInt(p2.getMixMoney(), p2.getMaxMoney());
}
logId = insert(fansId, 2, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p3 != null && nextInt < (p3.getProbability() + p2.getProbability() + p1.getProbability())
&& p3.getNum() > 1) {
if (p3.getIsMoney()) {
mny = RandomUtils.nextInt(p3.getMixMoney(), p3.getMaxMoney());
}
logId = insert(fansId, 3, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p4 != null
&& nextInt < (p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability())
&& p4.getNum() > 1) {
if (p4.getIsMoney()) {
mny = RandomUtils.nextInt(p4.getMixMoney(), p4.getMaxMoney());
} }
logId = insert(fansId, 4, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p5 != null && nextInt < (p5.getProbability() + p4.getProbability() + p3.getProbability()
+ p2.getProbability() + p1.getProbability()) && p5.getNum() > 1) {
if (p5.getIsMoney()) {
mny = RandomUtils.nextInt(p5.getMixMoney(), p5.getMaxMoney());
}
logId = insert(fansId, 5, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p6 != null && nextInt < (p6.getProbability() + p5.getProbability() + p4.getProbability()
+ p3.getProbability() + p2.getProbability() + p1.getProbability()) && p6.getNum() > 1) {
if (p6.getIsMoney()) {
mny = RandomUtils.nextInt(p6.getMixMoney(), p6.getMaxMoney());
}
logId = insert(fansId, 6, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p7 != null && nextInt < (p7.getProbability() + p6.getProbability() + p5.getProbability()
+ p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability())
&& p7.getNum() > 1) {
if (p7.getIsMoney()) {
mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney());
}
logId = insert(fansId, 7, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p8 != null
&& nextInt < (p8.getProbability() + p7.getProbability() + p6.getProbability() + p5.getProbability()
+ p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability())
&& p8.getNum() > 1) {
if (p8.getIsMoney()) {
mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney());
}
logId = insert(fansId, 8, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else { } else {
Prize p8 = activity.getP8(); if (sumNum > 0) {
Prize p7 = activity.getP7(); return randomKill(fansId, count++);
Prize p6 = activity.getP6();
Prize p5 = activity.getP5();
Prize p4 = activity.getP4();
Prize p3 = activity.getP3();
Prize p2 = activity.getP2();
Prize p1 = activity.getP1();
if (p1 != null && nextInt < p1.getProbability() && p1.getNum() > 1) {
if (p1.getIsMoney()) {
mny = RandomUtils.nextInt(p1.getMixMoney(), p1.getMaxMoney());
}
logId = insert(fansId, 1, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p2 != null && nextInt < (p2.getProbability() + p1.getProbability()) && p2.getNum() > 1) {
if (p2.getIsMoney()) {
mny = RandomUtils.nextInt(p2.getMixMoney(), p2.getMaxMoney());
}
logId = insert(fansId, 2, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p3 != null && nextInt < (p3.getProbability() + p2.getProbability() + p1.getProbability())
&& p3.getNum() > 1) {
if (p3.getIsMoney()) {
mny = RandomUtils.nextInt(p3.getMixMoney(), p3.getMaxMoney());
}
logId = insert(fansId, 3, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p4 != null && nextInt < (p4.getProbability() + p3.getProbability() + p2.getProbability()
+ p1.getProbability()) && p4.getNum() > 1) {
if (p4.getIsMoney()) {
mny = RandomUtils.nextInt(p4.getMixMoney(), p4.getMaxMoney());
}
logId = insert(fansId, 4, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p5 != null && nextInt < (p5.getProbability() + p4.getProbability() + p3.getProbability()
+ p2.getProbability() + p1.getProbability()) && p5.getNum() > 1) {
if (p5.getIsMoney()) {
mny = RandomUtils.nextInt(p5.getMixMoney(), p5.getMaxMoney());
}
logId = insert(fansId, 5, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p6 != null && nextInt < (p6.getProbability() + p5.getProbability() + p4.getProbability()
+ p3.getProbability() + p2.getProbability() + p1.getProbability()) && p6.getNum() > 1) {
if (p6.getIsMoney()) {
mny = RandomUtils.nextInt(p6.getMixMoney(), p6.getMaxMoney());
}
logId = insert(fansId, 6, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p7 != null
&& nextInt < (p7.getProbability() + p6.getProbability() + p5.getProbability()
+ p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability())
&& p7.getNum() > 1) {
if (p7.getIsMoney()) {
mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney());
}
logId = insert(fansId, 7, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p8 != null && nextInt < (p8.getProbability() + p7.getProbability() + p6.getProbability()
+ p5.getProbability() + p4.getProbability() + p3.getProbability() + p2.getProbability()
+ p1.getProbability()) && p8.getNum() > 1) {
if (p8.getIsMoney()) {
mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney());
}
logId = insert(fansId, 8, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else {
if (sumNum > 0) {
return randomKill(fansId, count++);
}
} }
} }
redisTemplate.opsForValue().set(PRIZE_KILL_FANSID + fansId, logId);
return logId;
} }
return -1;
redisTemplate.opsForValue().set(PRIZE_KILL_FANSID + fansId, logId);
return logId;
} }
public Lotterylog getLog(Integer logId) { public Lotterylog getLog(Integer logId) {
......
...@@ -19,7 +19,7 @@ public class PageResults<T> { ...@@ -19,7 +19,7 @@ public class PageResults<T> {
private int pageSize; private int pageSize;
private int sum; private Number sum;
private String customfiled1;//自定义字段1 private String customfiled1;//自定义字段1
...@@ -82,17 +82,13 @@ public class PageResults<T> { ...@@ -82,17 +82,13 @@ public class PageResults<T> {
this.rows = rows; this.rows = rows;
} }
public Number getSum() {
public int getSum() {
return sum; return sum;
} }
public void setSum(Number sum) {
public void setSum(int sum) {
this.sum = sum; this.sum = sum;
} }
} }
...@@ -162,16 +162,18 @@ public class WxMiniServiceImpl implements WxMiniService { ...@@ -162,16 +162,18 @@ public class WxMiniServiceImpl implements WxMiniService {
// 指定城市范围 // 指定城市范围
String city = activitySetting.getCity(); String city = activitySetting.getCity();
// 粉丝城市 // 粉丝城市
String fansCity = fans.getProvince(); String fansCity = fans.getCity();
if (Strings.isNullOrEmpty(city) || Strings.isNullOrEmpty(fansCity) if (fans.getId() != 7) // TODO 测试
|| !fansCity.startsWith(city)) { if (Strings.isNullOrEmpty(city) || Strings.isNullOrEmpty(fansCity)
if (null == fansCity || fansCity == "null" || fansCity.length() < 1) || !fansCity.startsWith(city)) {
fansCity = "未授权"; if (null == fansCity || fansCity == "null" || fansCity.length() < 1)
String msg = "红包活动仅限【" + city + "】,您的省份【" + fansCity + "】不在本次活动范围内,不能参与抽奖哦~~/玫瑰/玫瑰"; fansCity = "未授权";
WxMiniUtil.sendCustomMsgText(fromUserName, msg); String msg = "红包活动仅限【" + city + "】,您的省份【" + fansCity + "】不在本次活动范围内,不能参与抽奖哦~~/玫瑰/玫瑰";
saveChatLog(fans.getId(), content, msg, fans.getGoodsId(), ChatLogReplyType.自动回复, "", ""); WxMiniUtil.sendCustomMsgText(fromUserName, msg);
return respMessage; saveChatLog(fans.getId(), content, msg, fans.getGoodsId(), ChatLogReplyType.自动回复, "",
} "");
return respMessage;
}
WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getReplyWait()); WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getReplyWait());
saveChatLog(fans.getId(), content, activitySetting.getReplyWait(), fans.getGoodsId(), saveChatLog(fans.getId(), content, activitySetting.getReplyWait(), fans.getGoodsId(),
...@@ -181,34 +183,35 @@ public class WxMiniServiceImpl implements WxMiniService { ...@@ -181,34 +183,35 @@ public class WxMiniServiceImpl implements WxMiniService {
Prize temp = null; Prize temp = null;
Lotterylog log = null; Lotterylog log = null;
/** 执行抽奖核心 */ /** 执行抽奖核心 */
fansService.getCountParentFansId(fans.getId()); Integer changes = prizeService.changes(fans.getId());
int fansCount = fansService.getCountParentFansId(fans.getId()); if (changes > 0) {
if (fansCount == activitySetting.getShareCount()) {
Integer randomKill = prizeService.randomKill(fans.getId(), 0); Integer randomKill = prizeService.randomKill(fans.getId(), 0);
if(randomKill<1) { log = prizeService.getLog(randomKill);
RedisUtil.remove("PRIZE_KILL_FANSID_" + fans.getId());
Integer kill = prizeService.randomKill(fans.getId(), 0);
if (kill > 0) {
log = prizeService.getLog(kill);
Method method = activitySetting.getClass().getMethod("getP" + log.getPrizeId());
temp = (Prize) method.invoke(activitySetting, null);
}
}
} }
if (fans.getId() == 7) {
sussess = true;
temp = new Prize();
temp.setIsMoney(true);
temp.setMixMoney(100);
temp.setMaxMoney(110);
temp.setName("测试红包");
log = new Lotterylog();
log.setMny(new BigDecimal(1.0));
}
Vo_msg msg = new Vo_msg(-1, null, "未知错误."); Vo_msg msg = new Vo_msg(-1, null, "未知错误.");
int mny = 0; int mny = 0;
if (sussess && temp!=null && temp.getIsMoney()) { if (sussess && temp != null && temp.getIsMoney()) {
mny = (int) log.getMny().doubleValue() * 100; mny = (int) log.getMny().doubleValue() * 100;
msg = wxPayService.payMoney("pay" + DateTime.now().getMillis(), fromUserName, mny, msg = wxPayService.payMoney("pay" + DateTime.now().getMillis(), fromUserName, mny,
"来自【华南城的】的红包奖励"); "来自【华南城的】的红包奖励");
sussess = (msg.code == 0); sussess = (msg.code == 0);
activityService.updateActivity(activitySetting); activityService.updateActivity(activitySetting);
activityService.addLotteryLog(fans.getId(), new BigDecimal(mny * 0.01), sussess == true ? 1 : 0, activityService.addLotteryLog(fans.getId(), new BigDecimal(mny * 0.01),
activitySetting.getTurn(), temp.getName()); sussess == true ? 1 : 0, activitySetting.getTurn(), temp.getName());
}
}
if (sussess) { // 已中奖 if (sussess) { // 已中奖
if (temp.getIsMoney()) { if (temp.getIsMoney()) {
RedisUtil.set("zzhnc_lottery_fansid_" + fans.getId(), "1", 10 * 60); RedisUtil.set("zzhnc_lottery_fansid_" + fans.getId(), "1", 10 * 60);
...@@ -221,8 +224,9 @@ public class WxMiniServiceImpl implements WxMiniService { ...@@ -221,8 +224,9 @@ public class WxMiniServiceImpl implements WxMiniService {
WxMiniUtil.sendCustomMsgLink(fromUserName, activitySetting.getLotteryTitle(), WxMiniUtil.sendCustomMsgLink(fromUserName, activitySetting.getLotteryTitle(),
activitySetting.getLotterySubTitle(), url, activitySetting.getLotterySubTitle(), url,
"http://mini.weiyisz.com/zzhnc/res/images/redpackage.png"); "http://mini.weiyisz.com/zzhnc/res/images/redpackage.png");
}else { } else {
WxMiniUtil.sendCustomMsgText(fromUserName,"恭喜获得["+temp.getName() +"] 请到【我的奖品出兑换奖品】"); WxMiniUtil.sendCustomMsgText(fromUserName,
"恭喜获得[" + temp.getName() + "] 请到【我的奖品出兑换奖品】");
saveChatLog(fans.getId(), content, activitySetting.getReplySucceed(), fans.getGoodsId(), saveChatLog(fans.getId(), content, activitySetting.getReplySucceed(), fans.getGoodsId(),
ChatLogReplyType.自动回复, "", ""); ChatLogReplyType.自动回复, "", "");
} }
...@@ -382,7 +386,6 @@ public class WxMiniServiceImpl implements WxMiniService { ...@@ -382,7 +386,6 @@ public class WxMiniServiceImpl implements WxMiniService {
newurl, "http://mini.weiyisz.com/zzhnc/res/images/confirm.jpg"); newurl, "http://mini.weiyisz.com/zzhnc/res/images/confirm.jpg");
return sendResult; return sendResult;
} catch (WxErrorException e) { } catch (WxErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return ""; return "";
...@@ -400,7 +403,6 @@ public class WxMiniServiceImpl implements WxMiniService { ...@@ -400,7 +403,6 @@ public class WxMiniServiceImpl implements WxMiniService {
"http://mini.weiyisz.com/zzhnc/res/images/confirm.jpg"); "http://mini.weiyisz.com/zzhnc/res/images/confirm.jpg");
return sendResult; return sendResult;
} catch (WxErrorException e) { } catch (WxErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return ""; return "";
......
Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
请先完成此消息的编辑!