Browse Source

fix:修复费用使用预算异常

fix: 初始化历史单据缺失费用占用脚本
fix:批量导入预算状态异常修复
checkBack
Yen 1 year ago
parent
commit
f321fa3187
  1. 3
      src/main/java/com/qs/serve/modules/bms/entity/BmsSubject.java
  2. 4
      src/main/java/com/qs/serve/modules/bms/entity/vo/BmsSubjectTreeVo.java
  3. 3
      src/main/java/com/qs/serve/modules/tbs/common/util/TbsBudgetLogBuildUtil.java
  4. 3
      src/main/java/com/qs/serve/modules/tbs/controller/TbsActivityController.java
  5. 11
      src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetLogController.java
  6. 24
      src/main/java/com/qs/serve/modules/tbs/mapper/TbsActivityChannelPointMapper.java
  7. 1
      src/main/java/com/qs/serve/modules/tbs/mapper/TbsScheduleItemBudgetMapper.java
  8. 38
      src/main/java/com/qs/serve/modules/tbs/service/TbsActivityDebugApplicationService.java
  9. 79
      src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetReleaseApplicationService.java
  10. 2
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetBatchServiceImpl.java
  11. 11
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetManagerServiceImpl.java
  12. 12
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyOperationServiceImpl.java
  13. 8
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java

3
src/main/java/com/qs/serve/modules/bms/entity/BmsSubject.java

@ -61,6 +61,9 @@ public class BmsSubject implements Serializable {
private Integer level; private Integer level;
/** 应用与发布费用时,必选网点拦截 */
private Integer pointSelectFlag;
/** 备注 */ /** 备注 */
@Length(max = 255,message = "备注长度不能超过255字") @Length(max = 255,message = "备注长度不能超过255字")
private String remark; private String remark;

4
src/main/java/com/qs/serve/modules/bms/entity/vo/BmsSubjectTreeVo.java

@ -49,4 +49,8 @@ public class BmsSubjectTreeVo extends TreeNode {
/** 是否进场费用 */ /** 是否进场费用 */
private Integer slottingFlag; private Integer slottingFlag;
/** 应用与发布费用时,必选网点拦截 */
private Integer pointSelectFlag;
} }

3
src/main/java/com/qs/serve/modules/tbs/common/util/TbsBudgetLogBuildUtil.java

