Commit f8d9a91c by lzxry

Merge branch 'bugfix_1608_new'

parents 66eb977c 32c44e53
...@@ -336,6 +336,7 @@ public class ContractController { ...@@ -336,6 +336,7 @@ public class ContractController {
@ResponseBody @ResponseBody
public ResultModel change(@CurrentAccount User loginAccount, public ResultModel change(@CurrentAccount User loginAccount,
@RequestBody ContractChange contract, HttpServletRequest request, @PathVariable String platform) { @RequestBody ContractChange contract, HttpServletRequest request, @PathVariable String platform) {
contract.setPlatform(platform);
Contract contract1 = service.change(loginAccount, contract, null); Contract contract1 = service.change(loginAccount, contract, null);
NewUserLogThread userlog = new NewUserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), contract1.getContractCode(), "修改套餐", "", contract1.toString(), request, platform); NewUserLogThread userlog = new NewUserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), contract1.getContractCode(), "修改套餐", "", contract1.toString(), request, platform);
userlog.start(); userlog.start();
...@@ -643,7 +644,7 @@ public class ContractController { ...@@ -643,7 +644,7 @@ public class ContractController {
rowBody.createCell(8).setCellValue(df.format(contract.getMoney())); rowBody.createCell(8).setCellValue(df.format(contract.getMoney()));
rowBody.createCell(9).setCellValue(contract.getTrackFlow()); rowBody.createCell(9).setCellValue(contract.getTrackFlow());
rowBody.createCell(10).setCellValue(contract.getUnitPrice()); rowBody.createCell(10).setCellValue(contract.getUnitPrice());
rowBody.createCell(11).setCellValue(contract.getClickFlow()); rowBody.createCell(11).setCellValue(contract.getClickFlow()==null?0.0:contract.getClickFlow());
rowBody.createCell(12).setCellValue(df.format(contract.getIntervaIncomeShare() / 100.0)); rowBody.createCell(12).setCellValue(df.format(contract.getIntervaIncomeShare() / 100.0));
rowBody.createCell(13).setCellValue(df.format(contract.getAdjustmentFund() / 100.0)); rowBody.createCell(13).setCellValue(df.format(contract.getAdjustmentFund() / 100.0));
rowBody.createCell(14).setCellValue(df.format(contract.getIncomeShareAll() / 100.0)); rowBody.createCell(14).setCellValue(df.format(contract.getIncomeShareAll() / 100.0));
......
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author liyin
* @description
* @date
*/
@Entity
public class CalculationFlow {
private Long id;
private String email;
private String contractCode;
private String triggerType;
private Boolean isAll;
private Integer status;
private String createTime;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContractCode() {
return contractCode;
}
public void setContractCode(String contractCode) {
this.contractCode = contractCode;
}
public String getTriggerType() {
return triggerType;
}
public void setTriggerType(String triggerType) {
this.triggerType = triggerType;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Boolean getIsAll() {
return isAll;
}
public void setIsAll(Boolean isAll) {
this.isAll = isAll;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}
...@@ -94,7 +94,7 @@ public class Contract { ...@@ -94,7 +94,7 @@ public class Contract {
private String barrioName;//行政区域名称 private String barrioName;//行政区域名称
private String belongGroup;//隶属集团 private String belongGroup;//隶属集团
private Double trackFlow;//流量,tkio的 private Double trackFlow;//流量,tkio的,万单位
private Double unitPrice;//单价,tkio private Double unitPrice;//单价,tkio
private Double clickFlow;//区间点击数,tkio private Double clickFlow;//区间点击数,tkio
......
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author liyin
* @description
* @date
*/
@Entity
public class TkioFlow {
@Id
@GeneratedValue
private Long id;
private String ds;
private String email;
private String contractCode;
private Long flow;
private Long costFlow;
public String getDs() {
return ds;
}
public void setDs(String ds) {
this.ds = ds;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContractCode() {
return contractCode;
}
public void setContractCode(String contractCode) {
this.contractCode = contractCode;
}
public Long getFlow() {
return flow;
}
public void setFlow(Long flow) {
this.flow = flow;
}
public Long getCostFlow() {
return costFlow;
}
public void setCostFlow(Long costFlow) {
this.costFlow = costFlow;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
package common.repository;
import common.model.CalculationFlow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional
public interface CalculationFlowRepository extends JpaRepository<CalculationFlow,Long> {
@Query(value = "select * from calculation_flow where status = ?1",nativeQuery = true)
List<CalculationFlow> findByStatus(int status);
}
...@@ -122,4 +122,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -122,4 +122,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select * from contract where contract_code=?1 limit 1 ", nativeQuery = true) @Query(value = "select * from contract where contract_code=?1 limit 1 ", nativeQuery = true)
Contract checkByCode(String code); Contract checkByCode(String code);
@Query(value = "select distinct email from contract where platform = ?1", nativeQuery = true)
List<String> findDistinctEmailByPlatform(String platform);
@Query(value = "SELECT * from contract where platform = ?1 and email = ?2", nativeQuery = true)
List<Contract> findByPlatformAndEmail(String platform, String email);
} }
package common.repository;
import common.model.TkioFlow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
public interface TkioFlowRepository extends JpaRepository<TkioFlow, Long> {
@Query(value = "select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2", nativeQuery = true)
BigDecimal sumFlowByEmailAndContractCode(String email, String contractCode);
@Transactional
@Modifying
@Query(value = "delete from tkio_flow where email = ?1", nativeQuery = true)
void deleteByEmail(String email);
@Query(value = "select sum(flow) from tkio_flow where contract_code = ?1 and ds >= ?2 and ds <= ?3", nativeQuery = true)
BigDecimal sumFlowByContractCodeAndDs(String code, String startDate, String endDate);
}
...@@ -220,6 +220,9 @@ public class ContractServiceImpl implements ContractService { ...@@ -220,6 +220,9 @@ public class ContractServiceImpl implements ContractService {
@Autowired @Autowired
private BarrioCityRepository barrioCityRepository; private BarrioCityRepository barrioCityRepository;
@Autowired
private CalculationFlowRepository calculationFlowRepository;
@Override @Override
public Map<String, Object> checkAccount(String email, String platfrom) { public Map<String, Object> checkAccount(String email, String platfrom) {
...@@ -564,11 +567,33 @@ public class ContractServiceImpl implements ContractService { ...@@ -564,11 +567,33 @@ public class ContractServiceImpl implements ContractService {
//this.calculateShareIncome(resource);//判断是否计算调整金 //this.calculateShareIncome(resource);//判断是否计算调整金
//判断库里是否已有合同的主账号
if("tkio".equals(resource.getPlatform())){
List<Contract> contracts = contractRepository.findByPlatformAndEmail(resource.getPlatform(), resource.getEmail());
CalculationFlow calculationFlow = new CalculationFlow();
calculationFlow.setEmail(resource.getEmail());
calculationFlow.setContractCode(resource.getContractCode());
calculationFlow.setStatus(0);
calculationFlow.setTriggerType("新建");
calculationFlow.setCreateTime(DateUtil.getCurrentDateStr());
calculationFlow.setIsAll(false);
if(contracts==null || contracts.size()>0){
for (Contract contract : contracts) {
if(intersection(contract,resource)){//有交集
calculationFlow.setIsAll(true);
break;
}
}
}
calculationFlowRepository.save(calculationFlow);
}
resource = contractRepository.save(resource); resource = contractRepository.save(resource);
this.saveContractRelations(resource, resource.getId()); this.saveContractRelations(resource, resource.getId());
List<String> codes = contractRepository.findContractBodyNames(resource.getCustomerBody(), resource.getContractCode()); List<String> codes = contractRepository.findContractBodyNames(resource.getCustomerBody(), resource.getContractCode());
if (!codes.isEmpty()) { if (!codes.isEmpty()) {
// 合同编号已存在 // 合同编号已存在
...@@ -866,9 +891,40 @@ public class ContractServiceImpl implements ContractService { ...@@ -866,9 +891,40 @@ public class ContractServiceImpl implements ContractService {
resource.setId(contract.getId()); resource.setId(contract.getId());
//判断库里是否已有合同的主账号
if("tkio".equals(resource.getPlatform()) && (contract.getStartDate()!=resource.getStartDate()&&contract.getEndDate()!=resource.getEndDate())){
List<Contract> contracts = contractRepository.findByPlatformAndEmail(resource.getPlatform(), resource.getEmail());
CalculationFlow calculationFlow = new CalculationFlow();
calculationFlow.setEmail(resource.getEmail());
calculationFlow.setContractCode(resource.getContractCode());
calculationFlow.setStatus(0);
calculationFlow.setTriggerType("编辑");
calculationFlow.setCreateTime(DateUtil.getCurrentDateStr(DateUtil.C_TIME_PATTON_DEFAULT));
calculationFlow.setIsAll(false);
if(contracts==null || contracts.size()>0){
for (Contract contract1 : contracts) {
if(contract1.getId()!=contract.getId()){
if(intersection(contract1,resource) || intersection(contract1,contract)){//有交集
calculationFlow.setIsAll(true);
break;
}
}
}
}
calculationFlowRepository.save(calculationFlow);
}
return contractRepository.save(resource); return contractRepository.save(resource);
} }
public Boolean intersection(Contract contract1 ,Contract contract2 ){
return (DateUtil.getDate(contract1.getStartDate()).getTime()<=DateUtil.getDate(contract2.getStartDate()).getTime()&&
DateUtil.getDate(contract1.getEndDate()).getTime()>=DateUtil.getDate(contract2.getStartDate()).getTime() )||
(DateUtil.getDate(contract1.getStartDate()).getTime()<=DateUtil.getDate(contract2.getEndDate()).getTime()&&
DateUtil.getDate(contract1.getEndDate()).getTime()>=DateUtil.getDate(contract2.getEndDate()).getTime()) ||
(DateUtil.getDate(contract2.getStartDate()).getTime()<=DateUtil.getDate(contract1.getStartDate()).getTime()&&
DateUtil.getDate(contract2.getEndDate()).getTime()>=DateUtil.getDate(contract1.getEndDate()).getTime());
}
private List<ChangeDelDetail> changeDelInfoForContract(Contract byfind, Contract resource, Long pid, String ip) { private List<ChangeDelDetail> changeDelInfoForContract(Contract byfind, Contract resource, Long pid, String ip) {
...@@ -1679,6 +1735,28 @@ public class ContractServiceImpl implements ContractService { ...@@ -1679,6 +1735,28 @@ public class ContractServiceImpl implements ContractService {
resource.setContent(ContractStatusEnum.SUSPEND.getValue()); resource.setContent(ContractStatusEnum.SUSPEND.getValue());
contract.setStatus(ContractStatusEnum.SUSPEND.getKey()); contract.setStatus(ContractStatusEnum.SUSPEND.getKey());
showTip = true; showTip = true;
//判断库里是否已有合同的主账号
if("tkio".equals(resource.getPlatform())){
List<Contract> contracts = contractRepository.findByPlatformAndEmail(resource.getPlatform(), resource.getEmail());
CalculationFlow calculationFlow = new CalculationFlow();
calculationFlow.setEmail(resource.getEmail());
calculationFlow.setContractCode(resource.getContractCode());
calculationFlow.setStatus(0);
calculationFlow.setTriggerType("中止");
calculationFlow.setCreateTime(DateUtil.getCurrentDateStr());
calculationFlow.setIsAll(false);
if(contracts==null || contracts.size()>0){
for (Contract contract1 : contracts) {
if(contract1.getId()!=contract.getId()){
if(intersection(contract1,contract)){//有交集
calculationFlow.setIsAll(true);
break;
}
}
}
}
calculationFlowRepository.save(calculationFlow);
}
} }
} }
...@@ -2321,6 +2399,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -2321,6 +2399,7 @@ public class ContractServiceImpl implements ContractService {
Map<String, String> codeUniqueDic = new HashMap<>(); Map<String, String> codeUniqueDic = new HashMap<>();
List<String> accountsEmail = new ArrayList<>(); List<String> accountsEmail = new ArrayList<>();
List<String> moreEmail = new ArrayList<>();
for (int j = 1; j <= rowNumber; j++) { for (int j = 1; j <= rowNumber; j++) {
Row row_data = sheet.getRow(j); Row row_data = sheet.getRow(j);
Object[] s_data = new Object[titleKey.size() + extend_size]; Object[] s_data = new Object[titleKey.size() + extend_size];
...@@ -2434,6 +2513,9 @@ public class ContractServiceImpl implements ContractService { ...@@ -2434,6 +2513,9 @@ public class ContractServiceImpl implements ContractService {
s_data[w] = dataSTR; s_data[w] = dataSTR;
if ("email".equals(sheetTitle) && !StringUtils.isEmpty(dataSTR) && "tkio".equals(platformexcl)) { if ("email".equals(sheetTitle) && !StringUtils.isEmpty(dataSTR) && "tkio".equals(platformexcl)) {
if(!accountsEmail.contains(dataSTR.trim())){
moreEmail.add(dataSTR.trim());
}
accountsEmail.add(dataSTR.trim()); accountsEmail.add(dataSTR.trim());
} }
} }
...@@ -2509,7 +2591,17 @@ public class ContractServiceImpl implements ContractService { ...@@ -2509,7 +2591,17 @@ public class ContractServiceImpl implements ContractService {
// TransactionStatus transactionStatus = transactionUtils.begin(); // TransactionStatus transactionStatus = transactionUtils.begin();
jdbcTemplate.batchUpdate(sql.toString(), args_data); jdbcTemplate.batchUpdate(sql.toString(), args_data);
// transactionUtils.commit(transactionStatus); // transactionUtils.commit(transactionStatus);
if("tkio".equals(platform)){
for (String email : moreEmail) {
CalculationFlow calculationFlow = new CalculationFlow();
calculationFlow.setEmail(email);
calculationFlow.setStatus(0);
calculationFlow.setTriggerType("导入");
calculationFlow.setCreateTime(DateUtil.getCurrentDateStr());
calculationFlow.setIsAll(true);
calculationFlowRepository.save(calculationFlow);
}
}
return ResultModel.OK(); return ResultModel.OK();
} }
......
package track.task; package track.task;
import common.model.Account4Web;
import common.model.TrackAccount4Web; import common.model.TrackAccount4Web;
import common.repository.TrackAccount4WebRepository; import common.repository.TrackAccount4WebRepository;
import org.jsoup.helper.DataUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import track.model.Account; import track.model.Account;
import track.repository.TrackAccountRepository; import track.repository.TrackAccountRepository;
......
...@@ -63,4 +63,16 @@ ...@@ -63,4 +63,16 @@
<!--<task:scheduled ref="accountTaskCheck" method="task" cron="0 10 8 * * ?"/>--> <!--<task:scheduled ref="accountTaskCheck" method="task" cron="0 10 8 * * ?"/>-->
<!--</task:scheduled-tasks>--> <!--</task:scheduled-tasks>-->
<bean id="syncTrackingFlowTask" class="track.task.TrackingFlowTask"></bean>
<task:scheduled-tasks>
<!--定时同步昨日流量(每天10点执行一次)-->
<task:scheduled ref="syncTrackingFlowTask" method="task" cron="0 0 10 * * ?"/>
</task:scheduled-tasks>
<bean id="syncCalculationFlowTask" class="track.task.TrackingFlowTask"></bean>
<task:scheduled-tasks>
<!--定时同步流量(每7分钟执行一次)-->
<task:scheduled ref="syncCalculationFlowTask" method="syncFlow" cron="0 0/7 * * * ? "/>
</task:scheduled-tasks>
</beans> </beans>
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