|
|
@ -20,9 +20,9 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
import org.apache.commons.lang.RandomStringUtils;
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
import org.apache.commons.lang.math.RandomUtils;
|
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
|
import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@ -152,7 +152,7 @@ public class RedpackServiceImpl implements RedpackService {
|
|
|
|
|
|
|
|
|
|
|
|
int min = CurrencyAmountUtils.toCent(config.getBigDecimal("min_amount"), "CNY");
|
|
|
|
int min = CurrencyAmountUtils.toCent(config.getBigDecimal("min_amount"), "CNY");
|
|
|
|
int max = CurrencyAmountUtils.toCent(config.getBigDecimal("max_amount"), "CNY");
|
|
|
|
int max = CurrencyAmountUtils.toCent(config.getBigDecimal("max_amount"), "CNY");
|
|
|
|
int amount = min == max ? min : RandomUtils.nextInt(max - min) + min;
|
|
|
|
int amount = min == max ? min : RandomUtils.nextInt(0,max - min) + min;
|
|
|
|
WechatRedpack wechatRedpack = new WechatRedpack();
|
|
|
|
WechatRedpack wechatRedpack = new WechatRedpack();
|
|
|
|
JSONObject customerRelation = customerMapper.findCustomerByOpenId(openId);
|
|
|
|
JSONObject customerRelation = customerMapper.findCustomerByOpenId(openId);
|
|
|
|
MpWechatApi redpackApi = mpWechatApiProvider.getApi("Redpack");
|
|
|
|
MpWechatApi redpackApi = mpWechatApiProvider.getApi("Redpack");
|
|
|
@ -185,7 +185,7 @@ public class RedpackServiceImpl implements RedpackService {
|
|
|
|
if (redpack_counts > 0) {
|
|
|
|
if (redpack_counts > 0) {
|
|
|
|
for (int i = 0; i < redpack_counts; i++) {
|
|
|
|
for (int i = 0; i < redpack_counts; i++) {
|
|
|
|
BigDecimal amount = amountFrom.equals(amountTo) ? amountFrom
|
|
|
|
BigDecimal amount = amountFrom.equals(amountTo) ? amountFrom
|
|
|
|
: amountFrom.add(BigDecimal.valueOf(RandomUtils.nextInt(amountTo.subtract(amountFrom).multiply(hundred).intValue())).divide(hundred,
|
|
|
|
: amountFrom.add(BigDecimal.valueOf(RandomUtils.nextInt(0,amountTo.subtract(amountFrom).multiply(hundred).intValue())).divide(hundred,
|
|
|
|
2, BigDecimal.ROUND_DOWN));
|
|
|
|
2, BigDecimal.ROUND_DOWN));
|
|
|
|
JSONObject prize = new JSONObject();
|
|
|
|
JSONObject prize = new JSONObject();
|
|
|
|
String prefix = DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS");
|
|
|
|
String prefix = DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS");
|
|
|
@ -263,7 +263,7 @@ public class RedpackServiceImpl implements RedpackService {
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
totalWeight += prizeType.getIntValue("weight");
|
|
|
|
totalWeight += prizeType.getIntValue("weight");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int ran = RandomUtils.nextInt(totalWeight);
|
|
|
|
int ran = RandomUtils.nextInt(0,totalWeight);
|
|
|
|
|
|
|
|
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
ran -= prizeType.getIntValue("weight");
|
|
|
|
ran -= prizeType.getIntValue("weight");
|
|
|
@ -383,7 +383,7 @@ public class RedpackServiceImpl implements RedpackService {
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
totalWeight += prizeType.getIntValue("weight");
|
|
|
|
totalWeight += prizeType.getIntValue("weight");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int ran = RandomUtils.nextInt(totalWeight);
|
|
|
|
int ran = RandomUtils.nextInt(0,totalWeight);
|
|
|
|
|
|
|
|
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
for (JSONObject prizeType : prizeTypes) {
|
|
|
|
ran -= prizeType.getIntValue("weight");
|
|
|
|
ran -= prizeType.getIntValue("weight");
|
|
|
|