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 c9c91f94a..87faf2ff2 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 @@ -11,7 +11,9 @@ public interface CustomerRewardLogService { void saveReward(int type2,int type3,String type1,String date); - void checkRedpacksStatus(String rewardId); + void checkRedpacksStatus(String rewardId,String sendListId); 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 5645c8bf3..fc087c270 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 @@ -188,9 +188,9 @@ public class CustomerRewardLogServiceImpl implements CustomerRewardLogService { } @Override - public void checkRedpacksStatus(String rewardId) { + public void checkRedpacksStatus(String rewardId,String sendListId) { MpWechatApi redpackApi = mpWechatApiProvider.getApi("redpack"); - JSONObject redpack = redpackApi.redpackStatus(rewardId); + JSONObject redpack = redpackApi.redpackStatus(sendListId); int status = redpack.getIntValue("status"); JSONObject params = new JSONObject(); if(status == 2){ diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/task/RedpackSendingTask.java b/src/main/java/au/com/royalpay/payment/manage/customers/task/RedpackSendingTask.java index 3aca45c85..3cebd17c3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/task/RedpackSendingTask.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/task/RedpackSendingTask.java @@ -24,7 +24,7 @@ public class RedpackSendingTask { public void checkRedpacks() { List unConfirmedRedpacks = cusRewardLogsMapper.listUnconfirmRewards(); for (JSONObject redpack : unConfirmedRedpacks) { - customerRewardLogService.checkRedpacksStatus(redpack.getString("send_listid")); + customerRewardLogService.checkRedpacksStatus(redpack.getString("reward_id"),redpack.getString("send_listid")); } } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 1a0a346b7..ceb4f0a05 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -313,6 +313,8 @@ public interface ClientManager { String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); + void registerAlipayGms(String clientMoniker,JSONObject manager); + List listMerchantIds(String clientMoniker,JSONObject manager); void clearCacheSubMerchantIdApplices(String clientMoniker); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index fbe7bf079..e0f2f3742 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1,5 +1,8 @@ package au.com.royalpay.payment.manage.merchants.core.impls; +import au.com.royalpay.payment.channels.alipay.config.AlipayConfig; +import au.com.royalpay.payment.channels.alipay.config.AlipayEnvironment; +import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient; import au.com.royalpay.payment.channels.rpay.runtime.RpayApi; import au.com.royalpay.payment.channels.rpay.runtime.beans.SubRpayMerchantInfo; import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; @@ -12,6 +15,7 @@ import au.com.royalpay.payment.channels.yeepay.runtime.YeePayClient; import au.com.royalpay.payment.core.PaymentChannelApi; import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; +import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; @@ -144,6 +148,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URISyntaxException; import java.net.URL; +import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -225,6 +230,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private SignInAccountService signInAccountService; @Resource private WxPayClient wxPayClient; + @Resource + private AlipayClient alipayClient; @Resource private RpayApi rpayApi; @@ -3664,6 +3671,31 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return sub_merchant_id; } + @Override + public void registerAlipayGms(String clientMoniker, JSONObject manager) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); + } + checkOrgPermission(manager, client); + if (!client.containsKey("store_photo") || !client.containsKey("company_photo")) { + throw new InvalidParameterException("store photo cannot be empty "); + } + AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant(); + Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client); + if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { + throw new BadRequestException(resultElement.elementText("error")); + } + try { + Element responseElement = resultElement.element("response").element("alipay"); + if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) { + throw new BadRequestException(responseElement.elementText("result_code")); + } + } catch (Exception e) { + throw new ServerErrorException(e); + } + } + @Override public void subRpayMerchantApplication(String clientMoniker, JSONObject merchantInfo,JSONObject manager) { JSONObject client = getClientInfoByMoniker(clientMoniker); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 3f3ed611b..1a0b3aabd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -566,6 +566,11 @@ public class PartnerManageController { return clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager); } + @ManagerMapping(value = "/{clientMoniker}/register/alipay_gms", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) + public void registerAlipayGms(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.registerAlipayGms(clientMoniker,manager); + } + @ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN}) public List getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { return clientManager.listMerchantIds(clientMoniker,manager);