From 2d530b36c81b9ce980d1e0cc4cb4607d37a378c9 Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 11:51:38 +0800 Subject: [PATCH 1/7] update act images --- .../manage/customers/web/EncourageMoneyController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 841bc9b33..9d2ad73b1 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,6 +3,7 @@ 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; import org.springframework.web.bind.annotation.*; @@ -32,7 +33,7 @@ public class EncourageMoneyController { } - @RequestMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.PUT) + @WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.PUT) public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { if (wxUser == null) { return new JSONObject(); @@ -40,7 +41,7 @@ public class EncourageMoneyController { return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid")); } - @RequestMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.PUT) + @AlipayMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.PUT) public JSONObject takeEncourageMoneyAlipay(@PathVariable String orderId, @ModelAttribute(CommonConsts.ALIUSER) JSONObject alipayInfo) { if (alipayInfo == null) { return new JSONObject(); From 106c9b98c65ffcb2b10fe459f11d235235ea8c4f Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 12:09:07 +0800 Subject: [PATCH 2/7] update --- .../customers/web/EncourageMoneyController.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 9d2ad73b1..a90e4b7e2 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 @@ -6,6 +6,8 @@ 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.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -14,17 +16,19 @@ import javax.annotation.Resource; /** * Created by yixian on 2017-04-28. */ -@RestController +@Controller @RequestMapping("/act/encourage_money") public class EncourageMoneyController { @Resource private EncourageService encourageService; - @RequestMapping(value = "/orders/{orderId}", method = RequestMethod.PUT) + @RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET) public String takeEncourageMoney(@PathVariable String orderId,@RequestHeader("User-Agent") String ua) { + ua = ua.toLowerCase(); if (ua.contains("micromessenger")) { return "redirect:/act/encourage_money/orders/" + orderId + "/wechat"; + } if (ua.contains("alipayclient")) { return "redirect:/act/encourage_money/orders/" + orderId + "/alipay"; @@ -33,7 +37,7 @@ public class EncourageMoneyController { } - @WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.PUT) + @WechatMapping(value = "/orders/{orderId}/wechat", method = RequestMethod.GET) public JSONObject takeEncourageMoneyWeChat(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser) { if (wxUser == null) { return new JSONObject(); @@ -41,7 +45,7 @@ public class EncourageMoneyController { return encourageService.takeEncourageMoney(orderId, wxUser.getString("openid")); } - @AlipayMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.PUT) + @AlipayMapping(value = "/orders/{orderId}/alipay", method = RequestMethod.GET) public JSONObject takeEncourageMoneyAlipay(@PathVariable String orderId, @ModelAttribute(CommonConsts.ALIUSER) JSONObject alipayInfo) { if (alipayInfo == null) { return new JSONObject(); From 70e234eff7f4a6f24c0f8534d4dbcf8eeaf06bd4 Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 12:14:17 +0800 Subject: [PATCH 3/7] update act images --- src/main/ui/static/templates/payment/success.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/ui/static/templates/payment/success.js b/src/main/ui/static/templates/payment/success.js index 8bb8587a3..2fff056c0 100644 --- a/src/main/ui/static/templates/payment/success.js +++ b/src/main/ui/static/templates/payment/success.js @@ -33,7 +33,7 @@ $(function () { function loadEncourage() { $.ajax({ url: '/act/encourage_money/orders/' + window.order_id, - method: 'PUT', + method: 'GET', dataType: 'json', success: function (encourage) { if (encourage.access_amount) { From c18da355f03c1404ac00038fd0d2451153968d91 Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 13 Jul 2018 12:49:50 +0800 Subject: [PATCH 4/7] update --- .../manage/customers/web/EncourageMoneyController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 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 a90e4b7e2..e9d1fe4aa 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 @@ -23,15 +23,14 @@ public class EncourageMoneyController { private EncourageService encourageService; @RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET) - public String takeEncourageMoney(@PathVariable String orderId,@RequestHeader("User-Agent") String ua) { - + public ModelAndView takeEncourageMoney(@PathVariable String orderId,@RequestHeader("User-Agent") String ua) { ua = ua.toLowerCase(); if (ua.contains("micromessenger")) { - return "redirect:/act/encourage_money/orders/" + orderId + "/wechat"; + return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/wechat"); } if (ua.contains("alipayclient")) { - return "redirect:/act/encourage_money/orders/" + orderId + "/alipay"; + return new ModelAndView("redirect:/act/encourage_money/orders/" + orderId + "/alipay"); } return null; } From b3d57f7bd9b708bb617e69ecc20e5b8a58ae1d37 Mon Sep 17 00:00:00 2001 From: luoyang14z7 <704328506@qq.com> Date: Fri, 13 Jul 2018 13:04:09 +0800 Subject: [PATCH 5/7] fix : ActChairty --- .../core/impls/ActChairtyServiceImp.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java index b7d86ffbf..30c3c928f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java @@ -10,12 +10,13 @@ import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.lang3.time.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -26,7 +27,7 @@ import java.util.List; */ @Service public class ActChairtyServiceImp implements ActChairtyService { - + Logger logger = LoggerFactory.getLogger(getClass()); @Resource private ClientManager clientManager; @Resource @@ -64,18 +65,18 @@ public class ActChairtyServiceImp implements ActChairtyService { public List getWeekendAnalysis(JSONObject params) { List result = new ArrayList<>(); List getAnalysis = actChairtyMapper.getChairtyWeekAnalysis(params.getDate("begin"), params.getDate("end")); - SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd"); + DateFormatUtils df = new DateFormatUtils(); Calendar cal = Calendar.getInstance(); cal.setTime(params.getDate("begin")); cal.add(cal.DAY_OF_MONTH, -1); long beginTime = params.getDate("begin").getTime(); long endTime = params.getDate("end").getTime(); long betweenDays = (long)((endTime - beginTime) / (1000 * 60 * 60 *24)); - List weekStart = new ArrayList(); + List weekStart = new ArrayList<>(); for(int i=0;i<=betweenDays;i++){ cal.add(cal.DAY_OF_MONTH, 1);//DATE=日 if ((cal.get(Calendar.DAY_OF_WEEK)) == 2) { - weekStart.add(df.format(cal.getTime())); + weekStart.add(df.format(cal.getTime(),"yyyy-MM-dd")); } } for(int i=0;i= dateStar.getTime() && orderDate < dateEnd.getTime()) { @@ -99,16 +96,15 @@ public class ActChairtyServiceImp implements ActChairtyService { } BigDecimal chairty = new BigDecimal(0.01); BigDecimal chairty_amount = count_ordernum.multiply(chairty); - double f1 = sum_ordernum.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - double f2 = chairty_amount.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - + BigDecimal f1 = sum_ordernum.setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal f2 = chairty_amount.setScale(2, BigDecimal.ROUND_HALF_UP); weekDay.put("weekstart", weekStart.get(i)); weekDay.put("count_ordernum", count_ordernum); weekDay.put("sum_ordernum", f1); weekDay.put("chairty_amount",f2 ); result.add(weekDay); } catch (Exception e) { - e.printStackTrace(); + logger.info("Act_Chairty Error:",e); } } 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 6/7] 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 7/7] 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) {