master
wangning 7 years ago
parent 1731d9e973
commit 7ee91fb885

@ -80,6 +80,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -1892,23 +1893,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client.put("company_name_acn", client.getString("company_name") + " (ABN " + client.getString("abn") + ")");
}
List<JSONObject> clientRate = clientRateMapper.minExpiryTime(client.getIntValue("client_id"),null);
if(CollectionUtils.isEmpty(clientRate)){
List<JSONObject> clientRate = clientRateMapper.minExpiryTime(client.getIntValue("client_id"), null);
if (CollectionUtils.isEmpty(clientRate)) {
throw new BadRequestException("The Partner's Rate is not config!");
}
clientRate.forEach((p)->{
clientRate.forEach((p) -> {
String rate_name = p.getString("rate_name");
if("Wechat".equals(rate_name)){
if ("Wechat".equals(rate_name)) {
client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
client.put("clean", "T+" + p.getString("clean_days"));
client.put("clean_days", p.getString("clean_days"));
}else if("Alipay".equals(rate_name)){
} else if ("Alipay".equals(rate_name)) {
client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}else if("Bestpay".equals(rate_name)){
} else if ("Bestpay".equals(rate_name)) {
client.put("bestpay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}else if("jd".equals(rate_name)){
} else if ("jd".equals(rate_name)) {
client.put("jd_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}else if("AlipayOnline".equals(rate_name)){
} else if ("AlipayOnline".equals(rate_name)) {
client.put("alipay_online_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}
});
@ -1930,7 +1931,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
File file = new File(clientMoniker + "_agreement.pdf");
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
InputStream stream = new ByteArrayInputStream(bos.toByteArray());
JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker +"_"+System.currentTimeMillis()+ "_agreement.pdf", false);
JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_" + System.currentTimeMillis() + "_agreement.pdf", false);
if (fileRes != null) {
importAgreeFile(clientMoniker, manager, fileRes.getString("url"));
}
@ -2035,13 +2036,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
file.put("file_value", sourceFile);
file.put("client_id", client.getIntValue("client_id"));
file.put("last_update_date", now);
if(manager == null){
if (manager == null) {
file.put("last_update_by", "System Import");
}else {
} else {
file.put("last_update_by", manager.getString("display_name"));
}
JSONObject contract = clientsContractMapper.findByClientId(client.getIntValue("client_id"));
if (contract == null ||now.compareTo(contract.getDate("expiry_date"))>0||existFile == null || existFile.isEmpty()) {
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 || existFile == null || existFile.isEmpty()) {
clientFilesMapper.save(file);
} else {
file.put("file_id", existFile.getString("file_id"));
@ -3116,18 +3117,41 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public JSONObject getCheckClientInfo(JSONObject account) {
JSONObject result = clientContractService.getClientContractExpire(account.getIntValue("client_id"));
if(PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER){
result.put("is_ordinary",true);
boolean expire = result.getBoolean("rate_expire");
boolean waring = result.getBoolean("rate_waring");
if(!expire && waring){
JSONObject config = sysConfigManager.getSysConfig();
boolean expire = result.getBoolean("rate_expire");
boolean waring = result.getBoolean("rate_waring");
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,config.getString("sys_contract_ordinary_waring")));
}
if (expire) {
result.put("contract_info",config.getString("sys_contract_ordinary_info"));
}
return result;
}
result.put("is_ordinary", false);
if (!expire && waring) {
String [] key = {result.getString("expire_days")};
result.put("contract_info",editContractOrdinaryWaring(key,config.getString("sys_contract_waring")));
}
if (expire) {
result.put("contract_info",config.getString("sys_contract_info"));
}
JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id"));
result.put("file_url", file.getString("file_value"));
result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info"));
result.put("contract_info", config.getString("sys_contract_info"));
return result;
}
private String editContractOrdinaryWaring(String[] key, String sourceStr) {
if(StringUtils.isEmpty(sourceStr) || ArrayUtils.isEmpty(key)){
return "";
}
for (int i = 0; i < key.length; i++) {
sourceStr = sourceStr.replace("{" + i + "}", key[i]);
}
return sourceStr;
}
}

@ -110,6 +110,7 @@ public class ClientContractServiceImpl implements ClientContractService {
p.put("create_time",now);
p.put("active_time",now);
p.put("expiry_time",DateUtils.addYears(now,1));
clientRateMapper.saveRate(p);
});
}
if(!expire && waring){
@ -118,6 +119,7 @@ public class ClientContractServiceImpl implements ClientContractService {
p.put("create_time",now);
p.put("active_time",DateUtils.addYears(p.getDate("active_time"),1));
p.put("expiry_time",DateUtils.addYears(p.getDate("expiry_time"),1));
clientRateMapper.saveRate(p);
});
}
@ -161,6 +163,7 @@ public class ClientContractServiceImpl implements ClientContractService {
result.put("rate_waring", true);
}
});
result.put("expire_days",(int)(rateInfo.get(0).getDate("expiry_time").getTime()-now.getTime())/(1000*60*60*24));
return result;
}
}

Loading…
Cancel
Save