From 3bfb19535fa71235ebb5c13a49cd40d980208db2 Mon Sep 17 00:00:00 2001 From: yangkai Date: Mon, 3 Sep 2018 13:32:31 +0800 Subject: [PATCH] =?UTF-8?q?Ctrip=E5=8D=A1=E5=88=B8=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/impls/RetailAppServiceImp.java | 19 ++++++++++++++++--- .../customers/core/CouponValidateService.java | 2 +- .../core/impls/CouponValidateServiceImpl.java | 5 ++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 77e6022e6..371db155a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -174,6 +174,8 @@ public class RetailAppServiceImp implements RetailAppService { private CustomerServiceService customerServiceService; @Resource private CouponAccuessLogMapper couponAccuessLogMapper; + @Resource + private CouponValidateService couponValidateService; private Map senderMap = new HashMap<>(); private final String fileName[] = { "client_bank_file", "client_id_file", "client_company_file" }; @@ -449,7 +451,7 @@ public class RetailAppServiceImp implements RetailAppService { @Override public JSONObject ctripCouponInfo(JSONObject device, String coupon_id) { - return couponVerificationService.ctripCouponInfo(coupon_id,device.getIntValue("client_id")); + return couponVerificationService.ctripCouponInfo(coupon_id,device.getIntValue("client_id"), true); } @@ -459,9 +461,20 @@ public class RetailAppServiceImp implements RetailAppService { if (client == null) { throw new BadRequestException("Partner not exists"); } - PageList cusCouponLog = couponAccuessLogMapper.getCouponAccuessLog( + PageList cusCouponLogs = couponAccuessLogMapper.getCouponAccuessLog( client.getIntValue("client_id"), new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("creation_date.desc"))); - return PageListUtils.buildPageListResult(cusCouponLog); + HashMap couponMap = new HashMap<>(); + for(JSONObject cusCouponLog : cusCouponLogs) { + cusCouponLog.put("client_moniker", client_moniker); + if (couponMap.containsKey(cusCouponLog.getString("coupon_id"))) { + cusCouponLog.put("coupon", couponMap.get(cusCouponLog.getString("coupon_id"))); + continue; + } + JSONObject coupon = couponValidateService.ctripCouponInfo(cusCouponLog.getString("coupon_id"), cusCouponLog.getIntValue("client_id"), false); + couponMap.put(cusCouponLog.getString("coupon_id"), coupon); + cusCouponLog.put("coupon", coupon); + } + return PageListUtils.buildPageListResult(cusCouponLogs); } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/CouponValidateService.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/CouponValidateService.java index aa4c83f1f..12daea020 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/CouponValidateService.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/CouponValidateService.java @@ -18,7 +18,7 @@ public interface CouponValidateService { JSONObject ctripCheck(int client_id); - JSONObject ctripCouponInfo(String coupon_log_id,int client_id); + JSONObject ctripCouponInfo(String coupon_log_id,int client_id,boolean is_expiry); JSONObject ctripCouponLogNotice(String coupon_log_id,String order_id,String open_id,String status); } diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CouponValidateServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CouponValidateServiceImpl.java index bca4104db..4de0054a5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CouponValidateServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CouponValidateServiceImpl.java @@ -177,7 +177,7 @@ public class CouponValidateServiceImpl implements CouponValidateService { } @Override - public JSONObject ctripCouponInfo(String coupon_id, int client_id) { + public JSONObject ctripCouponInfo(String coupon_id, int client_id, boolean is_expiry) { JSONObject client = clientManager.getClientInfo(client_id); if(client==null){ throw new NotFoundException("Merchant Not Found"); @@ -185,6 +185,9 @@ public class CouponValidateServiceImpl implements CouponValidateService { String uri = signUrl(UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "/coupon/"+coupon_id+"/couponLogInfo")); HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET); gen.addQueryString("client_moniker",client.getString("client_moniker")); + if (!is_expiry) { + gen.addQueryString("is_expiry", "0"); + } try { HttpRequestResult reqResult = gen.execute(); if (reqResult.isSuccess()) {