|
@@ -4,27 +4,27 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.winhc.common.base.BeanResponse;
|
|
|
import com.winhc.common.enums.CodeMsg;
|
|
|
import com.winhc.common.exception.CommonException;
|
|
|
import com.winhc.repal.cloud.WinCoinService;
|
|
|
import com.winhc.repal.cloud.dto.WinCoinOrderFormDTO;
|
|
|
import com.winhc.repal.cloud.vo.WinCoinOrderFormVO;
|
|
|
-import com.winhc.repal.entity.RepalBill;
|
|
|
-import com.winhc.repal.entity.RepalCustomer;
|
|
|
-import com.winhc.repal.entity.RepalDynamic;
|
|
|
-import com.winhc.repal.entity.RepalGroup;
|
|
|
+import com.winhc.repal.entity.*;
|
|
|
import com.winhc.repal.enums.*;
|
|
|
import com.winhc.repal.model.bo.UserContextBO;
|
|
|
import com.winhc.repal.model.dto.*;
|
|
|
import com.winhc.repal.model.vo.RepalLinkVO;
|
|
|
import com.winhc.repal.model.vo.RepalSmsTemplateVO;
|
|
|
import com.winhc.repal.repository.RepalDynamicMapper;
|
|
|
+import com.winhc.repal.repository.RepalVipMapper;
|
|
|
import com.winhc.repal.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.winhc.repal.util.UserContextUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
@@ -57,6 +57,12 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
@Autowired
|
|
|
private RepalCustomerService repalCustomerService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RepalVipService repalVipService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RepalVipMapper repalVipMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean addDynamic(DynamicContentDTO dto) {
|
|
|
UserContextBO userContextBO = UserContextUtil.getUser();
|
|
@@ -97,6 +103,7 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Boolean urgeBySms(RepalSmsDTO dto) {
|
|
|
//校验权限
|
|
|
UserContextBO userContextBO = UserContextUtil.getUser();
|
|
@@ -104,7 +111,6 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
if(!allFlag){
|
|
|
throw new CommonException(CodeMsg.FORBIDDEN,"暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
}
|
|
|
- //todo 扣减vip次数
|
|
|
if(CollUtil.isEmpty(dto.getLinks())){
|
|
|
throw new CommonException(CodeMsg.FAILED,"请至少选择一个联系人");
|
|
|
}
|
|
@@ -116,7 +122,15 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
if(ObjectUtil.isNull(repalBill) || CollUtil.isEmpty(templates)){
|
|
|
throw new CommonException(CodeMsg.FAILED,"发送失败");
|
|
|
}
|
|
|
-
|
|
|
+ //扣减vip次数
|
|
|
+ RepalVip repalVip = repalVipService.getOne(Wrappers.lambdaQuery(RepalVip.class).eq(RepalVip::getRepalGroupId,repalBill.getRepalGroupId()),false);
|
|
|
+ if(ObjectUtil.isNull(repalVip) || RepalVipSignEnum.无特权.getCode().equals(repalVip.getRepalVipSign())){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"请先开通特权");
|
|
|
+ }
|
|
|
+ int count = repalVipMapper.updateSomeCount(repalVip.getId(),RepalDynamicTypeEnum.短信.getCode());
|
|
|
+ if(count < 1){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"可用短信次数不足");
|
|
|
+ }
|
|
|
for(RepalSmsTemplateVO template:templates){
|
|
|
if(template.getSmsCode().equals(dto.getSmsCode())){
|
|
|
Map<String,Object> paraMap = new HashMap<>();
|
|
@@ -157,6 +171,7 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Boolean urgeByLawyerLetter(RepalLetterDTO dto) {
|
|
|
//校验权限
|
|
|
UserContextBO userContextBO = UserContextUtil.getUser();
|
|
@@ -164,11 +179,19 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
if(!allFlag){
|
|
|
throw new CommonException(CodeMsg.FORBIDDEN,"暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
}
|
|
|
- //todo 扣减vip次数
|
|
|
RepalBill repalBill = repalBillService.getById(dto.getRepalBillId());
|
|
|
if(ObjectUtil.isNull(repalBill)){
|
|
|
throw new CommonException(CodeMsg.FAILED,"发送失败,账款不存在");
|
|
|
}
|
|
|
+ //扣减vip次数
|
|
|
+ RepalVip repalVip = repalVipService.getOne(Wrappers.lambdaQuery(RepalVip.class).eq(RepalVip::getRepalGroupId,repalBill.getRepalGroupId()),false);
|
|
|
+ if(ObjectUtil.isNull(repalVip) || RepalVipSignEnum.无特权.getCode().equals(repalVip.getRepalVipSign())){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"请先开通特权");
|
|
|
+ }
|
|
|
+ int count = repalVipMapper.updateSomeCount(repalVip.getId(),RepalDynamicTypeEnum.律师函.getCode());
|
|
|
+ if(count < 1){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"可用催款函次数不足");
|
|
|
+ }
|
|
|
Map<String,Object> paraMap = new HashMap<>();
|
|
|
paraMap.put("company",repalBill.getCustomerName());
|
|
|
paraMap.put("links",dto.getLinks());
|
|
@@ -196,6 +219,7 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Boolean urgeByConsult(RepalConsultDTO dto) {
|
|
|
//校验权限
|
|
|
UserContextBO userContextBO = UserContextUtil.getUser();
|
|
@@ -203,12 +227,19 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
if(!allFlag){
|
|
|
throw new CommonException(CodeMsg.FORBIDDEN,"暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
}
|
|
|
- //todo 扣减vip次数
|
|
|
RepalBill repalBill = repalBillService.getById(dto.getRepalBillId());
|
|
|
if(ObjectUtil.isNull(repalBill)){
|
|
|
throw new CommonException(CodeMsg.FAILED,"参数有误");
|
|
|
}
|
|
|
-
|
|
|
+ //扣减vip次数
|
|
|
+ RepalVip repalVip = repalVipService.getOne(Wrappers.lambdaQuery(RepalVip.class).eq(RepalVip::getRepalGroupId,repalBill.getRepalGroupId()),false);
|
|
|
+ if(ObjectUtil.isNull(repalVip) || RepalVipSignEnum.无特权.getCode().equals(repalVip.getRepalVipSign())){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"请先开通特权");
|
|
|
+ }
|
|
|
+ int count = repalVipMapper.updateSomeCount(repalVip.getId(),RepalDynamicTypeEnum.咨询.getCode());
|
|
|
+ if(count < 1){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"咨询律师次数不足");
|
|
|
+ }
|
|
|
Map<String,Object> paraMap = new HashMap<>();
|
|
|
paraMap.put("province",dto.getProvince());
|
|
|
paraMap.put("city",dto.getCity());
|
|
@@ -239,6 +270,7 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Boolean urgeByLawsuit(RepalLawDTO dto) {
|
|
|
//校验权限
|
|
|
UserContextBO userContextBO = UserContextUtil.getUser();
|
|
@@ -246,12 +278,19 @@ public class RepalDynamicServiceImpl extends ServiceImpl<RepalDynamicMapper, Rep
|
|
|
if(!allFlag){
|
|
|
throw new CommonException(CodeMsg.FORBIDDEN,"暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
}
|
|
|
- //todo 扣减vip次数
|
|
|
RepalBill repalBill = repalBillService.getById(dto.getRepalBillId());
|
|
|
RepalCustomer repalCustomer = repalCustomerService.getById(repalBill.getCustomerId());
|
|
|
if(ObjectUtil.isNull(repalBill) || ObjectUtil.isNull(repalCustomer)){
|
|
|
throw new CommonException(CodeMsg.FAILED,"参数有误");
|
|
|
}
|
|
|
+ RepalVip repalVip = repalVipService.getOne(Wrappers.lambdaQuery(RepalVip.class).eq(RepalVip::getRepalGroupId,repalBill.getRepalGroupId()),false);
|
|
|
+ if(ObjectUtil.isNull(repalVip) || RepalVipSignEnum.无特权.getCode().equals(repalVip.getRepalVipSign())){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"请先开通特权");
|
|
|
+ }
|
|
|
+ int count = repalVipMapper.updateSomeCount(repalVip.getId(),RepalDynamicTypeEnum.诉讼.getCode());
|
|
|
+ if(count < 1){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"诉讼追款次数不足");
|
|
|
+ }
|
|
|
String productCode = "205";
|
|
|
if(RepalBillStageEnum.NON_PROSECUTE.getCode().equals(dto.getCaseStage())){
|
|
|
productCode = "203";
|