diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysRpayMerchantApplyMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysRpayMerchantApplyMapper.java
new file mode 100644
index 000000000..9aa1cdbff
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/SysRpayMerchantApplyMapper.java
@@ -0,0 +1,26 @@
+package au.com.royalpay.payment.manage.mappers.system;
+
+import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
+import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
+import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
+import com.alibaba.fastjson.JSONObject;
+import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Created by yangluo on 2017-03-14.
+ */
+@AutoMapper(tablename = "sys_rpay_merchant_apply",pkName = "merchant_app_id")
+public interface SysRpayMerchantApplyMapper {
+ @AutoSql(type = SqlType.SELECT)
+ List listRpayMerchantApplices(@Param("client_id") int client_id, PageBounds pageBounds);
+
+ @AutoSql(type = SqlType.INSERT)
+ void insertRpayMerchantApply(JSONObject params);
+
+ @AutoSql(type = SqlType.SELECT)
+ List selectByShortName(@Param("client_id") int client_id,@Param("merchant_shortname") String shortName);
+
+}
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 7c0e982ea..0604c11e3 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
@@ -60,6 +60,9 @@ public interface ClientManager {
@Transactional
void updateClientPaymentConfig(JSONObject manager, String clientMoniker, JSONObject subMerchantInfo);
+ @Transactional
+ void updateClientRpayPaymentConfig(JSONObject manager, String clientMoniker, JSONObject rpaySubMerchantInfo);
+
@Transactional
void updateAliSubMerchantId(JSONObject manager, String clientMoniker, JSONObject aliSubMerchantInfo);
@@ -296,6 +299,8 @@ public interface ClientManager {
List listSubMerchantIdApplys(JSONObject manager, String clientMoniker);
+ List listRpaySubMerchantIdApplys(JSONObject manager, String clientMoniker);
+
String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager);
List listMerchantIds(String clientMoniker,JSONObject manager);
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 7a853e253..4defc9826 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
@@ -25,24 +25,7 @@ import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper;
import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
-import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
-import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper;
-import au.com.royalpay.payment.manage.mappers.system.MailSendMapper;
-import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper;
-import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
-import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
-import au.com.royalpay.payment.manage.mappers.system.PermissionPartnerModuleMapper;
-import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
+import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
@@ -262,6 +245,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource
private SysWxMerchantApplyMapper sysWxMerchantApplyMapper;
@Resource
+ private SysRpayMerchantApplyMapper sysRpayMerchantApplyMapper;
+ @Resource
private SpringTemplateEngine thymeleaf;
@Resource
private DeviceManager deviceManager;
@@ -770,6 +755,40 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientInfoCacheSupport.clearClientCache(clientId);
}
+ @Override
+ public void updateClientRpayPaymentConfig(JSONObject manager, String clientMoniker, JSONObject rpaySubMerchantInfo) {
+ JSONObject client = getClientInfoByMoniker(clientMoniker);
+ if (client == null) {
+ throw new InvalidShortIdException();
+ }
+ checkOrgPermission(manager, client);
+ JSONObject update = new JSONObject();
+ int clientId = client.getIntValue("client_id");
+ String originSubMerchantId = client.getString("rpay_enterprise_id");
+ update.put("client_id", clientId);
+ String subMerchantId = rpaySubMerchantInfo.getString("rpay_enterprise_id");
+ update.put("rpay_enterprise_id", subMerchantId);
+ try {
+ recordSubMerchantLog(client, rpaySubMerchantInfo, manager);
+ } catch (Exception e) {
+ logger.error("记录log_client_sub_merchant_id失败", e);
+ }
+ clientMapper.update(update);
+ List children = clientMapper.listChildClients(clientId);
+ for (JSONObject child : children) {
+ if (Objects.equals(child.getString("rpay_enterprise_id"), originSubMerchantId)) {
+ update.put("client_id", child.getIntValue("client_id"));
+ try {
+ recordSubMerchantLog(child, rpaySubMerchantInfo, manager);
+ } catch (Exception e) {
+ logger.error("记录log_client_sub_merchant_id失败", e);
+ }
+ clientMapper.update(update);
+ }
+ }
+ clientInfoCacheSupport.clearClientCache(clientId);
+ }
+
@Override
public void updateAliSubMerchantId(JSONObject manager, String clientMoniker, JSONObject aliSubMerchantInfo) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
@@ -3513,6 +3532,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return null;
}
+ @Override
+ public List listRpaySubMerchantIdApplys(JSONObject manager, String clientMoniker) {
+ JSONObject client = getClientInfoByMoniker(clientMoniker);
+ if (client == null) {
+ throw new InvalidShortIdException();
+ }
+ checkOrgPermission(manager, client);
+ List applices = sysRpayMerchantApplyMapper.listRpayMerchantApplices(client.getInteger("client_id"),
+ new PageBounds(Order.formString("create_time.desc")));
+ if (!applices.isEmpty()) {
+ return applices;
+ }
+ return null;
+ }
+
@Override
@CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply, JSONObject manager) {
@@ -3548,22 +3582,30 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
checkOrgPermission(manager, client);
- SubRpayMerchantInfo subRpayMerchantInfo = JSONObject.toJavaObject(client, SubRpayMerchantInfo.class);
- subRpayMerchantInfo.CheckEmpty();
- rpayApi.registerMerchant(client.getIntValue("client_id"), subRpayMerchantInfo);
-
- logger.debug("访问成功,返回的信息是: " );
-
-
-
- // String sub_merchant_id = elem.elementText("sub_mch_id");
-/* if (StringUtils.isNotEmpty(sub_merchant_id)) {
-
+ List selectByshortName = sysRpayMerchantApplyMapper.selectByShortName(client.getIntValue("client_id"),client.getString("short_name"));
+ if (selectByshortName.size()>0) {
+ throw new BadRequestException("请修改【" + clientMoniker + "】的Company shortName信息(请避免和Rpay+商务号列表内的Company Short Name重复)");
+ }
- } else {
+ SubRpayMerchantInfo subRpayMerchantInfo = JSONObject.toJavaObject(client, SubRpayMerchantInfo.class);
+ subRpayMerchantInfo.CheckEmpty();
+ JSONObject rpayMerchantInfo = rpayApi.registerMerchant(client.getIntValue("client_id"), subRpayMerchantInfo);
+
+ if (rpayMerchantInfo != null) {
+ JSONObject merchantApply = new JSONObject();
+ merchantApply.put("merchant_id", rpayMerchantInfo.getString("rpay_order_id"));
+ merchantApply.put("client_id", client.getString("client_id"));
+ merchantApply.put("create_time", new Date());
+ merchantApply.put("operator", manager.getString("display_name"));
+ merchantApply.put("sub_merchant_id", rpayMerchantInfo.getString("merchantId"));
+ merchantApply.put("business_category", client.getString("royalpayindustry"));
+ merchantApply.put("merchant_shortname", client.getString("short_name"));
+ sysRpayMerchantApplyMapper.insertRpayMerchantApply(merchantApply);
+ }else {
throw new BadRequestException("请求失败");
- }*/
+ }
+
return null;
}
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 aa40c3310..c228f5995 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
@@ -155,6 +155,11 @@ public class PartnerManageController {
clientManager.updateClientPaymentConfig(manager, clientMoniker, subMerchantInfo);
}
+ @ManagerMapping(value = "/{clientMoniker}/rpay_payment_config", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
+ public void updatePartnerRpayPaymentConfig(@PathVariable String clientMoniker, @RequestBody JSONObject rpaySubMerchantInfo, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
+ clientManager.updateClientRpayPaymentConfig(manager, clientMoniker, rpaySubMerchantInfo);
+ }
+
@ManagerMapping(value = "/{clientMoniker}/ali_sub_merchant_id", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR})
public void updateAliSubMerchantId(@PathVariable String clientMoniker, @RequestBody JSONObject aliSubMerchantInfo, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.updateAliSubMerchantId(manager, clientMoniker, aliSubMerchantInfo);
@@ -518,6 +523,11 @@ public class PartnerManageController {
return clientManager.listSubMerchantIdApplys(manager, clientMoniker);
}
+ @ManagerMapping(value = "/{clientMoniker}/list_rpay_sub_applices", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
+ public List listRpaySubMerchantIdApplys(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
+ return clientManager.listRpaySubMerchantIdApplys(manager, clientMoniker);
+ }
+
@ManagerMapping(value = "/{clientMoniker}/sub_apply", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public String subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.subMerchantApplication(clientMoniker, subMerchantIdApply, manager);
diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js
index 63c39ada0..b855dae98 100644
--- a/src/main/ui/static/payment/partner/partner-manage.js
+++ b/src/main/ui/static/payment/partner/partner-manage.js
@@ -3084,6 +3084,9 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
$http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_sub_applices', {params: {}}).then(function (resp) {
$scope.subMerchantInfos = resp.data;
});
+ $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_rpay_sub_applices', {params: {}}).then(function (resp) {
+ $scope.subRpayMerchantInfos = resp.data;
+ });
};
$scope.useSubMerchantId = function (sub_merchant_id) {
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', {sub_merchant_id: sub_merchant_id}).then(function (resp) {
@@ -3097,6 +3100,18 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
});
}
+ $scope.useRpaySubMerchantId = function (sub_merchant_id) {
+ $http.put('/sys/partners/' + $scope.partner.client_moniker + '/rpay_payment_config', {rpay_enterprise_id: sub_merchant_id}).then(function (resp) {
+ commonDialog.alert({
+ title: 'Success',
+ content: 'Modify Rpay+ Sub Merchant ID successfully',
+ type: 'success'
+ });
+ $state.reload();
+ }, function (resp) {
+ commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
+ });
+ }
$scope.applyWxSubMerchantId = function () {
$uibModal.open({
templateUrl: '/static/payment/partner/templates/apply_wx_sub_merchant_id.html',
@@ -3117,7 +3132,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
$http.post('/sys/partners/' + $scope.partner.client_moniker + '/registRpaySubMerchantId').then(function (resp) {
commonDialog.alert({
title: 'Success',
- content: 'Modify Wechat Sub Merchant ID successfully',
+ content: 'Modify Rpay+ Sub Merchant ID successfully',
type: 'success'
});
$state.reload();
diff --git a/src/main/ui/static/payment/partner/templates/partner_payment_info.html b/src/main/ui/static/payment/partner/templates/partner_payment_info.html
index 6e6499a34..804ab968b 100644
--- a/src/main/ui/static/payment/partner/templates/partner_payment_info.html
+++ b/src/main/ui/static/payment/partner/templates/partner_payment_info.html
@@ -48,6 +48,14 @@
+
diff --git a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html
index 03309be2c..40fc8c119 100644
--- a/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html
+++ b/src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html
@@ -41,19 +41,6 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ Sub Merchant Id
+ (当前使用){{id_apply.sub_merchant_id}}
+
+ -
+ Apply Time
+
+
+ -
+ Company Short Name
+ {{id_apply.merchant_shortname | cut:true:20:' ...'}}
+
+ -
+ Business Category
+ {{id_apply.business_category | partner_royalpay_industry}}
+
+ -
+ Operator
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file