Browse Source

5月14日排序修改,消费网号校验

sjb
Your Name 3 days ago
parent
commit
185038f925
  1. 9
      src/main/java/com/example/demo/controller/RefundController.java
  2. 7
      src/main/java/com/example/demo/serviceImpl/RechargeServiceImpl.java
  3. 14
      src/main/java/com/example/demo/serviceImpl/RefundServiceImpl.java
  4. 2
      src/main/java/com/example/demo/sevice/RefundService.java

9
src/main/java/com/example/demo/controller/RefundController.java

@ -31,8 +31,13 @@ public class RefundController {
if (refundService.existsByContactId(detail.getContactId())) {
return Result.error("该订单已退款: " + detail.getContactId());
}
refundService.add(detail);
try {
refundService.add(detail);
}
catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace()));
return Result.error(e.getMessage());
}
refundService.addAudit(detail);
refundService.update(detail.getContactId());

7
src/main/java/com/example/demo/serviceImpl/RechargeServiceImpl.java

@ -3,6 +3,7 @@ package com.example.demo.serviceImpl;
import com.example.demo.domain.entity.Audit;
import com.example.demo.domain.entity.Detail;
import com.example.demo.domain.entity.Recharge;
import com.example.demo.domain.entity.User;
import com.example.demo.domain.vo.RechargeA;
import com.example.demo.domain.vo.RechargeVo;
import com.example.demo.domain.vo.Result;
@ -20,6 +21,7 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.util.Arrays;
@ -44,6 +46,11 @@ public class RechargeServiceImpl implements RechargeService {
@CacheEvict(value = "recharge",allEntries = true)
public int add(Recharge recharge) throws Exception {
User sUser = userMapper.select(recharge.getJwcode());
if(ObjectUtils.isEmpty(sUser)){
throw new Exception("无此精网号");
}
// return rechargeMapper.insert(recharge);
String uuid = UUID.randomUUID().toString().replace("-", ""); // 去掉UUID中的'-'

14
src/main/java/com/example/demo/serviceImpl/RefundServiceImpl.java

@ -2,18 +2,22 @@ package com.example.demo.serviceImpl;
import com.example.demo.domain.entity.Detail;
import com.example.demo.domain.entity.User;
import com.example.demo.domain.vo.RefundA;
import com.example.demo.mapper.RefundMapper;
import com.example.demo.mapper.UserMapper;
import com.example.demo.sevice.RefundService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.util.Arrays;
@ -27,10 +31,16 @@ import java.util.UUID;
@CacheConfig(cacheNames = "refund")
public class RefundServiceImpl implements RefundService {
private final RefundMapper refundMapper;
@Autowired
private UserMapper userMapper;
@CacheEvict(value = {"refund", "audit"}, allEntries = true)
@Override
public int add(Detail detail) {
public int add(Detail detail) throws Exception {
User sUser = userMapper.select(detail.getJwcode());
if(ObjectUtils.isEmpty(sUser)){
throw new Exception("无此精网号");
}
// 生成UUID作为订单编号
String uuid = UUID.randomUUID().toString().replaceAll("-", ""); // 去掉UUID中的'-'
detail.setOrderCode(uuid);

2
src/main/java/com/example/demo/sevice/RefundService.java

@ -10,7 +10,7 @@ import java.util.List;
@Service
public interface RefundService {
int add(Detail detail) ;
int add(Detail detail) throws Exception;
int addAudit(Detail detail);
void edit(Detail newDetail) ;
int update(Integer contactId) ;

Loading…
Cancel
Save