Commit 9071c041 by kangxiaoshan

前置机

parent 4916f9b0
...@@ -105,7 +105,7 @@ public class Contract { ...@@ -105,7 +105,7 @@ public class Contract {
private Double oneTimeRecognizedRevenue;//一次性确认收入 private Double oneTimeRecognizedRevenue;//一次性确认收入
private Boolean oneTime;//是否计算一次性收入,0不计算 private Boolean oneTime;//是否计算一次性收入,0不计算
private int businessType; //业务类型 1 VIP 2 共管 private int businessType; //业务类型 1 VIP 2 共管 3 前置机
private int agreementType; //协议类型 1 普通协议 2 框架协议 private int agreementType; //协议类型 1 普通协议 2 框架协议
private String businessTypeName; //业务类型 1 VIP 2 共管 private String businessTypeName; //业务类型 1 VIP 2 共管
private String agreementTypeName; //协议类型 1 普通协议 2 框架协议 private String agreementTypeName; //协议类型 1 普通协议 2 框架协议
......
...@@ -162,4 +162,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -162,4 +162,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Modifying @Modifying
@Query(value = "delete from contract where contract_code = ?1 and platform=?2", nativeQuery = true) @Query(value = "delete from contract where contract_code = ?1 and platform=?2", nativeQuery = true)
void deleteByCode(String contractCode, String platform); void deleteByCode(String contractCode, String platform);
@Query(value = "select * from contract where platform=?1 and email =?2", nativeQuery = true)
List<Contract> findbyEmailAndPlatform(String cas, String originEmail);
} }
...@@ -77,6 +77,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -77,6 +77,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
CONTRACT_TYPE_NAME.put("补充协议", "2"); CONTRACT_TYPE_NAME.put("补充协议", "2");
BUSINESS_TYPE_NAME.put("VIP", "1");//业务类型 1 VIP 2 共管 BUSINESS_TYPE_NAME.put("VIP", "1");//业务类型 1 VIP 2 共管
BUSINESS_TYPE_NAME.put("共管", "2"); BUSINESS_TYPE_NAME.put("共管", "2");
BUSINESS_TYPE_NAME.put("前置机", "3");
SETAGREEMENT_TYPE_NAME.put("普通协议", "1");//协议类型 1 普通协议 2 框架协议 SETAGREEMENT_TYPE_NAME.put("普通协议", "1");//协议类型 1 普通协议 2 框架协议
SETAGREEMENT_TYPE_NAME.put("框架协议", "2"); SETAGREEMENT_TYPE_NAME.put("框架协议", "2");
} }
...@@ -138,7 +139,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -138,7 +139,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
row.createCell(i).setCellValue(title[i]); row.createCell(i).setCellValue(title[i]);
} }
String[] bussinesName = new String[]{"", "VIP", "共管"}; String[] bussinesName = new String[]{"", "VIP", "共管","前置机"};
for (int j = 0; j < dmpIncomes.size(); j++) { for (int j = 0; j < dmpIncomes.size(); j++) {
HSSFRow rowBody = sheet.createRow(j + 1); HSSFRow rowBody = sheet.createRow(j + 1);
DmpIncome income = dmpIncomes.get(j); DmpIncome income = dmpIncomes.get(j);
......
...@@ -8,12 +8,17 @@ import common.repository.ContractRepository; ...@@ -8,12 +8,17 @@ import common.repository.ContractRepository;
import common.repository.PackageBaseRepository; import common.repository.PackageBaseRepository;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Days; import org.joda.time.Days;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import util.Constant;
import util.DateUtil; import util.DateUtil;
import util.HttpClientUtil;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -34,23 +39,23 @@ public class CASIPSendTimeTask { ...@@ -34,23 +39,23 @@ public class CASIPSendTimeTask {
PackageBaseRepository packageBaseRepository; PackageBaseRepository packageBaseRepository;
public void task(){ public void task() {
logger.info("CAS的IP定制发送日定时任务"); logger.info("CAS的IP定制发送日定时任务");
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus("cas", 1); List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus("cas", 1);
Map<Long, PackageBase> packageBaseMap = new HashMap<>(); Map<Long, PackageBase> packageBaseMap = new HashMap<>();
for (PackageBase base : packageBases) { for (PackageBase base : packageBases) {
packageBaseMap.put(base.getId(), base); packageBaseMap.put(base.getId(), base);
} }
List<Contract> contracts = contractRepository.findByPlatformAndShareSign("cas",0); List<Contract> contracts = contractRepository.findByPlatformAndShareSign("cas", 0);
for (Contract contract : contracts) { for (Contract contract : contracts) {
PackageBase packageBase = packageBaseMap.get(contract.getPriceLevel()); PackageBase packageBase = packageBaseMap.get(contract.getPriceLevel());
ADIUser adiUser = adiAccountService.findOne(contract.getEmail(), packageBase==null?"":packageBase.getPackageName()); ADIUser adiUser = adiAccountService.findOne(contract.getEmail(), packageBase == null ? "" : packageBase.getPackageName());
if(adiUser!=null&&!StringUtils.isEmpty(adiUser.getSendTime())){ if (adiUser != null && !StringUtils.isEmpty(adiUser.getSendTime())) {
contract.setShareSign(1); contract.setShareSign(1);
DateTime sendTime = new DateTime(DateUtil.parseDate(DateUtil.C_TIME_PATTON_DEFAULT,adiUser.getSendTime())); DateTime sendTime = new DateTime(DateUtil.parseDate(DateUtil.C_TIME_PATTON_DEFAULT, adiUser.getSendTime()));
DateTime startDate = new DateTime(contract.getStartDate()); DateTime startDate = new DateTime(contract.getStartDate());
if(sendTime.isBefore(startDate)){ if (sendTime.isBefore(startDate)) {
sendTime = startDate; sendTime = startDate;
} }
DateTime endDate = new DateTime(contract.getEndDate()); DateTime endDate = new DateTime(contract.getEndDate());
...@@ -62,5 +67,66 @@ public class CASIPSendTimeTask { ...@@ -62,5 +67,66 @@ public class CASIPSendTimeTask {
contractRepository.save(contract); contractRepository.save(contract);
} }
} }
//定时同步变更的账号到对应合同
//syncChangedAccount(packageBaseMap);
}
//定时同步变更的账号到对应合同 (packType: 国内 海外)
public void syncChangedAccount(Map<Long, PackageBase> packageBaseMap) {
String ds = DateTime.now().plusDays(-1).toString("yyyy-MM-dd");
//国内
String url = Constant.adiUrl.split(",")[0] + "/adi/api/user/change/day?date=" + ds;
syncChangedAccount(packageBaseMap, url, "国内");
//海外
url = Constant.adiUrl.split(",")[1] + "/adi/api/user/overseas/change/day?date=" + ds;
syncChangedAccount(packageBaseMap, url, "海外");
}
//定时同步变更的账号到对应合同 (packType: 国内 海外)
public void syncChangedAccount(Map<Long, PackageBase> packageBaseMap, String url, String packType) {
String request = HttpClientUtil.doHttpGetRequest(url, "");
try {
JSONObject rs = new JSONObject(request);
if ("200".equals(rs.get("code") + "")) {
if (rs.get("content") != null && !rs.get("content").toString().startsWith("[")) {
return;
}
JSONArray array = (JSONArray) rs.get("content");
for (int i = 0; i < array.length(); i++) {
JSONObject object = (JSONObject) array.get(i);
String newEmail = object.getString("newEmail");
String originEmail = object.getString("originEmail");
if (StringUtils.isEmpty(newEmail) || StringUtils.isEmpty(originEmail)) {
continue;
}
List<Contract> contracts = contractRepository.findbyEmailAndPlatform("cas", originEmail);
if (contracts == null) {
continue;
}
List<Contract> updateList = new ArrayList<>();
for (Contract contract : contracts) {
PackageBase packageBase = packageBaseMap.get(contract.getPriceLevel());
if (packageBase.getPackageName().contains(packType)) {
contract.setEmail(newEmail);
updateList.add(contract);
}
}
if (!updateList.isEmpty()) {
//更新账号
contractRepository.save(contracts);
}
}
}
} catch (Exception e) {
logger.error("syncChangedAccount erro " + packType, e);
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment