master
wangning 8 years ago
parent 391e254402
commit 498b30c519

@ -1,21 +1,29 @@
package au.com.royalpay.payment.manage.merchants.core.impls; package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.manage.mappers.system.*; 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.ClientBDMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.merchants.beans.ClientApplyInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientApplyInfo;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.core.ClientApply; import au.com.royalpay.payment.manage.merchants.core.ClientApply;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.impls.SourceModify;
import au.com.royalpay.payment.manage.merchants.events.ClientApplyEvent; import au.com.royalpay.payment.manage.merchants.events.ClientApplyEvent;
import au.com.royalpay.payment.manage.merchants.events.ClientApplyNotifyBDEvent; import au.com.royalpay.payment.manage.merchants.events.ClientApplyNotifyBDEvent;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
@ -26,11 +34,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
/** /**
* Created by yishuqian on 18/10/2016. * Created by yishuqian on 18/10/2016.
*/ */
@ -48,6 +57,8 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw
private OrgMapper orgMapper; private OrgMapper orgMapper;
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@Resource
private ClientModifySupport clientModifySupport;
@Value("${app.redis.prefix}") @Value("${app.redis.prefix}")
private String redisPrefix; private String redisPrefix;
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
@ -230,8 +241,7 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw
} }
JSONObject client = clientMapper.findClientByMoniker(info.getClientMoniker()); JSONObject client = clientMapper.findClientByMoniker(info.getClientMoniker());
Assert.notNull(client); Assert.notNull(client);
client.put("source",2);//自主申请 clientModifySupport.processClientModify(new SourceModify(manager,client.getString("client_moniker"),2));
clientMapper.update(client);
apply.put("client_id", client.getIntValue("client_id")); apply.put("client_id", client.getIntValue("client_id"));
apply.put("client_moniker", info.getClientMoniker()); apply.put("client_moniker", info.getClientMoniker());
apply.put("apply_approve_result", 2); apply.put("apply_approve_result", 2);

