|
|
@@ -24,28 +24,21 @@ import com.gubersail.shop.app.api.claim.entity.ShopAppClaim;
|
|
|
import com.gubersail.shop.app.api.claim.entity.ShopAppClaimAttachment;
|
|
|
import com.gubersail.shop.app.api.claim.entity.ShopAppClaimAudit;
|
|
|
import com.gubersail.shop.app.api.claim.vo.ShopAppClaimVO;
|
|
|
-import com.gubersail.shop.app.api.insurance.entity.ShopAppTireInsuranceRegister;
|
|
|
-import com.gubersail.shop.app.api.zcrm.customer.entity.ShopAppViewCustomerSel;
|
|
|
import com.gubersail.shop.app.claim.mapper.ShopAppClaimMapper;
|
|
|
import com.gubersail.shop.app.claim.service.IShopAppClaimAttachmentService;
|
|
|
import com.gubersail.shop.app.claim.service.IShopAppClaimAuditService;
|
|
|
import com.gubersail.shop.app.claim.service.IShopAppClaimService;
|
|
|
import com.gubersail.shop.app.insurance.mapper.ShopAppTireInsuranceRegisterMapper;
|
|
|
-import com.gubersail.shop.app.util.BillCodeUtil;
|
|
|
import com.gubersail.shop.app.wrapper.ShopAppClaimWrapper;
|
|
|
import com.gubersail.shop.app.zcrm.customer.service.IShopAppCustomerSelService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.springblade.common.enums.NumberEnum;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
-import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -69,101 +62,16 @@ public class ShopAppClaimServiceImpl extends ServiceImpl<ShopAppClaimMapper, Sho
|
|
|
|
|
|
private final IUserClient userClient;
|
|
|
|
|
|
- private final IShopAppCustomerSelService viewCustomerSelService;
|
|
|
-
|
|
|
- private final ShopAppTireInsuranceRegisterMapper shopAppTireInsuranceRegisterMapper;
|
|
|
-
|
|
|
- @Override
|
|
|
- public IPage<ShopAppClaimVO> selectBladeClaimPage(IPage<ShopAppClaimVO> page, ShopAppClaimVO bladeClaim) {
|
|
|
- return page.setRecords(baseMapper.selectBladeClaimPage(page, bladeClaim));
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R submit(ShopAppClaimVO bladeClaim) {
|
|
|
ShopAppClaim claim = new ShopAppClaim();
|
|
|
BeanUtil.copyProperties(bladeClaim, claim);
|
|
|
- //判断是否是第一次保存
|
|
|
- if (claim.getId() == null) {
|
|
|
- // 获取 流水号
|
|
|
- String billNo = BillCodeUtil.getBillCodeByType(SecureUtil.getTenantId(), "LP");
|
|
|
- if (!StringUtils.hasText(billNo) || billNo.length() < NumberEnum.FIFTEEN.number) {
|
|
|
- return R.fail(HttpStatus.INTERNAL_SERVER_ERROR.value(), "生成系统编号失败");
|
|
|
- }
|
|
|
- claim.setClaimNo(billNo);
|
|
|
- claim.setCreateTime(new Date());
|
|
|
- claim.setCreateUser(AuthUtil.getUserId());
|
|
|
- claim.setClaimSourceType(1);
|
|
|
- //查询当前登录人信息
|
|
|
- R<User> userR = userClient.userInfoById(AuthUtil.getUserId());
|
|
|
- if (!userR.isSuccess() || ObjectUtils.isNull(userR.getData())) {
|
|
|
- throw new RuntimeException("未查到当前登录人用户信息");
|
|
|
- }
|
|
|
- //判断当前登录人角色是否是管理员
|
|
|
- if (AuthUtil.getUserRole().contains("admin")) {
|
|
|
- claim.setSourceId(AuthUtil.getUserId());
|
|
|
- claim.setSourceCode("");
|
|
|
- claim.setSourceName(userR.getData().getRealName());
|
|
|
- claim.setCreateDept(Long.valueOf(userR.getData().getDeptId()));
|
|
|
- } else {
|
|
|
- //不是管理员角色需要按照用户信息中客户id查询客户信息
|
|
|
- ShopAppViewCustomerSel customerSel = viewCustomerSelService.getOne(new LambdaQueryWrapper<ShopAppViewCustomerSel>()
|
|
|
- .eq(ShopAppViewCustomerSel::getIsDeleted, 0)
|
|
|
- .eq(ShopAppViewCustomerSel::getCustomerId, userR.getData().getCustomerId())
|
|
|
- .orderByDesc(ShopAppViewCustomerSel::getCreateTime).last("LIMIT 1"));
|
|
|
- if (customerSel == null) {
|
|
|
- throw new RuntimeException("未查到客户档案信息");
|
|
|
- }
|
|
|
- claim.setSourceId(customerSel.getCustomerId());
|
|
|
- claim.setSourceCode(customerSel.getCustomerCode());
|
|
|
- claim.setSourceName(customerSel.getCustomerName());
|
|
|
- }
|
|
|
- } else {
|
|
|
- ShopAppClaim dataSourceClaim = baseMapper.selectOne(new LambdaQueryWrapper<ShopAppClaim>().select(ShopAppClaim::getId, ShopAppClaim::getVersion)
|
|
|
- .eq(ShopAppClaim::getId, claim.getId()));
|
|
|
- if (!Objects.equals(dataSourceClaim.getVersion(), claim.getVersion())) {
|
|
|
- return R.fail(601, "数据已被其他用户更新,请等待刷新后重试");
|
|
|
- }
|
|
|
- // 每更新一次往上累加一次版本
|
|
|
- // 旧数据处理
|
|
|
- int version = dataSourceClaim.getVersion() == null ? 1 : dataSourceClaim.getVersion();
|
|
|
- claim.setVersion(version + 1);
|
|
|
- claim.setUpdateUser(AuthUtil.getUserId());
|
|
|
- claim.setUpdateTime(new Date());
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(claim.getTyreNo())) {
|
|
|
- ShopAppTireInsuranceRegister tireInsuranceRegister = shopAppTireInsuranceRegisterMapper.selectOne(new LambdaQueryWrapper<ShopAppTireInsuranceRegister>()
|
|
|
- .eq(ShopAppTireInsuranceRegister::getInsuranceNo, claim.getTyreNo())
|
|
|
- .eq(ShopAppTireInsuranceRegister::getIsDeleted, 0)
|
|
|
- .last("LIMIT 1"));
|
|
|
- if (tireInsuranceRegister == null) {
|
|
|
- throw new RuntimeException("未查到对应轮胎宝单据信息");
|
|
|
- }
|
|
|
- if (tireInsuranceRegister.getTireQuantity() < claim.getTireQuantity()) {
|
|
|
- throw new RuntimeException("理赔轮胎数量大于轮胎保轮胎数量");
|
|
|
- }
|
|
|
- }
|
|
|
+ claim.setVersion(claim.getVersion() == null ? 1 : claim.getVersion() + 1);
|
|
|
+ claim.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ claim.setUpdateTime(new Date());
|
|
|
//保存数据
|
|
|
- this.saveOrUpdate(claim);
|
|
|
- //判断是否存在理赔审核结果及客户反馈数据
|
|
|
- if (ObjectUtils.isNotNull(bladeClaim.getBladeClaimAuditList()) && !bladeClaim.getBladeClaimAuditList().isEmpty()) {
|
|
|
- for (ShopAppClaimAudit item : bladeClaim.getBladeClaimAuditList()) {
|
|
|
- //添加理赔主表关联数据
|
|
|
- item.setClaimId(claim.getId());
|
|
|
- item.setClaimNo(claim.getClaimNo());
|
|
|
- //判断是否是第一次保存
|
|
|
- if (item.getId() == null) {
|
|
|
- item.setCreateTime(new Date());
|
|
|
- item.setCreateUser(AuthUtil.getUserId());
|
|
|
- item.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
- } else {
|
|
|
- item.setUpdateUser(AuthUtil.getUserId());
|
|
|
- item.setUpdateTime(new Date());
|
|
|
- }
|
|
|
- }
|
|
|
- //批量保存理赔审核结果及客户反馈数据
|
|
|
- bladeClaimAuditService.saveOrUpdateBatch(bladeClaim.getBladeClaimAuditList());
|
|
|
- }
|
|
|
+ this.updateById(claim);
|
|
|
//判断是否存在理赔附件数据
|
|
|
if (ObjectUtils.isNotNull(bladeClaim.getClaimAttachmentList()) && !bladeClaim.getClaimAttachmentList().isEmpty()) {
|
|
|
for (ShopAppClaimAttachment item : bladeClaim.getClaimAttachmentList()) {
|
|
|
@@ -204,74 +112,7 @@ public class ShopAppClaimServiceImpl extends ServiceImpl<ShopAppClaimMapper, Sho
|
|
|
.eq(ShopAppClaimAttachment::getClaimId, claim.getId())
|
|
|
.eq(ShopAppClaimAttachment::getIsDeleted, 0));
|
|
|
bladeClaimVO.setClaimAttachmentList(claimAttachmentList.isEmpty() ? new ArrayList<>() : claimAttachmentList);
|
|
|
- //查询理赔审核结果及客户反馈数据
|
|
|
- List<ShopAppClaimAudit> claimAuditList = bladeClaimAuditService.list(new LambdaQueryWrapper<ShopAppClaimAudit>()
|
|
|
- .eq(ShopAppClaimAudit::getClaimId, claim.getId())
|
|
|
- .eq(ShopAppClaimAudit::getIsDeleted, 0));
|
|
|
- bladeClaimVO.setBladeClaimAuditList(claimAuditList.isEmpty() ? new ArrayList<>() : claimAuditList);
|
|
|
return bladeClaimVO;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public R submitApproval(Long id) {
|
|
|
- //通过id查询理赔数据
|
|
|
- ShopAppClaim claim = this.getById(id);
|
|
|
- //判断审核状态是否是录入状态
|
|
|
- if (claim.getAuditStatus() > 0) {
|
|
|
- throw new RuntimeException("已提交审批,请勿重复审批");
|
|
|
- }
|
|
|
- claim.setAuditStatus(1);
|
|
|
- claim.setUpdateTime(new Date());
|
|
|
- claim.setUpdateUser(AuthUtil.getUserId());
|
|
|
- int version = claim.getVersion() == null ? 1 : claim.getVersion();
|
|
|
- claim.setVersion(version + 1);
|
|
|
- this.updateById(claim);
|
|
|
- return R.success("操作成功");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public R revokeApproval(Long id) {
|
|
|
- //通过id查询理赔数据
|
|
|
- ShopAppClaim claim = this.getById(id);
|
|
|
- //判断审核状态是否是审核中
|
|
|
- if (claim.getAuditStatus() != 1) {
|
|
|
- throw new RuntimeException("未提交审批,撤销失败");
|
|
|
- }
|
|
|
- claim.setAuditStatus(0);
|
|
|
- claim.setUpdateTime(new Date());
|
|
|
- claim.setUpdateUser(AuthUtil.getUserId());
|
|
|
- int version = claim.getVersion() == null ? 1 : claim.getVersion();
|
|
|
- claim.setVersion(version + 1);
|
|
|
- this.updateById(claim);
|
|
|
- return R.success("操作成功");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public R deleteByIds(List<Long> longList) {
|
|
|
- //删除理赔主表
|
|
|
- this.removeByIds(longList);
|
|
|
- //查询理赔附件数据明细
|
|
|
- List<ShopAppClaimAttachment> claimAttachmentList = bladeClaimAttachmentService.list(new LambdaQueryWrapper<ShopAppClaimAttachment>()
|
|
|
- .in(ShopAppClaimAttachment::getClaimId, longList)
|
|
|
- .eq(ShopAppClaimAttachment::getIsDeleted, 0));
|
|
|
- //判断是否存在理赔附件数据明细 true 删除明细数据
|
|
|
- if (!claimAttachmentList.isEmpty()) {
|
|
|
- bladeClaimAttachmentService.removeByIds(claimAttachmentList.stream().map(ShopAppClaimAttachment::getId)
|
|
|
- .collect(Collectors.toList()));
|
|
|
- }
|
|
|
- //查询理赔审核结果及客户反馈数据明细
|
|
|
- List<ShopAppClaimAudit> claimAuditList = bladeClaimAuditService.list(new LambdaQueryWrapper<ShopAppClaimAudit>()
|
|
|
- .in(ShopAppClaimAudit::getClaimId, longList)
|
|
|
- .eq(ShopAppClaimAudit::getIsDeleted, 0));
|
|
|
- //判断是否存在理赔审核结果及客户反馈数据明细 true 删除明细数据
|
|
|
- if (!claimAttachmentList.isEmpty()) {
|
|
|
- bladeClaimAuditService.removeByIds(claimAuditList.stream().map(ShopAppClaimAudit::getId)
|
|
|
- .collect(Collectors.toList()));
|
|
|
- }
|
|
|
- return R.success("操作成功");
|
|
|
- }
|
|
|
-
|
|
|
}
|