@ -62,7 +62,8 @@ public class TbsBudgetLogBuildUtil {
* @param activity * @param activity
* @return * @return
*/ */
public static TbsBudgetLog buildTbsBudgetLog(BudgetLogOptFlag optType, SysUser sysUser, TbsCostApply costApply, TbsBudgetCostItem item, TbsBudget budget, BigDecimal amount, TbsActivity activity) { public static TbsBudgetLog buildTbsBudgetLog(BudgetLogOptFlag optType, SysUser sysUser, TbsCostApply costApply,
TbsBudgetCostItem item, TbsBudget budget, BigDecimal amount, TbsActivity activity) {
TbsBudgetLog budgetLog = new TbsBudgetLog(); TbsBudgetLog budgetLog = new TbsBudgetLog();
budgetLog.setBudgetId(item.getBudgetId()); budgetLog.setBudgetId(item.getBudgetId());
budgetLog.setBudgetCode(budget.getBudgetCode()); budgetLog.setBudgetCode(budget.getBudgetCode());

3
src/main/java/com/qs/serve/modules/tbs/controller/TbsActivityController.java

File diff suppressed because one or more lines are too long

11
src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetLogController.java

@ -65,6 +65,17 @@ public class TbsBudgetLogController {
return R.ok(); return R.ok();
} }
/**
* 初始化活动申请费用
* @param activityId
* @return
*/
@GetMapping("/debugActivity")
public R<?> debugActivity(Long activityId){
tbsBudgetReleaseApplicationService.initHis(activityId);
return R.ok();
}
/** /**
* 翻页 * 翻页
* @param param * @param param

24
src/main/java/com/qs/serve/modules/tbs/mapper/TbsActivityChannelPointMapper.java

@ -1,7 +1,10 @@
package com.qs.serve.modules.tbs.mapper; package com.qs.serve.modules.tbs.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.modules.tbs.entity.TbsActivityChannelPoint; import com.qs.serve.modules.tbs.entity.TbsActivityChannelPoint;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/** /**
* 活动网点项 Mapper * 活动网点项 Mapper
@ -10,5 +13,26 @@ import com.qs.serve.modules.tbs.entity.TbsActivityChannelPoint;
*/ */
public interface TbsActivityChannelPointMapper extends BaseMapper<TbsActivityChannelPoint> { public interface TbsActivityChannelPointMapper extends BaseMapper<TbsActivityChannelPoint> {
/**
* 检查科目必选网点拦截
* @param activityId
* @return activityId表示被拦截空表示ok
*/
@InterceptorIgnore(tenantLine = "1")
@Select("select tbs_activity_subject.activity_id from tbs_activity_subject " +
"left join bms_subject on subject_id = bms_subject.id " +
"left join ( " +
" select count(1) as count_point,activity_id from tbs_activity_channel_point " +
" where del_flag = 0 and activity_id = #{activityId} " +
" group by activity_id " +
") t1 on t1.activity_id = tbs_activity_subject.activity_id " +
"where " +
" bms_subject.del_flag = 0 " +
"and tbs_activity_subject.del_flag = 0 " +
"and bms_subject.point_select_flag = 1 " +
"and (t1.activity_id is null or t1.count_point = 0) " +
"and tbs_activity_subject.activity_id = #{activityId}")
Long checkSubjectPoint(@Param("activityId") Long activityId);
} }

1
src/main/java/com/qs/serve/modules/tbs/mapper/TbsScheduleItemBudgetMapper.java

@ -226,7 +226,6 @@ public interface TbsScheduleItemBudgetMapper extends BaseMapper<TbsScheduleItemB
"tbs_budget_log.del_flag = 0 " + "tbs_budget_log.del_flag = 0 " +
"and tbs_budget.del_flag = 0 " + "and tbs_budget.del_flag = 0 " +
"and tbs_schedule_item_budget.del_flag = 0 " + "and tbs_schedule_item_budget.del_flag = 0 " +
"and tbs_budget.budget_state = 1 " +
"and tbs_budget_log.center_id = #{centerId} " + "and tbs_budget_log.center_id = #{centerId} " +
"and tbs_budget_log.center_type = #{centerType} " + "and tbs_budget_log.center_type = #{centerType} " +
"and tbs_budget_log.subject_id = #{subjectId} " + "and tbs_budget_log.subject_id = #{subjectId} " +

38
src/main/java/com/qs/serve/modules/tbs/service/TbsActivityDebugApplicationService.java

@ -51,16 +51,16 @@ public class TbsActivityDebugApplicationService {
TbsActivity activity = activityMapper.selectById(activityId); TbsActivity activity = activityMapper.selectById(activityId);
TbsCostApply costApply = tbsCostApplyMapper.selectById(activity.getCostApplyId()); //TbsCostApply costApply = tbsCostApplyMapper.selectById(activity.getCostApplyId());
if(costApply.getPolicyItemId()!=null){ // if(costApply.getPolicyItemId()!=null){
log.warn("随货折让不支持该方法"); // log.warn("随货折让不支持该方法");
return "随货折让不支持该方法"; // return "随货折让不支持该方法";
} // }
//过滤 CA SHX YX06 PortalOfCostApplication.createCostProcess() // //过滤 CA SHX YX06 PortalOfCostApplication.createCostProcess()
if(StringUtils.hasText(costApply.getBillNumber())||StringUtils.hasText(costApply.getDisCode())){ // if(StringUtils.hasText(costApply.getBillNumber())||StringUtils.hasText(costApply.getDisCode())){
log.warn("方法仅支持普通订单"); // log.warn("方法仅支持普通订单");
return "方法仅支持普通订单"; // return "方法仅支持普通订单";
} // }
BigDecimal checkeAmt = activity.getUsedAmount(); BigDecimal checkeAmt = activity.getUsedAmount();
if(activity.getReleaseFlag().equals(1)){ if(activity.getReleaseFlag().equals(1)){
@ -227,6 +227,19 @@ public class TbsActivityDebugApplicationService {
List<TbsActivityCenterGoods> goodsList = activityCenterGoodsListOfSubject.stream() List<TbsActivityCenterGoods> goodsList = activityCenterGoodsListOfSubject.stream()
.filter(a->a.getCenterId().equals(center.getCenterId())&&a.getCenterType().equals(center.getCenterType())) .filter(a->a.getCenterId().equals(center.getCenterId())&&a.getCenterType().equals(center.getCenterType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
if(goodsList.size()==0){
if(subjectCenterList.size()==1 && activityCenterGoodsListOfSubject.size()==1){
TbsActivityCenterGoods centerGoods = activityCenterGoodsListOfSubject.get(0);
centerGoods.setCenterType(center.getCenterType());
centerGoods.setCenterId(center.getCenterId());
centerGoods.setCenterName(center.getCenterName());
goodsList = new ArrayList<>();
goodsList.add(centerGoods);
}else {
log.error("商品数据缺失");
return "商品数据缺失";
}
}
final BigDecimal centerUsed = center.getUsedAmount(); final BigDecimal centerUsed = center.getUsedAmount();
final BigDecimal centerAmt = center.getCenterAmount(); final BigDecimal centerAmt = center.getCenterAmount();
@ -358,7 +371,6 @@ public class TbsActivityDebugApplicationService {
} }
if(activity.getUsedAmount().compareTo(totalSubjectUsedAmt)!=0){ if(activity.getUsedAmount().compareTo(totalSubjectUsedAmt)!=0){
log.error("活动和totalSubjectUsedAmt匹对金额异常:{}",activityId); log.error("活动和totalSubjectUsedAmt匹对金额异常:{}",activityId);
return "活动和totalSubjectUsedAmt匹对金额异常"; return "活动和totalSubjectUsedAmt匹对金额异常";
@ -415,6 +427,10 @@ public class TbsActivityDebugApplicationService {
continue; continue;
} }
if(goodApplyLogs.size()==0){
return "缺失费用申请log";
}
// 新log // 新log
TbsBudgetLog newApplyLog = CopierUtil.copy(goodApplyLogs.get(0),new TbsBudgetLog()); TbsBudgetLog newApplyLog = CopierUtil.copy(goodApplyLogs.get(0),new TbsBudgetLog());
newApplyLog.setId(null); newApplyLog.setId(null);

79
src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetReleaseApplicationService.java

@ -38,11 +38,85 @@ public class TbsBudgetReleaseApplicationService {
private final TbsActivityCenterGoodsService activityCenterGoodsService; private final TbsActivityCenterGoodsService activityCenterGoodsService;
private final TbsCostApplyService costApplyService; private final TbsCostApplyService costApplyService;
private final TbsActivityPayConditionService activityPayConditionService; private final TbsActivityPayConditionService activityPayConditionService;
private final TbsScheduleItemBudgetService tbsScheduleItemBudgetService;
public void initHis(Long activityId){
TbsBudget budget = budgetService.getById("1669");
TbsScheduleItemBudget scheduleItemBudget = tbsScheduleItemBudgetService.getById("4896");
TbsActivity activity = activityService.getById(activityId);
TbsCostApply costApply = costApplyService.getById(activity.getCostApplyId());
SysUser sysUser = new SysUser();
sysUser.setId("0");
sysUser.setName("系统执行");
sysUser.setCode("0");
List<TbsBudgetLog> budgetLogList = new ArrayList<>();
List<TbsActivityCenterGoods> centerGoodsList = activityCenterGoodsService.listByActivityId(activityId);
for (TbsActivityCenterGoods centerGoods : centerGoodsList) {
BigDecimal amount = centerGoods.getCenterGoodsAmount();
TbsBudgetCostItem costItem = new TbsBudgetCostItem();
costItem.setCenterGoodsCode(centerGoods.getCenterGoodsCode());
costItem.setCostApplyId(centerGoods.getCostApplyId());
costItem.setActivityId(centerGoods.getActivityId());
costItem.setActivityCode(centerGoods.getActivityCode());
costItem.setSupplierId(centerGoods.getSupplierId());
costItem.setSupplierCode(centerGoods.getSupplierCode());
costItem.setSupplierName(centerGoods.getSupplierName());
costItem.setSubjectId(centerGoods.getSubjectId());
costItem.setSubjectCode(centerGoods.getSubjectCode());
costItem.setSubjectName(centerGoods.getSubjectName());
costItem.setCenterType(centerGoods.getCenterType());
costItem.setCenterId(centerGoods.getCenterId());
costItem.setCenterCode(centerGoods.getCenterCode());
costItem.setCenterName(centerGoods.getCenterName());
costItem.setCenterAmount(centerGoods.getCenterAmount());
costItem.setCenterRate(centerGoods.getCenterRate());
costItem.setCenterGoodsAmount(centerGoods.getCenterGoodsAmount());
costItem.setCenterGoodsRate(centerGoods.getCenterGoodsRate());
costItem.setTargetType(centerGoods.getTargetType());
costItem.setTargetId(centerGoods.getTargetId());
costItem.setTargetCode(centerGoods.getTargetCode());
costItem.setTargetName(centerGoods.getTargetName());
costItem.setTargetLevelPathIds(centerGoods.getTargetLevelPathIds());
costItem.setTargetLevelPathNames(centerGoods.getTargetLevelPathNames());
costItem.setActStartDate(centerGoods.getActStartDate());
costItem.setActEndDate(centerGoods.getActEndDate());
costItem.setPreStartDate(centerGoods.getPreStartDate());
costItem.setPreEndDate(centerGoods.getPreEndDate());
costItem.setPreCheckDate(centerGoods.getPreCheckDate());
costItem.setCenterGoodItemId(centerGoods.getId());
TbsBudgetLog budgetLog = TbsBudgetLogBuildUtil.buildTbsBudgetLog(BudgetLogOptFlag.State_1,sysUser,costApply,costItem ,budget,amount,activity);
budgetLog.setBudgetId(budget.getId());
budgetLog.setScheduleItemBudgetId(scheduleItemBudget.getId());
budgetLog.setScheduleId(scheduleItemBudget.getScheduleId());
budgetLog.setScheduleItemId(scheduleItemBudget.getScheduleItemId());
budgetLog.setItemName(scheduleItemBudget.getItemName());
budgetLogList.add(budgetLog);
}
//移除历史记录
budgetLogService.remove(new LambdaQueryWrapper<TbsBudgetLog>()
.eq(TbsBudgetLog::getCostApplyId,activity.getCostApplyId())
.eq(TbsBudgetLog::getOptType, BudgetLogOptFlag.State_1.getCode())
.eq(TbsBudgetLog::getActivityId,activity.getId()));
//重新保存
if(CollectionUtil.isNotEmpty(budgetLogList)){
budgetLogService.saveBatch(budgetLogList);
}
}
/**
* 依据剩余预算刷新释放金额
*/
public void check(){ public void check(){
//校验活动的核销金额是否匹配,不匹配则中断 //校验活动的核销金额是否匹配,不匹配则中断
//查询需要补偿释放的活动ID //查询需要补偿释放的活动ID
List<Long> activityIds = vtbFundFlowMapper.listMissReleaseActivityId(); //List<Long> activityIds = vtbFundFlowMapper.listMissReleaseActivityId();
Long[] activityIds = new Long[]{229065L,229066L,229067L,229068L,229069L,229070L,229071L,229072L,229073L,229074L,229075L};
for (Long activityId : activityIds) { for (Long activityId : activityIds) {
TbsActivity activity = activityService.getById(activityId); TbsActivity activity = activityService.getById(activityId);
TbsCostApply costApply = costApplyService.getById(activity.getCostApplyId()); TbsCostApply costApply = costApplyService.getById(activity.getCostApplyId());
@ -84,6 +158,9 @@ public class TbsBudgetReleaseApplicationService {
budgetLogList.add(budgetLog); budgetLogList.add(budgetLog);
} }
//TODO 二次校验,释放金额是否一致
//移除历史记录 //移除历史记录
fundFlowService.remove( fundFlowService.remove(
new LambdaQueryWrapper<VtbFundFlow>() new LambdaQueryWrapper<VtbFundFlow>()

2
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetBatchServiceImpl.java

@ -553,7 +553,7 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper,
boolean conditionFlag = StringUtils.hasText(paramItem.getCategoryNames()) boolean conditionFlag = StringUtils.hasText(paramItem.getCategoryNames())
||StringUtils.hasText(paramItem.getSeriesNames()) ||StringUtils.hasText(paramItem.getSeriesNames())
||StringUtils.hasText(paramItem.getBrandNames()); ||StringUtils.hasText(paramItem.getBrandNames());
newBudget.setConditionFlag(conditionFlag?0:1); newBudget.setConditionFlag(conditionFlag?1:0);
newBudget.setUserId(sysUser.getId()); newBudget.setUserId(sysUser.getId());
newBudget.setUserCode(sysUser.getCode()); newBudget.setUserCode(sysUser.getCode());
newBudget.setUserName(sysUser.getName()); newBudget.setUserName(sysUser.getName());

11
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetManagerServiceImpl.java

@ -1,5 +1,6 @@
package com.qs.serve.modules.tbs.service.impl; package com.qs.serve.modules.tbs.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qs.serve.common.util.CollectionUtil; import com.qs.serve.common.util.CollectionUtil;
@ -131,10 +132,12 @@ public class TbsBudgetManagerServiceImpl implements TbsBudgetManagerService {
List<TbsActivityGoods> activityGoodsList = goodsListMap.get(activityId); List<TbsActivityGoods> activityGoodsList = goodsListMap.get(activityId);
for (TbsActivityGoods goods : activityGoodsList) { for (TbsActivityGoods goods : activityGoodsList) {
boolean isMatch = false; boolean isMatch = false;
for (TbsBudgetCondition condition : budgetConditionList) { if(CollUtil.isNotEmpty(budgetConditionList)){
if(goods.getTargetLevelPathIds().contains(condition.getTargetLevelPathIds())){ for (TbsBudgetCondition condition : budgetConditionList) {
isMatch = true; if(goods.getTargetLevelPathIds().contains(condition.getTargetLevelPathIds())){
break; isMatch = true;
break;
}
} }
} }
if(!isMatch){ if(!isMatch){

12
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyOperationServiceImpl.java

@ -221,12 +221,12 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService
ctpAffairVo.setAffairInfo(ctpAffair); ctpAffairVo.setAffairInfo(ctpAffair);
//2已发 //2已发
if(ctpAffair!=null&&ctpAffair.getState().equals(2)){ if(ctpAffair!=null&&ctpAffair.getState().equals(2)){
String costId = ctpAffair.getCostApplyId(); // String costId = ctpAffair.getCostApplyId();
if(costId!=null){ // if(costId!=null){
TbsCostApply costApply1 = costApplyService.getById(costId); // TbsCostApply costApply1 = costApplyService.getById(costId);
Date date = Date.from(costApply1.getSubmitTime().atZone(ZoneId.systemDefault()).toInstant()); // Date date = Date.from(costApply1.getSubmitTime().atZone(ZoneId.systemDefault()).toInstant());
ctpAffair.setCommentTime(date); // ctpAffair.setCommentTime(date);
} // }
} }
for (SysUser user : userList) { for (SysUser user : userList) {
if(ctpAffair.getMemberId().equals(user.getSyUserId())){ if(ctpAffair.getMemberId().equals(user.getSyUserId())){

8
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java

@ -88,6 +88,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor @AllArgsConstructor
public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsCostApply> implements TbsCostApplyService { public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsCostApply> implements TbsCostApplyService {
private TbsActivityChannelPointMapper tbsActivityChannelPointMapper;
private VtbVerificationMapper vtbVerificationMapper; private VtbVerificationMapper vtbVerificationMapper;
private TbsBudgetApplicationService budgetApplicationService; private TbsBudgetApplicationService budgetApplicationService;
private TbsBudgetCostItemService budgetCostItemService; private TbsBudgetCostItemService budgetCostItemService;
@ -513,6 +514,13 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
actLqw.eq(TbsActivity::getCostApplyId,id); actLqw.eq(TbsActivity::getCostApplyId,id);
List<TbsActivity> activityList = tbsActivityMapper.selectList(actLqw); List<TbsActivity> activityList = tbsActivityMapper.selectList(actLqw);
for (TbsActivity activity : activityList) {
Long actId = tbsActivityChannelPointMapper.checkSubjectPoint(activity.getId());
if(actId!=null){
Assert.throwEx("活动["+activity.getActivityCode() + "]因科目类型,必须选网点");
}
}
//判断是否进场费 //判断是否进场费
if(tbsCostApply.getContractFlag()!=null&&tbsCostApply.getContractFlag().equals(2)){ if(tbsCostApply.getContractFlag()!=null&&tbsCostApply.getContractFlag().equals(2)){
if (activityList.size()>1){ if (activityList.size()>1){

Loading…
Cancel
Save