parent
e1ba3b4eaa
commit
e0f564a19d
@ -0,0 +1,37 @@
|
||||
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
||||
|
||||
import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation;
|
||||
import au.com.royalpay.payment.tools.merchants.core.MerchantChannelPermissionResolver;
|
||||
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
||||
import au.com.royalpay.payment.tools.utils.JsonUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class SwitchChannelPermissionModify extends ClientModifyOperation {
|
||||
private final MerchantInfoProvider mchInfoProvider;
|
||||
private final MerchantChannelPermissionResolver channelResolver;
|
||||
private final boolean enableFlag;
|
||||
|
||||
public SwitchChannelPermissionModify(JSONObject account, String clientMoniker, MerchantInfoProvider mchInfoProvider, MerchantChannelPermissionResolver channelResolver, boolean enableFlag) {
|
||||
super(account, clientMoniker);
|
||||
this.mchInfoProvider = mchInfoProvider;
|
||||
this.channelResolver = channelResolver;
|
||||
this.enableFlag = enableFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String business() {
|
||||
return (enableFlag ? "开启 " : "关闭 ") + "渠道[" + channelResolver.payChannel().getChannelCode() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getModifyResult() {
|
||||
return JsonUtils.newJson(json -> json.put("enable_" + channelResolver.payChannel().getChannelCode(), enableFlag + ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Consumer<JSONObject> getModifyProcess() {
|
||||
return client -> channelResolver.switchPermission(mchInfoProvider, client.getIntValue("client_id"), enableFlag);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue