diff --git a/pom.xml b/pom.xml index a3ca784e9..2d7a0d240 100644 --- a/pom.xml +++ b/pom.xml @@ -5,11 +5,11 @@ au.com.royalpay.payment payment-parent - 2.2.25 + 2.2.26 4.0.0 manage - 2.3.76-SNAPSHOT + 2.3.77-SNAPSHOT UTF-8 2.4.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/MerchantChannelPermissionServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/MerchantChannelPermissionServiceImpl.java index 389b411d6..e8be89cff 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/MerchantChannelPermissionServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/MerchantChannelPermissionServiceImpl.java @@ -3,7 +3,6 @@ package au.com.royalpay.payment.manage.merchants.core.impls; import au.com.royalpay.payment.channels.rpaypaymentsvc.mappers.RPayMerchantMapper; import au.com.royalpay.payment.channels.rpaypaymentsvc.runtime.request.entities.RPayMerchantEntity; import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; -import au.com.royalpay.payment.manage.mappers.system.RateMapper; import au.com.royalpay.payment.manage.mappers.system.SysClientUpayProfileMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.MerchantChannelPermissionService; @@ -11,6 +10,7 @@ import au.com.royalpay.payment.tools.defines.PayChannel; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.merchants.exceptions.NoRateConfigException; import com.alibaba.fastjson.JSONObject; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -68,12 +68,13 @@ public class MerchantChannelPermissionServiceImpl implements MerchantChannelPerm } clientManager.switchPermission(manager, targetClientMoniker, "enable_rpaypmt_card", sourceMerchant.getBooleanValue("enable_rpaypmt_card")); clientManager.switchPermission(manager, targetClientMoniker, "enable_rpaypmt_dd", sourceMerchant.getBooleanValue("enable_rpaypmt_dd")); - JSONObject targetRate = merchantInfoProvider.clientCurrentRate(targetClientId, new Date(), PayChannel.RPAY_CHANNEL_CARD.getChannelCode()); - if (targetRate == null) { - JSONObject sourceRate = merchantInfoProvider.clientCurrentRate(sourceClientId, new Date(), PayChannel.RPAY_CHANNEL_CARD.getChannelCode()); - targetRate = new JSONObject(sourceRate); - targetRate.put("client_id", targetClientId); - clientRateMapper.saveRate(targetRate); + try { + merchantInfoProvider.clientCurrentRate(targetClientId, new Date(), PayChannel.RPAY_CHANNEL_CARD.getChannelCode()); + } catch (NoRateConfigException e) { + JSONObject rate = merchantInfoProvider.clientCurrentRate(sourceClientId, new Date(), PayChannel.RPAY_CHANNEL_CARD.getChannelCode()); + rate.put("client_id", targetClientId); + rate.remove("client_rate_id"); + clientRateMapper.saveRate(rate); } return targetRPayMch; } diff --git a/src/main/resources/application-proxy.yml b/src/main/resources/application-proxy.yml index ea2691494..ea9b304c2 100644 --- a/src/main/resources/application-proxy.yml +++ b/src/main/resources/application-proxy.yml @@ -5,8 +5,8 @@ spring: master: driver-class-name: com.mysql.cj.jdbc.Driver jdbc-url: jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false - password: read0nly - username: readonly + password: ZOIBhellor0yalpay + username: root schema-name: royalpay_production slave: driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/src/test/java/au/com/royalpay/payment/manage/merchants/core/impls/MerchantChannelPermissionServiceImplTest.java b/src/test/java/au/com/royalpay/payment/manage/merchants/core/impls/MerchantChannelPermissionServiceImplTest.java new file mode 100644 index 000000000..e40799fcd --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/merchants/core/impls/MerchantChannelPermissionServiceImplTest.java @@ -0,0 +1,30 @@ +package au.com.royalpay.payment.manage.merchants.core.impls; + +import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; +import au.com.royalpay.payment.manage.merchants.core.MerchantChannelPermissionService; +import com.alibaba.fastjson.JSONObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +@RunWith(SpringRunner.class) +@SpringBootTest +@ActiveProfiles({"proxy","common", "alipay", "wechat", "rpay", "rppaysvc"}) +public class MerchantChannelPermissionServiceImplTest { + + @Resource + private MerchantChannelPermissionService merchantChannelPermissionService; + + @Resource + private ManagerMapper managerMapper; + + @Test + public void test() { + JSONObject manager = managerMapper.findByLoginId("yixian"); + merchantChannelPermissionService.copyMerchantWarriorConfig(manager, "DV11", "DV02"); + } +} \ No newline at end of file