Commit 6778b148 by kangxiaoshan

v1.3

parent f8b78a2f
......@@ -75,6 +75,15 @@ public class ContractController {
return ResultModel.OK(service.findAll(loginAccount,startDate, endDate, platform,contractId));
}
@RequestMapping(value = "findOne", method = RequestMethod.GET)
@ResponseBody
public ResultModel findOne(@CurrentAccount User loginAccount, @PathVariable String platform,
@RequestParam String startDate, @RequestParam String endDate,String contractId) {
return ResultModel.OK(service.findOne(loginAccount,startDate, endDate, platform,contractId));
}
@RequestMapping(value = "export", method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
public ResponseEntity<byte[]> export(@CurrentAccount User loginAccount, @PathVariable String platform, @RequestParam String startDate
......
......@@ -79,4 +79,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@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, int status);
@Query(value = "select * from contract where contract_code =?2 and platform = ?1 ",nativeQuery = true)
Contract findOneByCode(String platform, String contractId);
}
......@@ -70,4 +70,6 @@ public interface ContractService {
List<ChangeDelDetail> getChangeDelDetailData(User loginAccount, String pid);
ChangeDelInfo changesDelRecover(String id, String type, User loginAccount);
Contract findOne(User loginAccount, String startDate, String endDate, String platform, String contractId);
}
\ No newline at end of file
......@@ -49,11 +49,11 @@ public class ContractServiceImpl implements ContractService {
}};
public static final Map<String,String> FUNCTION_TYPE = new HashMap(){{
put("1","流量赠送");
put("2","合同变更记录");
put("3","收款/开票记录");
put("4","合同管理");
public static final Map<String, String> FUNCTION_TYPE = new HashMap() {{
put("1", "流量赠送");
put("2", "合同变更记录");
put("3", "收款/开票记录");
put("4", "合同管理");
}};
@Autowired
......@@ -230,8 +230,8 @@ public class ContractServiceImpl implements ContractService {
// return code + "-" + platform.toUpperCase() + "-" + DateUtil.getDays2(0) + "-" + lastCode;
String codeName = contractRepository.findLastCode(code);
if("fake".equals(platform)){
String codeName = contractRepository.findLastCode(code);
if ("fake".equals(platform)) {
platform = "FZBWS";
}
......@@ -255,8 +255,7 @@ public class ContractServiceImpl implements ContractService {
lastCode = "" + (codeInt + 1);
}
return code + "-" + platform.toUpperCase() + "-" + DateUtil.getDays2(0) + "-" + lastCode;
return code + "-" + platform.toUpperCase() + "-" + DateUtil.getDays2(0) + "-" + lastCode;
}
......@@ -303,16 +302,14 @@ public class ContractServiceImpl implements ContractService {
}
return list;
}else{
} else {
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus(platform,1);
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus(platform, 1);
return packageBases;
}
}
@Override
......@@ -374,22 +371,21 @@ public class ContractServiceImpl implements ContractService {
}
resource.setInvoice(0L);
Long extraFlow = resource.getExtraFlow();
if(extraFlow==null){
if (extraFlow == null) {
extraFlow = 0L;
}
if(resource.getPayMoney()==null){
if (resource.getPayMoney() == null) {
resource.setPayMoney(0L);
}
resource.setDs(DateUtil.getBeforeDays(0));
this.saveIncrementFlow(resource,extraFlow);
this.saveIncrementFlow(resource, extraFlow);
this.dealContractStatus(resource,loginUser,"save");
this.dealContractStatus(resource, loginUser, "save");
if (resource.getRelationContract() == null) {
resource.setRelationContract(-1L);
......@@ -415,13 +411,13 @@ public class ContractServiceImpl implements ContractService {
resource = contractRepository.save(resource);
this.saveContractRelations(resource,resource.getId());
this.saveContractRelations(resource, resource.getId());
return resource;
}
private void saveIncrementFlow( Contract resource, Long extraFlow){
private void saveIncrementFlow(Contract resource, Long extraFlow) {
if (resource.getType().equals("main")) {
if (resource.getPlatform().equals("tkio")) {
if (!(extraFlow.longValue() == 0)) {
......@@ -441,7 +437,7 @@ public class ContractServiceImpl implements ContractService {
}
private void saveContractRelations(Contract resource,Long contractId){
private void saveContractRelations(Contract resource, Long contractId) {
if (resource.getRelationContract() != null && resource.getRelationContract() > 0) {
//保存关联合同信息
ContractRelation relation = new ContractRelation();
......@@ -450,8 +446,8 @@ public class ContractServiceImpl implements ContractService {
relation.setRelationId(resource.getRelationContract());
relation.setPlatform(resource.getPlatform());
ContractRelation relationOrig = contractRelationRepository.findByRelationData(relation.getMainContract(),relation.getRelationId(),resource.getPlatform());
if(relationOrig==null){
ContractRelation relationOrig = contractRelationRepository.findByRelationData(relation.getMainContract(), relation.getRelationId(), resource.getPlatform());
if (relationOrig == null) {
contractRelationRepository.save(relation);
}
......@@ -614,7 +610,7 @@ public class ContractServiceImpl implements ContractService {
public Contract update(User loginUser, Contract resource, String ip) {
Contract contract = contractRepository.findOne(resource.getId());
if(!contract.getContractCode().equals(resource.getContractCode())){
if (!contract.getContractCode().equals(resource.getContractCode())) {
Contract contractExist = contractRepository.findByCode(resource.getContractCode());
if (contractExist != null) {
// 合同编号已存在
......@@ -625,9 +621,9 @@ public class ContractServiceImpl implements ContractService {
}
}
this.dealContractStatus(resource,loginUser,"update");
this.dealContractStatus(resource, loginUser, "update");
this.saveContractRelations(resource,contract.getId());
this.saveContractRelations(resource, contract.getId());
ChangeDelInfo delInfo = new ChangeDelInfo();
......@@ -643,7 +639,7 @@ public class ContractServiceImpl implements ContractService {
delInfo.setIp(ip);
List<ChangeDelDetail> updateFields = this.changeDelInfoForContract(contract,resource,delInfo.getId(),"");
List<ChangeDelDetail> updateFields = this.changeDelInfoForContract(contract, resource, delInfo.getId(), "");
if (updateFields != null && updateFields.size() > 0) {
changeDelInfoRepository.save(delInfo);
......@@ -672,70 +668,68 @@ public class ContractServiceImpl implements ContractService {
}
private List<ChangeDelDetail> changeDelInfoForContract(Contract byfind, Contract resource, Long pid, String ip){
private List<ChangeDelDetail> changeDelInfoForContract(Contract byfind, Contract resource, Long pid, String ip) {
List<ChangeDelDetail> delDetailsList = new ArrayList<>();
String contractCode = byfind.getContractCode();
this.dealChangeInfoDetail(byfind.getCustomerBody(),resource.getCustomerBody(),
"客户签约主体","customerBody",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getCustomerShort(),resource.getCustomerShort(),
"客户简称","customerShort",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getCustomerThird(),resource.getCustomerThird(),
"第三方签约主体","customerThird",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getCustomerBody(), resource.getCustomerBody(),
"客户签约主体", "customerBody", pid, delDetailsList, byfind);
this.dealChangeInfoDetail(byfind.getCustomerShort(), resource.getCustomerShort(),
"客户简称", "customerShort", pid, delDetailsList, byfind);
this.dealChangeInfoDetail(byfind.getCustomerThird(), resource.getCustomerThird(),
"第三方签约主体", "customerThird", pid, delDetailsList, byfind);
if (byfind.getTradeType() != resource.getTradeType()) {
List<TradeType> types = tradeTypeRepsitory.findByTwoId(byfind.getTradeType(), resource.getTradeType());
Map<String,String> dataDic = new HashMap();
for(TradeType tradeType: types){
dataDic.put(tradeType.getId().toString(),tradeType.getName());
Map<String, String> dataDic = new HashMap();
for (TradeType tradeType : types) {
dataDic.put(tradeType.getId().toString(), tradeType.getName());
}
String nameFind = dataDic.get(byfind.getTradeType()+"");
String nameResource = dataDic.get(resource.getTradeType()+"");
String nameFind = dataDic.get(byfind.getTradeType() + "");
String nameResource = dataDic.get(resource.getTradeType() + "");
this.dealChangeInfoDetail(nameFind == null ? "无" : nameFind, nameResource == null ? "无" : nameResource,
"行业分类", "tradeType", pid, delDetailsList, byfind);
}
this.dealChangeInfoDetail(byfind.getStartDate(),resource.getStartDate(),
"合同开始日期","startDate",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getStartDate(), resource.getStartDate(),
"合同开始日期", "startDate", pid, delDetailsList, byfind);
this.dealChangeInfoDetail(byfind.getEndDate(),resource.getEndDate(),
"合同结束日期","startDate",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getEndDate(), resource.getEndDate(),
"合同结束日期", "startDate", pid, delDetailsList, byfind);
if (byfind.getSale() != resource.getSale()) {
List<Sales> sales = salesRepository.findByTwoId(byfind.getSale(),resource.getSale());
this.dealChangeInfoDetail(sales.get(0).getName(),sales.get(1).getName(),
"签约销售","sale",pid,delDetailsList,byfind);
List<Sales> sales = salesRepository.findByTwoId(byfind.getSale(), resource.getSale());
this.dealChangeInfoDetail(sales.get(0).getName(), sales.get(1).getName(),
"签约销售", "sale", pid, delDetailsList, byfind);
}
this.dealChangeInfoDetail(byfind.getExtraFlow()==null?"":byfind.getExtraFlow().toString(),
resource.getExtraFlow()==null?"":resource.getExtraFlow().toString(),
"赠送流量","extraFlow",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getExtraFlow() == null ? "" : byfind.getExtraFlow().toString(),
resource.getExtraFlow() == null ? "" : resource.getExtraFlow().toString(),
"赠送流量", "extraFlow", pid, delDetailsList, byfind);
this.dealChangeInfoDetail(byfind.getEmail(),resource.getEmail(),
"客户主账号","startDate",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getEmail(), resource.getEmail(),
"客户主账号", "startDate", pid, delDetailsList, byfind);
this.dealChangeInfoDetail(CONTRACT_TYPE.get(byfind.getContractType()),
CONTRACT_TYPE.get(resource.getContractType()),
"签约类型","startDate",pid,delDetailsList,byfind);
"签约类型", "startDate", pid, delDetailsList, byfind);
this.dealChangeInfoDetail(byfind.getDiscountTimeLong()==null?"":byfind.getDiscountTimeLong().toString(),
resource.getDiscountTimeLong()==null?"":resource.getDiscountTimeLong().toString(),
"赠送时长","discountTimeLong",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getDiscountTimeLong() == null ? "" : byfind.getDiscountTimeLong().toString(),
resource.getDiscountTimeLong() == null ? "" : resource.getDiscountTimeLong().toString(),
"赠送时长", "discountTimeLong", pid, delDetailsList, byfind);
this.dealChangeInfoDetail(byfind.getRelationCode()==null?"无":byfind.getRelationCode(),
resource.getRelationCode()==null?"无":resource.getRelationCode(),
"关联合同","relationCode",pid,delDetailsList,byfind);
this.dealChangeInfoDetail(byfind.getRelationCode() == null ? "无" : byfind.getRelationCode(),
resource.getRelationCode() == null ? "无" : resource.getRelationCode(),
"关联合同", "relationCode", pid, delDetailsList, byfind);
return delDetailsList;
}
private void dealChangeInfoDetail(String before, String now,String delDetailinfo,String fildeName,
Long pid,List<ChangeDelDetail> delDetails,Contract contract) {
private void dealChangeInfoDetail(String before, String now, String delDetailinfo, String fildeName,
Long pid, List<ChangeDelDetail> delDetails, Contract contract) {
ChangeDelDetail delDetail = new ChangeDelDetail();
delDetail.setFiledName(fildeName);
......@@ -887,7 +881,7 @@ public class ContractServiceImpl implements ContractService {
}
private void dealContractStatus(Contract resource,User loginUser,String type){
private void dealContractStatus(Contract resource, User loginUser, String type) {
if (resource.getPayMoney() != null) {
if (resource.getMoney() == null) {
......@@ -898,27 +892,25 @@ public class ContractServiceImpl implements ContractService {
//未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
}else if(resource.getPayMoney().longValue() < resource.getMoney().longValue()){
} else if (resource.getPayMoney().longValue() < resource.getMoney().longValue()) {
// 部分回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_PART.getKey());
//记录收款记录
ContractMoney money = new ContractMoney();
money.setType("pay");
saveContractMoney(money,loginUser,resource,type);
saveContractMoney(money, loginUser, resource, type);
}else{
} else {
// 已回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_ALL.getKey());
ContractMoney money = new ContractMoney();
money.setType("pay");
saveContractMoney(money,loginUser,resource,type);
saveContractMoney(money, loginUser, resource, type);
}
} else {
//未回款
resource.setStatus(ContractStatusEnum.MONEY_BACK_NONE.getKey());
......@@ -930,11 +922,11 @@ public class ContractServiceImpl implements ContractService {
if (resource.getInvoiceMoney() == null) {
resource.setInvoiceMoney(new BigDecimal(0));
}else{
} else {
// 记录发票记录
ContractMoney money = new ContractMoney();
money.setType("invoice");
saveContractMoney(money,loginUser,resource,type);
saveContractMoney(money, loginUser, resource, type);
}
if (resource.getDiscountTimeLong() == null) {
......@@ -945,9 +937,9 @@ public class ContractServiceImpl implements ContractService {
resource.setExtraFlow(0L);
}
if(resource.getDiscountTimeLong()> 0 || resource.getExtraFlow()> 0){
if (resource.getDiscountTimeLong() > 0 || resource.getExtraFlow() > 0) {
//记录优惠信息
saveFlowChange(resource,loginUser,type, resource.getDiscountTimeLong(), resource.getExtraFlow());
saveFlowChange(resource, loginUser, type, resource.getDiscountTimeLong(), resource.getExtraFlow());
}
//处理合同编号
......@@ -957,9 +949,9 @@ public class ContractServiceImpl implements ContractService {
//保存开票收款记录
private void saveContractMoney(ContractMoney money,User loginUser,Contract contract,String type){
private void saveContractMoney(ContractMoney money, User loginUser, Contract contract, String type) {
if(!"save".equals(type)){
if (!"save".equals(type)) {
return;
}
......@@ -984,13 +976,13 @@ public class ContractServiceImpl implements ContractService {
}
// 保存优惠流量 优惠时长 记录
private void saveFlowChange(Contract contract, User loginUser, String type, Long discountTimeLong, Long extraFlow){
private void saveFlowChange(Contract contract, User loginUser, String type, Long discountTimeLong, Long extraFlow) {
if(!"save".equals(type)){
if (!"save".equals(type)) {
return;
}
FlowChange change = new FlowChange();
FlowChange change = new FlowChange();
change.setDiscountFlow(extraFlow);
change.setDiscountTimeLong(discountTimeLong);
change.setAddDate(new DateTime().toString("yyyy-MM-dd"));
......@@ -1007,75 +999,35 @@ public class ContractServiceImpl implements ContractService {
/**
*
* @param loginAccount
* @param startDate
* @param endDate
* @param platform
* @param contractId 用于 获取关联合同列表
* @param contractId 用于 获取关联合同列表
* @return
*/
@Override
public List<Contract> findAll(User loginAccount, String startDate, String endDate, String platform, String contractId) {
List<Contract> result = new ArrayList<>();
List<Sales> salesList = salesRepository.findAllByStatusOn();
Map<Long, String> saleMap = new HashMap<>();
if (ValidateUtil.isValid(salesList)) {
for (Sales s : salesList) {
saleMap.put(s.getId(), s.getName());
}
}
List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>();
if (ValidateUtil.isValid(typeList)) {
for (PackageType s : typeList) {
typeMap.put(s.getId(), s.getPackageName());
}
}
List<ContractIncrement> incrementList = contractIncrementRepository.findAll();
Map<Long, String> incremenMap = new HashMap<>();
if (ValidateUtil.isValid(incrementList)) {
for (ContractIncrement s : incrementList) {
incremenMap.put(s.getId(), s.getPackageName());
}
}
List<BPUContract> bpuContractList = bpuContractRepository.findAll();
Map<Long, String> bpuMap = new HashMap<>();
if (ValidateUtil.isValid(bpuContractList)) {
for (BPUContract s : bpuContractList) {
bpuMap.put(s.getId(), s.getPackageName());
}
}
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus(platform,1);
Map<Long,PackageBase> packageBaseMap = new HashMap<>();
for(PackageBase base:packageBases){
packageBaseMap.put(base.getId(),base);
}
List<String> platforms = new ArrayList<>();
Map<String,String> idsDic = new HashMap<>();
Map<String, String> idsDic = new HashMap<>();
platforms.add(platform);
if (!StringUtils.isEmpty(contractId)) {
//获取 关联合同列表
List<String> conIds = new ArrayList<>();
conIds.add(contractId);
this.getContractRelationIds(conIds,idsDic);
this.getContractRelationIds(conIds, idsDic);
idsDic.remove(contractId);
if("fake".equals(platform)){
if ("fake".equals(platform)) {
platforms.add("tkio");
}
}
List<Contract> contractList = new ArrayList<>();
List<String> ids = new ArrayList<>(idsDic.keySet());
List<String> ids = new ArrayList<>(idsDic.keySet());
if (loginAccount.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey()) || loginAccount.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())) {
......@@ -1089,13 +1041,13 @@ public class ContractServiceImpl implements ContractService {
// contractList = contractRepository.findByDsAndRoile(startDate, endDate, platfrom, idList);
if(!StringUtils.isEmpty(contractId)){
if (!StringUtils.isEmpty(contractId)) {
//查看关联合同
if (ids != null && ids.size() > 0) {
contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platforms, idList, ids);
}
}else{
} else {
contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList);
}
......@@ -1103,16 +1055,26 @@ public class ContractServiceImpl implements ContractService {
} else {
// contractList = contractRepository.findByDs(startDate, endDate, platform);
if(!StringUtils.isEmpty(contractId)){
if (!StringUtils.isEmpty(contractId)) {
if (ids != null && ids.size() > 0) {
contractList = contractRepository.findByDsRelation(startDate, endDate, platforms, ids);
}
}else{
} else {
contractList = contractRepository.findByDs(startDate, endDate, platform);
}
}
Map<String, String> saleMap = new HashMap();
Map<String, String> typeMap = new HashMap();
Map<String, PackageBase> packageBaseMap = new HashMap<>();
// 获取字典数据
this.getDicMapDatas(saleMap, typeMap, null, null, packageBaseMap, platform);
if (ValidateUtil.isValid(contractList)) {
for (Contract c : contractList) {
......@@ -1125,7 +1087,7 @@ public class ContractServiceImpl implements ContractService {
c.setHasDiscount("无");
}
if(c.getRelationContract()==null){
if (c.getRelationContract() == null) {
c.setRelationContract(-1L);
}
......@@ -1139,11 +1101,11 @@ public class ContractServiceImpl implements ContractService {
// }
c.setSaleName(saleMap.containsKey(c.getSale()) ? saleMap.get(c.getSale()) : "");
if("tkio".equals(platform)){
if ("tkio".equals(platform)) {
c.setPriceLevelName(typeMap.containsKey(c.getPriceLevel()) ? typeMap.get(c.getPriceLevel()) : "");
}else{
} else {
c.setPriceLevelName(packageBaseMap.get(c.getPriceLevel())==null?"":packageBaseMap.get(c.getPriceLevel()).getPackageName());
c.setPriceLevelName(packageBaseMap.get(c.getPriceLevel()) == null ? "" : packageBaseMap.get(c.getPriceLevel()).getPackageName());
}
......@@ -1155,7 +1117,86 @@ public class ContractServiceImpl implements ContractService {
}
private void getContractRelationIds (List<String> contractId,Map<String,String> idsDic){
public void getDicMapDatas(Map saleMap, Map typeMap, Map incremenMap, Map bpuMap, Map packageBaseMap, String platform) {
if (saleMap != null) {
List<Sales> salesList = salesRepository.findAllByStatusOn();
if (ValidateUtil.isValid(salesList)) {
for (Sales s : salesList) {
saleMap.put(s.getId(), s.getName());
}
}
}
if (typeMap != null) {
List<PackageType> typeList = packageTypeRepository.findAll();
if (ValidateUtil.isValid(typeList)) {
for (PackageType s : typeList) {
typeMap.put(s.getId(), s.getPackageName());
}
}
}
if (incremenMap != null) {
List<ContractIncrement> incrementList = contractIncrementRepository.findAll();
if (ValidateUtil.isValid(incrementList)) {
for (ContractIncrement s : incrementList) {
incremenMap.put(s.getId(), s.getPackageName());
}
}
}
if (bpuMap != null) {
List<BPUContract> bpuContractList = bpuContractRepository.findAll();
if (ValidateUtil.isValid(bpuContractList)) {
for (BPUContract s : bpuContractList) {
bpuMap.put(s.getId(), s.getPackageName());
}
}
}
if (packageBaseMap != null) {
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus(platform, 1);
for (PackageBase base : packageBases) {
packageBaseMap.put(base.getId(), base);
}
}
}
@Override
public Contract findOne(User loginAccount, String startDate, String endDate, String platform, String contractId) {
Contract contract = contractRepository.findOneByCode(platform, contractId);
Map<String, String> saleMap = new HashMap();
Map<String, String> typeMap = new HashMap();
Map<String, PackageBase> packageBaseMap = new HashMap<>();
// 获取字典数据
this.getDicMapDatas(saleMap, typeMap, null, null, packageBaseMap, platform);
contract.setSaleName(saleMap.containsKey(contract.getSale()) ? saleMap.get(contract.getSale()) : "");
if ("tkio".equals(platform)) {
contract.setPriceLevelName(typeMap.containsKey(contract.getPriceLevel()) ? typeMap.get(contract.getPriceLevel()) : "");
} else {
contract.setPriceLevelName(packageBaseMap.get(contract.getPriceLevel()) == null ? "" : packageBaseMap.get(contract.getPriceLevel()).getPackageName());
}
contract.setCreateName(saleMap.containsKey(contract.getCreateAccount()) ? saleMap.get(contract.getCreateAccount()) : "");
return contract;
}
private void getContractRelationIds(List<String> contractId, Map<String, String> idsDic) {
//获取 关联合同 id
List<String> contractIds = new ArrayList<>();
......@@ -1163,18 +1204,18 @@ public class ContractServiceImpl implements ContractService {
List<BigInteger> ids = contractRelationRepository.findRelationIds(contractId);
if (ids != null && ids.size() > 0) {
for(BigInteger id : ids){
for (BigInteger id : ids) {
String idss = id.toString();
if (idsDic.get(idss) == null) {
contractIds.add(idss);
idsDic.put(idss,"0");
idsDic.put(idss, "0");
}
}
if(contractIds.size()>0){
if (contractIds.size() > 0) {
//递归 查询 id 查询所有相关联的合同
this.getContractRelationIds(contractIds,idsDic);
this.getContractRelationIds(contractIds, idsDic);
}
}
}
......@@ -1199,13 +1240,13 @@ public class ContractServiceImpl implements ContractService {
contract.setStatus(status);
changeDelInfo.setDetail("废弃合同");
changeDelInfo.setSourceId(contract.getId());
this.saveChangeDelInfo(changeDelInfo,4,2,ip,loginUser); // type 2 修改
this.saveChangeDelInfo(changeDelInfo, 4, 2, ip, loginUser); // type 2 修改
} else {
changeDelInfo.setDetail("删除合同");
changeDelInfo.setOriginal(contract.getStatus());
changeDelInfo.setSourceId(contract.getId());
this.saveChangeDelInfo(changeDelInfo,4,1,ip,loginUser);
this.saveChangeDelInfo(changeDelInfo, 4, 1, ip, loginUser);
contract.setStatus(ContractStatusEnum.DELETE.getKey());
}
......@@ -1269,13 +1310,13 @@ public class ContractServiceImpl implements ContractService {
public ContractMoney pay(User loginUser, ContractMoney resource) {
Contract contract = contractRepository.findByCode(resource.getContractCode());
if (resource.getType().equals("pay")) {
contract.setPayMoney(contract.getPayMoney()+resource.getMoney());
contract.setPayMoney(contract.getPayMoney() + resource.getMoney());
//判断回款状态
this.dealContractStatus(contract,loginUser,"update");
this.dealContractStatus(contract, loginUser, "update");
} else {
contract.setInvoiceMoney(contract.getInvoiceMoney().add(new BigDecimal(resource.getMoney().toString())) );
contract.setInvoiceMoney(contract.getInvoiceMoney().add(new BigDecimal(resource.getMoney().toString())));
}
if (contract.getType().equals(ContractTypeEnum.INCREMENT.getKey())) {
......@@ -1308,26 +1349,26 @@ public class ContractServiceImpl implements ContractService {
if (resource.getType().equals("price")) {
resource.setContent(packageMap.get(contract.getPriceLevel())+"改为"+packageMap.get(resource.getLevel()));
resource.setMarke(contract.getMoney()+"元改为"+resource.getMoney()+"元");
resource.setContent(packageMap.get(contract.getPriceLevel()) + "改为" + packageMap.get(resource.getLevel()));
resource.setMarke(contract.getMoney() + "元改为" + resource.getMoney() + "元");
contract.setMoney(resource.getMoney());
contract.setPriceLevel(resource.getLevel());
// 处理回款状态
this.dealContractStatus(contract,loginUser,"update");
this.dealContractStatus(contract, loginUser, "update");
}else if("give".equals(resource.getType())){
} else if ("give".equals(resource.getType())) {
//变更优惠记录
this.saveFlowChange(contract,loginUser,"save",resource.getDiscountTimeLong(),resource.getExtraFlow());
this.saveFlowChange(contract, loginUser, "save", resource.getDiscountTimeLong(), resource.getExtraFlow());
// 累加 合同表中数据
if(resource.getExtraFlow()!=null){
contract.setExtraFlow(contract.getExtraFlow()+resource.getExtraFlow());
if (resource.getExtraFlow() != null) {
contract.setExtraFlow(contract.getExtraFlow() + resource.getExtraFlow());
}
if(resource.getDiscountTimeLong()!=null){
contract.setDiscountTimeLong(contract.getDiscountTimeLong()+resource.getDiscountTimeLong());
if (resource.getDiscountTimeLong() != null) {
contract.setDiscountTimeLong(contract.getDiscountTimeLong() + resource.getDiscountTimeLong());
}
} else {
......@@ -1347,7 +1388,7 @@ public class ContractServiceImpl implements ContractService {
resource.setDs(DateUtil.getBeforeDays(0));
resource.setUser(loginUser.getId());
if(!"give".equals(resource.getType())){
if (!"give".equals(resource.getType())) {
contractChangeRepository.save(resource);
}
......@@ -1359,8 +1400,7 @@ public class ContractServiceImpl implements ContractService {
public Object changesDel(String platform, String id, String type, String ip, User loginUser) {
if("give".equals(type)){
if ("give".equals(type)) {
// 优惠流量
FlowChange change = flowChangeRepository.findOne(Long.parseLong(id));
change.setDelFlag(1);
......@@ -1370,12 +1410,12 @@ public class ContractServiceImpl implements ContractService {
changeDelInfo.setContractCode(change.getContractCode());
changeDelInfo.setEmail(change.getEmail());
changeDelInfo.setSourceId(change.getId());
changeDelInfo.setDetail("赠送时长:"+change.getDiscountTimeLong()+"天 — 赠送流量"+ change.getDiscountFlow());
changeDelInfo.setDetail("赠送时长:" + change.getDiscountTimeLong() + "天 — 赠送流量" + change.getDiscountFlow());
this.saveChangeDelInfo(changeDelInfo,1,1,ip,loginUser);
this.saveChangeDelInfo(changeDelInfo, 1, 1, ip, loginUser);
return change;
}else if("change".equals(type)){
} else if ("change".equals(type)) {
//套餐变更
ContractChange contractChange = contractChangeRepository.findOne(Long.parseLong(id));
contractChange.setDelFlag(1);
......@@ -1386,10 +1426,10 @@ public class ContractServiceImpl implements ContractService {
changeDelInfo.setDetail("套餐变更");
changeDelInfo.setEmail(contractChange.getEmail());
changeDelInfo.setSourceId(contractChange.getId());
this.saveChangeDelInfo(changeDelInfo,2,1,ip,loginUser);
this.saveChangeDelInfo(changeDelInfo, 2, 1, ip, loginUser);
return contractChange;
}else{
} else {
ContractMoney contractMoney = contractMoneyRepository.findOne(Long.parseLong(id));
contractMoney.setDelFlag(1);
......@@ -1400,36 +1440,35 @@ public class ContractServiceImpl implements ContractService {
changeDelInfo.setEmail(contractMoney.getEmail());
changeDelInfo.setSourceId(contractMoney.getId());
if("pay".equals(contractMoney.getType())){
if ("pay".equals(contractMoney.getType())) {
this.dealPayMoneyByContractMoney(contractMoney,-1);
changeDelInfo.setDetail("收款记录-金额:"+contractMoney.getMoney());
this.dealPayMoneyByContractMoney(contractMoney, -1);
changeDelInfo.setDetail("收款记录-金额:" + contractMoney.getMoney());
}else{
changeDelInfo.setDetail("开票记录-金额:"+contractMoney.getMoney());
} else {
changeDelInfo.setDetail("开票记录-金额:" + contractMoney.getMoney());
}
this.saveChangeDelInfo(changeDelInfo,3,1,ip,loginUser);
this.saveChangeDelInfo(changeDelInfo, 3, 1, ip, loginUser);
return contractMoney;
}
}
private void dealPayMoneyByContractMoney(ContractMoney contractMoney,int addOr){
private void dealPayMoneyByContractMoney(ContractMoney contractMoney, int addOr) {
// 删除收款记录 修改相应收款金额
// 恢复收款记录 修改相应合同收款金额
Contract contract = contractRepository.findByCode(contractMoney.getContractCode());
contract.setPayMoney(contract.getPayMoney() + contractMoney.getMoney()*addOr);
contract.setPayMoney(contract.getPayMoney() + contractMoney.getMoney() * addOr);
contractRepository.save(contract);
}
@Override
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;
}
......@@ -1447,30 +1486,30 @@ public class ContractServiceImpl implements ContractService {
// 恢复删除
ChangeDelInfo changeDelInfo = changeDelInfoRepository.findOne(Long.parseLong(id));
if(changeDelInfo.getModifyType()==1){
if (changeDelInfo.getModifyType() == 1) {
// put("1","流量赠送");
// put("2","合同变更记录");
// put("3","收款/开票记录");
// put("4","合同管理");
if(changeDelInfo.getFunction()==1){
if (changeDelInfo.getFunction() == 1) {
FlowChange change = flowChangeRepository.findOne(changeDelInfo.getSourceId());
change.setDelFlag(0);
flowChangeRepository.save(change);
}else if(changeDelInfo.getFunction()==2){
} else if (changeDelInfo.getFunction() == 2) {
ContractChange contractChange = contractChangeRepository.findOne(changeDelInfo.getSourceId());
contractChange.setDelFlag(0);
contractChangeRepository.save(contractChange);
}else if(changeDelInfo.getFunction()==3){
} else if (changeDelInfo.getFunction() == 3) {
//
ContractMoney money = contractMoneyRepository.findOne(changeDelInfo.getSourceId());
String detail = changeDelInfo.getDetail();
if(detail!=null && detail.startsWith("收款")){
if (detail != null && detail.startsWith("收款")) {
//恢复收款记录 修改相应合同收款金额
dealPayMoneyByContractMoney(money,1);
dealPayMoneyByContractMoney(money, 1);
}
money.setDelFlag(0);
contractMoneyRepository.save(money);
}else if(changeDelInfo.getFunction()==4){
} else if (changeDelInfo.getFunction() == 4) {
// 合同恢复
Contract contract = contractRepository.findOne(changeDelInfo.getSourceId());
contract.setStatus(changeDelInfo.getOriginal());
......@@ -1484,7 +1523,7 @@ public class ContractServiceImpl implements ContractService {
return null;
}
public void saveChangeDelInfo(ChangeDelInfo changeDelInfo, int function, int type, String ip, User loginUser){
public void saveChangeDelInfo(ChangeDelInfo changeDelInfo, int function, int type, String ip, User loginUser) {
changeDelInfo.setCreatTime(new Date());
changeDelInfo.setFunction(function);// 1 赠送记录
......@@ -1543,7 +1582,7 @@ public class ContractServiceImpl implements ContractService {
@Override
public List<FlowChange> findflowChange(String startDate, String endDate, String code) {
return flowChangeRepository.findByAddDate(startDate, endDate, code);
return flowChangeRepository.findByAddDate(startDate, endDate, code);
}
@Override
......@@ -1573,7 +1612,7 @@ public class ContractServiceImpl implements ContractService {
changeDelInfo.setDetail("修改详情");//
changeDelInfo.setContractCode(contractMoney.getContractCode());
changeDelInfo.setEmail(contractMoney.getEmail());
this.saveChangeDelInfo(changeDelInfo,3,2,ip,loginUser);
this.saveChangeDelInfo(changeDelInfo, 3, 2, ip, loginUser);
delDetail.setCreatTime(new Date());
delDetail.setContractCode(contractMoney.getContractCode());
......@@ -1640,9 +1679,9 @@ public class ContractServiceImpl implements ContractService {
@Override
public List<Map> contractCodeAll(String platform, String contractId) {
Map<String,String> data = new HashMap<>();
data.put("id","-1");
data.put("contractCode","无");
Map<String, String> data = new HashMap<>();
data.put("id", "-1");
data.put("contractCode", "无");
List result = new ArrayList();
result.add(data);
......@@ -1651,35 +1690,35 @@ public class ContractServiceImpl implements ContractService {
plats.add(platform);
if("fake".equals(platform)){
if ("fake".equals(platform)) {
plats.add("tkio");
}
List<ContractRelation> ids = null;
Contract contract = null;
if(!StringUtils.isEmpty(contractId) && !contractId.equals("null")){
ids = contractRelationRepository.findRelationIdsMain(contractId);
if (!StringUtils.isEmpty(contractId) && !contractId.equals("null")) {
ids = contractRelationRepository.findRelationIdsMain(contractId);
contract = contractRepository.findOne(Long.parseLong(contractId));
}
if (ids != null) {
// 已关联合同 字典
Map<String,String> filterMap = new HashMap();
for(ContractRelation relation : ids){
Map<String, String> filterMap = new HashMap();
for (ContractRelation relation : ids) {
if(contract!=null && !relation.getRelationId().equals(contract.getRelationContract())){
filterMap.put(relation.getRelationId()+"_","");
if (contract != null && !relation.getRelationId().equals(contract.getRelationContract())) {
filterMap.put(relation.getRelationId() + "_", "");
}
}
// 所有可关联合同
List<Map> resultBefore = contractRepository.contractCodePlatform(plats);
for (Map m : resultBefore) {
for (Map m : resultBefore) {
String m_id = m.get("id").toString() + "_";
if (filterMap.get(m_id) == null && !m_id.equals(contractId+"_")) {
if (filterMap.get(m_id) == null && !m_id.equals(contractId + "_")) {
result.add(m);
}
}
......@@ -1695,12 +1734,12 @@ public class ContractServiceImpl implements ContractService {
Contract contractExist = contractRepository.findByCodePlatform(contractCode, platform);
Map<String,String> data = new HashMap<>();
Map<String, String> data = new HashMap<>();
if(contractExist!=null){
data.put("exist","true");
}else{
data.put("exist","false");
if (contractExist != null) {
data.put("exist", "true");
} else {
data.put("exist", "false");
}
return data;
}
......@@ -1757,8 +1796,4 @@ public class ContractServiceImpl implements ContractService {
}
}
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