|
|
@@ -113,6 +113,7 @@ public class ShopAppTireInsuranceRegisterServiceImpl extends ServiceImpl<ShopApp
|
|
|
tireInsuranceRegister.setInsuranceNo(billNo);
|
|
|
tireInsuranceRegister.setCreateTime(new Date());
|
|
|
tireInsuranceRegister.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tireInsuranceRegister.setStatus(0);
|
|
|
//查询当前登录人信息
|
|
|
R<User> userR = userClient.userInfoById(AuthUtil.getUserId());
|
|
|
if (!userR.isSuccess() || ObjectUtils.isNull(userR.getData())) {
|
|
|
@@ -142,9 +143,45 @@ public class ShopAppTireInsuranceRegisterServiceImpl extends ServiceImpl<ShopApp
|
|
|
BeanUtil.copyProperties(appTireInsuranceRegister, tireInsuranceRegister);
|
|
|
|
|
|
// 2. 设置更新信息
|
|
|
- tireInsuranceRegister.setUpdateUser(AuthUtil.getUserId()); // 设置更新人ID
|
|
|
- tireInsuranceRegister.setUpdateTime(new Date()); // 设置更新时间
|
|
|
- tireInsuranceRegister.setStatus(2); // 设置状态为1(已提交)
|
|
|
+ // 设置更新人ID
|
|
|
+ tireInsuranceRegister.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ // 设置更新时间
|
|
|
+ tireInsuranceRegister.setUpdateTime(new Date());
|
|
|
+ // 设置状态为1(已提交)
|
|
|
+ tireInsuranceRegister.setStatus(1);
|
|
|
+ // 3. 更新轮胎保险注册信息
|
|
|
+ this.updateById(tireInsuranceRegister);
|
|
|
+ // 4. 返回处理结果
|
|
|
+ return R.data(appTireInsuranceRegister);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R revokeTireInsurance(Long id) {
|
|
|
+ ShopAppTireInsuranceRecord record = appTireInsuranceRecordService.getById(id);
|
|
|
+ if (record == null){
|
|
|
+ throw new RuntimeException("未查到理赔记录信息");
|
|
|
+ }
|
|
|
+ appTireInsuranceRecordService.removeById(id);
|
|
|
+ ShopAppClaim claim = bladeClaimService.getById(record.getClaimId());
|
|
|
+ if(claim != null){
|
|
|
+ if (2 == claim.getStatus()){
|
|
|
+ throw new RuntimeException("理赔已通过,删除失败");
|
|
|
+ }
|
|
|
+ bladeClaimService.removeById(claim.getId());
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("claim_id", claim.getId());
|
|
|
+ bladeClaimAttachmentService.removeByMap(map);
|
|
|
+ }
|
|
|
+ return R.data("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R generateShopAppClaim(ShopAppTireInsuranceRegisterVO appTireInsuranceRegister) {
|
|
|
+ // 1. 创建轮胎保险注册实体并复制属性
|
|
|
+ ShopAppTireInsuranceRegister tireInsuranceRegister = new ShopAppTireInsuranceRegister();
|
|
|
+ BeanUtil.copyProperties(appTireInsuranceRegister, tireInsuranceRegister);
|
|
|
+
|
|
|
Calendar cal1 = Calendar.getInstance();
|
|
|
cal1.setTime(new Date());
|
|
|
cal1.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
@@ -161,19 +198,14 @@ public class ShopAppTireInsuranceRegisterServiceImpl extends ServiceImpl<ShopApp
|
|
|
if (cal1.before(cal2)) {
|
|
|
System.out.println("轮胎保已失效,操作失败!");
|
|
|
}
|
|
|
- // 3. 更新轮胎保险注册信息
|
|
|
- this.updateById(tireInsuranceRegister);
|
|
|
-
|
|
|
// 4. 创建理赔申请实体
|
|
|
ShopAppClaim claim = new ShopAppClaim();
|
|
|
-
|
|
|
// 5. 生成理赔单号
|
|
|
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); // 设置理赔单号
|
|
|
-
|
|
|
// 6. 设置理赔基本信息
|
|
|
claim.setCreateTime(new Date()); // 创建时间
|
|
|
claim.setCreateUser(AuthUtil.getUserId()); // 创建人ID
|
|
|
@@ -183,7 +215,7 @@ public class ShopAppTireInsuranceRegisterServiceImpl extends ServiceImpl<ShopApp
|
|
|
claim.setTireQuantity(tireInsuranceRegister.getTireQuantity()); // 轮胎数量
|
|
|
claim.setTyreNo(tireInsuranceRegister.getInsuranceNo()); // 胎号/轮胎宝编号
|
|
|
claim.setTyreSpecs(tireInsuranceRegister.getTyreSpecs()); // 规格型号
|
|
|
- claim.setAuditStatus(1); // 审核状态
|
|
|
+ claim.setAuditStatus(0); // 审核状态
|
|
|
claim.setSubmitTime(new Date()); // 提交时间
|
|
|
claim.setClaimReason("");
|
|
|
// 7. 设置理赔来源信息(区分管理员和普通用户)
|
|
|
@@ -221,41 +253,6 @@ public class ShopAppTireInsuranceRegisterServiceImpl extends ServiceImpl<ShopApp
|
|
|
|
|
|
// 8. 保存理赔申请信息
|
|
|
bladeClaimService.save(claim);
|
|
|
-
|
|
|
- // 9. 处理理赔附件信息
|
|
|
- List<ShopAppClaimAttachment> claimAttachmentList = new ArrayList<>();
|
|
|
-
|
|
|
- // 9.1 整车照片附件
|
|
|
- if (ObjectUtils.isNotNull(tireInsuranceRegister.getOverallVehicleUrl())) {
|
|
|
- ShopAppClaimAttachment shopAppClaimAttachment =
|
|
|
- saveClaimAttachment(tireInsuranceRegister.getOverallVehicleUrl(), claim.getId(), 1);
|
|
|
- claimAttachmentList.add(shopAppClaimAttachment);
|
|
|
- }
|
|
|
-
|
|
|
- // 9.2 轮胎点照片附件
|
|
|
- if (ObjectUtils.isNotNull(tireInsuranceRegister.getTireDotUrl())) {
|
|
|
- ShopAppClaimAttachment shopAppClaimAttachment =
|
|
|
- saveClaimAttachment(tireInsuranceRegister.getTireDotUrl(), claim.getId(), 2);
|
|
|
- claimAttachmentList.add(shopAppClaimAttachment);
|
|
|
- }
|
|
|
-
|
|
|
- // 9.3 轮胎花纹照片附件
|
|
|
- if (ObjectUtils.isNotNull(tireInsuranceRegister.getTirePatternUrl())) {
|
|
|
- ShopAppClaimAttachment shopAppClaimAttachment =
|
|
|
- saveClaimAttachment(tireInsuranceRegister.getTirePatternUrl(), claim.getId(), 3);
|
|
|
- claimAttachmentList.add(shopAppClaimAttachment);
|
|
|
- }
|
|
|
-
|
|
|
- // 9.4 行驶证照片附件
|
|
|
- if (ObjectUtils.isNotNull(tireInsuranceRegister.getVehicleLicenseUrl())) {
|
|
|
- ShopAppClaimAttachment shopAppClaimAttachment =
|
|
|
- saveClaimAttachment(tireInsuranceRegister.getVehicleLicenseUrl(), claim.getId(), 5);
|
|
|
- claimAttachmentList.add(shopAppClaimAttachment);
|
|
|
- }
|
|
|
-
|
|
|
- // 10. 批量保存理赔附件
|
|
|
- bladeClaimAttachmentService.saveBatch(claimAttachmentList);
|
|
|
-
|
|
|
ShopAppTireInsuranceRecord tireInsuranceRecord = new ShopAppTireInsuranceRecord();
|
|
|
tireInsuranceRecord.setInsuranceNo(tireInsuranceRegister.getInsuranceNo());
|
|
|
tireInsuranceRecord.setInsuranceId(tireInsuranceRegister.getId());
|
|
|
@@ -267,40 +264,11 @@ public class ShopAppTireInsuranceRegisterServiceImpl extends ServiceImpl<ShopApp
|
|
|
tireInsuranceRecord.setClaimReason(claim.getClaimReason());
|
|
|
tireInsuranceRecord.setClaimDate(new Date());
|
|
|
appTireInsuranceRecordService.save(tireInsuranceRecord);
|
|
|
+ appTireInsuranceRegister.setClaimId(tireInsuranceRecord.getClaimId());
|
|
|
// 11. 返回处理结果
|
|
|
return R.data(appTireInsuranceRegister);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public R revokeTireInsurance(Long id) {
|
|
|
- ShopAppTireInsuranceRegister tireInsuranceRegister = baseMapper.selectById(id);
|
|
|
-
|
|
|
- // 2. 设置更新信息
|
|
|
- tireInsuranceRegister.setUpdateUser(AuthUtil.getUserId()); // 设置更新人ID
|
|
|
- tireInsuranceRegister.setUpdateTime(new Date()); // 设置更新时间
|
|
|
- if (2 != tireInsuranceRegister.getStatus()) {
|
|
|
- throw new RuntimeException("工厂已受理/审核通过,撤销失败!");
|
|
|
- }
|
|
|
- tireInsuranceRegister.setStatus(1); // 设置状态为1(已提交)
|
|
|
-
|
|
|
- // 3. 更新轮胎保险注册信息
|
|
|
- this.updateById(tireInsuranceRegister);
|
|
|
-
|
|
|
- ShopAppClaim claim = bladeClaimService.getOne(new LambdaQueryWrapper<ShopAppClaim>()
|
|
|
- .eq(ShopAppClaim::getTyreNo, tireInsuranceRegister.getInsuranceNo())
|
|
|
- .eq(ShopAppClaim::getIsDeleted, 0)
|
|
|
- .eq(ShopAppClaim::getAuditStatus, 1)
|
|
|
- .last("LIMIT 1"));
|
|
|
- if(claim != null){
|
|
|
- bladeClaimService.removeById(claim.getId());
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("claim_id", claim.getId());
|
|
|
- bladeClaimAttachmentService.removeByMap(map);
|
|
|
- }
|
|
|
- return R.data(tireInsuranceRegister);
|
|
|
- }
|
|
|
-
|
|
|
private ShopAppClaimAttachment saveClaimAttachment(String url, Long claimId, int type) {
|
|
|
ShopAppClaimAttachment shopAppClaimAttachment = new ShopAppClaimAttachment();
|
|
|
shopAppClaimAttachment.setClaimId(claimId);
|