Commit 5ae66cca by kangxiaoshan

调整金

parent 4b36d979
...@@ -2,6 +2,7 @@ package common.controller; ...@@ -2,6 +2,7 @@ package common.controller;
import common.model.*; import common.model.*;
import common.service.ContractService; import common.service.ContractService;
import common.service.ShareIncomeService;
import dic.AuthMenuEnmm; import dic.AuthMenuEnmm;
import dic.ContractStatusEnum; import dic.ContractStatusEnum;
import dic.OperateObjectTypeEnum; import dic.OperateObjectTypeEnum;
...@@ -67,6 +68,9 @@ public class ContractController { ...@@ -67,6 +68,9 @@ public class ContractController {
@Autowired @Autowired
private ContractService service; private ContractService service;
@Autowired
private ShareIncomeService shareIncomeService;
@RequestMapping(value = "find", method = RequestMethod.GET) @RequestMapping(value = "find", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@AuthKey(AuthMenuEnmm.CONTRACTMNG_V) @AuthKey(AuthMenuEnmm.CONTRACTMNG_V)
...@@ -435,7 +439,7 @@ public class ContractController { ...@@ -435,7 +439,7 @@ public class ContractController {
@RequestParam String startDate, @RequestParam String endDate, @RequestParam String startDate, @RequestParam String endDate,
String bodyCode, String serchName) { String bodyCode, String serchName) {
return ResultModel.OK(service.shareIncomeList(loginAccount, startDate, endDate, platform, bodyCode, serchName)); return ResultModel.OK(shareIncomeService.shareIncomeList(loginAccount, startDate, endDate, platform, bodyCode, serchName));
} }
......
...@@ -6,6 +6,7 @@ import javax.persistence.Id; ...@@ -6,6 +6,7 @@ import javax.persistence.Id;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* Created by mxq on 2018/1/16. * Created by mxq on 2018/1/16.
...@@ -63,6 +64,10 @@ public class Contract { ...@@ -63,6 +64,10 @@ public class Contract {
private Long intervaIncomeShare;//区间分摊收入(*100的结果) private Long intervaIncomeShare;//区间分摊收入(*100的结果)
private Long incomeShareAll;//分摊总收入(*100的结果) private Long incomeShareAll;//分摊总收入(*100的结果)
private String searchName;
private List<String> customBodyNames;
/** /**
* 新增字段 20190427 * 新增字段 20190427
...@@ -528,4 +533,22 @@ public class Contract { ...@@ -528,4 +533,22 @@ public class Contract {
public void setBackStatus(Integer backStatus) { public void setBackStatus(Integer backStatus) {
this.backStatus = backStatus; this.backStatus = backStatus;
} }
@Transient
public String getSearchName() {
return searchName;
}
public void setSearchName(String searchName) {
this.searchName = searchName;
}
@Transient
public List<String> getCustomBodyNames() {
return customBodyNames;
}
public void setCustomBodyNames(List<String> customBodyNames) {
this.customBodyNames = customBodyNames;
}
} }
...@@ -14,6 +14,7 @@ public class ContractChange { ...@@ -14,6 +14,7 @@ public class ContractChange {
private String company; private String company;
private String ds; private String ds;
private String type; private String type;
private String status; //合同状态
private String content; private String content;
private String marke; //备注 private String marke; //备注
private Long level; private Long level;
...@@ -203,4 +204,12 @@ public class ContractChange { ...@@ -203,4 +204,12 @@ public class ContractChange {
public void setDiscountTimeLong(Long discountTimeLong) { public void setDiscountTimeLong(Long discountTimeLong) {
this.discountTimeLong = discountTimeLong; this.discountTimeLong = discountTimeLong;
} }
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
} }
...@@ -19,4 +19,6 @@ public interface ContractChangeRepository extends JpaRepository<ContractChange, ...@@ -19,4 +19,6 @@ public interface ContractChangeRepository extends JpaRepository<ContractChange,
@Query(value="SELECT * from contract_change where platform = ?1 and email = ?2 and ds >= ?3 and ds <= ?4 order by ds desc",nativeQuery=true) @Query(value="SELECT * from contract_change where platform = ?1 and email = ?2 and ds >= ?3 and ds <= ?4 order by ds desc",nativeQuery=true)
List<ContractChange> findByPlatformAndEmail(String platform, String email, String startDate, String endDate); List<ContractChange> findByPlatformAndEmail(String platform, String email, String startDate, String endDate);
@Query(value = "select * from contract_change where content=?1 and contract_code=?2 order by create_time desc limit 1",nativeQuery = true)
ContractChange findByContentCode(String type, String contractCode);
} }
...@@ -4,6 +4,7 @@ import common.model.Contract; ...@@ -4,6 +4,7 @@ import common.model.Contract;
import common.model.Role; import common.model.Role;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger; import java.math.BigInteger;
...@@ -14,55 +15,55 @@ import java.util.Map; ...@@ -14,55 +15,55 @@ import java.util.Map;
@Transactional @Transactional
public interface ContractRepository extends JpaRepository<Contract, Long> { public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="select count(*) from contract where ds = ?1",nativeQuery=true) @Query(value = "select count(*) from contract where ds = ?1", nativeQuery = true)
BigInteger countNumByDs(String ds); BigInteger countNumByDs(String ds);
@Query(value="select count(*) from contract where email = ?1 and platform = ?2",nativeQuery=true) @Query(value = "select count(*) from contract where email = ?1 and platform = ?2", nativeQuery = true)
BigInteger countNumByEmail(String email, String platfrom); BigInteger countNumByEmail(String email, String platfrom);
@Query(value="select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform = ?3 and status!='del' order by ds desc",nativeQuery=true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform = ?3 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDs(String startDate, String endDate, String platfrom); List<Contract> findByDs(String startDate, String endDate, String platfrom);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and create_account in ?4 and status!='del' order by ds desc",nativeQuery=true) @Query(value = "select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and create_account in ?4 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDsAndRoile(String startDate, String endDate, String platfrom, List<Long> userids); List<Contract> findByDsAndRoile(String startDate, String endDate, String platfrom, List<Long> userids);
@Query(value="select * from contract where contract_code = ?1",nativeQuery=true) @Query(value = "select * from contract where contract_code = ?1", nativeQuery = true)
Contract findByCode(String contract_code); Contract findByCode(String contract_code);
@Query(value="SELECT * from contract where platform = ?1 and type = 'main'",nativeQuery=true) @Query(value = "SELECT * from contract where platform = ?1 and type = 'main'", nativeQuery = true)
List<Contract> findByPlatform(String platform); List<Contract> findByPlatform(String platform);
@Query(value="SELECT * from contract where platform = ?1 and email = ?2 and type = ?3",nativeQuery=true) @Query(value = "SELECT * from contract where platform = ?1 and email = ?2 and type = ?3", nativeQuery = true)
List<Contract> findByPlatformAndEmail(String platform, String email, String type); List<Contract> findByPlatformAndEmail(String platform, String email, String type);
@Query(value="SELECT * from contract where platform = ?1 and email = ?2 and type = ?3 order by ds,end_date desc limit 1",nativeQuery=true) @Query(value = "SELECT * from contract where platform = ?1 and email = ?2 and type = ?3 order by ds,end_date desc limit 1", nativeQuery = true)
Contract findByPlatformAndEmailLimit1(String platform, String email,String type); Contract findByPlatformAndEmailLimit1(String platform, String email, String type);
@Query(value="SELECT * from contract where platform = ?1 and email = ?2 and type = ?3 and price_level = ?4 order by ds desc limit 1",nativeQuery=true) @Query(value = "SELECT * from contract where platform = ?1 and email = ?2 and type = ?3 and price_level = ?4 order by ds desc limit 1", nativeQuery = true)
Contract findByPlatformAndEmailAndPricelevelLimit1(String platform, String email,String type, Long priceLevel); Contract findByPlatformAndEmailAndPricelevelLimit1(String platform, String email, String type, Long priceLevel);
@Query(value="SELECT * from contract where platform = ?1 and email = ?2 and (status = 'wait' or status = 'executing') and type = 'main' order by ds desc limit 1",nativeQuery=true) @Query(value = "SELECT * from contract where platform = ?1 and email = ?2 and (status = 'wait' or status = 'executing') and type = 'main' order by ds desc limit 1", nativeQuery = true)
Contract findByPlatformAndEmailLimitVaild(String platform, String email); Contract findByPlatformAndEmailLimitVaild(String platform, String email);
@Query(value="SELECT * from contract where start_date = ?1 and status <> 'cancel'",nativeQuery=true) @Query(value = "SELECT * from contract where start_date = ?1 and status <> 'cancel'", nativeQuery = true)
List<Contract> findByStartDate(String startDate); List<Contract> findByStartDate(String startDate);
@Query(value="SELECT * from contract where end_date <= ?1 and (status <> 'end' or status <> 'cancel')",nativeQuery=true) @Query(value = "SELECT * from contract where end_date <= ?1 and (status <> 'end' or status <> 'cancel')", nativeQuery = true)
List<Contract> findByEndDate(String endDate); List<Contract> findByEndDate(String endDate);
@Query(value = "select count(*) from contract where my_body_code = ?1",nativeQuery = true) @Query(value = "select count(*) from contract where my_body_code = ?1", nativeQuery = true)
BigInteger findcountContract(String platform); BigInteger findcountContract(String platform);
@Query(value = "select new map( c.id as id, c.contractCode as contractCode ) from Contract c where c.platform in ?1 and c.contractCode is not null and c.contractCode <> 'null' and c.status <>'del'") @Query(value = "select new map( c.id as id, c.contractCode as contractCode ) from Contract c where c.platform in ?1 and c.contractCode is not null and c.contractCode <> 'null' and c.status <>'del'")
List<Map> contractCodePlatform(List<String> platform); List<Map> contractCodePlatform(List<String> platform);
@Query(value = "select * from contract where platform = ?1 and contract_code = ?2",nativeQuery = true) @Query(value = "select * from contract where platform = ?1 and contract_code = ?2", nativeQuery = true)
Contract findByCodePlatform(String contractCode, String platform); Contract findByCodePlatform(String contractCode, String platform);
@Query(value="select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform in ?3 and id in ?4 and status!='del' order by ds desc",nativeQuery=true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform in ?3 and id in ?4 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDsRelation(String startDate, String endDate, List<String> platform, List<String> contractIds); List<Contract> findByDsRelation(String startDate, String endDate, List<String> platform, List<String> contractIds);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and create_account in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery=true) @Query(value = "select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and create_account in ?4 and id in ?5 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDsAndRoileRelation(String startDate, String endDate, List<String> platform, List<Long> create_account, List<String> contractIds); List<Contract> findByDsAndRoileRelation(String startDate, String endDate, List<String> platform, List<Long> create_account, List<String> contractIds);
...@@ -70,50 +71,52 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -70,50 +71,52 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
List<Contract> contractCodePlatformNot(List<String> plats, List<Long> ids); List<Contract> contractCodePlatformNot(List<String> plats, List<Long> ids);
@Query(value = "select contract_code from contract where my_body_code = ?1 order by code_num desc limit 1",nativeQuery = true) @Query(value = "select contract_code from contract where my_body_code = ?1 order by code_num desc limit 1", nativeQuery = true)
String findLastCode(String code); String findLastCode(String code);
@Query(value = "select * from contract where id = ?1 union all select * from contract where id = ?2",nativeQuery = true) @Query(value = "select * from contract where id = ?1 union all select * from contract where id = ?2", nativeQuery = true)
List<Contract> findByTwoIds(Long relationContract, Long relationContract1); List<Contract> findByTwoIds(Long relationContract, Long relationContract1);
@Query(value="SELECT * from contract where platform =?1 and email = ?2 and (status <> 'end' or status <> 'cancel')",nativeQuery=true) @Query(value = "SELECT * from contract where platform =?1 and email = ?2 and (status <> 'end' or status <> 'cancel')", nativeQuery = true)
List<Contract> findByPlatformAndEmailStatus(String platgorm, String email); List<Contract> findByPlatformAndEmailStatus(String platgorm, String email);
@Query(value = "select * from contract where contract_code =?2 and platform = ?1 ",nativeQuery = true) @Query(value = "select * from contract where contract_code =?2 and platform = ?1 ", nativeQuery = true)
Contract findOneByCode(String platform, String contractId); Contract findOneByCode(String platform, String contractId);
@Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform in ?3 and my_body_code in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform in ?3 and my_body_code in ?4 and id in ?5 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDsContractBody(String startDate, String endDate, List<String> platforms, List bodyids, List<String> ids); List<Contract> findByDsContractBody(String startDate, String endDate, List<String> platforms, List bodyids, List<String> ids);
@Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform = ?3 and my_body_code in ?4 and status!='del' order by ds desc",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform = ?3 and my_body_code in ?4 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDsContractBody(String startDate, String endDate, String platform, List bodyids); List<Contract> findByDsContractBody(String startDate, String endDate, String platform, List bodyids);
@Query(value = "select * from contract where((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform = ?3 and sale in ?4 and status!='del' order by ds desc",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform = ?3 and sale in ?4 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDsContractSalse(String startDate, String endDate, String platform, List salseid); List<Contract> findByDsContractSalse(String startDate, String endDate, String platform, List salseid);
@Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform in ?3 and sale in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform in ?3 and sale in ?4 and id in ?5 and status!='del' order by ds desc", nativeQuery = true)
List<Contract> findByDsContractSalse(String startDate, String endDate, List<String> platforms, List salseid, List<String> ids); List<Contract> findByDsContractSalse(String startDate, String endDate, List<String> platforms, List salseid, List<String> ids);
@Query(value = "select contract_code,my_body_code,sale,platform from contract where contract_code in ?1",nativeQuery = true) @Query(value = "select contract_code,my_body_code,sale,platform from contract where contract_code in ?1", nativeQuery = true)
List<Object[]> findByContractCode(List<String> codesList); List<Object[]> findByContractCode(List<String> codesList);
// @Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time <= ?4 and platform=?3 and status!='del' ",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform=?3 and status!='del' ", nativeQuery = true)
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and platform=?3 and status!='del' ",nativeQuery = true) List<Contract> findShareContranctByDate3(String startDate, String endDate, String platform);
List<Contract> findShareContranctByDate3(String startDate, String endDate, String platform );
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and platform=?3 and my_body_code = ?4 and status!='del' ",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform=?3 and my_body_code = ?4 and status!='del' ", nativeQuery = true)
List<Contract> findShareContranctByDate2(String startDate, String endDate, String platform, String bodyCode); List<Contract> findShareContranctByDate2(String startDate, String endDate, String platform, String bodyCode);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and platform=?3 and (my_body_name like %?4% or customer_body like %?4% or contract_code like %?4%) and status!='del' ",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform=?3 and (my_body_name like %?4% or customer_body like %?4% or contract_code like %?4%) and status!='del' ", nativeQuery = true)
List<Contract> findShareContranctByDateSerche(String startDate, String endDate, String platform, String serchName); List<Contract> findShareContranctByDateSerche(String startDate, String endDate, String platform, String serchName);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and platform=?3 and my_body_code = ?4 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%) and status!='del' ",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform=?3 and my_body_code = ?4 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%) and status!='del' ", nativeQuery = true)
List<Contract> findShareContranctByDate1(String startDate, String endDate, String platform, String bodyCode, String serchName); List<Contract> findShareContranctByDate1(String startDate, String endDate, String platform, String bodyCode, String serchName);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and platform=?3 and (my_body_name like %?4% or customer_body like %?4% or contract_code like %?5%) and my_body_code in ?5 and status!='del' ",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform=?3 and (my_body_name like %?4% or customer_body like %?4% or contract_code like %?5%) and my_body_code in ?5 and status!='del' ", nativeQuery = true)
List<Contract> findShareContranctByDateSercheFinace(String startDate, String endDate, String platform, String serchName, List<String> financeBodies); List<Contract> findShareContranctByDateSercheFinace(String startDate, String endDate, String platform, String serchName, List<String> financeBodies);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and platform=?3 and my_body_code in ?4 and status!='del' ",nativeQuery = true) @Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform=?3 and my_body_code in ?4 and status!='del' ", nativeQuery = true)
List<Contract> findShareContranctByDateFinace(String startDate, String endDate, String platform, List<String> financeBodies); List<Contract> findShareContranctByDateFinace(String startDate, String endDate, String platform, List<String> financeBodies);
@Query(value = "select contract_code from contract where customer_body =? limit 3 ",nativeQuery = true)
List<String> findContractBodyNames(String customerBody);
} }
package common.service;
import common.model.Contract;
import common.model.User;
import java.util.List;
public interface ShareIncomeService {
List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String platform, String bodyCode, String serchName);
}
...@@ -1583,12 +1583,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -1583,12 +1583,8 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public Contract change(User loginUser, ContractChange resource, FlowChange flowChange) { public Contract change(User loginUser, ContractChange resource, FlowChange flowChange) {
Map<Long, String> saleMap = getSaleMap();
Contract contract = contractRepository.findByCode(resource.getContractCode()); Contract contract = contractRepository.findByCode(resource.getContractCode());
Map<Long, String> packageMap = getPackageMap(contract); Map<Long, String> packageMap = getPackageMap(contract);
// ChangeDelInfo changeDelInfo = new ChangeDelInfo();
// changeDelInfo.setContractCode(contract.getContractCode());
// changeDelInfo.setEmail(contract.getEmail());
if (resource.getType().equals("price")) { if (resource.getType().equals("price")) {
...@@ -1605,25 +1601,24 @@ public class ContractServiceImpl implements ContractService { ...@@ -1605,25 +1601,24 @@ public class ContractServiceImpl implements ContractService {
//变更优惠记录 //变更优惠记录
this.saveFlowChange(contract, loginUser, "save", resource.getDiscountTimeLong(), resource.getExtraFlow()); this.saveFlowChange(contract, loginUser, "save", resource.getDiscountTimeLong(), resource.getExtraFlow());
// 累加 合同表中数据 // 累加 合同表中数据
if (resource.getExtraFlow() != null) { if (resource.getExtraFlow() != null) {
contract.setExtraFlow(contract.getExtraFlow() + resource.getExtraFlow()); contract.setExtraFlow(contract.getExtraFlow() + resource.getExtraFlow());
} }
if (resource.getDiscountTimeLong() != null) { if (resource.getDiscountTimeLong() != null) {
contract.setDiscountTimeLong(contract.getDiscountTimeLong() + resource.getDiscountTimeLong()); contract.setDiscountTimeLong(contract.getDiscountTimeLong() + resource.getDiscountTimeLong());
} }
} else { } else {
// //同步修改trackingio的数据
// if (contract.getPlatform().equals("tkio") && contract.getType().equals("main")) { if (ContractStatusEnum.CANCEL.getKey().equals(resource.getStatus())) {
// accountService.forbiden(contract);
// } else if (contract.getPlatform().equals("io") && contract.getType().equals("main")) {
// accountIOService.update(contract);
// }
//状态变更 //状态变更
resource.setContent("作废"); resource.setContent(ContractStatusEnum.CANCEL.getValue());
contract.setStatus("cancel"); contract.setStatus(ContractStatusEnum.CANCEL.getKey());
} else if (ContractStatusEnum.SUSPEND.getKey().equals(resource.getStatus())) {
resource.setContent(ContractStatusEnum.SUSPEND.getValue());
contract.setStatus(ContractStatusEnum.SUSPEND.getKey());
}
} }
resource.setPlatform(contract.getPlatform()); resource.setPlatform(contract.getPlatform());
resource.setCreateAccount(loginUser.getId()); resource.setCreateAccount(loginUser.getId());
...@@ -1631,11 +1626,27 @@ public class ContractServiceImpl implements ContractService { ...@@ -1631,11 +1626,27 @@ public class ContractServiceImpl implements ContractService {
resource.setDs(DateUtil.getBeforeDays(0)); resource.setDs(DateUtil.getBeforeDays(0));
resource.setUser(loginUser.getId()); resource.setUser(loginUser.getId());
if (ContractStatusEnum.SUSPEND.getKey().equals(resource.getStatus())) {
resource.setCreateTime(new DateTime(resource.getDs()).toDate());
} else {
resource.setCreateTime(new Date());
resource.setDs(DateUtil.getBeforeDays(0));
}
if (!"give".equals(resource.getType())) { if (!"give".equals(resource.getType())) {
contractChangeRepository.save(resource); contractChangeRepository.save(resource);
} }
return contractRepository.save(contract); contractRepository.save(contract);
if (ContractStatusEnum.SUSPEND.getKey().equals(contract.getStatus())) {
//获取相关执行合同名称
List<String> codes = contractRepository.findContractBodyNames(contract.getCustomerBody());
contract.setCustomBodyNames(codes);
}
return contract;
} }
...@@ -1709,7 +1720,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -1709,7 +1720,8 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public List<ChangeDelInfo> getChangeDelData(User loginAccount, String contranctCode, String startDate, String endDate) { public List<ChangeDelInfo> getChangeDelData(User loginAccount, String contranctCode, String startDate, String
endDate) {
List<ChangeDelInfo> datas = changeDelInfoRepository.findOnStartDate(startDate, endDate); List<ChangeDelInfo> datas = changeDelInfoRepository.findOnStartDate(startDate, endDate);
return datas; return datas;
...@@ -1895,7 +1907,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -1895,7 +1907,8 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public List<ContractMoney> findPayAll(User loginAccount, String startDate, String endDate, String platfrom, String moneyType, String packageTypeSearch, String money_ids) { public List<ContractMoney> findPayAll(User loginAccount, String startDate, String endDate, String
platfrom, String moneyType, String packageTypeSearch, String money_ids) {
Map<Long, PackageType> packageTypeMap = new HashMap<>(); Map<Long, PackageType> packageTypeMap = new HashMap<>();
Map<Long, String> saleMap = new HashMap<>(); Map<Long, String> saleMap = new HashMap<>();
...@@ -1974,7 +1987,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -1974,7 +1987,8 @@ public class ContractServiceImpl implements ContractService {
return list; return list;
} }
private List<ContractMoney> filterContractMoney(List<String> codesList, Map<String, Object> authdata, List<ContractMoney> list, int nextIndex) { private List<ContractMoney> filterContractMoney
(List<String> codesList, Map<String, Object> authdata, List<ContractMoney> list, int nextIndex) {
if (codesList == null || codesList.size() == 0) { if (codesList == null || codesList.size() == 0) {
return list; return list;
...@@ -2114,7 +2128,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -2114,7 +2128,8 @@ public class ContractServiceImpl implements ContractService {
} }
public static Map<String, String> convertBean(Object bean) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { public static Map<String, String> convertBean(Object bean) throws
IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Class type = bean.getClass(); Class type = bean.getClass();
Map<String, String> returnMap = new HashMap<String, String>(); Map<String, String> returnMap = new HashMap<String, String>();
BeanInfo beanInfo = Introspector.getBeanInfo(type); BeanInfo beanInfo = Introspector.getBeanInfo(type);
...@@ -2371,7 +2386,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -2371,7 +2386,8 @@ public class ContractServiceImpl implements ContractService {
} }
@Override @Override
public List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String platform, String bodyCode, String serchName) { public List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String
platform, String bodyCode, String serchName) {
List<Contract> contracts = new ArrayList<>(); List<Contract> contracts = new ArrayList<>();
......
package common.service.impl;
import common.model.*;
import common.repository.AuthRepository;
import common.repository.ContractBodyRepository;
import common.repository.ContractChangeRepository;
import common.repository.ContractRepository;
import common.service.ShareIncomeService;
import dic.ContractStatusEnum;
import dic.RoleEnum;
import net.sf.json.JSONArray;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ShareIncomeServiceImpl implements ShareIncomeService {
@Autowired
private ContractRepository contractRepository;
@Autowired
private AuthRepository authRepository;
@Autowired
private ContractBodyRepository contractBodyRepository;
@Autowired
private ContractChangeRepository contractChangeRepository;
@Override
public List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String platform, String bodyCode, String serchName) {
List<Contract> contracts = new ArrayList<>();
if ("all".equals(bodyCode)) {
bodyCode = null;
}
List<String> financeBodies = null;
if (RoleEnum.FINANCE.getKey().equals(loginAccount.getRole())) {
Auth auth = authRepository.findByUser(loginAccount.getId());
financeBodies = JSONArray.fromObject(auth.getAuthExtend());
}
if (!StringUtils.isEmpty(bodyCode) && !StringUtils.isEmpty(serchName)) {
if (financeBodies != null && !financeBodies.contains(bodyCode)) {
//沒有权限查看
return contracts;
} else {
contracts = contractRepository.findShareContranctByDate1(startDate, endDate, platform, bodyCode, serchName);
}
} else if (!StringUtils.isEmpty(bodyCode)) {
if (financeBodies != null && !financeBodies.contains(bodyCode)) {
//沒有权限查看
return contracts;
} else {
contracts = contractRepository.findShareContranctByDate2(startDate, endDate, platform, bodyCode);
}
} else if (!StringUtils.isEmpty(serchName)) {
if (financeBodies != null) {
contracts = contractRepository.findShareContranctByDateSercheFinace(startDate, endDate, platform, serchName, financeBodies);
} else {
contracts = contractRepository.findShareContranctByDateSerche(startDate, endDate, platform, serchName);
}
} else {
if (financeBodies != null) {
contracts = contractRepository.findShareContranctByDateFinace(startDate, endDate, platform, financeBodies);
} else {
contracts = contractRepository.findShareContranctByDate3(startDate, endDate, platform);
}
}
List<ContractBody> bodies = contractBodyRepository.findAll();
Map<String, String> bodiesNameMap = bodies.stream().collect(
Collectors.toMap(ContractBody::getCode, ContractBody::getName, (v1, v2) -> v1));
DateTime start = new DateTime(startDate);
DateTime end = new DateTime(endDate);
for (Contract contract : contracts) {
this.caculateShareIncome(contract, start, end);
contract.setMyBodyName(bodiesNameMap.get(contract.getMyBodyCode()));
}
return contracts;
}
private void caculateShareIncome(Contract contract, DateTime start, DateTime end) {
DateTime create = new DateTime(contract.getCreateTime());
DateTime contractStart = new DateTime(contract.getStartDate());
DateTime contractEnd = new DateTime(contract.getEndDate());
// 时间范围是否包含合同结束日期
boolean containEnd = end.compareTo(contractEnd) >= 0;
// 时间范围是否包含合同开始日期
boolean containStart = start.compareTo(contractStart) <= 0;
//所选结束时间包含合同结束时间 取合同结束时间 反之 取所选结束时间
DateTime usedEnd = containEnd ? contractEnd : end;
//所选开始时间包含合同开始时间 则取合同开始时间 反之 取所选开始时间
DateTime usedStart = containStart ? contractStart : start;
contract.setIntervalUseDays(Days.daysBetween(contractStart, usedEnd).getDays() + 1);//区间使用天数
int allDay = Days.daysBetween(contractStart, contractEnd).getDays() + 1;
Long excludTax = contract.getMoney() * 94;//不含税收入*100 :contract.getMoney()*100 - contract.getMoney()*0.06*100 = contract.getMoney()*94
contract.setIncomeExcludingTax(excludTax);
DateTime creatMonth = create.dayOfMonth().withMinimumValue();//合同录入月1号
int aferDays = 9;
if (contractStart.monthOfYear().get() == 12) {
// 12月份的合同 次月30号(包含)
aferDays = 29;
}
DateTime nextMonth;
if (ContractStatusEnum.CANCEL.getKey().equals(contract.getStatus()) || ContractStatusEnum.SUSPEND.getKey().equals(contract.getStatus())) {
//合同作废
String contentKey = ContractStatusEnum.CANCEL.getKey().equals(contract.getStatus()) ?
ContractStatusEnum.CANCEL.getValue() : ContractStatusEnum.SUSPEND.getValue();
ContractChange contractChange = contractChangeRepository.findByContentCode(contentKey, contract.getContractCode());
// 合同终止日 或 作废日
DateTime cancelDate = new DateTime(contractChange.getDs());
//每天的分摊收入
Long shareIncomDay = contract.getMoney() * 94 / allDay;
usedEnd = cancelDate.compareTo(usedEnd) <= 0 ? cancelDate : usedEnd;
int daysIncom = Days.daysBetween(contractStart, usedEnd).getDays() + 1;
//区间分摊总收入
contract.setIntervaIncomeShare(shareIncomDay * daysIncom);
//调整金
int daysCancle = Days.daysBetween(cancelDate, contractStart).getDays() + 1;
Long adjustmentFund = daysCancle * excludTax / allDay * -1;
if (checkTwoTime(start, cancelDate)) {
contract.setAdjustmentFund(adjustmentFund);
//分摊加入调整金
contract.setIntervaIncomeShare(shareIncomDay * daysIncom + adjustmentFund);
} else {
contract.setAdjustmentFund(0L);
}
} else if (contractStart.dayOfMonth().withMaximumValue().plusDays(aferDays).isBefore(create)) {
int betweenMonth = create.getMonthOfYear() - contractStart.getMonthOfYear();
//录入时间在次月10以后
if (betweenMonth == 1) {
//相差一月
nextMonth = contractStart.dayOfMonth().withMaximumValue().plusDays(1);//合同开始次月1号
} else if (betweenMonth > 1) {
//相差多月
nextMonth = creatMonth.plusDays(-1).dayOfMonth().withMinimumValue();//合同录入月上月1号
} else {
//相差小于1月
nextMonth = null;
}
if (nextMonth == null || checkTwoTime(nextMonth, end)) {
if (nextMonth == null) {
//执行期内的分摊金额开始时间
nextMonth = usedStart;
}
//筛选结束时间包含合同开始次月1号 则计算分摊收入
//每天的分摊收入
Long shareIncomDay = contract.getMoney() * 94 / allDay;
//时间范围内用于计算分摊金额的天数
DateTime shareStart = nextMonth.compareTo(start) >= 0 ? nextMonth : start;
int daysIncom = Days.daysBetween(shareStart, usedEnd).getDays() + 1;
//区间分摊总收入
contract.setIntervaIncomeShare(shareIncomDay * daysIncom);
} else {
contract.setIntervaIncomeShare(0L);
}
//调证金 筛选时间包含录入月1号 则计算调证金
//调证金:(合同开始月最后一日 - 合同开始日期 + 1)* (不含税收入 / 合同总天数)
Long adjustmentFund = nextMonth == null ? 0 : (contractStart.dayOfMonth().withMaximumValue().dayOfMonth().get()
- contractStart.getDayOfMonth() + 1) * excludTax / allDay;
if (nextMonth != null && checkTwoTime(start, creatMonth) && checkTwoTime(end, nextMonth)) {
contract.setAdjustmentFund(adjustmentFund);
} else {
contract.setAdjustmentFund(0L);
}
if (nextMonth != null && checkTwoTime(start, nextMonth)) {
//筛选开始时间包含次月1号,则分摊金需加上调证金
contract.setIntervaIncomeShare(contract.getIntervaIncomeShare() + adjustmentFund);
}
contract.setIncomeShareAll(contract.getIntervaIncomeShare() + contract.getAdjustmentFund());
}
}
public boolean checkTwoTime(DateTime dateTime1, DateTime dateTime2) {
return dateTime1.isBefore(dateTime2) || dateTime1.isEqual(dateTime2);
}
public static void main(String[] args) {
DateTime contractStart = new DateTime("2020-05-15");
DateTime create = new DateTime("2020-06-15");
// System.out.println(contractStart.monthOfYear().getDateTime());
System.out.println(contractStart.dayOfMonth().withMaximumValue().plusDays(1));
System.out.println(contractStart.dayOfMonth().withMaximumValue().plusDays(9).isBefore(create));
System.out.println(contractStart.compareTo(create));
}
}
...@@ -20,6 +20,7 @@ public enum ContractStatusEnum { ...@@ -20,6 +20,7 @@ public enum ContractStatusEnum {
MONEY_BACK_FIRST("backfirst", "先回款待录入"), MONEY_BACK_FIRST("backfirst", "先回款待录入"),
CANCEL("cancel", "作废"), CANCEL("cancel", "作废"),
SUSPEND("suspend", "中止"),
NFORMAL("normal","常规"), NFORMAL("normal","常规"),
DELETE("del", "已删除"), DELETE("del", "已删除"),
......
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