master
wangning 7 years ago
parent 29d7835400
commit 5db7294880

@ -110,5 +110,5 @@ public interface RetailAppService {
JSONObject getAdDetail(JSONObject device, String article_id);
JSONObject getClientRateExpire(int client_id);
JSONObject getClientContractExpire(int client_id);
}

@ -18,6 +18,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
@ -138,6 +139,8 @@ public class RetailAppServiceImp implements RetailAppService {
private ClientDeviceTokenMapper clientDeviceTokenMapper;
@Resource
private ClientRateMapper clientRateMapper;
@Resource
private ClientsContractMapper clientsContractMapper;
private Map<String, AppMsgSender> senderMap = new HashMap<>();
@ -1329,7 +1332,7 @@ public class RetailAppServiceImp implements RetailAppService {
}
@Override
public JSONObject getClientRateExpire(int client_id) {
public JSONObject getClientContractExpire(int client_id) {
JSONObject client = clientManager.getClientInfo(client_id);
if (client == null) {
throw new NotFoundException("merchant not found please check ID");
@ -1338,10 +1341,14 @@ public class RetailAppServiceImp implements RetailAppService {
JSONObject result = new JSONObject();
result.put("rate_expire", false);
result.put("rate_waring", 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")){
return result;
}
if (CollectionUtils.isEmpty(rateInfo)) {
return result;
}
Date now = new Date();
rateInfo.forEach((p)->{
if (now.compareTo(p.getDate("expiry_time")) > -1) {
result.put("rate_expire", true);

@ -200,7 +200,7 @@ public class RetailAppController {
@RequestMapping(value = "/client/check", method = RequestMethod.GET)
public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
JSONObject result = retailAppService.getClientRateExpire(device.getIntValue("client_id"));
JSONObject result = retailAppService.getClientContractExpire(device.getIntValue("client_id"));
JSONObject file = appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id"));
result.put("file_url", file.getString("file_value"));
result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info"));
@ -339,6 +339,14 @@ public class RetailAppController {
return result;
}
@RequestMapping(value = "/file/agree", method = RequestMethod.GET)
public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
JSONObject file = appFileService.getSourceAgreement(device.getIntValue("client_id"));
JSONObject result = new JSONObject();
result.put("file_url",file.getString("file_value"));
return result;
}
@RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST)
public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
appFileService.confirmSourceAgreement(device.getIntValue("client_id"));

@ -7,4 +7,6 @@ public interface AppFileService {
JSONObject getOrGenerateSourceAgreement(int client_id);
void confirmSourceAgreement(int client_id);
JSONObject getSourceAgreement(int client_id);
}

@ -6,6 +6,8 @@ import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import com.alibaba.fastjson.JSONObject;
@ -14,6 +16,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
@ -37,6 +40,9 @@ public class AppFileServiceImpl implements AppFileService {
@Transactional
public JSONObject getOrGenerateSourceAgreement(int client_id) {
JSONObject client = clientManager.getClientInfo(client_id);
if (client == null) {
throw new NotFoundException("merchant not found");
}
JSONObject contract = clientsContractMapper.findByClientId(client_id);
Date now = new Date();
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) {
@ -44,18 +50,20 @@ public class AppFileServiceImpl implements AppFileService {
clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null);
} catch (Exception e) {
logger.info("App generate PDF failed");
throw new ServerErrorException("System error");
}
List<JSONObject> files =clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
saveContract(client_id, now);
return files.get(0);
} else {
JSONObject expireInfo = retailAppService.getClientRateExpire(client_id);
JSONObject expireInfo = retailAppService.getClientContractExpire(client_id);
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
JSONObject file = files.get(0);
if(expireInfo.getBoolean("rate_expire")){
file.put("last_update_date",now);
if (expireInfo.getBoolean("rate_expire")) {
contract.put("create_time", now);
contract.put("expiry_date", DateUtils.addYears(now, 1));
clientsContractMapper.update(contract);
}
clientFilesMapper.update(file);
return file;
}
@ -81,4 +89,13 @@ public class AppFileServiceImpl implements AppFileService {
clientsContractMapper.update(file);
}
@Override
public JSONObject getSourceAgreement(int client_id) {
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
if (CollectionUtils.isEmpty(files)) {
throw new NotFoundException("Contract not generated");
}
return files.get(0);
}
}

Loading…
Cancel
Save