Commit 065e5ebd authored by 查济's avatar 查济

Merge branch 'feature-zhaji' into 'develop'

"feature-zhaJi:修改商险重发部分逻辑"

See merge request fangxinjiang/yifu!239
parents 16c50c06 703ce61c
......@@ -38,7 +38,7 @@ public class TInsuranceEkp implements Serializable {
/**
* 单据类型 (0、与薪资合并结算 1、单独结算)
*/
private Integer settleType;
private String settleType;
/**
* 项目编码
......@@ -138,7 +138,7 @@ public class TInsuranceEkp implements Serializable {
/**
* 单据状态
*/
private Integer interactiveType;
private String interactiveType;
/**
* 重发标识
......
......@@ -5648,13 +5648,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
param.setInteractiveType(InsurancesConstants.CORRECT_SETTLE_BILL);
param.setSettleType(InsurancesConstants.ACTUAL_SETTLE_BILL);
pushType = CommonConstants.FIVE_INT;
pushType = CommonConstants.SIX_INT;
}
//4更新实际保费(用于登记保单保费场景推送过实缴保费)
if(CommonConstants.FOUR_INT == type){
param.setInteractiveType(InsurancesConstants.UPDATE_SETTLE_BILL);
param.setSettleType(InsurancesConstants.ACTUAL_SETTLE_BILL);
pushType = CommonConstants.SEVEN_INT;
pushType = CommonConstants.THREE_INT;
}
//作废
if(CommonConstants.FIVE_INT == type){
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.util.EkpInsuranceUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.constants.InsurancesConstants;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
......@@ -58,183 +59,185 @@ public class TInsuranceEkpServiceImpl extends ServiceImpl<TInsuranceEkpMapper, T
@Override
public R resend() {
List<TInsuranceEkp> ekpRefundList = this.baseMapper.getEkpRefundList();
List<TInsuranceEkp> failList = new ArrayList<>();
List<TInsuranceEkp> successLit = new ArrayList<>();
if (CollectionUtils.isNotEmpty(ekpRefundList)){
for (TInsuranceEkp tInsuranceEkp : ekpRefundList) {
TInsuranceDetail byId = tInsuranceDetailService.getById(tInsuranceEkp.getDetailId());
String defaultSettleId = byId.getDefaultSettleId();
if (tInsuranceEkp.getDefaultSettleId().equals(defaultSettleId)){
//ekp结算信息
SettleVo settleVo = tInsuranceDetailService.getInsuranceDetailSettleStatus(tInsuranceEkp.getDetailId(), tInsuranceEkp.getDefaultSettleId());
String s = null;
String settleType = tInsuranceEkp.getSettleType();
Integer pushType = tInsuranceEkp.getPushType();
//商险结算信息
TInsuranceSettle insuranceSettle = tInsuranceSettleService.getById(tInsuranceEkp.getDefaultSettleId());
//预估推送状态
Integer isEstimatePush = insuranceSettle.getIsEstimatePush();
//实缴推送状态
Integer isActualPush = insuranceSettle.getIsActualPush();
//实缴结算状态
String actualStatus = settleVo.getActualStatus();
//预缴结算状态
String estimateStatus = settleVo.getEstimateStatus();
Integer pushType = tInsuranceEkp.getPushType();
//如果当前需要重发预估保费的数据已发送,则过滤掉执行下一条数据
if(CommonConstants.ONE_INT == pushType && CommonConstants.ONE_INT == isEstimatePush){
tInsuranceEkp.setResendFlag(CommonConstants.THREE_INT);
failList.add(tInsuranceEkp);
continue;
}
//如果当前需要重发实际保费的数据已发送,则过滤掉执行下一条数据
if(CommonConstants.TWO_INT == pushType && CommonConstants.ONE_INT == isActualPush){
tInsuranceEkp.setResendFlag(CommonConstants.THREE_INT);
failList.add(tInsuranceEkp);
continue;
}
boolean settleIdEquals = tInsuranceEkp.getDefaultSettleId().equals(defaultSettleId);
//预估是否已发送
boolean estimatePush = Common.isEmpty(insuranceSettle) && insuranceSettle.getIsEstimatePush() == CommonConstants.ZERO_INT;
//实缴是否已发送
boolean actualPush = Common.isEmpty(insuranceSettle) && insuranceSettle.getIsActualPush() == CommonConstants.ZERO_INT;
//结算类型是否一致
boolean settleTypeEquals = settleType.equals(byId.getSettleType().toString());
EkpInteractiveParam ekpParam = new EkpInteractiveParam();
BeanCopyUtils.copyProperties(tInsuranceEkp,ekpParam);
//如果预估未结算
LambdaUpdateWrapper<TInsuranceSettle> updateWrapper = new LambdaUpdateWrapper<>();
String s = null;
if(InsurancesConstants.SETTLE_ZERO.equals(estimateStatus)){
//实缴未结算
if(InsurancesConstants.SETTLE_ZERO.equals(actualStatus)){
//如果是新增预估保费,则推送预估保费新增
LambdaUpdateWrapper<TInsuranceSettle> settleUpdate = new LambdaUpdateWrapper<>();
settleUpdate.eq(TInsuranceSettle :: getId,tInsuranceEkp.getDefaultSettleId());
LambdaUpdateWrapper<TInsuranceDetail> detailUpdate = new LambdaUpdateWrapper<>();
detailUpdate.eq(TInsuranceDetail :: getId,tInsuranceEkp.getDetailId());
LambdaUpdateWrapper<TInsuranceEkp> ekpUpdate = new LambdaUpdateWrapper<>();
ekpUpdate.eq(TInsuranceEkp :: getId,tInsuranceEkp.getId());
if(settleType.equals(CommonConstants.ZERO_STRING)){
ekpParam.setEstimateStatus(EkpConstants.HAVE);
}else{
ekpParam.setEstimateStatus(EkpConstants.NOTHING);
}
//预估新增重发
if(CommonConstants.ONE_INT == pushType){
//如果结算类型不一致,结算类型不为空且已预估发送,结算id不一致
if(!settleTypeEquals || !estimatePush || !settleIdEquals){
ekpUpdate.set(TInsuranceEkp :: getResendFlag,CommonConstants.TWO_INT);
update(ekpUpdate);
continue;
}else{
ekpParam.setInteractiveType(InsurancesConstants.NEW_SETTLE_BILL);
ekpParam.setSettleType(InsurancesConstants.ESTIMATE_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)){
updateWrapper.eq(TInsuranceSettle :: getId,tInsuranceEkp.getDefaultSettleId())
.set(TInsuranceSettle :: getIsEstimatePush,CommonConstants.ONE_INT)
.set(TInsuranceSettle :: getEstimatePushTime, LocalDateTime.now());
tInsuranceSettleService.update(updateWrapper);
}
}
//如果是新增实缴保费,则推送实缴保费新增
if(CommonConstants.TWO_INT == pushType){
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)) {
updateWrapper.eq(TInsuranceSettle::getId, tInsuranceEkp.getDefaultSettleId())
.set(TInsuranceSettle::getIsActualPush, CommonConstants.ONE_INT)
.set(TInsuranceSettle::getActualPushTime, LocalDateTime.now());
tInsuranceSettleService.update(updateWrapper);
settleUpdate.set(TInsuranceSettle :: getEstimatePushTime,LocalDateTime.now())
.set(TInsuranceSettle ::getIsEstimatePush,CommonConstants.ONE_INT);
tInsuranceSettleService.update(settleUpdate);
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
break;
}
}
//如果是变更结算信息,则推送变更结算信息
if(CommonConstants.THREE_INT == pushType){
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)) {
updateWrapper.eq(TInsuranceSettle::getId, tInsuranceEkp.getDefaultSettleId())
.set(TInsuranceSettle::getIsActualPush, CommonConstants.ONE_INT)
.set(TInsuranceSettle::getActualPushTime, LocalDateTime.now());
tInsuranceSettleService.update(updateWrapper);
LambdaUpdateWrapper<TInsuranceDetail> detailLambdaUpdate = new LambdaUpdateWrapper<>();
detailLambdaUpdate.eq(TInsuranceDetail::getId, tInsuranceEkp.getDetailId())
.set(TInsuranceDetail::getSettleMonth, CommonConstants.ONE_INT);
tInsuranceSettleService.update(updateWrapper);
}
}
//如果是作废信息,则推送作废信息
if(CommonConstants.FOUR_INT == pushType){
s = ekpInsuranceUtil.sendToEkp(ekpParam);
}
if(CommonConstants.FIVE_INT == pushType || CommonConstants.SIX_INT == pushType){
tInsuranceEkp.setResendFlag(CommonConstants.TWO_INT);
failList.add(tInsuranceEkp);
//实缴新增重发
if(CommonConstants.TWO_INT == pushType){
//如果结算类型不一致,结算类型不为空且已发送,结算id不一致
if(!settleTypeEquals || !actualPush || !settleIdEquals){
ekpUpdate.set(TInsuranceEkp :: getResendFlag,CommonConstants.TWO_INT);
update(ekpUpdate);
continue;
}
//成功则更新,不成功则跳出循环
if(StringUtils.isNotBlank(s)) {
tInsuranceEkp.setResendFlag(CommonConstants.ONE_INT);
updateById(tInsuranceEkp);
}else{
break;
}
}
//实缴结算中,已结算
if(InsurancesConstants.SETTLE_ONE.equals(actualStatus) || InsurancesConstants.SETTLE_TWO.equals(actualStatus)){
//如果是作废,则推送实缴红冲
if(CommonConstants.FOUR_INT == pushType){
BigDecimal actualPremium = ekpParam.getActualPremium();
ekpParam.setActualPremium(actualPremium.negate());
ekpParam.setInteractiveType(InsurancesConstants.CORRECT_SETTLE_BILL);
ekpParam.setInteractiveType(InsurancesConstants.NEW_SETTLE_BILL);
ekpParam.setSettleType(InsurancesConstants.ACTUAL_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)) {
tInsuranceEkp.setResendFlag(CommonConstants.ONE_INT);
updateById(tInsuranceEkp);
if(StringUtils.isNotBlank(s)){
settleUpdate.set(TInsuranceSettle :: getActualPushTime,LocalDateTime.now())
.set(TInsuranceSettle ::getIsActualPush,CommonConstants.ONE_INT);
tInsuranceSettleService.update(settleUpdate);
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
break;
}
}
if(CommonConstants.SIX_INT == pushType){
}
//ekp结算信息
SettleVo settleVo = tInsuranceDetailService.getInsuranceDetailSettleStatus(tInsuranceEkp.getDetailId(), tInsuranceEkp.getDefaultSettleId());
//实缴结算状态
String actualStatus = null;
//预缴结算状态
String estimateStatus = null;
if(!Common.isEmpty(settleVo) ){
estimateStatus = settleVo.getEstimateStatus();
actualStatus = settleVo.getActualStatus();
}
boolean eStatus = InsurancesConstants.SETTLE_ZERO.equals(estimateStatus);
boolean aStatus = InsurancesConstants.SETTLE_ZERO.equals(actualStatus);
//变更结算信息
if(CommonConstants.THREE_INT == pushType){
//如果结算类型不一致,结算类型不为空且已发送,结算id不一致
if(!settleTypeEquals || !settleIdEquals || !eStatus || !aStatus){
ekpUpdate.set(TInsuranceEkp :: getResendFlag,CommonConstants.TWO_INT);
update(ekpUpdate);
continue;
}else{
ekpParam.setInteractiveType(InsurancesConstants.UPDATE_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)) {
tInsuranceEkp.setResendFlag(CommonConstants.ONE_INT);
updateById(tInsuranceEkp);
if(StringUtils.isNotBlank(s)){
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
break;
}
}else{
//推送预估新增,实缴新增,变更结算信息,作废,则不进行重发
tInsuranceEkp.setResendFlag(CommonConstants.TWO_INT);
updateById(tInsuranceEkp);
}
}
}else{
//如果实缴未结算
if(InsurancesConstants.SETTLE_ZERO.equals(actualStatus)){
//如果是作废信息,则推送预估红冲信息
//推送作废信息
if(CommonConstants.FOUR_INT == pushType){
BigDecimal estimatePremium = ekpParam.getEstimatePremium();
ekpParam.setActualPremium(estimatePremium.negate());
ekpParam.setInteractiveType(InsurancesConstants.CORRECT_SETTLE_BILL);
//如果结算类型不一致,结算类型不为空且已发送,结算id不一致
if(eStatus && aStatus){
ekpParam.setSettleType(InsurancesConstants.ESTIMATE_SETTLE_BILL);
ekpParam.setInteractiveType(InsurancesConstants.ABOLISH_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)) {
tInsuranceEkp.setResendFlag(CommonConstants.ONE_INT);
updateById(tInsuranceEkp);
if(StringUtils.isNotBlank(s)){
detailUpdate.set(TInsuranceDetail :: getDefaultSettleId,null);
tInsuranceDetailService.update(detailUpdate);
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
break;
}
} else if(CommonConstants.FIVE_INT == pushType){
//如果是预估红冲信息,则推送预估红冲信息
}
if(!eStatus || !aStatus){
ekpParam.setInteractiveType(InsurancesConstants.CORRECT_SETTLE_BILL);
//如果为合并结算,则推送预估红冲
if(settleType.equals(CommonConstants.ZERO_STRING) && actualPush){
BigDecimal estimatePremium = ekpParam.getEstimatePremium();
ekpParam.setEstimatePremium(estimatePremium.negate());
ekpParam.setSettleType(InsurancesConstants.ESTIMATE_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)) {
tInsuranceEkp.setResendFlag(CommonConstants.ONE_INT);
updateById(tInsuranceEkp);
if(StringUtils.isNotBlank(s)){
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
break;
}
}else{
tInsuranceEkp.setResendFlag(CommonConstants.TWO_INT);
updateById(tInsuranceEkp);
}
}else{
//如果是实缴红冲信息,则推送实缴红冲信息
if(CommonConstants.SIX_INT == pushType){
//如果为合并结算,则推送实缴红冲
if(!actualPush){
ekpParam.setSettleType(InsurancesConstants.ACTUAL_SETTLE_BILL);
BigDecimal actualPremium = ekpParam.getActualPremium();
ekpParam.setActualPremium(actualPremium.negate());
ekpParam.setInteractiveType(InsurancesConstants.CORRECT_SETTLE_BILL);
ekpParam.setSettleType(InsurancesConstants.ACTUAL_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)) {
tInsuranceEkp.setResendFlag(CommonConstants.ONE_INT);
updateById(tInsuranceEkp);
if(StringUtils.isNotBlank(s)){
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
break;
}
}
}else{
tInsuranceEkp.setResendFlag(CommonConstants.TWO_INT);
updateById(tInsuranceEkp);
ekpUpdate.set(TInsuranceEkp :: getResendFlag,CommonConstants.TWO_INT);
update(ekpUpdate);
continue;
}
}
//推送预估红冲信息
if(CommonConstants.FIVE_INT == pushType){
ekpParam.setSettleType(InsurancesConstants.ESTIMATE_SETTLE_BILL);
ekpParam.setInteractiveType(InsurancesConstants.CORRECT_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)){
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
break;
}
}
//推送实缴红冲信息
if(CommonConstants.SIX_INT == pushType){
ekpParam.setSettleType(InsurancesConstants.ACTUAL_SETTLE_BILL);
ekpParam.setInteractiveType(InsurancesConstants.CORRECT_SETTLE_BILL);
s = ekpInsuranceUtil.sendToEkp(ekpParam);
if(StringUtils.isNotBlank(s)){
ekpUpdate.set(TInsuranceEkp :: getResendFlag ,CommonConstants.ONE_INT);
update(ekpUpdate);
}else{
//结算id与当前不一致则不进行重发
tInsuranceEkp.setResendFlag(CommonConstants.THREE_INT);
failList.add(tInsuranceEkp);
break;
}
}
updateBatchById(failList);
}
return R.ok("发送成功");
}else{
return R.failed("无需要发送的信息");
......
......@@ -32,6 +32,7 @@
<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
<result property="pushTime" column="PUSH_TIME" jdbcType="TIMESTAMP"/>
<result property="pushType" column="PUSH_TYPE" jdbcType="TINYINT"/>
<result property="settleType" column="SETTLE_TYPE" jdbcType="TINYINT"/>
</resultMap>
......@@ -44,7 +45,7 @@
POLICY_END,BUY_STANDARD,MEDICAL_QUOTA,
DIE_DISABLE_QUOTA,ACTUAL_PREMIUM,ESTIMATE_PREMIUM,
SETTLE_MONTH,INTERACTIVE_TYPE,RESEND_FLAG,
CREATE_TIME,PUSH_TIME,PUSH_TYPE
CREATE_TIME,PUSH_TIME,PUSH_TYPE,SETTLE_TYPE
</sql>
<select id="getEkpRefundList" resultMap="BaseResultMap">
......
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