update contract

master
wangning 7 years ago
parent 011bba9eb3
commit 3b53be6de3

@ -230,6 +230,15 @@ public class RetailAppController {
return retailAppService.getCheckClientInfo(device);
}
@RequestMapping(value = "/client/checkContract", method = RequestMethod.GET)
public JSONObject getCheckClientInfoV2(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
String version = device.getString("version");
if("2.9.3".equals(version)){
throw new BadRequestException("test");
}
return retailAppService.getCheckClientInfo(device);
}
@RequestMapping(value = "/client", method = RequestMethod.PUT)
public void updateClient(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody AppClientBean appClientBean) {
retailAppService.updateClient(device, appClientBean);

@ -245,8 +245,6 @@ public interface ClientManager {
void setSkipClearing(String clientMoniker, Boolean skip_clearing);
void setSkipContract(String clientMoniker, Boolean new_contract);
void enableGatewayUpgrade(String clientMoniker, boolean gatewayUpgrade);
void setCustomerSurchargeRate(String clientMoniker, BigDecimal customer_surcharge_rate);

@ -53,7 +53,6 @@ import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
import au.com.royalpay.payment.tools.connections.mpsupport.exceptions.WechatException;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.RequestEnvironment;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
@ -2839,20 +2838,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
public void setSkipContract(String clientMoniker, Boolean new_contract) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
JSONObject update = new JSONObject();
int clientId = client.getIntValue("client_id");
update.put("client_id", clientId);
update.put("new_contract", new_contract);
clientMapper.update(update);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
public void enableGatewayUpgrade(String clientMoniker, boolean gatewayUpgrade) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
@ -3257,45 +3242,60 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
public JSONObject getCheckClientInfo(int client_id, String account_id) {
JSONObject result = clientContractService.getClientContractExpire(client_id);
JSONObject account = clientAccountMapper.findById(account_id);
boolean expire = result.getBoolean("rate_expire");
boolean waring = result.getBoolean("rate_waring");
boolean old_contract = result.getBoolean("old_contract");
if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) {
result.put("is_ordinary", true);
if (!expire && waring) {
String[] key = { result.getString("expire_days") };
result.put("contract_info",
editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.ordinary.waring", null, RequestEnvironment.getLocale())));
}
if (expire) {
result.put("contract_info", messageSource.getMessage("sys.contract.ordinary.info", null, RequestEnvironment.getLocale()));
}
if (old_contract) {
result.put("contract_info", messageSource.getMessage("contract.old.waring", null, RequestEnvironment.getLocale()));
}
result.put("alert", false);
} else {
result.put("is_ordinary", false);
if (!expire && waring) {
String[] key = { result.getString("expire_days") };
result.put("contract_info",
editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.waring", null, RequestEnvironment.getLocale())));
}
if (expire) {
result.put("contract_info", messageSource.getMessage("sys.contract.info", null, RequestEnvironment.getLocale()));
if(result.getBoolean("alert")){
result.put("content","Dear Valued Merchants,\n" +
"\n" +
"\n" +
"\n" +
"We would like to extend our warm gratitude to your business for your continued support of RoyalPay. Without our merchants we wouldn't be where we are today. \n" +
"\n" +
"\n" +
"\n" +
"RoyalPay has and always will be committed to complying with all Australian laws, rules and regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax Office) to make sure that we are in alignment with all tax requirements. \n" +
"\n" +
"\n" +
"\n" +
"\n" +
"During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. \n" +
"\n" +
"\n" +
"\n" +
"This will result in contractual changes to your agreement. However, your business may be eligible to claim this amount back depending on the tax relationship of your business. Please consult with your accounting team in relation to these changes. \n" +
"\n" +
"\n" +
"\n" +
"If you have any questions related to this change please direct them to our Sales Management Team or your relevant BD officer.\n" +
"\n" +
"\n" +
"\n" +
"(note: GST is for the surcharge fee only, not related to the price of the goods.)\n" +
"\n" +
"\n" +
"\n" +
"尊敬的商户,\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式这两年来我们不断地与相关机构探讨最为合适的监管法令应用同时澳洲的相应法律法规也在不断地完善来提供更全面的监管来营造更加稳定、健康、健全的金融市场。\n" +
"\n" +
"\n" +
"\n" +
"RoyalPay于近期正式收到澳洲监管机构的通知针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复目前澳洲市场上的移动支付扫码解决方案所产生的手续费部分的GST并不能享受Tax Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST Return。感谢您的支持和理解愿我们一起共同努力塑造一个良好而有序的澳洲移动支付市场。\n" +
"\n" +
"\n" +
"\n" +
"有任何疑问,请随时联络我们的客服与公众号。\n" +
"\n" +
"GST只针对手续费部分与商品价格无关\n" +
"\n");
result.put("title","【Important重要】GST Modification Notice | 澳洲监管机构关于手续费GST调整问题通知\n");
}
if (old_contract) {
result.put("contract_info", messageSource.getMessage("contract.old.waring", null, RequestEnvironment.getLocale()));
}
}
JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id"), "pc");
if (file != null) {
result.put("file_url", file.getString("file_value"));
} else {
result.put("file_url", "");
}
return result;
}
private String editContractOrdinaryWaring(String[] key, String sourceStr) {

@ -534,9 +534,4 @@ public class PartnerManageController {
clientContractService.confirmSourceAgreement(account.getIntValue("client_id"),account.getString("account_id"),"PC");
}
@ManagerMapping(value = "/{clientMoniker}/new_contract", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public void skipContract(@PathVariable String clientMoniker, @RequestBody JSONObject new_contract) {
clientManager.setSkipContract(clientMoniker, new_contract.getBooleanValue("new_contract"));
}
}

@ -2,17 +2,20 @@ package au.com.royalpay.payment.manage.system.core;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.util.List;
public interface ClientContractService {
JSONObject getOrGenerateSourceAgreement(int client_id,String channel);
JSONObject getOrGenerateSourceAgreement(int client_id, String channel);
void confirmSourceAgreement(int client_id,String account_id,String channel);
void confirmSourceAgreement(int client_id, String account_id, String channel);
JSONObject getSourceAgreement(int client_id);
JSONObject getClientContractExpire(int client_id);
void saveContract(int client_id, Date expire_date, String channel);
List<JSONObject> list();
}

@ -2,12 +2,10 @@ package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
@ -21,9 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -38,8 +34,6 @@ public class ClientContractServiceImpl implements ClientContractService {
@Resource
private ClientsContractMapper clientsContractMapper;
@Resource
private ClientRateMapper clientRateMapper;
@Resource
private SysConfigManager sysConfigManager;
@Resource
private ClientAccountMapper clientAccountMapper;
@ -51,40 +45,22 @@ public class ClientContractServiceImpl implements ClientContractService {
if (client == null) {
throw new NotFoundException("merchant not found");
}
JSONObject expireInfo = getClientContractExpire(client_id);
JSONObject contract = clientsContractMapper.findByClientId(client_id);
Date now = new Date();
if ((expireInfo.getBoolean("rate_waring") || expireInfo.getBoolean("old_contract"))
&& (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0)) {
try {
clientManager.getNewAggregateAgreeFile(client.getString("client_moniker"), null, true);
} catch (Exception e) {
logger.info("App generate PDF failed");
throw new ServerErrorException("System error");
}
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
saveContract(client_id, now, channel);
return files.get(0);
} else {
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
if (!CollectionUtils.isEmpty(files)) {
JSONObject file = files.get(0);
if (expireInfo.getBoolean("rate_expire")) {
contract.put("create_time", now);
contract.put("expiry_date", DateUtils.addYears(now, 1));
clientsContractMapper.update(contract);
}
return file;
}
return null;
try {
clientManager.getNewAggregateAgreeFile(client.getString("client_moniker"), null, true);
} catch (Exception e) {
logger.info("App generate PDF failed");
throw new ServerErrorException("System error");
}
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
return files.get(0);
}
private void saveContract(int client_id, Date now, String channel) {
@Override
public void saveContract(int client_id, Date expire_date, String channel) {
JSONObject newContract = new JSONObject();
newContract.put("create_time", now);
newContract.put("expiry_date", DateUtils.addYears(now, 1));
newContract.put("create_time", new Date());
newContract.put("expiry_date", DateUtils.addYears(expire_date, 1));
newContract.put("sign_channel", channel);
newContract.put("client_id", client_id);
newContract.put("has_sign", false);
@ -98,40 +74,20 @@ public class ClientContractServiceImpl implements ClientContractService {
if (client == null) {
throw new NotFoundException("merchant not found");
}
// JSONObject rateExpire = getClientContractExpire(client_id);
// boolean expire = rateExpire.getBoolean("rate_expire");
// boolean waring = rateExpire.getBoolean("rate_waring");
// boolean old_contract = rateExpire.getBoolean("old_contract");
JSONObject contract = clientsContractMapper.findByClientId(client_id);
if (contract == null) {
throw new BadRequestException("generate contract first");
}
if (contract.getBoolean("has_sign")) {
if (contract != null && contract.getBoolean("has_sign")) {
return;
}
Date now = new Date();
JSONObject account = clientAccountMapper.findById(account_id);
contract.put("has_sign", 1);
contract.put("sign_account_id", account_id);
contract.put("sign_channel", channel);
contract.put("confirm_time", now);
contract.put("signatory", account.getString("display_name"));
clientsContractMapper.update(contract);
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
rateInfo.forEach((p) -> {
p.remove("client_rate_id");
p.put("create_time", now);
p.put("active_time", now);
p.put("update_time", now);
p.put("manager_id", "0");
p.put("expiry_time", DateUtils.addYears(now, 1));
p.put("manager_name", "merchant_" + account_id + "_" + account.getString("display_name"));
clientRateMapper.saveRate(p);
});
getOrGenerateSourceAgreement(client_id, channel);
clientManager.setClientTaxInSurcharge(client.getString("client_moniker"), false);
clientManager.setSkipContract(client.getString("client_moniker"), true);
}
@Override
@ -150,74 +106,24 @@ public class ClientContractServiceImpl implements ClientContractService {
throw new NotFoundException("merchant not found please check ID");
}
JSONObject sysconfig = sysConfigManager.getSysConfig();
JSONObject defaultResult = new JSONObject();
defaultResult.put("rate_expire", false);
defaultResult.put("rate_waring", false);
defaultResult.put("old_contract", false);
if (sysconfig != null && !sysconfig.getBoolean("sys_new_contract_on")) {
return defaultResult;
}
if(client.getBooleanValue("new_contract")){
return defaultResult;
}
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
JSONObject result = new JSONObject();
if (CollectionUtils.isEmpty(rateInfo)) {
result.put("rate_expire", true);
result.put("rate_waring", true);
return result;
}
result.put("rate_expire", false);
result.put("rate_waring", false);
result.put("old_contract", false);
Date now = new Date();
JSONObject contract = clientsContractMapper.findByClientId(client_id);
if (contract != null && contract.getDate("expiry_date").compareTo(now) > 0 && contract.getBoolean("has_sign")) {
result.put("alert", false);
if (sysconfig != null && !sysconfig.getBoolean("sys_new_contract_on")) {
return result;
}
int waringDays = sysconfig.getIntValue("rate_warning_days");
Map<String, JSONObject> filterMap = new HashMap<>();
rateInfo.forEach((p) -> {
String key = p.getString("rate_name");
JSONObject tmp = filterMap.get(key);
if (tmp == null) {
filterMap.put(key, p);
} else {
if (tmp.getDate("expiry_time").compareTo(p.getDate("expiry_time")) < 0) {
filterMap.put(key, p);
}
}
});
for (JSONObject p : filterMap.values()) {
if (now.compareTo(DateUtils.addDays(p.getDate("expiry_time"), 1)) > -1) {
result.put("rate_expire", true);
}
if (DateUtils.addDays(now, waringDays).compareTo(DateUtils.addDays(p.getDate("expiry_time"), 1)) > -1) {
int expireDay = 0;
long expireSS = (DateUtils.addDays(p.getDate("expiry_time"), 1).getTime() - now.getTime());
expireDay = (int) expireSS / (1000 * 60 * 60 * 24);
if (expireSS % (1000 * 60 * 60 * 24) > 1) {
++expireDay;
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
if (!CollectionUtils.isEmpty(files)) {
JSONObject file = files.get(0);
if (sysconfig.getDate("sys_new_contract_time").compareTo(file.getDate("last_update_date")) > 0) {
JSONObject contract = clientsContractMapper.findByClientId(client_id);
if (contract == null) {
saveContract(client_id, new Date(), null);
}
result.put("expire_days", expireDay);
result.put("rate_waring", true);
}
}
if (!result.getBoolean("rate_waring") && !result.getBoolean("rate_expire")) {
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
if (CollectionUtils.isEmpty(files)) {
result.put("old_contract", true);
result.put("rate_waring", true);
} else {
JSONObject file = files.get(0);
if (sysconfig.getDate("sys_new_contract_time").compareTo(file.getDate("last_update_date")) > 0
|| (contract != null && !contract.getBoolean("has_sign"))) {
result.put("old_contract", true);
result.put("rate_waring", true);
}
}
if (client.getBooleanValue("tax_in_surcharge")) {
result.put("alert", true);
return result;
}
return result;
}

@ -2352,12 +2352,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
return url;
};
$scope.setSkipContract = function () {
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/new_contract',{new_contract: $scope.partner.new_contract}).then(function(){
})
};
$scope.updateFile = function () {
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/file', $scope.file).then(function () {
commonDialog.alert({

@ -3,18 +3,6 @@
width: 100%;
}
</style>
<div class="panel panel-default">
<div class="panel-heading">Contract</div>
<div class="panel-body">
<label class="col-sm-7 control-label">Skip New Contract</label>
<div class="col-sm-5">
<input type="checkbox" ng-model="partner.new_contract" bs-switch
switch-change="setSkipContract()">
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Audit Files &nbsp;&nbsp;&nbsp;
<button class="btn-group btn btn-warning" ng-if="partner.approve_result==2 && partner.source==4" type="button"

Loading…
Cancel
Save