|
@@ -8,15 +8,19 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysDictItem;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
import com.qunzhixinxi.hnqz.admin.config.TaxNotifyConfig;
|
|
import com.qunzhixinxi.hnqz.admin.config.TaxNotifyConfig;
|
|
import com.qunzhixinxi.hnqz.admin.config.UpmsConfig;
|
|
import com.qunzhixinxi.hnqz.admin.config.UpmsConfig;
|
|
import com.qunzhixinxi.hnqz.admin.entity.*;
|
|
import com.qunzhixinxi.hnqz.admin.entity.*;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.SettleNoteStatusOutput;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.SettleNoteStatusOutput;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleInput;
|
|
import com.qunzhixinxi.hnqz.admin.entity.input.WmScorePackageSettleInput;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.PackageStatusEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.PackageTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.PackageTypeEnum;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.SettleStatusEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectLocation;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectLocation;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.enums.SubjectTypeEnum;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.mapper.SysDictItemMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserSubMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserSubMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.WmPayOffMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.WmPayOffMapper;
|
|
@@ -56,6 +60,7 @@ import java.math.RoundingMode;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
+import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -80,11 +85,11 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
private final WmScorePackageSettleNoteService noteService;
|
|
private final WmScorePackageSettleNoteService noteService;
|
|
private final SysDeptService sysDeptService;
|
|
private final SysDeptService sysDeptService;
|
|
private final SysDeptSubService sysDeptSubService;
|
|
private final SysDeptSubService sysDeptSubService;
|
|
|
|
+ private final SysDictItemMapper sysDictItemMapper;
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
private final MonitoringIndicatorService monitoringIndicatorService;
|
|
private final MonitoringIndicatorService monitoringIndicatorService;
|
|
private final TaxHelperService taxHelperService;
|
|
private final TaxHelperService taxHelperService;
|
|
private final TaxNotifyConfig taxNotifyConfig;
|
|
private final TaxNotifyConfig taxNotifyConfig;
|
|
- private final RestTemplate restTemplate;
|
|
|
|
|
|
|
|
private final MathContext mc = new MathContext(2, RoundingMode.HALF_EVEN);
|
|
private final MathContext mc = new MathContext(2, RoundingMode.HALF_EVEN);
|
|
private final String GIG_TOKEN_URL = "%s/gig/operation/token?tenantId={tenantId}&action={action}&userId={userId}";
|
|
private final String GIG_TOKEN_URL = "%s/gig/operation/token?tenantId={tenantId}&action={action}&userId={userId}";
|
|
@@ -157,7 +162,7 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
note.setPackageStatusId(String.valueOf(status.getId()));
|
|
note.setPackageStatusId(String.valueOf(status.getId()));
|
|
note.setPackageId(status.getPackageId());
|
|
note.setPackageId(status.getPackageId());
|
|
|
|
|
|
- if ("1".equals(wmScorePackage.getPackageType1())) {
|
|
|
|
|
|
+ if (StrUtil.equals(PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val(), wmScorePackage.getPackageType1())) {
|
|
|
|
|
|
note.setSettleAmount(StringUtils.isEmpty(status.getUserScore()) ? BigDecimal.ZERO : new BigDecimal(status.getUserScore(), mc));
|
|
note.setSettleAmount(StringUtils.isEmpty(status.getUserScore()) ? BigDecimal.ZERO : new BigDecimal(status.getUserScore(), mc));
|
|
|
|
|
|
@@ -235,6 +240,119 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
return R.ok(resultMap);
|
|
return R.ok(resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 多人承接-按积分值业务结算-查询
|
|
|
|
+ *
|
|
|
|
+ * @param taskIds 任务id
|
|
|
|
+ * @return 结算信息
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public R<?> settleInfoByTaskIds(String[] taskIds) {
|
|
|
|
+ // 查询任务
|
|
|
|
+ List<WmTask> taskList = wmTaskService.listByIds(Arrays.asList(taskIds));
|
|
|
|
+ Set<String> taskIdSet = taskList.stream().map(WmTask::getScorePackageId).collect(Collectors.toSet());
|
|
|
|
+ if (taskIdSet.size() > 1) {
|
|
|
|
+ return R.failed("所选任务不属于同一个积分包");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String scorePackageId = taskList.get(0).getScorePackageId();
|
|
|
|
+ WmScorePackage wmScorePackage = wmScorePackageService.getById(scorePackageId);
|
|
|
|
+
|
|
|
|
+ // user-taskList map
|
|
|
|
+ Map<String, List<WmTask>> userTaskMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getTaskUserId));
|
|
|
|
+ // taskId-task Map
|
|
|
|
+ Map<String, WmTask> taskMap = taskList.stream().collect(Collectors.toMap(WmTask::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 查询settleNote
|
|
|
|
+ List<WmScorePackageSettleNote> notes = noteService.list(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ .in(WmScorePackageSettleNote::getTaskId, Arrays.asList(taskIds))
|
|
|
|
+ .eq(WmScorePackageSettleNote::getPackageId, scorePackageId));
|
|
|
|
+ Map<String, WmScorePackageSettleNote> taskSettleNoteMap = notes.stream()
|
|
|
|
+ .filter(note -> StrUtil.isNotBlank(note.getTaskId()))
|
|
|
|
+ .collect(Collectors.toMap(WmScorePackageSettleNote::getTaskId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 查询user
|
|
|
|
+ Set<String> allUserIdSet = new HashSet<>();
|
|
|
|
+ allUserIdSet.addAll(userTaskMap.keySet());
|
|
|
|
+ allUserIdSet.addAll(notes.stream().map(WmScorePackageSettleNote::getUserId).collect(Collectors.toSet()));
|
|
|
|
+ List<SysUser> sysUsers = sysUserMapper.selectBatchIds(allUserIdSet);
|
|
|
|
+ Map<Integer, SysUser> userMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 页面回显的结算对象列表
|
|
|
|
+ List<WmScorePackageSettleNote> userNotes = new ArrayList<>();
|
|
|
|
+ // 用于结算的note参数
|
|
|
|
+ List<WmScorePackageSettleNote> toSettleNotes = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ if (wmScorePackage.getLocation() != null) {
|
|
|
|
+ wmScorePackage.setSubjectLocation(wmScorePackage.getLocation().name());
|
|
|
|
+ }
|
|
|
|
+// if (StrUtil.isBlank(wmScorePackage.getSubjectLocation())){
|
|
|
|
+// return R.failed("结算积分包未勾选税源地");
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ // 按结算对象分组,统计分别对应的结算信息
|
|
|
|
+ for (String userId : userTaskMap.keySet()) {
|
|
|
|
+ WmScorePackageSettleNote oneUserNote = new WmScorePackageSettleNote();
|
|
|
|
+ List<WmTask> userTasks = userTaskMap.get(userId);
|
|
|
|
+
|
|
|
|
+ // 计算每个人的总任务积分
|
|
|
|
+ BigDecimal userTotalSettleAmount = BigDecimal.ZERO;
|
|
|
|
+ for (WmTask task : userTasks) {
|
|
|
|
+ WmScorePackageSettleNote settleNote = taskSettleNoteMap.get(task.getId());
|
|
|
|
+ // 存在note,则取note金额,否则取task的积分
|
|
|
|
+ if (settleNote != null) {
|
|
|
|
+ userTotalSettleAmount = userTotalSettleAmount.add(settleNote.getSettleAmount());
|
|
|
|
+ } else {
|
|
|
|
+ userTotalSettleAmount = userTotalSettleAmount.add(BigDecimal.valueOf(task.getScore()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ oneUserNote.setPackageId(scorePackageId);
|
|
|
|
+ oneUserNote.setSettleAmount(userTotalSettleAmount);
|
|
|
|
+ oneUserNote.setDiscount(BigDecimal.ONE);
|
|
|
|
+ oneUserNote.setUserId(userId);
|
|
|
|
+ oneUserNote.setSettleNoteStatus(Integer.valueOf(SettleStatusEnum.SETTLE_STATUS_NOTSETTLE.getVal()));
|
|
|
|
+
|
|
|
|
+ SysUser noteUser = userMap.get(Integer.parseInt(userId));
|
|
|
|
+ oneUserNote.setRealName(noteUser.getRealname());
|
|
|
|
+ oneUserNote.setIdCardNumber(noteUser.getIdCardNumber());
|
|
|
|
+ userNotes.add(oneUserNote);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加用于结算的note参数
|
|
|
|
+ for (String taskId : taskIds) {
|
|
|
|
+ WmScorePackageSettleNote note = new WmScorePackageSettleNote();
|
|
|
|
+ // note存在则直接获取
|
|
|
|
+ WmScorePackageSettleNote settleNote = taskSettleNoteMap.get(taskId);
|
|
|
|
+ if (settleNote != null) {
|
|
|
|
+ toSettleNotes.add(settleNote);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // note不存在,取task中的信息作为结算信息
|
|
|
|
+ WmTask task = taskMap.get(taskId);
|
|
|
|
+ note.setSettleAmount(BigDecimal.valueOf(task.getScore()));
|
|
|
|
+ note.setSettleNo(IdUtil.fastSimpleUUID());
|
|
|
|
+ note.setPackageId(scorePackageId);
|
|
|
|
+ note.setTaskId(taskId);
|
|
|
|
+ note.setDiscount(BigDecimal.ONE);
|
|
|
|
+ note.setUserId(task.getTaskUserId());
|
|
|
|
+ note.setSettleNoteStatus(Integer.valueOf(SettleStatusEnum.SETTLE_STATUS_NOTSETTLE.getVal()));
|
|
|
|
+ // user信息
|
|
|
|
+ SysUser noteUser = userMap.get(Integer.parseInt(task.getTaskUserId()));
|
|
|
|
+ note.setRealName(noteUser.getRealname());
|
|
|
|
+ note.setIdCardNumber(noteUser.getIdCardNumber());
|
|
|
|
+ toSettleNotes.add(note);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>(3);
|
|
|
|
+ resultMap.put("wsp", wmScorePackage);
|
|
|
|
+ resultMap.put("notes", toSettleNotes);
|
|
|
|
+ resultMap.put("userNotes", userNotes);
|
|
|
|
+
|
|
|
|
+ return R.ok(resultMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 业务提交结算信息到财务
|
|
* 业务提交结算信息到财务
|
|
*
|
|
*
|
|
@@ -289,17 +407,24 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
updateEntity.setId(input.getId());
|
|
updateEntity.setId(input.getId());
|
|
updateEntity.setSettleStatus(DingEnum.SETTLE_STATUS_WAIT.getType());
|
|
updateEntity.setSettleStatus(DingEnum.SETTLE_STATUS_WAIT.getType());
|
|
updateEntity.setScorePackageStatus("5");
|
|
updateEntity.setScorePackageStatus("5");
|
|
- updateEntity.setSettleFlag("1");
|
|
|
|
updateEntity.setDescription(input.getDescription());
|
|
updateEntity.setDescription(input.getDescription());
|
|
updateEntity.setSubType(String.valueOf(location.getGigType().getCode()));
|
|
updateEntity.setSubType(String.valueOf(location.getGigType().getCode()));
|
|
updateEntity.setLocation(input.getSubjectLocation());
|
|
updateEntity.setLocation(input.getSubjectLocation());
|
|
updateEntity.setSettlementDate(LocalDateTime.now());
|
|
updateEntity.setSettlementDate(LocalDateTime.now());
|
|
|
|
|
|
- if ("2".equals(wmScorePackage.getPackageType2())) {
|
|
|
|
|
|
+ if (PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(wmScorePackage.getPackageType2())
|
|
|
|
+ && !StrUtil.equals(PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val(), wmScorePackage.getPackageType1())) {
|
|
updateEntity.setPackageFinishStatus("1");
|
|
updateEntity.setPackageFinishStatus("1");
|
|
updateEntity.setTaskAddFlag("0");
|
|
updateEntity.setTaskAddFlag("0");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (StrUtil.equals(PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val(), wmScorePackage.getPackageType1())) {
|
|
|
|
+ // 多人承接积分包可以一直结算
|
|
|
|
+ updateEntity.setSettleFlag("0");
|
|
|
|
+ } else {
|
|
|
|
+ updateEntity.setSettleFlag("1");
|
|
|
|
+ }
|
|
|
|
+
|
|
wmScorePackageService.updateById(updateEntity);
|
|
wmScorePackageService.updateById(updateEntity);
|
|
noteService.saveOrUpdateBatch(notes);
|
|
noteService.saveOrUpdateBatch(notes);
|
|
|
|
|
|
@@ -458,6 +583,10 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
else if (SubjectTypeEnum.TYPE_ZHONG_YI_YUN.getCode().equals(subType)) {
|
|
else if (SubjectTypeEnum.TYPE_ZHONG_YI_YUN.getCode().equals(subType)) {
|
|
return this.settleByZhongYiYun(input, wmScorePackage, taxCode, operator);
|
|
return this.settleByZhongYiYun(input, wmScorePackage, taxCode, operator);
|
|
}
|
|
}
|
|
|
|
+ // 中智
|
|
|
|
+ else if (SubjectTypeEnum.TYPE_ZHONG_ZHI.getCode().equals(subType)) {
|
|
|
|
+ return this.settleByZhongZhi(input, wmScorePackage, taxCode, operator);
|
|
|
|
+ }
|
|
// 税邦云
|
|
// 税邦云
|
|
else {
|
|
else {
|
|
log.info("税邦云结算开始-获取会员所属企业的统一社会信用代码:{} ", taxCode);
|
|
log.info("税邦云结算开始-获取会员所属企业的统一社会信用代码:{} ", taxCode);
|
|
@@ -466,6 +595,201 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 中智结算操作
|
|
|
|
+ *
|
|
|
|
+ * @param input 结算数据
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @param taxCode 税号
|
|
|
|
+ * @param operator 操作员
|
|
|
|
+ * @return 结果
|
|
|
|
+ */
|
|
|
|
+ private R<?> settleByZhongZhi(WmScorePackageSettleInput input,
|
|
|
|
+ WmScorePackage wmScorePackage,
|
|
|
|
+ String taxCode,
|
|
|
|
+ HnqzUser operator) {
|
|
|
|
+
|
|
|
|
+ List<WmScorePackageSettleNote> notes = input.getNotes();
|
|
|
|
+ StringBuilder noticeInfo = new StringBuilder();
|
|
|
|
+
|
|
|
|
+ // WmScorePackageSettleNote
|
|
|
|
+ for (WmScorePackageSettleNote note : notes) {
|
|
|
|
+ note.setInvoiceType(input.getInvoiceCategory());
|
|
|
|
+ note.setCategoryName(StrUtil.isNotBlank(input.getCategoryName()) ? input.getCategoryName() : note.getCategoryName());
|
|
|
|
+ note.setSubToGigTime(LocalDateTime.now());
|
|
|
|
+ }
|
|
|
|
+ noteService.updateBatchById(notes);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (WmScorePackageSettleNote note : notes) {
|
|
|
|
+ SysUser sysUser = sysUserMapper.selectById(note.getUserId());
|
|
|
|
+
|
|
|
|
+ SysUserSub userSub = sysUserSubMapper.selectOne(Wrappers.<SysUserSub>lambdaQuery()
|
|
|
|
+ .eq(SysUserSub::getUserId, sysUser.getUserId())
|
|
|
|
+ .eq(SysUserSub::getSubjectLocation, input.getSubjectLocation())
|
|
|
|
+ .eq(SysUserSub::getDeptId, operator.getDeptId())
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (userSub == null) {
|
|
|
|
+ log.info("结算对象-" + sysUser.getRealname() + ":认证信息不存在,不能结算");
|
|
|
|
+ return R.failed("结算对象-" + sysUser.getRealname() + ":认证信息不存在,不能结算");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!Objects.equals(userSub.getCertStatus(), DingEnum.CER_STATUS_1.getType())) {
|
|
|
|
+ return R.failed(sysUser.getRealname() + "人员未认证或未绑卡,不能结算");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Boolean.TRUE.equals(redisTemplate.hasKey(CacheConstants.SETTLE_PACKAGE_KEY + note.getId()))) {
|
|
|
|
+ return R.failed("结算对象-" + sysUser.getRealname() + ":正在结算,请勿重复结算");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (DingEnum.NOTE_STATUS_SUCCESS.getType().equals(note.getSettleNoteStatus())) {
|
|
|
|
+ log.info("结算对象-" + sysUser.getRealname() + ":已结算,请勿重复结算");
|
|
|
|
+ return R.failed("结算对象-" + sysUser.getRealname() + ":已结算,请勿重复结算");
|
|
|
|
+ }
|
|
|
|
+ if (DingEnum.NOTE_STATUS_SUBMIT.getType().equals(note.getSettleNoteStatus())) {
|
|
|
|
+ log.info("结算对象-" + sysUser.getRealname() + ":已提交,请等待耐心结算结果");
|
|
|
|
+ return R.failed("结算对象-" + sysUser.getRealname() + ":已提交,请等待耐心结算结果");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (WmScorePackageSettleNote note : notes) {
|
|
|
|
+ // 加锁
|
|
|
|
+ redisTemplate.opsForValue().set(CacheConstants.SETTLE_PACKAGE_KEY + note.getId(),
|
|
|
|
+ note.getId(), CacheConstants.SETTLE_TIME, TimeUnit.DAYS);
|
|
|
|
+
|
|
|
|
+ SysUser sysUser = sysUserMapper.selectById(note.getUserId());
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ // 获取请求token
|
|
|
|
+ String url = String.format(GIG_TOKEN_URL, upmsConfig.getGigServiceUrl());
|
|
|
|
+ log.info("远端请求gig-token:{}", url);
|
|
|
|
+ ResponseEntity<String> tokenResult = new RestTemplate().getForEntity(url, String.class,
|
|
|
|
+ String.valueOf(operator.getDeptId()), "settle", String.valueOf(operator.getId()));
|
|
|
|
+ log.warn("获取结算token:{}", tokenResult.getBody());
|
|
|
|
+ if (!JSONUtil.isJson(tokenResult.getBody())) {
|
|
|
|
+ return R.failed("获取结算token失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(tokenResult.getBody());
|
|
|
|
+
|
|
|
|
+ if (jsonObject.getInt("code") != 0 || StrUtil.isBlank(jsonObject.getStr("data"))) {
|
|
|
|
+ return R.failed("获取结算token失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String token = jsonObject.getStr("data");
|
|
|
|
+
|
|
|
|
+ // 间隔100毫秒
|
|
|
|
+ Thread.sleep(100);
|
|
|
|
+
|
|
|
|
+ // 查询发票类目对应的字典
|
|
|
|
+ SysDictItem zhongzhiInvoice = sysDictItemMapper.selectOne(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .eq(SysDictItem::getType, "zhongzhi_invoice")
|
|
|
|
+ .eq(SysDictItem::getValue, String.valueOf(note.getInvoiceType())));
|
|
|
|
+
|
|
|
|
+ // 封装结算参数
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ params.put("token", token);
|
|
|
|
+ params.put("tenantId", operator.getDeptId());
|
|
|
|
+ params.put("operatorId", operator.getId());
|
|
|
|
+ params.put("requestId", RandomStringUtils.randomAlphabetic(12));
|
|
|
|
+ params.put("taskName", wmScorePackage.getScorePackageName() + "_" + System.currentTimeMillis());
|
|
|
|
+ params.put("amount", String.valueOf(note.getSettleAmount().doubleValue()));
|
|
|
|
+ params.put("taskStartTime", wmScorePackage.getCreateTime().toLocalDate());
|
|
|
|
+ params.put("taskEndTime", wmScorePackage.getUpdateTime().toLocalDate());
|
|
|
|
+ params.put("taskLocation", "要易云");
|
|
|
|
+ params.put("username", sysUser.getBankPhone());
|
|
|
|
+ params.put("idCard", sysUser.getIdCardNumber());
|
|
|
|
+ params.put("idCardType","ID_CARD");
|
|
|
|
+ params.put("realName", sysUser.getRealname());
|
|
|
|
+ params.put("bankCard", sysUser.getBankCardNumber());
|
|
|
|
+ params.put("bankPhone", sysUser.getBankPhone());
|
|
|
|
+ // 行业类别id
|
|
|
|
+ params.put("tagId", zhongzhiInvoice.getDescription());
|
|
|
|
+ // 税收项目编号
|
|
|
|
+ params.put("taskInvoiceContent", zhongzhiInvoice.getRemarks());
|
|
|
|
+ params.put("endType", "CSO");
|
|
|
|
+ params.put("enterpriseCode", taxCode);
|
|
|
|
+ params.put("subjectType", "ZHONG_ZHI");
|
|
|
|
+ params.put("channel", "DEFAULT");
|
|
|
|
+ params.put("subjectLocation", input.getSubjectLocation().getType());
|
|
|
|
+ params.put("taxMode", "SPECIAL");
|
|
|
|
+ params.put("transactionModel", "CHANNEL");
|
|
|
|
+ params.put("taskDescription", "根据要求,执行、并完成学术推广活动,并以在线平台工具采集、记录活动内容");
|
|
|
|
+
|
|
|
|
+ // 发起结算
|
|
|
|
+ String url1 = String.format(GIG_SETTLE_URL, upmsConfig.getGigServiceUrl());
|
|
|
|
+ log.info("远端请求gig-settle:{}", url);
|
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
+ log.info("中智结算req: {}", params);
|
|
|
|
+ HttpEntity<String> result = new RestTemplate().exchange(url1, HttpMethod.POST, new HttpEntity<>(params, headers), String.class);
|
|
|
|
+ log.info("中智结算resp:{}", result.getBody());
|
|
|
|
+ if (!JSONUtil.isJson(result.getBody())) {
|
|
|
|
+ return R.failed("结算失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject settleObj = JSONUtil.parseObj(result.getBody());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (Objects.equals(settleObj.getInt("code"), CommonConstants.SUCCESS)) {
|
|
|
|
+ JSONObject dataJsonObj = settleObj.getJSONObject("data");
|
|
|
|
+ log.info("中智结算提交成功: {}", settleObj.getStr("data"));
|
|
|
|
+ note.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ //streamId 获取不到
|
|
|
|
+ if (dataJsonObj != null) {
|
|
|
|
+ String requestId = dataJsonObj.getStr("requestId");
|
|
|
|
+ if (StrUtil.isNotBlank(requestId)) {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_SUBMIT.getType());
|
|
|
|
+ // 新增字段streamId
|
|
|
|
+ note.setStreamId(requestId);
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
|
|
+ } else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":" + dataJsonObj.getStr("message"));
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
|
|
+ log.warn("中智结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.warn("中智结算失败: {}", note.getSettleNo());
|
|
|
|
+ note.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":结算提交失败-").append(settleObj.getStr("msg")).append(";");
|
|
|
|
+
|
|
|
|
+ log.info("认证状态异常,结算解锁settleNoteId:{}", note.getId());
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("", e);
|
|
|
|
+ log.warn("中智结算提交失败: {}", note.getSettleNo());
|
|
|
|
+ note.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":结算提交失败;");
|
|
|
|
+
|
|
|
|
+ log.info("认证状态异常,结算解锁settleNoteId:{}", note.getId());
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ noteService.updateBatchById(notes);
|
|
|
|
+
|
|
|
|
+ // 更新结算结果
|
|
|
|
+ SettleNoteStatusOutput output = noteService.selectSettleNoteStatus(input.getId());
|
|
|
|
+ WmScorePackage updateEntity = new WmScorePackage();
|
|
|
|
+ updateEntity.setId(input.getId());
|
|
|
|
+ updateEntity.setSettleStatus(output.toSettleStatus());
|
|
|
|
+ wmScorePackageService.updateById(updateEntity);
|
|
|
|
+
|
|
|
|
+ return R.ok(null, noticeInfo.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 众蚁云结算操作
|
|
* 众蚁云结算操作
|
|
*
|
|
*
|
|
@@ -611,11 +935,15 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
note.setStreamId(requestId);
|
|
note.setStreamId(requestId);
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
} else {
|
|
} else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
noticeInfo.append(sysUser.getRealname()).append(":" + dataJsonObj.getStr("message"));
|
|
noticeInfo.append(sysUser.getRealname()).append(":" + dataJsonObj.getStr("message"));
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
log.warn("众蚁云结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
log.warn("众蚁云结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.warn("众蚁云结算失败: {}", note.getSettleNo());
|
|
log.warn("众蚁云结算失败: {}", note.getSettleNo());
|
|
@@ -806,11 +1134,14 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
note.setStreamId(requestId);
|
|
note.setStreamId(requestId);
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
} else {
|
|
} else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
noticeInfo.append(sysUser.getRealname()).append(":" + dataJsonObj.getStr("message"));
|
|
noticeInfo.append(sysUser.getRealname()).append(":" + dataJsonObj.getStr("message"));
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.warn("汇企云结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
log.warn("汇企云结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.warn("汇企云结算失败: {}", note.getSettleNo());
|
|
log.warn("汇企云结算失败: {}", note.getSettleNo());
|
|
@@ -994,10 +1325,18 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
}
|
|
}
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
- note.setSettleNoteStatus(DingEnum.NOTE_STATUS_SUBMIT.getType());
|
|
|
|
- // 新增字段streamId
|
|
|
|
- note.setStreamId(dataJsonObj.getStr("requestId"));
|
|
|
|
- noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
|
|
|
|
+
|
|
|
|
+ String requestId = dataJsonObj.getStr("requestId");
|
|
|
|
+ if (StrUtil.isNotBlank(requestId)) {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_SUBMIT.getType());
|
|
|
|
+ // 新增字段streamId
|
|
|
|
+ note.setStreamId(requestId);
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
|
|
+ } else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
log.warn("浪潮结算失败: {}", note.getSettleNo());
|
|
log.warn("浪潮结算失败: {}", note.getSettleNo());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
@@ -1174,11 +1513,14 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
note.setStreamId(requestId);
|
|
note.setStreamId(requestId);
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
} else {
|
|
} else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.warn("政企之星结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
log.warn("政企之星结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.warn("政企之星结算失败: {}", note.getSettleNo());
|
|
log.warn("政企之星结算失败: {}", note.getSettleNo());
|
|
@@ -1362,14 +1704,23 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
if (dataJsonObj == null) {
|
|
if (dataJsonObj == null) {
|
|
log.warn("自由职家结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
log.warn("自由职家结算提交成功 data 获取不到: {}", note.getSettleNo());
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
}
|
|
}
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
note.setSettleNoteStatus(DingEnum.NOTE_STATUS_SUBMIT.getType());
|
|
note.setSettleNoteStatus(DingEnum.NOTE_STATUS_SUBMIT.getType());
|
|
- // 新增字段streamId
|
|
|
|
- note.setStreamId(dataJsonObj.getStr("requestId"));
|
|
|
|
- // 第三方任务id
|
|
|
|
- note.setThirdTaskId(dataJsonObj.getStr("taskId"));
|
|
|
|
- noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
|
|
|
|
+
|
|
|
|
+ String requestId = dataJsonObj.getStr("requestId");
|
|
|
|
+ if (StrUtil.isNotBlank(requestId)) {
|
|
|
|
+ // 新增字段streamId
|
|
|
|
+ note.setStreamId(requestId);
|
|
|
|
+ // 第三方任务id
|
|
|
|
+ note.setThirdTaskId(dataJsonObj.getStr("taskId"));
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
|
|
+ } else {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
log.warn("自由职家结算提交失败: {}", note.getSettleNo());
|
|
log.warn("自由职家结算提交失败: {}", note.getSettleNo());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
@@ -1510,14 +1861,17 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
|
|
log.info("税邦云结算提交成功: {}", note.getSettleNo());
|
|
log.info("税邦云结算提交成功: {}", note.getSettleNo());
|
|
//streamId 获取不到
|
|
//streamId 获取不到
|
|
if (StringUtils.isEmpty(response.getMessage())) {
|
|
if (StringUtils.isEmpty(response.getMessage())) {
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_FAIL.getType());
|
|
log.info("税邦云结算提交成功 streamId 获取不到: {}", note.getSettleNo());
|
|
log.info("税邦云结算提交成功 streamId 获取不到: {}", note.getSettleNo());
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
noticeInfo.append(sysUser.getRealname()).append(":提交结算成功,业务流水号获取不到,请联系管理员;");
|
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + note.getId());
|
|
|
|
+ } else {
|
|
|
|
+ // 新增字段streamId
|
|
|
|
+ note.setStreamId(response.getMessage());
|
|
|
|
+ note.setSettleNoteStatus(DingEnum.NOTE_STATUS_SUBMIT.getType());
|
|
|
|
+ noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
}
|
|
}
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
- note.setSettleNoteStatus(DingEnum.NOTE_STATUS_SUBMIT.getType());
|
|
|
|
- // 新增字段streamId
|
|
|
|
- note.setStreamId(response.getMessage());
|
|
|
|
- noticeInfo.append(sysUser.getRealname()).append(":提交结算成功;");
|
|
|
|
} else {
|
|
} else {
|
|
log.info("税邦云结算提交失败: {}", note.getSettleNo());
|
|
log.info("税邦云结算提交失败: {}", note.getSettleNo());
|
|
note.setUpdateTime(LocalDateTime.now());
|
|
note.setUpdateTime(LocalDateTime.now());
|