|
|
@@ -4,10 +4,9 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fasterxml.jackson.databind.JsonNode;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ydtech.constants.InsuranceEnum;
|
|
|
@@ -18,6 +17,7 @@ import com.ydtech.modules.base.controller.BaseController;
|
|
|
import com.ydtech.modules.esm.model.EsmInsCompany;
|
|
|
import com.ydtech.modules.esm.service.EsmInsCompanyService;
|
|
|
import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
|
|
|
+import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
|
|
|
import com.ydtech.modules.fnc.entity.*;
|
|
|
import com.ydtech.modules.fnc.service.*;
|
|
|
import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
|
|
|
@@ -66,7 +66,9 @@ import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.YearMonth;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -103,6 +105,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
private ImportAsyncService importAsyncService;
|
|
|
@Autowired
|
|
|
private IncomeTaskRelationshipService incomeTaskRelationshipService;
|
|
|
+ @Autowired
|
|
|
+ private SettlementDocumentaryFeesSumService settlementDocumentaryFeesSumService;
|
|
|
|
|
|
@Value("${upload.file.path}")
|
|
|
private String uploadPath;
|
|
|
@@ -125,8 +129,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
|
|
|
e.printStackTrace();
|
|
|
return HttpResult.error("查询异常");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -519,6 +521,7 @@ handlingProportion,
|
|
|
if (!CollectionUtils.isEmpty(incomeIds)) {
|
|
|
params.put("incomeIds", incomeIds);
|
|
|
params.remove("handlingFeesStatus");
|
|
|
+ params.remove("id");
|
|
|
}
|
|
|
}
|
|
|
List<InsPlyIncome> list = this.baseMapper.queryNew(params);
|
|
|
@@ -1211,28 +1214,33 @@ handlingProportion,
|
|
|
noSuperviseCostsProportion)); //手续费比例 = 商业手续费比例 + 交强手续费比例 + 非车手续费比例
|
|
|
if (jqSuperviseCostsProportion != null && jqPremium != null) {
|
|
|
insPlyIncome.setJqSuperviseCostsPremiums(this.algorithmAmount(jqPremium, jqSuperviseCostsProportion)); //交强手续费
|
|
|
+ insPlyIncome.setJqSuperviseCostsProportion(jqSuperviseCostsProportion);
|
|
|
+
|
|
|
}
|
|
|
if (sySuperviseCostsProportion != null && syPremium != null) {
|
|
|
insPlyIncome.setSySuperviseCostsPremiums(this.algorithmAmount(syPremium, sySuperviseCostsProportion)); //商业手续费
|
|
|
+ insPlyIncome.setSySuperviseCostsProportion(sySuperviseCostsProportion);
|
|
|
}
|
|
|
if (noSuperviseCostsProportion != null && noPremium != null) {
|
|
|
insPlyIncome.setNoSuperviseCostsPremiums(this.algorithmAmount(noPremium, noSuperviseCostsProportion)); //非车手续费
|
|
|
+ insPlyIncome.setNoSuperviseCostsProportion(noSuperviseCostsProportion);
|
|
|
}
|
|
|
if (jqOtherCostsProportion != null && jqPremium != null) {
|
|
|
insPlyIncome.setJqOtherCostsPremium(this.algorithmAmount(jqPremium, jqOtherCostsProportion)); //交强跟单费
|
|
|
+ insPlyIncome.setJqOtherCostsProportion(jqOtherCostsProportion);
|
|
|
}
|
|
|
if (syOtherCostsProportion != null && syPremium != null) {
|
|
|
insPlyIncome.setSyOtherCostsPremium(this.algorithmAmount(syPremium, syOtherCostsProportion)); //商业跟单费
|
|
|
+ insPlyIncome.setSyOtherCostsProportion(syOtherCostsProportion);
|
|
|
}
|
|
|
if (noOtherCostsProportion != null && noPremium != null) {
|
|
|
insPlyIncome.setNoOtherCostsPremium(this.algorithmAmount(noPremium, noOtherCostsProportion)); //非车跟单费
|
|
|
+ insPlyIncome.setNoOtherCostsProportion(noOtherCostsProportion);
|
|
|
}
|
|
|
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),
|
|
|
- insPlyIncome.getSySuperviseCostsPremiums(), insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
|
|
|
+ insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
|
|
|
insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion, sySuperviseCostsProportion,
|
|
|
- noSuperviseCostsProportion)); //手续费比例
|
|
|
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),
|
|
|
- insPlyIncome.getSyOtherCostsPremium(), insPlyIncome.getNoOtherCostsPremium())); //跟单费金额
|
|
|
+ noSuperviseCostsProportion)); //手续费比例
|
|
|
+ insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), insPlyIncome.getNoOtherCostsPremium())); //跟单费金额
|
|
|
insPlyIncome.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion, syOtherCostsProportion, noOtherCostsProportion));
|
|
|
//跟单费比例
|
|
|
insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), insPlyIncome.getOtherFeevalue(), null)); // 总费用 = 手续费+跟单费
|
|
|
@@ -1248,7 +1256,7 @@ handlingProportion,
|
|
|
BigDecimal noNoTaxPremium = insPlyIncomeVo.getNoPremium();// 非车手续费 按照思路 非车不含税保费* 非车手续费比例 =非车手续费
|
|
|
if (jqNoTaxPremium != null && insPlyIncomeVo.getJqSuperviseCostsProportion() != null && insPlyIncomeVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
|
- insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(syNoTaxPremium, insPlyIncomeVo.getJqSuperviseCostsProportion()));
|
|
|
+ insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(jqNoTaxPremium, insPlyIncomeVo.getJqSuperviseCostsProportion()));
|
|
|
insPlyIncome.setJqSuperviseCostsProportion(insPlyIncomeVo.getJqSuperviseCostsProportion());
|
|
|
|
|
|
}
|
|
|
@@ -1279,16 +1287,12 @@ handlingProportion,
|
|
|
}
|
|
|
|
|
|
if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) { //保险 手续费 =不含税保费* 手续费比例
|
|
|
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),
|
|
|
- insPlyIncome.getSySuperviseCostsPremiums(), null)); // 手续费
|
|
|
- insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),
|
|
|
- insPlyIncome.getSySuperviseCostsProportion(), null));//手续费比例
|
|
|
+ insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), null)); // 手续费
|
|
|
+ insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(), insPlyIncome.getSySuperviseCostsProportion(), null));//手续费比例
|
|
|
insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), null, null));//总金额
|
|
|
} else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) { //保险跟单费 交强跟单+商业跟单
|
|
|
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),
|
|
|
- insPlyIncome.getSyOtherCostsPremium(), null));
|
|
|
- insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(),
|
|
|
- insPlyIncome.getSyOtherCostsProportion(), null));
|
|
|
+ insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), null));
|
|
|
+ insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(), insPlyIncome.getSyOtherCostsProportion(), null));
|
|
|
insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(), null, null));//总金额
|
|
|
}
|
|
|
if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())) {// 非车
|
|
|
@@ -1352,16 +1356,49 @@ handlingProportion,
|
|
|
Long id = new SnowFlakeUtil().nextId();
|
|
|
InsPlyIncome insPlyIncome = new InsPlyIncome();
|
|
|
insPlyIncomeVo.setOrderno(id.toString());
|
|
|
+ String signdateStr = insPlyIncomeVo.getSignDate();
|
|
|
+ LocalDateTime localDateTime = this.LocalDatePareLocalDateTime(signdateStr);
|
|
|
+ insPlyIncomeVo.setSignDate(null);
|
|
|
BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
|
|
|
insPlyIncome.setUserId(BaseController.getUser().getId());
|
|
|
insPlyIncome.setDocumentaryFeesStatus("0");
|
|
|
insPlyIncome.setHandlingFeesStatus("0");
|
|
|
insPlyIncome.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
|
|
|
insPlyIncome.setIsNotDocumentary(insPlyIncomeVo.getIsNotDocumentary()); //是否是跟单
|
|
|
+ insPlyIncome.setSignDate(localDateTime);
|
|
|
+ insPlyIncome.setDeptId(BaseController.getUser().getDeptId());
|
|
|
+
|
|
|
+ insPlyIncome.setCreateTime(LocalDate.now());
|
|
|
+ insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncomeVo.getJqOtherCostsProportion(),insPlyIncomeVo.getSyOtherCostsProportion(),insPlyIncomeVo.getNoOtherCostsProportion()));
|
|
|
+ insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncomeVo.getJqSuperviseCostsProportion(),insPlyIncomeVo.getSySuperviseCostsProportion(),insPlyIncomeVo.getNoSuperviseCostsProportion()));
|
|
|
+
|
|
|
+ if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getJqSuperviseCostsProportion() != null && insPlyIncome.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(insPlyIncome.getJqPremium(), insPlyIncomeVo.getJqSuperviseCostsProportion()));
|
|
|
+ }
|
|
|
+ if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getSySuperviseCostsProportion() != null && insPlyIncome.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ insPlyIncome.setSySuperviseCostsPremiums(getBigDecimal(insPlyIncome.getSyPremium(), insPlyIncomeVo.getSySuperviseCostsProportion()));
|
|
|
+ }
|
|
|
+ if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getNoSuperviseCostsProportion() != null && insPlyIncome.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ insPlyIncome.setNoSuperviseCostsPremiums(getBigDecimal(insPlyIncome.getNoPremium(), insPlyIncomeVo.getNoSuperviseCostsProportion()));
|
|
|
+ }
|
|
|
+ if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getJqOtherCostsProportion() != null && insPlyIncome.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ insPlyIncome.setJqOtherCostsPremium(getBigDecimal(insPlyIncome.getJqPremium(), insPlyIncomeVo.getJqOtherCostsProportion()));
|
|
|
+ }
|
|
|
+ if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getSyOtherCostsProportion() != null && insPlyIncome.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ insPlyIncome.setSyOtherCostsPremium(getBigDecimal(insPlyIncome.getSyPremium(), insPlyIncomeVo.getSyOtherCostsProportion()));
|
|
|
+ }
|
|
|
+ if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getNoOtherCostsProportion() != null && insPlyIncome.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ insPlyIncome.setNoOtherCostsPremium(getBigDecimal(insPlyIncome.getNoPremium(), insPlyIncomeVo.getNoOtherCostsProportion()));
|
|
|
+ }
|
|
|
+ insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),insPlyIncome.getOtherFeevalue(),null));
|
|
|
|
|
|
+ String partnerCompaniesId = insPlyIncome.getPartnerCompaniesId();
|
|
|
+ insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
|
|
|
+ EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
|
|
|
+ String name = esmInsCompany.getNamesimple(); //合作名称
|
|
|
+ insPlyIncome.setPartnerCompaniesName(name);
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
- params.put("companyId", insPlyIncomeVo.getCompanyId());
|
|
|
- params.put("partnerCompaniesId", insPlyIncomeVo.getPartnerCompaniesId());
|
|
|
+ params.put("agreeId",insPlyIncomeVo.getAgreeId());
|
|
|
|
|
|
PtlAgreement ptlAgreement = ptlAgreementService.selectAgreeId(params);
|
|
|
if (ObjectUtils.isEmpty(ptlAgreement)) {
|
|
|
@@ -1373,55 +1410,59 @@ handlingProportion,
|
|
|
insPlyIncomeVo.setCrudStatus("1");
|
|
|
this.saveLog(insPlyIncomeVo); //添加日志
|
|
|
|
|
|
-// HashMap<String, Object> params = new HashMap<>();
|
|
|
-//
|
|
|
-// if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
|
|
|
-// params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
|
|
|
-// }
|
|
|
-// params.put("isOther","1");
|
|
|
-// if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
|
|
|
-// params.put("year",insPlyIncomeVo.getYear());
|
|
|
-// }
|
|
|
-// if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
|
|
|
-// params.put("companyId",insPlyIncomeVo.getCompanyId());
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
|
|
|
-// if(!CollectionUtils.isEmpty(list)){
|
|
|
-// for (InsPlyIncome item :list){
|
|
|
-// return HttpResult.ok(item.getIds());
|
|
|
-// }
|
|
|
-// }
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
+ private LocalDateTime LocalDatePareLocalDateTime(String signdateStr) {
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+
|
|
|
+ // 将字符串解析为LocalDate
|
|
|
+ LocalDate signdate = LocalDate.parse(signdateStr, formatter);
|
|
|
+ // 创建一个 LocalTime 对象表示中午12点
|
|
|
+ LocalTime noon = LocalTime.of(12, 0);
|
|
|
+ // 使用 LocalDate 和 LocalTime 来创建 LocalDateTime
|
|
|
+ return LocalDateTime.of(signdate, noon);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除id 已开票或者已结算都不可以进行 删除
|
|
|
+ * 因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去查询判断 保司机构 id
|
|
|
+ * @param insPlyIncomeVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public HttpResult<InsPlyIncome> deleteById(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
-
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())) {
|
|
|
- params.put("isNotCar", insPlyIncomeVo.getIsNotCar());
|
|
|
- }
|
|
|
- params.put("isOther", "1");
|
|
|
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
|
|
|
- params.put("year", insPlyIncomeVo.getYear());
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())) {
|
|
|
- params.put("companyId", insPlyIncomeVo.getCompanyId());
|
|
|
- }
|
|
|
- baseMapper.deleteById(insPlyIncomeVo.getId());
|
|
|
- insPlyIncomeVo.setCrudStatus("3");
|
|
|
- this.saveLog(insPlyIncomeVo);
|
|
|
- List<InsPlyIncome> list = this.baseMapper.NonSettlementQuery(params);
|
|
|
- if (!CollectionUtils.isEmpty(list)) {
|
|
|
- for (InsPlyIncome item : list) {
|
|
|
- return HttpResult.ok(item.getIds());
|
|
|
+ params.put("id",insPlyIncomeVo.getId());
|
|
|
+ List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
|
|
|
+ InsPlyIncome insPlyIncome = insPlyIncomes.get(0);
|
|
|
+ if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "1".equals(insPlyIncome.getAgreementType())) {
|
|
|
+ if ("1".equals(insPlyIncome.getHandlingFeesStatus())) {
|
|
|
+ throw new SystemException("已结算不可以进行删除");
|
|
|
+ }
|
|
|
+ } else if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "2".equals(insPlyIncome.getAgreementType())) {
|
|
|
+ if ("0".equals(insPlyIncome.getIsNotDocumentary())) {
|
|
|
+ String taskId = insPlyIncome.getTaskId();
|
|
|
+ if (StringUtils.isNotEmpty(taskId)) {
|
|
|
+ throw new SystemException("已开票不能进行删除");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+// 因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去进行判断
|
|
|
+ String partnerCompaniesId = insPlyIncome.getPartnerCompaniesId(); // 保司机构id
|
|
|
+ if (StringUtils.isEmpty(partnerCompaniesId)) {
|
|
|
+ throw new SystemException("该单据没有保司机构id");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<SettlementDocumentaryFeesEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SettlementDocumentaryFeesEntity::getPartnerCompaniesId, partnerCompaniesId)
|
|
|
+ .eq(SettlementDocumentaryFeesEntity::getSettlementStatus, "2");
|
|
|
+ List<SettlementDocumentaryFeesEntity> settlementDocumentaryFeesEntities = settlementDocumentaryFeesService.getBaseMapper().selectList(queryWrapper);
|
|
|
+ if (settlementDocumentaryFeesEntities.size() > 0) {
|
|
|
+ throw new SystemException("已开票不能进行删除");
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- return HttpResult.ok(null);
|
|
|
-
|
|
|
}
|
|
|
+ baseMapper.deleteById(insPlyIncomeVo.getId()); //删除 结算 然后删除结算表
|
|
|
return HttpResult.ok("删除成功");
|
|
|
|
|
|
}
|
|
|
@@ -1505,7 +1546,7 @@ handlingProportion,
|
|
|
|
|
|
String id = insPlyIncomeVo.getId(); // 开票id
|
|
|
SettlementDocumentaryFeesEntity settlementDocumentaryFeesServiceById = settlementDocumentaryFeesService.getById(id); //
|
|
|
- BigDecimal allAmount = settlementDocumentaryFeesServiceById.getTotalAmount();
|
|
|
+ BigDecimal allAmount = settlementDocumentaryFeesServiceById.getSettlementAmount();
|
|
|
|
|
|
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
@@ -1551,6 +1592,91 @@ handlingProportion,
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpResult<Object> batchSumBalance(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
+
|
|
|
+ List<InsPlyIncomeVo> multipleSelection = insPlyIncomeVo.getMultipleSelection();
|
|
|
+ HashMap<String, Object> params = new HashMap<>();
|
|
|
+ BigDecimal settleMentAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal settleNotMentAmount = BigDecimal.ZERO;
|
|
|
+ for (InsPlyIncomeVo item : multipleSelection){
|
|
|
+ SettlementDocumentaryFeesEntity settlementDocumentaryFeesVo = new SettlementDocumentaryFeesEntity();
|
|
|
+ if(item.getSettlementAmount() ==null || item .getSettlementAmount().compareTo(BigDecimal.ZERO) <0){
|
|
|
+ throw new SystemException("请输入正确金额");
|
|
|
+ }
|
|
|
+ String id = item.getId();
|
|
|
+ SettlementDocumentaryFeesEntity settlementDocumentaryFeesEntity = settlementDocumentaryFeesService.getBaseMapper().selectById(id); // 开票
|
|
|
+ BigDecimal invoicedNotSettledAmount = settlementDocumentaryFeesEntity.getInvoicedNotSettledAmount();//未结算金额
|
|
|
+ if(item.getSettlementAmount().compareTo(invoicedNotSettledAmount) >0){
|
|
|
+ throw new SystemException("结算金额大于未结算金额");
|
|
|
+ }
|
|
|
+ if(item.getSettlementAmount().compareTo(BigDecimal.ZERO) >0){
|
|
|
+ settlementDocumentaryFeesVo.setInvoiceId(settlementDocumentaryFeesEntity.getInvoicId()); //开票号
|
|
|
+ settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
|
|
|
+ settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
|
|
|
+ settlementDocumentaryFeesVo.setCompanyId(settlementDocumentaryFeesEntity.getCompanyId()); // 保险公司id
|
|
|
+ settlementDocumentaryFeesVo.setPartnerCompaniesId(settlementDocumentaryFeesEntity.getPartnerCompaniesId()); //合作公司id
|
|
|
+ settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算金额
|
|
|
+ settlementDocumentaryFeesVo.setIsNotCar(settlementDocumentaryFeesEntity.getIsNotCar()); // 是否是非车
|
|
|
+ settlementDocumentaryFeesVo.setInvoicingMethod(settlementDocumentaryFeesEntity.getInvoicingMethod()); //开票方式
|
|
|
+ settlementDocumentaryFeesVo.setTaxPoints(settlementDocumentaryFeesEntity.getTaxPoints()); //税点
|
|
|
+ settlementDocumentaryFeesVo.setSettlementImageId(settlementDocumentaryFeesEntity.getSettlementImageId());
|
|
|
+ if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
|
|
|
+ settlementDocumentaryFeesVo.setExpendAmount(settlementDocumentaryFeesEntity.getSettlementAmount().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
|
|
|
+ } else {
|
|
|
+ settlementDocumentaryFeesVo.setExpendAmount(settlementDocumentaryFeesEntity.getSettlementAmount()); //进账金额
|
|
|
+ }
|
|
|
+ settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
|
|
|
+ settlementDocumentaryFeesVo.setHandlingFeesStatus(settlementDocumentaryFeesEntity.getHandlingFeesStatus());
|
|
|
+ settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
|
|
|
+ settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
|
|
|
+ settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
|
|
|
+ settlementDocumentaryFeesVo.setAgreementType("2"); //1平台 2 保险
|
|
|
+
|
|
|
+ // 生成跟单费结算记录
|
|
|
+ SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
|
|
|
+ settlementDocumentaryLogEntity.setAmount(settlementDocumentaryFeesVo.getSettlementAmount()); // 结算金额
|
|
|
+ settlementDocumentaryLogEntity.setSettlementDocumentaryId(settlementDocumentaryFeesEntity.getId()); // 关联id
|
|
|
+ settlementDocumentaryLogEntity.setAmountType("2"); //跟单费结算
|
|
|
+ settlementDocumentaryLogEntity.setCreateTime(new Date());
|
|
|
+ settlementDocumentaryFeesVo.setSettlementSumId(insPlyIncomeVo.getSettlementSumId());
|
|
|
+ settlementDocumentaryFeesService.getBaseMapper().insert(settlementDocumentaryFeesVo);
|
|
|
+ settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
|
|
|
+ //修改开票金额
|
|
|
+
|
|
|
+ BigDecimal add = settlementDocumentaryFeesEntity.getInvoicedSettledAmount().add(insPlyIncomeVo.getSettlementAmount());
|
|
|
+ settlementDocumentaryFeesEntity.setInvoicedSettledAmount(add);
|
|
|
+
|
|
|
+ BigDecimal subtract = settlementDocumentaryFeesEntity.getTotalAmount().subtract(add);
|
|
|
+ settlementDocumentaryFeesEntity.setInvoicedNotSettledAmount(subtract);
|
|
|
+
|
|
|
+ if (subtract.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ settlementDocumentaryFeesEntity.setCompletionStatus("2");
|
|
|
+ } else if (subtract.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ settlementDocumentaryFeesEntity.setCompletionStatus("1");
|
|
|
+ }
|
|
|
+ settlementDocumentaryFeesService.updateById(settlementDocumentaryFeesEntity);
|
|
|
+ settleMentAmount = settleMentAmount.add(settlementDocumentaryFeesEntity.getInvoicedSettledAmount());
|
|
|
+ settleNotMentAmount = settleNotMentAmount.add(settlementDocumentaryFeesEntity.getInvoicedNotSettledAmount());
|
|
|
+ }
|
|
|
+// 更新金额
|
|
|
+
|
|
|
+
|
|
|
+ SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = settlementDocumentaryFeesSumService.getById(insPlyIncomeVo.getSettlementSumId());
|
|
|
+ settlementDocumentaryFeesSumEntity.setInvoicedSettledAmount(settleMentAmount);
|
|
|
+ settlementDocumentaryFeesSumEntity.setInvoicedNotSettledAmount(settleNotMentAmount);
|
|
|
+ if (settleNotMentAmount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ settlementDocumentaryFeesSumEntity.setCompletionStatus("2");
|
|
|
+ } else if (settleNotMentAmount.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ settlementDocumentaryFeesSumEntity.setCompletionStatus("1");
|
|
|
+ }
|
|
|
+ settlementDocumentaryFeesSumService.updateById(settlementDocumentaryFeesSumEntity);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param insPlyIncomeVo
|
|
|
* @return
|
|
|
@@ -1569,7 +1695,7 @@ handlingProportion,
|
|
|
BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
|
|
|
BigDecimal unSettledAmount; //未结算金额
|
|
|
params.put("partnerCompaniesId", item.getPartnerCompaniesId());
|
|
|
-
|
|
|
+ params.remove("handlingFeesStatus");
|
|
|
List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params); //金额总数
|
|
|
for (InsPlyIncome all : insPlyIncomes) {
|
|
|
commissionFeevalue = commissionFeevalue.add(all.getCommissionFeevalue());
|
|
|
@@ -1933,9 +2059,41 @@ handlingProportion,
|
|
|
} else {
|
|
|
settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount());
|
|
|
}
|
|
|
+// 跟单生成批次表
|
|
|
+ SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = this.saveSumSettlement(insPlyIncomeVo);
|
|
|
+ if(ObjectUtils.isNotEmpty(settlementDocumentaryFeesSumEntity)){
|
|
|
+ settlementDocumentaryFeesVo.setSettlementSumId(settlementDocumentaryFeesSumEntity.getId());
|
|
|
+ }
|
|
|
return settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
|
|
|
}
|
|
|
|
|
|
+ private SettlementDocumentaryFeesSumEntity saveSumSettlement(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
+ String handlingFeesStatus = insPlyIncomeVo.getHandlingFeesStatus();
|
|
|
+ SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = new SettlementDocumentaryFeesSumEntity();
|
|
|
+ BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
+ if("1".equals(handlingFeesStatus)){
|
|
|
+ List<InsPlyIncomeVo> nowInsPlyIncomeVo = insPlyIncomeVo.getMultipleSelection();
|
|
|
+ for (InsPlyIncomeVo item: nowInsPlyIncomeVo ){
|
|
|
+ totalAmount = totalAmount.add(item.getSettlementAmount()) ;
|
|
|
+ }
|
|
|
+ settlementDocumentaryFeesSumEntity.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
|
|
|
+ settlementDocumentaryFeesSumEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
|
|
|
+ settlementDocumentaryFeesSumEntity.setCreateTime(new Date());
|
|
|
+ settlementDocumentaryFeesSumEntity.setInvoicId(insPlyIncomeVo.getInvoicId());
|
|
|
+ settlementDocumentaryFeesSumEntity.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod());
|
|
|
+ settlementDocumentaryFeesSumEntity.setIsNotCar(insPlyIncomeVo.getIsNotCar());
|
|
|
+ settlementDocumentaryFeesSumEntity.setSettlementStatus("1");
|
|
|
+ settlementDocumentaryFeesSumEntity.setUserId(BaseController.getUser().getId());
|
|
|
+ settlementDocumentaryFeesSumEntity.setInvoicedSettledAmount(BigDecimal.ZERO);
|
|
|
+ settlementDocumentaryFeesSumEntity.setCompletionStatus("0");
|
|
|
+ settlementDocumentaryFeesSumEntity.setTotalAmount(totalAmount);// 开票总额
|
|
|
+ settlementDocumentaryFeesSumEntity.setInvoicedNotSettledAmount(totalAmount);
|
|
|
+ settlementDocumentaryFeesSumService.getBaseMapper().insert(settlementDocumentaryFeesSumEntity);
|
|
|
+ return settlementDocumentaryFeesSumEntity;
|
|
|
+ }
|
|
|
+ return settlementDocumentaryFeesSumEntity;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
@@ -2216,11 +2374,14 @@ handlingProportion,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public HttpResult<Object> singleInvoic(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
|
|
|
// 通过ids 查出跟单非结算单
|
|
|
SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo(); // 生成跟单费结算表
|
|
|
if (!CollectionUtils.isEmpty(insPlyIncomeVo.getMultipleSelection())) {
|
|
|
+ SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = this.saveSumSettlement(insPlyIncomeVo);
|
|
|
+
|
|
|
for (InsPlyIncomeVo insPlyIncomeVo1 : insPlyIncomeVo.getMultipleSelection()) {
|
|
|
|
|
|
insPlyIncomeVo.setSettlementAmount(insPlyIncomeVo1.getSettlementAmount());
|
|
|
@@ -2283,6 +2444,9 @@ handlingProportion,
|
|
|
BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
|
|
|
settlementDocumentaryFeesVo.setExpendAmount(settlementAmount.multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
|
|
|
}
|
|
|
+ if(ObjectUtils.isNotEmpty(settlementDocumentaryFeesSumEntity)){
|
|
|
+ settlementDocumentaryFeesVo.setSettlementSumId(settlementDocumentaryFeesSumEntity.getId());
|
|
|
+ }
|
|
|
settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
|
|
|
}
|
|
|
}
|
|
|
@@ -2477,5 +2641,21 @@ handlingProportion,
|
|
|
}
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/18 10:14
|
|
|
+ * @Description: 通过保险公司id和状态查询平台的记录
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PlatformSettlementRecordDto> platformSettlementRecord(InsPlyIncomeVo insPlyIncomeVo) {
|
|
|
+ if(insPlyIncomeVo.getPartnerCompaniesId()==null || "".equals(insPlyIncomeVo.getPartnerCompaniesId())){
|
|
|
+ throw new SystemException("合作公司编码(partnerCompaniesId)不能为空");
|
|
|
+ }
|
|
|
+ if(insPlyIncomeVo.getHandlingFeesStatus()==null || "".equals(insPlyIncomeVo.getHandlingFeesStatus())){
|
|
|
+ throw new SystemException("结算状态 0 未结算 1已结算(handlingFeesStatus)不能为空");
|
|
|
+ }
|
|
|
+ return baseMapper.platformSettlementRecord(insPlyIncomeVo.getPartnerCompaniesId(),insPlyIncomeVo.getHandlingFeesStatus());
|
|
|
+ }
|
|
|
|
|
|
}
|