@ -58,6 +58,7 @@ import au.com.royalpay.payment.manage.merchants.entity.impls.OrderExpiryModify;
import au.com.royalpay.payment.manage.merchants.entity.impls.ParentIdModify; import au.com.royalpay.payment.manage.merchants.entity.impls.ParentIdModify;
import au.com.royalpay.payment.manage.merchants.entity.impls.PaypadVersionModify; import au.com.royalpay.payment.manage.merchants.entity.impls.PaypadVersionModify;
import au.com.royalpay.payment.manage.merchants.entity.impls.RefundAuditModify; import au.com.royalpay.payment.manage.merchants.entity.impls.RefundAuditModify;
import au.com.royalpay.payment.manage.merchants.entity.impls.AuditModify;
import au.com.royalpay.payment.manage.merchants.entity.impls.SettleHourModify; import au.com.royalpay.payment.manage.merchants.entity.impls.SettleHourModify;
import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify; import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify;
import au.com.royalpay.payment.manage.merchants.entity.impls.TimeZoneModify; import au.com.royalpay.payment.manage.merchants.entity.impls.TimeZoneModify;
@ -561,7 +562,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
Assert.notNull(client); Assert.notNull(client);
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
int clientId = client.getIntValue("client_id"); int clientId = client.getIntValue("client_id");
LogoModify clientModify = new LogoModify(manager,clientMoniker,null,null); LogoModify clientModify = new LogoModify(manager, clientMoniker, null, null);
List<JSONObject> clients = clientMapper.listChildClients(clientId); List<JSONObject> clients = clientMapper.listChildClients(clientId);
if (StringUtils.isNotEmpty(info.getLogoId())) { if (StringUtils.isNotEmpty(info.getLogoId())) {
String fileUrl = attachmentClient.getFileUrl(info.getLogoId()); String fileUrl = attachmentClient.getFileUrl(info.getLogoId());
@ -623,21 +624,17 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client.putAll(clientConfigService.find(client.getIntValue("client_id"))); client.putAll(clientConfigService.find(client.getIntValue("client_id")));
Integer open_status = client.getInteger("open_status"); Integer open_status = client.getInteger("open_status");
boolean checkGreenChannel = client.getIntValue("approve_result") == 2 && (client.getIntValue("source") == 1 || client.getIntValue("source") == 2); boolean checkGreenChannel = client.getIntValue("approve_result") == 2 && (client.getIntValue("source") == 1 || client.getIntValue("source") == 2);
client.put("approve_result", pass); AuditModify auditModify = new AuditModify(manager, clientMoniker, pass, manager.getString("manager_id"), new Date());
client.put("approver", manager.getString("manager_id")); auditModify.setOpen_status(5);
client.put("approve_time", new Date());
client.put("open_status", 5);
if (client.getIntValue("source") == 5) { if (client.getIntValue("source") == 5) {
client.put("source", 1); auditModify.setSource(1);
} }
clientModifySupport.processClientModify(auditModify);
clientMapper.update(client);
sendCommissionWechatMessage(client);// wxMessage sendCommissionWechatMessage(client);// wxMessage
if (pass == 1) { if (pass == 1) {
client.put("skip_clearing", 0); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "skip_clearing", false));
clientMapper.update(client);
if (client.getIntValue("source") == 4) { if (client.getIntValue("source") == 4) {
sendAuthInitEmail(manager,client); sendAuthInitEmail(manager, client);
} else if (checkGreenChannel && client.getIntValue("open_status") == 5) { } else if (checkGreenChannel && client.getIntValue("open_status") == 5) {
// 绿色通道通过后不发邮件 // 绿色通道通过后不发邮件
logger.info("PASS 绿色通道:" + clientMoniker); logger.info("PASS 绿色通道:" + clientMoniker);
@ -687,7 +684,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
username += "1"; username += "1";
} }
} }
sendInitEmail(manager,client, username, pwd); sendInitEmail(manager, client, username, pwd);
} }
@Override @Override
@ -701,7 +698,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new BadRequestException("Email validating... Wait for a moment"); throw new BadRequestException("Email validating... Wait for a moment");
} }
int clientId = client.getIntValue("client_id"); int clientId = client.getIntValue("client_id");
clientModifySupport.processClientConfigModify(new EmailModify(manager,clientMoniker,4,null)); clientModifySupport.processClientConfigModify(new EmailModify(manager, clientMoniker, 4, null));
if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) { if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
int checkBDPermission = clientBDMapper.checkBDPermission(clientId, manager.getString("manager_id")); int checkBDPermission = clientBDMapper.checkBDPermission(clientId, manager.getString("manager_id"));
if (checkBDPermission <= 0) { if (checkBDPermission <= 0) {
@ -710,7 +707,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
List<JSONObject> accounts = clientAccountMapper.listAdminAccounts(clientId); List<JSONObject> accounts = clientAccountMapper.listAdminAccounts(clientId);
if (client.getIntValue("source") == 4) { if (client.getIntValue("source") == 4) {
sendAuthInitEmail(manager,client); sendAuthInitEmail(manager, client);
} else { } else {
if (accounts.size() == 0) { if (accounts.size() == 0) {
initAdminUserAndSendEmail(manager, clientMoniker, client); initAdminUserAndSendEmail(manager, clientMoniker, client);
@ -718,13 +715,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject account = accounts.get(0); JSONObject account = accounts.get(0);
String pwd = RandomStringUtils.random(8, true, true); String pwd = RandomStringUtils.random(8, true, true);
resetAccountPwd(manager, clientMoniker, account.getString("account_id"), pwd); resetAccountPwd(manager, clientMoniker, account.getString("account_id"), pwd);
sendInitEmail(manager,client, account.getString("username"), pwd); sendInitEmail(manager, client, account.getString("username"), pwd);
} }
} }
} }
@Override @Override
public void sendInitEmail(JSONObject account,final JSONObject client, String username, String pwd) { public void sendInitEmail(JSONObject account, final JSONObject client, String username, String pwd) {
logger.debug("sending email after comply"); logger.debug("sending email after comply");
JSONObject model = new JSONObject(); JSONObject model = new JSONObject();
model.put("username", username); model.put("username", username);
@ -762,16 +759,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
try { try {
String emailId = mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", mailTo, String emailId = mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content); emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
clientModifySupport.processClientConfigModify(new EmailModify(account,client.getString("client_moniker"),3,emailId)); clientModifySupport.processClientConfigModify(new EmailModify(account, client.getString("client_moniker"), 3, emailId));
} catch (Exception e) { } catch (Exception e) {
clientModifySupport.processClientConfigModify(new EmailModify(account,client.getString("client_moniker"),0,null)); clientModifySupport.processClientConfigModify(new EmailModify(account, client.getString("client_moniker"), 0, null));
throw new EmailException("Email Sending Failed", e); throw new EmailException("Email Sending Failed", e);
} }
} }
}.start(); }.start();
} }
public void sendAuthInitEmail(JSONObject account ,final JSONObject client) { public void sendAuthInitEmail(JSONObject account, final JSONObject client) {
logger.debug("sending email after comply about a new partner opening by quick access"); logger.debug("sending email after comply about a new partner opening by quick access");
JSONObject model = new JSONObject(); JSONObject model = new JSONObject();
model.put("client_moniker", client.getString("client_moniker")); model.put("client_moniker", client.getString("client_moniker"));
@ -809,7 +806,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
try { try {
String emailId = mailService.sendEmail("Your Partner Account Has Been Authenticated Successfully", mailTo, String emailId = mailService.sendEmail("Your Partner Account Has Been Authenticated Successfully", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content); emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
clientModifySupport.processClientConfigModify(new EmailModify(account,client.getString("client_moniker"),3,emailId)); clientModifySupport.processClientConfigModify(new EmailModify(account, client.getString("client_moniker"), 3, emailId));
} catch (Exception e) { } catch (Exception e) {
throw new EmailException("Email Sending Failed", e); throw new EmailException("Email Sending Failed", e);
} }
@ -1102,16 +1099,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void updateClientBDUser(JSONObject account,String clientMoniker, int managerId) { public void updateClientBDUser(JSONObject account, String clientMoniker, int managerId) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientModify(new BDUserModify(account,clientMoniker,String.valueOf(managerId),null)); clientModifySupport.processClientModify(new BDUserModify(account, clientMoniker, String.valueOf(managerId), null));
List<JSONObject> subClients = clientMapper.listChildClients(client.getIntValue("client_id")); List<JSONObject> subClients = clientMapper.listChildClients(client.getIntValue("client_id"));
for (JSONObject subClient : subClients) { for (JSONObject subClient : subClients) {
subClient.put("bd_user", managerId); subClient.put("bd_user", managerId);
clientModifySupport.processClientModify(new BDUserModify(account,subClient.getString("client_moniker"),String.valueOf(managerId),null)); clientModifySupport.processClientModify(new BDUserModify(account, subClient.getString("client_moniker"), String.valueOf(managerId), null));
} }
} }
@ -1122,7 +1119,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
clientModifySupport.processClientConfigModify(new CredentialCodeModify(manager,clientMoniker, RandomStringUtils.random(32, true, true))); clientModifySupport.processClientConfigModify(new CredentialCodeModify(manager, clientMoniker, RandomStringUtils.random(32, true, true)));
} }
@Override @Override
@ -1648,12 +1645,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void updateTimeZone(JSONObject account,String clientMoniker, String timezone) { public void updateTimeZone(JSONObject account, String clientMoniker, String timezone) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientModify(new TimeZoneModify(account,clientMoniker,timezone)); clientModifySupport.processClientModify(new TimeZoneModify(account, clientMoniker, timezone));
} }
@Override @Override
@ -1746,36 +1743,35 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void setMaxOrderAmount(JSONObject account,String clientMoniker, BigDecimal limit) { public void setMaxOrderAmount(JSONObject account, String clientMoniker, BigDecimal limit) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new MaxOrderAmountModify(account,clientMoniker,limit)); clientModifySupport.processClientConfigModify(new MaxOrderAmountModify(account, clientMoniker, limit));
} }
@Override @Override
public void setCustomerSurchargeRate(JSONObject account,String clientMoniker, BigDecimal customer_surcharge_rate) { public void setCustomerSurchargeRate(JSONObject account, String clientMoniker, BigDecimal customer_surcharge_rate) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
if (customer_surcharge_rate == null) { if (customer_surcharge_rate == null) {
clientModifySupport.processClientConfigModify(new CustomerSurchargeRateModify(account,clientMoniker,null)); clientModifySupport.processClientConfigModify(new CustomerSurchargeRateModify(account, clientMoniker, null));
} else { } else {
BigDecimal rate_value = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat").getBigDecimal("rate_value"); BigDecimal rate_value = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat").getBigDecimal("rate_value");
if (customer_surcharge_rate.compareTo(PlatformEnvironment.getEnv().getMaxCustomerSurchargeRate()) > 0 if (customer_surcharge_rate.compareTo(PlatformEnvironment.getEnv().getMaxCustomerSurchargeRate()) > 0
|| customer_surcharge_rate.compareTo(rate_value) < 0) { || customer_surcharge_rate.compareTo(rate_value) < 0) {
throw new ForbiddenException("Invalid Range"); throw new ForbiddenException("Invalid Range");
} }
clientModifySupport.processClientConfigModify(new CustomerSurchargeRateModify(account,clientMoniker,customer_surcharge_rate)); clientModifySupport.processClientConfigModify(new CustomerSurchargeRateModify(account, clientMoniker, customer_surcharge_rate));
} }
} }
@Override @Override
public void setOrderExpiryConfig(JSONObject account ,String clientMoniker, String orderExpiryConfig) { public void setOrderExpiryConfig(JSONObject account, String clientMoniker, String orderExpiryConfig) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
@ -1784,7 +1780,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", client.getIntValue("client_id")); update.put("client_id", client.getIntValue("client_id"));
if (orderExpiryConfig != null) { if (orderExpiryConfig != null) {
OrderExpiryRuleResolver.resolveExpiryTime(orderExpiryConfig, new Date()); OrderExpiryRuleResolver.resolveExpiryTime(orderExpiryConfig, new Date());
clientModifySupport.processClientConfigModify(new OrderExpiryModify(account,clientMoniker,orderExpiryConfig)); clientModifySupport.processClientConfigModify(new OrderExpiryModify(account, clientMoniker, orderExpiryConfig));
} }
} }
@ -2121,7 +2117,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientFilesMapper.update(file); clientFilesMapper.update(file);
} }
if (!renewal) { if (!renewal) {
clientModifySupport.processClientModify(new OpenStatusModify(manager,clientMoniker,2)); clientModifySupport.processClientModify(new OpenStatusModify(manager, clientMoniker, 2));
} }
if (manager != null) { if (manager != null) {
@ -2140,7 +2136,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (CollectionUtils.isEmpty(existFiles)) { if (CollectionUtils.isEmpty(existFiles)) {
throw new BadRequestException("The Agree File is not Complete!"); throw new BadRequestException("The Agree File is not Complete!");
} }
clientModifySupport.processClientModify(new OpenStatusModify(manager,clientMoniker,3)); clientModifySupport.processClientModify(new OpenStatusModify(manager, clientMoniker, 3));
saveClientAuditProcess(client.getIntValue("client_id"), 2, 3, "合同制作完成等待BD处理", manager); saveClientAuditProcess(client.getIntValue("client_id"), 2, 3, "合同制作完成等待BD处理", manager);
// sendAgreeFileMsgToBD(client,null); // sendAgreeFileMsgToBD(client,null);
sendCommissionWechatMessage(client); sendCommissionWechatMessage(client);
@ -2203,9 +2199,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (StringUtils.isNotBlank(master_client.getString("parent_client_id"))) { if (StringUtils.isNotBlank(master_client.getString("parent_client_id"))) {
throw new BadRequestException("Master Merchant is not valid"); throw new BadRequestException("Master Merchant is not valid");
} }
clientModifySupport.processClientModify(new ParentIdModify(manager,clientMoniker,master_client.getIntValue("client_id"))); clientModifySupport.processClientModify(new ParentIdModify(manager, clientMoniker, master_client.getIntValue("client_id")));
} else { } else {
clientModifySupport.processClientModify(new ParentIdModify(manager,clientMoniker,null)); clientModifySupport.processClientModify(new ParentIdModify(manager, clientMoniker, null));
} }
} }
@ -2235,46 +2231,46 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void setWeekendDelay(JSONObject account,String clientMoniker,int clientId, boolean delay) { public void setWeekendDelay(JSONObject account, String clientMoniker, int clientId, boolean delay) {
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,clientMoniker,"weekend_delay",delay)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "weekend_delay", delay));
} }
@Override @Override
public void setClientQRCodePaySurCharge(JSONObject account,String clientMoniker, boolean paySurcharge) { public void setClientQRCodePaySurCharge(JSONObject account, String clientMoniker, boolean paySurcharge) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,clientMoniker,"qrcode_surcharge",paySurcharge)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "qrcode_surcharge", paySurcharge));
} }
@Override @Override
public void setClientApiPaySurCharge(JSONObject account,String clientMoniker, boolean enableApiSurcharge) { public void setClientApiPaySurCharge(JSONObject account, String clientMoniker, boolean enableApiSurcharge) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,clientMoniker,"api_surcharge",enableApiSurcharge)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "api_surcharge", enableApiSurcharge));
} }
@Override @Override
public void setClientRetailPaySurCharge(JSONObject account,String clientMoniker, boolean paySurcharge) { public void setClientRetailPaySurCharge(JSONObject account, String clientMoniker, boolean paySurcharge) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,clientMoniker,"retail_surcharge",paySurcharge)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "retail_surcharge", paySurcharge));
} }
@Override @Override
public void setClientTaxInSurcharge(JSONObject account , String clientMoniker, boolean taxInSurcharge) { public void setClientTaxInSurcharge(JSONObject account, String clientMoniker, boolean taxInSurcharge) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,clientMoniker,"tax_in_surcharge",taxInSurcharge)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "tax_in_surcharge", taxInSurcharge));
} }
@ -2473,7 +2469,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new BadRequestException("The Partner's Bank Account is not config!"); throw new BadRequestException("The Partner's Bank Account is not config!");
} }
int open_status_from = client.getIntValue("open_status"); int open_status_from = client.getIntValue("open_status");
OpenStatusModify openStatusModify = new OpenStatusModify(manager,clientMoniker,4); OpenStatusModify openStatusModify = new OpenStatusModify(manager, clientMoniker, 4);
if ((client.getIntValue("source") == 1 || client.getIntValue("source") == 2) && client.getIntValue("approve_result") == 2) { if ((client.getIntValue("source") == 1 || client.getIntValue("source") == 2) && client.getIntValue("approve_result") == 2) {
openStatusModify.setApprove_time(new Date()); openStatusModify.setApprove_time(new Date());
} else { } else {
@ -2538,7 +2534,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (account == null || account.size() <= 0) { if (account == null || account.size() <= 0) {
throw new BadRequestException("The Partner's Bank Account is not config!"); throw new BadRequestException("The Partner's Bank Account is not config!");
} }
OpenStatusModify openStatusModify = new OpenStatusModify(manager,clientMoniker,1); OpenStatusModify openStatusModify = new OpenStatusModify(manager, clientMoniker, 1);
openStatusModify.setApprove_result(4); openStatusModify.setApprove_result(4);
openStatusModify.setApprove_time(new Date()); openStatusModify.setApprove_time(new Date());
clientModifySupport.processClientModify(openStatusModify); clientModifySupport.processClientModify(openStatusModify);
@ -2580,7 +2576,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new BadRequestException("The Partner's Bank Account is not config!"); throw new BadRequestException("The Partner's Bank Account is not config!");
} }
Integer open_status_from = client.getInteger("open_status"); Integer open_status_from = client.getInteger("open_status");
OpenStatusModify openStatusModify = new OpenStatusModify(manager,clientMoniker,10); OpenStatusModify openStatusModify = new OpenStatusModify(manager, clientMoniker, 10);
openStatusModify.setApprove_result(4); openStatusModify.setApprove_result(4);
openStatusModify.setApprove_time(new Date()); openStatusModify.setApprove_time(new Date());
clientModifySupport.processClientModify(openStatusModify); clientModifySupport.processClientModify(openStatusModify);
@ -2598,7 +2594,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
clientModifySupport.processClientConfigModify(new PaypadVersionModify(manager,clientMoniker,paypad_version)); clientModifySupport.processClientConfigModify(new PaypadVersionModify(manager, clientMoniker, paypad_version));
} }
@Override @Override
@ -2608,7 +2604,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new PaypadVersionModify(account,client.getString("client_moniker"),paypad_version)); clientModifySupport.processClientConfigModify(new PaypadVersionModify(account, client.getString("client_moniker"), paypad_version));
} }
@ -2641,7 +2637,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,client.getString("client_moniker"),"qrcode_surcharge",paySurcharge)); clientModifySupport
.processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "qrcode_surcharge", paySurcharge));
} }
@ -2652,7 +2649,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,client.getString("client_moniker"),"api_surcharge",enableApiSurcharge)); clientModifySupport
.processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "api_surcharge", enableApiSurcharge));
} }
@ -2667,23 +2665,27 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
// cashier cannot change this config // cashier cannot change this config
throw new ForbiddenException("Cashier has no permission to switch retail surcharge"); throw new ForbiddenException("Cashier has no permission to switch retail surcharge");
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,client.getString("client_moniker"),"retail_surcharge",paySurcharge)); clientModifySupport
.processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "retail_surcharge", paySurcharge));
} }
@Override @Override
public void changeSurcharge(JSONObject account,JSONObject device, UpdateSurchargeDTO updateSurchargeDTO) { public void changeSurcharge(JSONObject account, JSONObject device, UpdateSurchargeDTO updateSurchargeDTO) {
JSONObject client = clientMapper.findClient(device.getIntValue("client_id")); JSONObject client = clientMapper.findClient(device.getIntValue("client_id"));
if (client == null) { if (client == null) {
throw new NotFoundException("Client not found, please check"); throw new NotFoundException("Client not found, please check");
} }
if (updateSurchargeDTO.getApiSurcharge() != null) { if (updateSurchargeDTO.getApiSurcharge() != null) {
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,client.getString("client_moniker"),"api_surcharge",updateSurchargeDTO.getApiSurcharge())); clientModifySupport.processClientConfigModify(
new SwitchPermissionModify(account, client.getString("client_moniker"), "api_surcharge", updateSurchargeDTO.getApiSurcharge()));
} }
if (updateSurchargeDTO.getQrcodeSurcharge() != null) { if (updateSurchargeDTO.getQrcodeSurcharge() != null) {
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,client.getString("client_moniker"),"qrcode_surcharge",updateSurchargeDTO.getQrcodeSurcharge())); clientModifySupport.processClientConfigModify(
new SwitchPermissionModify(account, client.getString("client_moniker"), "qrcode_surcharge", updateSurchargeDTO.getQrcodeSurcharge()));
} }
if (updateSurchargeDTO.getRetailSurcharge() != null) { if (updateSurchargeDTO.getRetailSurcharge() != null) {
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,client.getString("client_moniker"),"retail_surcharge",updateSurchargeDTO.getRetailSurcharge())); clientModifySupport.processClientConfigModify(
new SwitchPermissionModify(account, client.getString("client_moniker"), "retail_surcharge", updateSurchargeDTO.getRetailSurcharge()));
} }
} }
@ -2697,26 +2699,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new ForbiddenException(); throw new ForbiddenException();
} }
int open_status = client.getIntValue("open_status"); int open_status = client.getIntValue("open_status");
AuditModify auditModify = new AuditModify(manager, clientMoniker, 5, manager.getString("manager_id"), new Date());
if (open_status == 1) { if (open_status == 1) {
client.put("open_status", null); auditModify.setOpen_status(null);
} else { } else {
client.put("open_status", open_status - 1); auditModify.setOpen_status(-1);
} }
client.put("approve_result", 5);
client.put("approver", manager.getString("manager_id"));
client.put("approve_time", new Date());
if (refuse_remark != null && !refuse_remark.isEmpty()) { if (refuse_remark != null && !refuse_remark.isEmpty()) {
client.put("refuse_remark", refuse_remark); auditModify.setRefuse_remark(refuse_remark);
} }
saveClientAuditProcess(client.getIntValue("client_id"), open_status, client.getInteger("open_status"), "打回," + refuse_remark, manager); saveClientAuditProcess(client.getIntValue("client_id"), open_status, client.getInteger("open_status"), "打回," + refuse_remark, manager);
clientModifySupport.processClientModify(auditModify);
clientMapper.update(client);
try { try {
sendMessageToBD(client, refuse_remark); sendMessageToBD(client, refuse_remark);
} catch (Exception e) { } catch (Exception e) {
logger.error("RefusePartnerError=======:" + clientMoniker + "," + e.getMessage()); logger.error("RefusePartnerError=======:" + clientMoniker + "," + e.getMessage());
} }
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
} }
@Override @Override
@ -2734,7 +2733,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void updateAppClient(JSONObject account,int client_id, AppClientBean appClientBean) { public void updateAppClient(JSONObject account, int client_id, AppClientBean appClientBean) {
JSONObject client = getClientInfo(client_id); JSONObject client = getClientInfo(client_id);
Assert.notNull(client); Assert.notNull(client);
JSONObject updateObj = appClientBean.updateObject(); JSONObject updateObj = appClientBean.updateObject();
@ -2747,26 +2746,26 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new ForbiddenException("customerSurchargeRate is 0"); throw new ForbiddenException("customerSurchargeRate is 0");
} }
BigDecimal customerSurchargeRate = new BigDecimal(appClientBean.getCustomerSurchargeRate()).setScale(2, BigDecimal.ROUND_HALF_DOWN); BigDecimal customerSurchargeRate = new BigDecimal(appClientBean.getCustomerSurchargeRate()).setScale(2, BigDecimal.ROUND_HALF_DOWN);
setCustomerSurchargeRate(account,client.getString("client_moniker"), customerSurchargeRate); setCustomerSurchargeRate(account, client.getString("client_moniker"), customerSurchargeRate);
} }
} }
@Override @Override
public void setSkipClearing(JSONObject account,String clientMoniker, Boolean skip_clearing) { public void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,clientMoniker,"skip_clearing",skip_clearing)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "skip_clearing", skip_clearing));
} }
@Override @Override
public void enableGatewayUpgrade(JSONObject account,String clientMoniker, boolean gatewayUpgrade) { public void enableGatewayUpgrade(JSONObject account, String clientMoniker, boolean gatewayUpgrade) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,clientMoniker,"gateway_upgrade",gatewayUpgrade)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "gateway_upgrade", gatewayUpgrade));
} }
private void sendMessagetoCompliance(JSONObject client, String bd_user_name) { private void sendMessagetoCompliance(JSONObject client, String bd_user_name) {

@ -0,0 +1,65 @@
package au.com.royalpay.payment.manage.merchants.entity.impls;
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
/**
* Create by yixian at 2018-04-12 16:43
*/
public class AuditModify extends ClientModify {
private Integer source;
private Integer open_status;
private Integer approve_result;
private String approver;
private Date approve_time;
private String refuse_remark;
public AuditModify(JSONObject account, String clientMoniker, Integer approve_result, String approver, Date approve_time) {
super(account, clientMoniker);
this.approve_result = approve_result;
this.approver = approver;
this.approve_time = approve_time;
}
@Override
protected String business() {
return "修改商户source状态为:" + source;
}
@Override
protected JSONObject getModifyResult() {
JSONObject modify = new JSONObject();
modify.put("approve_result",approve_result);
modify.put("approver",approver);
modify.put("approve_time",approve_time);
if(source!=null){
modify.put("source",source);
}
if(open_status!=null){
modify.put("open_status",open_status);
}
if(StringUtils.isNotEmpty(refuse_remark)){
modify.put("refuse_remark",refuse_remark);
}
return modify;
}
public void setSource(Integer source) {
this.source = source;
}
public void setOpen_status(Integer open_status) {
this.open_status = open_status;
}
public void setRefuse_remark(String refuse_remark) {
this.refuse_remark = refuse_remark;
}
}

@ -0,0 +1,30 @@
package au.com.royalpay.payment.manage.merchants.entity.impls;
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
import com.alibaba.fastjson.JSONObject;
/**
* Create by yixian at 2018-04-12 16:43
*/
public class SourceModify extends ClientModify {
private int source;
public SourceModify(JSONObject account, String clientMoniker, int source) {
super(account, clientMoniker);
this.source = source;
}
@Override
protected String business() {
return "修改商户source状态为:" + source;
}
@Override
protected JSONObject getModifyResult() {
JSONObject modify = new JSONObject();
modify.put("source", source);
return modify;
}
}

@ -377,6 +377,6 @@ public class PartnerViewController {
@PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER}) @PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@ResponseBody @ResponseBody
public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) {
clientContractService.confirmSourceAgreement(account,account.getIntValue("client_id"), account.getString("account_id"), "PC"); clientContractService.confirmSourceAgreement(account.getIntValue("client_id"), account.getString("account_id"), "PC");
} }
} }

