From b23ad3d78224cc1277290e80f18af0bd331ae475 Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Mon, 4 Feb 2019 12:39:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=8F=91=E7=BA=A2=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/CustomerRewardLogService.java | 2 ++ .../impls/CustomerRewardLogServiceImpl.java | 20 +++++++++++++++++++ .../web/NewYearRedPacketController.java | 5 +++++ .../customers/CusRewardLogsMapper.java | 3 +++ 4 files changed, 30 insertions(+) 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 9eb022f7d..2545c8dd6 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(); }