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()) {