@ -9,7 +9,7 @@ public interface ClientContractService {
JSONObject getOrGenerateSourceAgreement(int client_id, String channel); JSONObject getOrGenerateSourceAgreement(int client_id, String channel);
void confirmSourceAgreement(JSONObject account,int client_id, String account_id, String channel); void confirmSourceAgreement(int client_id, String account_id, String channel);
JSONObject getSourceAgreement(int client_id); JSONObject getSourceAgreement(int client_id);

@ -74,7 +74,7 @@ public class ClientContractServiceImpl implements ClientContractService {
@Override @Override
@Transactional @Transactional
public void confirmSourceAgreement(JSONObject manager,int client_id, String account_id, String channel) { public void confirmSourceAgreement(int client_id, String account_id, String channel) {
JSONObject client = clientManager.getClientInfo(client_id); JSONObject client = clientManager.getClientInfo(client_id);
if (client == null) { if (client == null) {
throw new NotFoundException("merchant not found"); throw new NotFoundException("merchant not found");
@ -107,7 +107,7 @@ public class ClientContractServiceImpl implements ClientContractService {
contract.put("confirm_time", now); contract.put("confirm_time", now);
contract.put("signatory", account.getString("display_name")); contract.put("signatory", account.getString("display_name"));
clientsContractMapper.update(contract); clientsContractMapper.update(contract);
clientManager.setClientTaxInSurcharge(manager,client.getString("client_moniker"), false); clientManager.setClientTaxInSurcharge(clientAccountMapper.findById(account_id),client.getString("client_moniker"), false);
} }
@Override @Override

Loading…
Cancel
Save