diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerRewardLogService.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerRewardLogService.java index 929a4ad32..c9c91f94a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerRewardLogService.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerRewardLogService.java @@ -12,4 +12,6 @@ public interface CustomerRewardLogService { void saveReward(int type2,int type3,String type1,String date); void checkRedpacksStatus(String rewardId); + + void reSendRedPacks(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerRewardLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerRewardLogServiceImpl.java index 920e7255f..5645c8bf3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerRewardLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerRewardLogServiceImpl.java @@ -206,6 +206,26 @@ public class CustomerRewardLogServiceImpl implements CustomerRewardLogService { } } + @Override + public void reSendRedPacks() { + List redpacks = cusRewardLogsMapper.resendRewards(); + for(JSONObject pack:redpacks){ + String sendName = "RoyalPay"; + String actName = cusRewardConfigMapper.getValue("act_name").getString("value"); + String wishing = cusRewardConfigMapper.getValue("wishing").getString("value"); + String notifyUrl = PlatformEnvironment.getEnv().concatUrl("/act/new_year/redpacks/"+pack.getString("reward_id")); + MpWechatApi redpackApi = mpWechatApiProvider.getApi("redpack"); + WechatRedpack wechatRedpack = new WechatRedpack(); + wechatRedpack.setSendName(sendName).setOpenId(pack.getString("openid")).setActName(actName) + .setRemark(actName).setAmount(pack.getBigDecimal("amount")).setWishing(wishing).setNotifyUrl(notifyUrl); + JSONObject res = redpackApi.sendRedpack(wechatRedpack); + logger.info("2019新年活动获取的红包信息==>"+res.toJSONString()); + pack.put("status",0); + pack.put("send_listid",res.getString("redpack_id")); + cusRewardLogsMapper.update(pack); + } + } + private JSONObject getRandomReward(String openid){ JSONObject reward = cusRewardCouponMapper.randomType(); diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/NewYearRedPacketController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/NewYearRedPacketController.java index 7ef011fa5..f287ceaff 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/NewYearRedPacketController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/NewYearRedPacketController.java @@ -74,4 +74,9 @@ public class NewYearRedPacketController { // mpWechatApi(request.getRequestURI(), sign, timestamp); // redpackSupport.checkRedpack(rewardId); } + + @RequestMapping(value = "/resendRedpacks", method = RequestMethod.GET) + public void updateRedpackStatus(){ + customerRewardLogService.reSendRedPacks(); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CusRewardLogsMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CusRewardLogsMapper.java index dfb3c8385..ee6bacb48 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CusRewardLogsMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CusRewardLogsMapper.java @@ -33,4 +33,7 @@ public interface CusRewardLogsMapper { @Select("SELECT * FROM cus_reward_log WHERE type=1 AND (`status`=0 OR `status`=1) AND openid IS NOT NULL ORDER BY send_time ASC") List listUnconfirmRewards(); + + @Select("select * from cus_reward_log where openid is not null and type=1 and send_listid is null") + List resendRewards(); }