master
wangning 8 years ago
parent cf05d18db6
commit 2a55ed7198

@ -129,10 +129,10 @@ public class RedpackServiceImpl implements RedpackService {
WechatRedpack redpack = newRedpack(config, orderOpenId); WechatRedpack redpack = newRedpack(config, orderOpenId);
String redpackId = mpWechatApiProvider.getApi("Redpack").sendRedpack(redpack).getString("redpack_id"); String redpackId = mpWechatApiProvider.getApi("Redpack").sendRedpack(redpack).getString("redpack_id");
JSONObject obj = redpack.toJSON(); JSONObject obj = redpack.toJSON();
obj.put("redpack_id",redpackId); obj.put("redpack_id", redpackId);
obj.put("create_time", new Date()); obj.put("create_time", new Date());
obj.put("status", 0); obj.put("status", 0);
obj.put("order_id",orderId); obj.put("order_id", orderId);
obj.put("client_id", clientId); obj.put("client_id", clientId);
redPackLogMapper.saveLog(obj); redPackLogMapper.saveLog(obj);
} catch (RedPackException e) { } catch (RedPackException e) {
@ -186,7 +186,7 @@ public class RedpackServiceImpl implements RedpackService {
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(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");
String red_packet_order_id = prefix + RandomStringUtils.random(28 - prefix.length(), true, true); String red_packet_order_id = prefix + RandomStringUtils.random(28 - prefix.length(), true, true);
@ -269,8 +269,8 @@ public class RedpackServiceImpl implements RedpackService {
ran -= prizeType.getIntValue("weight"); ran -= prizeType.getIntValue("weight");
if (ran < 0) { if (ran < 0) {
String lock = Long.toString(System.currentTimeMillis(), 36) + RandomStringUtils.random(5, true, true); String lock = Long.toString(System.currentTimeMillis(), 36) + RandomStringUtils.random(5, true, true);
int lockedCount = actPartnerLMLogMapper.lockPrize(act_id, lock, prizeType.getString("type_id"), open_id, client_id, orderId, orderAmount.doubleValue(), int lockedCount = actPartnerLMLogMapper.lockPrize(act_id, lock, prizeType.getString("type_id"), open_id, client_id, orderId,
new Date()); orderAmount.doubleValue(), new Date());
if (lockedCount > 0) { if (lockedCount > 0) {
JSONObject invitationClient = actClientInvitationCodeMapper.getInvitationClient(act_id, client_id); JSONObject invitationClient = actClientInvitationCodeMapper.getInvitationClient(act_id, client_id);
if (invitationClient != null && invitationClient.getBoolean("auto_send")) { if (invitationClient != null && invitationClient.getBoolean("auto_send")) {
@ -301,8 +301,8 @@ public class RedpackServiceImpl implements RedpackService {
throw new RedPackException("ServerError", "Customer openid for redpack not available!"); throw new RedPackException("ServerError", "Customer openid for redpack not available!");
} }
String rpOpenId = customerRelation.getString(redpackApi.getOpenIdKey()); String rpOpenId = customerRelation.getString(redpackApi.getOpenIdKey());
wechatRedpack.setSendName(sendName).setOpenId(rpOpenId).setActName(act.getString("act_name")) wechatRedpack.setSendName(sendName).setOpenId(rpOpenId).setActName(act.getString("act_name")).setRemark("店长激励计划")
.setRemark("店长激励计划").setAmount(totalAmount).setWishing(wishing).setNotifyUrl(null); .setAmount(totalAmount).setWishing(wishing).setNotifyUrl(null);
String redPacketId = mpWechatApiProvider.getApi("Redpack").sendRedpack(wechatRedpack).getString("redpack_id"); String redPacketId = mpWechatApiProvider.getApi("Redpack").sendRedpack(wechatRedpack).getString("redpack_id");
for (JSONObject prizeDetail : reallySend) { for (JSONObject prizeDetail : reallySend) {
@ -389,8 +389,8 @@ public class RedpackServiceImpl implements RedpackService {
ran -= prizeType.getIntValue("weight"); ran -= prizeType.getIntValue("weight");
if (ran < 0) { if (ran < 0) {
String lock = Long.toString(System.currentTimeMillis(), 36) + RandomStringUtils.random(5, true, true); String lock = Long.toString(System.currentTimeMillis(), 36) + RandomStringUtils.random(5, true, true);
int lockedCount = actPartnerLMLogMapper.lockPrize(act_id, lock, prizeType.getString("type_id"), open_id, client_id, orderId, orderAmount.doubleValue(), int lockedCount = actPartnerLMLogMapper.lockPrize(act_id, lock, prizeType.getString("type_id"), open_id, client_id, orderId,
new Date()); orderAmount.doubleValue(), new Date());
if (lockedCount > 0) { if (lockedCount > 0) {
JSONObject invitationClient = actClientInvitationCodeMapper.getInvitationClient(act_id, client_id); JSONObject invitationClient = actClientInvitationCodeMapper.getInvitationClient(act_id, client_id);
if (invitationClient != null && invitationClient.getBoolean("auto_send")) { if (invitationClient != null && invitationClient.getBoolean("auto_send")) {
@ -412,8 +412,6 @@ public class RedpackServiceImpl implements RedpackService {
String wishing = "恭喜获得ROYALPAY店长福利红包"; String wishing = "恭喜获得ROYALPAY店长福利红包";
String notifyUrl = "https://mpay.royalpay.com.au/sys/lucky_money/partner/" + red_packet_order_id + "notify"; String notifyUrl = "https://mpay.royalpay.com.au/sys/lucky_money/partner/" + red_packet_order_id + "notify";
WechatRedpack wechatRedpack = new WechatRedpack(); WechatRedpack wechatRedpack = new WechatRedpack();
JSONObject customerRelation = customerMapper.findCustomerByOpenId(open_id); JSONObject customerRelation = customerMapper.findCustomerByOpenId(open_id);
MpWechatApi redpackApi = mpWechatApiProvider.getApi("Redpack"); MpWechatApi redpackApi = mpWechatApiProvider.getApi("Redpack");
@ -421,10 +419,10 @@ public class RedpackServiceImpl implements RedpackService {
throw new RedPackException("ServerError", "Customer openid for redpack not available!"); throw new RedPackException("ServerError", "Customer openid for redpack not available!");
} }
String rpOpenId = customerRelation.getString(redpackApi.getOpenIdKey()); String rpOpenId = customerRelation.getString(redpackApi.getOpenIdKey());
wechatRedpack.setSendName(sendName).setOpenId(rpOpenId).setActName(actName) wechatRedpack.setSendName(sendName).setOpenId(rpOpenId).setActName(actName).setRemark("店长激励计划").setAmount(luckyMoeny).setWishing(wishing)
.setRemark("店长激励计划").setAmount(luckyMoeny).setWishing(wishing).setNotifyUrl(notifyUrl); .setNotifyUrl(notifyUrl);
String redPacketId = mpWechatApiProvider.getApi("Redpack").sendRedpack(wechatRedpack).getString("redpack_id"); String redPacketId = mpWechatApiProvider.getApi("Redpack").sendRedpack(wechatRedpack).getString("redpack_id");
logger.debug("kira-->>>>"+redPacketId); logger.debug("kira-->>>>" + redPacketId);
prizeDetail.put("red_packet_id", redPacketId); prizeDetail.put("red_packet_id", redPacketId);
prizeDetail.put("status", 1); prizeDetail.put("status", 1);
actPartnerLMLogMapper.update(prizeDetail); actPartnerLMLogMapper.update(prizeDetail);
@ -448,9 +446,11 @@ public class RedpackServiceImpl implements RedpackService {
break; break;
} }
AlipayRedpack alipayRedpack = new AlipayRedpack(); AlipayRedpack alipayRedpack = new AlipayRedpack();
alipayRedpack.setPayeeAccount(alipayUserId).setAmount(prizeDetail.getBigDecimal("red_packet_amount")).setPayerShowName("RoyalPay福利社"). alipayRedpack.setPayeeAccount(alipayUserId).setAmount(prizeDetail.getBigDecimal("red_packet_amount")).setPayerShowName("RoyalPay福利社")
setRemark("RoyalPay店长活动-" + (rate.intValue() > 1 ? rate.intValue() + "倍" : "") + "红包奖励" + specialDocuments); .setRemark("RoyalPay店长活动-" + (rate.intValue() > 1 ? rate.intValue() + "倍" : "") + "红包奖励" + specialDocuments);
String redPacketId = mpAlipayRedpackApi.sendRedpack(alipayRedpack).getString("redpack_id"); JSONObject mpAlipayJson = mpAlipayRedpackApi.sendRedpack(alipayRedpack);
logger.debug("mpAlipayJson------" + mpAlipayJson.toJSONString());
String redPacketId = mpAlipayJson.getString("redpack_id");
prizeDetail.put("red_packet_id", redPacketId); prizeDetail.put("red_packet_id", redPacketId);
prizeDetail.put("status", 5); prizeDetail.put("status", 5);
actPartnerLMLogMapper.update(prizeDetail); actPartnerLMLogMapper.update(prizeDetail);
@ -463,7 +463,7 @@ public class RedpackServiceImpl implements RedpackService {
List<JSONObject> redPacketOrders = actPartnerLMLogMapper.sendList(params); List<JSONObject> redPacketOrders = actPartnerLMLogMapper.sendList(params);
for (JSONObject redPack : redPacketOrders) { for (JSONObject redPack : redPacketOrders) {
JSONObject supportRedPack = mpAlipayRedpackApi.redpackStatus(redPack.getString("red_packet_id")); JSONObject supportRedPack = mpAlipayRedpackApi.redpackStatus(redPack.getString("red_packet_id"));
logger.debug("kiratest----------"+supportRedPack.toJSONString()); logger.debug("kiratest----------" + supportRedPack.toJSONString());
if (supportRedPack != null && !supportRedPack.isEmpty()) { if (supportRedPack != null && !supportRedPack.isEmpty()) {
switch (supportRedPack.getString("status")) { switch (supportRedPack.getString("status")) {
case "0": case "0":

Loading…
Cancel
Save