client modify

master
yixian 7 years ago
parent c7fcb2c867
commit b2dbbcbfce

@ -121,7 +121,7 @@ public interface ClientManager {
void changeRole(JSONObject manager, String clientMoniker, String accountId, int role); void changeRole(JSONObject manager, String clientMoniker, String accountId, int role);
@Transactional @Transactional
void toggleAuditRefund(String clientMoniker, boolean enable); void toggleAuditRefund(String clientMoniker, boolean enable, JSONObject account);
List<JSONObject> listPaymentNoticeAccounts(int clientId); List<JSONObject> listPaymentNoticeAccounts(int clientId);

@ -0,0 +1,11 @@
package au.com.royalpay.payment.manage.merchants.core;
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
/**
* Create by yixian at 2018-04-12 16:24
*/
public interface ClientModifySupport {
void processClientModify(ClientModify clientModify);
}

@ -41,6 +41,8 @@ import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply;
import au.com.royalpay.payment.manage.merchants.core.ClientComplyValidator; import au.com.royalpay.payment.manage.merchants.core.ClientComplyValidator;
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.impls.RefundAuditModify;
import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.signin.beans.TodoNotice; import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider; import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
@ -176,6 +178,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
// todo 作用 // todo 作用
@Resource @Resource
private ClientComplyValidator[] validators; private ClientComplyValidator[] validators;
@Resource
private ClientModifySupport clientModifySupport;
@Resource @Resource
private PaymentChannelApi[] channels; private PaymentChannelApi[] channels;
@Resource @Resource
@ -1083,12 +1088,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void toggleAuditRefund(String clientMoniker, boolean enable) { public void toggleAuditRefund(String clientMoniker, boolean enable, JSONObject account) {
JSONObject partner = getClientInfoByMoniker(clientMoniker); clientModifySupport.processClientModify(new RefundAuditModify(account, clientMoniker, enable));
Assert.notNull(partner, "Merchant is null");
partner.put("enable_refund_auth", enable);
clientMapper.update(partner);
clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id"));
} }
@Override @Override

@ -0,0 +1,30 @@
package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* Create by yixian at 2018-04-12 16:25
*/
@Service
public class ClientModifySupportImpl implements ClientModifySupport {
@Resource
private MerchantInfoProvider merchantInfoProvider;
@Resource
private ClientInfoCacheSupport clientInfoCacheSupport;
@Resource
private ClientMapper clientMapper;
@Override
public void processClientModify(ClientModify modify) {
int clientId = modify.doModify(merchantInfoProvider, mapper, clientMapper);
clientInfoCacheSupport.clearClientCache(clientId);
}
}

@ -0,0 +1,53 @@
package au.com.royalpay.payment.manage.merchants.entity;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Create by yixian at 2018-04-12 16:19
*/
public abstract class ClientModify {
private JSONObject manager;
private JSONObject account;
private String clientMoniker;
public ClientModify(JSONObject manager, JSONObject account, String clientMoniker) {
this.manager = manager;
this.account = account;
this.clientMoniker = clientMoniker;
}
protected abstract String business();
protected abstract JSONObject getModifyResult();
public int doModify(MerchantInfoProvider merchantInfoProvider, ModifyHistoryMapper modifyHistoryMapper, ClientMapper clientMapper) {
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
JSONObject modifyResult = getModifyResult();
saveModifyHistory(modifyHistoryMapper, client, modifyResult);
int clientId = client.getIntValue("client_id");
modifyResult.put("client_id", clientId);
clientMapper.update(modifyResult);
return clientId;
}
private void saveModifyHistory(ModifyHistoryMapper modifyHistoryMapper, JSONObject client, JSONObject modifyResult) {
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get));
JSONObject modifyHistory = new JSONObject();
modifyHistory.put("client_id", client.getIntValue("client_id"));
modifyHistory.put("business", business());
modifyHistory.put("user_type", manager == null ? "Merchant" : "Manager");
modifyHistory.put("user_id", manager == null ? account.getString("account_id") : manager.getString("manager_id"));
modifyHistory.put("username", manager == null ? account.getString("display_name") : manager.getString("display_name"));
modifyHistory.put("origin_data", JSON.toJSONString(beforeModify));
modifyHistory.put("new_data", modifyResult.toJSONString());
modifyHistoryMapper.saveModifyHistory(modifyHistory);
}
}

@ -0,0 +1,28 @@
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 RefundAuditModify extends ClientModify {
private boolean enable;
public RefundAuditModify(JSONObject account, String clientMoniker, boolean enable) {
super(null, account, clientMoniker);
this.enable = enable;
}
@Override
protected String business() {
return "refund_audit";
}
@Override
protected JSONObject getModifyResult() {
JSONObject modify = new JSONObject();
modify.put("enable_refund_auth", enable)
return modify;
}
}

@ -225,7 +225,7 @@ public class PartnerViewController {
@PartnerMapping(value = "/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN) @PartnerMapping(value = "/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN)
@ResponseBody @ResponseBody
public void toggleAuditRefund(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) { public void toggleAuditRefund(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) {
clientManager.toggleAuditRefund(account.getString("client_moniker"), enable.getBooleanValue("enable")); clientManager.toggleAuditRefund(account.getString("client_moniker"), enable.getBooleanValue("enable"), account);
} }
@PartnerMapping(value = "/refund_pwd", method = RequestMethod.PUT, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER}) @PartnerMapping(value = "/refund_pwd", method = RequestMethod.PUT, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})

Loading…
Cancel
Save