From a2c3128cb06d78b217af40507c344458eec32f8b Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 13:40:32 +0800 Subject: [PATCH 1/4] add log --- .../customers/web/EncourageMoneyController.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java index e9d1fe4aa..967889aa9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java @@ -5,10 +5,17 @@ import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType; import au.com.royalpay.payment.tools.permission.alipay.AlipayMapping; import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; + import com.alibaba.fastjson.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; @@ -19,6 +26,7 @@ import javax.annotation.Resource; @Controller @RequestMapping("/act/encourage_money") public class EncourageMoneyController { + Logger logger = LoggerFactory.getLogger(getClass()); @Resource private EncourageService encourageService; @@ -38,17 +46,22 @@ public class EncourageMoneyController { @WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET) public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { + logger.info("kiratest---wechat"); if (wxUser == null) { return new JSONObject(); } + logger.info(wxUser.toJSONString()); return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid")); } @AlipayMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.GET) public JSONObject takeEncourageMoneyAlipay(@PathVariable String orderId, @ModelAttribute(CommonConsts.ALIUSER) JSONObject alipayInfo) { + logger.info("kiratest---alipay"); + if (alipayInfo == null) { return new JSONObject(); } + logger.info(alipayInfo.toJSONString()); return encourageService.takeEncourageMoney(orderId, alipayInfo.getString("user_id")); } From 735aaadc273463b6205eac9b93c72c5aae77f12c Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 14:32:20 +0800 Subject: [PATCH 2/4] update --- .../web/EncourageMoneyController.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java index 967889aa9..907c34b6a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java @@ -8,12 +8,12 @@ import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; @@ -31,20 +31,21 @@ public class EncourageMoneyController { private EncourageService encourageService; @RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET) - public ModelAndView takeEncourageMoney(@PathVariable String orderId,@RequestHeader("User-Agent") String ua) { - ua = ua.toLowerCase(); - if (ua.contains("micromessenger")) { - return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/wechat"); - + public JSONObject takeEncourageMoney(@PathVariable String orderId,@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) { + String user_id = ""; + if(wxUser==null){ + user_id = aliuser.getString("user_id"); + }else { + user_id = wxUser.getString("openid"); } - if (ua.contains("alipayclient")) { - return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/alipay"); + if(StringUtils.isEmpty(user_id)){ + return new JSONObject(); } - return null; + return encourageService.takeEncourageMoney(orderId, user_id); } - @WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET) + @RequestMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET) public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { logger.info("kiratest---wechat"); if (wxUser == null) { From ed032015bc7f755cc0992becf065cef2207bee24 Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 14:52:21 +0800 Subject: [PATCH 3/4] update --- .../payment/manage/customers/web/EncourageMoneyController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java index 907c34b6a..626f73529 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; @@ -23,7 +24,7 @@ import javax.annotation.Resource; /** * Created by yixian on 2017-04-28. */ -@Controller +@RestController @RequestMapping("/act/encourage_money") public class EncourageMoneyController { Logger logger = LoggerFactory.getLogger(getClass()); From b69737a554b11c9a3d711ffde71fe773180539a6 Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 15:03:47 +0800 Subject: [PATCH 4/4] update --- .../web/EncourageMoneyController.java | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java index 626f73529..e122427a8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java @@ -3,7 +3,6 @@ package au.com.royalpay.payment.manage.customers.web; import au.com.royalpay.payment.manage.customers.core.EncourageService; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType; -import au.com.royalpay.payment.tools.permission.alipay.AlipayMapping; import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; import com.alibaba.fastjson.JSONObject; @@ -11,7 +10,6 @@ import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -45,48 +43,32 @@ public class EncourageMoneyController { return encourageService.takeEncourageMoney(orderId, user_id); } - - @RequestMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET) - public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { - logger.info("kiratest---wechat"); - if (wxUser == null) { - return new JSONObject(); - } - logger.info(wxUser.toJSONString()); - return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid")); - } - - @AlipayMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.GET) - public JSONObject takeEncourageMoneyAlipay(@PathVariable String orderId, @ModelAttribute(CommonConsts.ALIUSER) JSONObject alipayInfo) { - logger.info("kiratest---alipay"); - - if (alipayInfo == null) { - return new JSONObject(); - } - logger.info(alipayInfo.toJSONString()); - return encourageService.takeEncourageMoney(orderId, alipayInfo.getString("user_id")); - } - @RequestMapping(value = "/orders/{orderId}/crit", method = RequestMethod.PUT) public JSONObject takeEncourageMoneyCrit(@PathVariable String orderId) { return encourageService.doubleEncourageMoney(orderId); } - @WechatMapping(value = "/my", method = RequestMethod.GET, oauthType = WxOauthType.USERINFO) - public ModelAndView encourageLogs(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { + @RequestMapping(value = "/my", method = RequestMethod.GET) + public ModelAndView encourageLogs(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) { ModelAndView mav = new ModelAndView("activity/encourage_money/my"); mav.addObject("wxUser", wxUser); - JSONObject balanceStatus = encourageService.getBalanceStatus(wxUser.getString("openid")); + String user_id = ""; + if(wxUser==null){ + user_id = aliuser.getString("user_id"); + }else { + user_id = wxUser.getString("openid"); + } + JSONObject balanceStatus = encourageService.getBalanceStatus(user_id); mav.addObject("balance_status", balanceStatus); return mav; } - @WechatMapping(value = "/desc",method = RequestMethod.GET) + @RequestMapping(value = "/desc",method = RequestMethod.GET) public ModelAndView descPage(){ return new ModelAndView("activity/encourage_money/desc"); } - @WechatMapping(value = "/merchants",method = RequestMethod.GET) + @RequestMapping(value = "/merchants",method = RequestMethod.GET) public ModelAndView merchantsPage(){ return new ModelAndView("activity/encourage_money/merchants"); }