|
|
@ -2,23 +2,31 @@ package com.example.demo.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.example.demo.domain.entity.Audit; |
|
|
|
import com.example.demo.domain.entity.Detail; |
|
|
|
import com.example.demo.domain.entity.User; |
|
|
|
import com.example.demo.domain.vo.Page; |
|
|
|
import com.example.demo.domain.vo.Result; |
|
|
|
import com.example.demo.mapper.DetailMapper; |
|
|
|
import com.example.demo.mapper.UserMapper; |
|
|
|
import com.example.demo.sevice.AuditService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/audit/audit") |
|
|
|
@RequiredArgsConstructor |
|
|
|
@Slf4j |
|
|
|
@Transactional |
|
|
|
@CrossOrigin |
|
|
|
public class AuditController { |
|
|
|
|
|
|
|
private UserMapper userMapper; |
|
|
|
private DetailMapper detailMapper; |
|
|
|
private final AuditService auditService; |
|
|
|
@PostMapping("/add") |
|
|
|
public Result add(@RequestBody Audit audit){ |
|
|
@ -32,13 +40,34 @@ public class AuditController { |
|
|
|
} |
|
|
|
@PostMapping("/edit") |
|
|
|
public Result edit(@RequestBody Audit audit){ |
|
|
|
try { |
|
|
|
|
|
|
|
//先执行auditService.edit(audit); |
|
|
|
//然后创建一个类,去接收这个audit,如果status=1 |
|
|
|
//根据退款ID找到detail表中的记录获取到他的三种金币 |
|
|
|
//把金币加到user表中对应的金币中 |
|
|
|
|
|
|
|
auditService.edit(audit); |
|
|
|
return Result.success(); |
|
|
|
}catch (Exception e){ |
|
|
|
log.warn(Arrays.toString(e.getStackTrace())); |
|
|
|
return Result.error(e.getMessage()); |
|
|
|
if(audit.getStatus() == 1 && audit.getRefundId()!=null){ |
|
|
|
Detail detail = detailMapper.selectByRefundId(audit.getRefundId()); |
|
|
|
BigDecimal rechargeCoin = detail.getRechargeCoin(); |
|
|
|
BigDecimal taskCoin = detail.getTaskCoin(); |
|
|
|
BigDecimal freeCoin = detail.getFreeCoin(); |
|
|
|
|
|
|
|
User user = userMapper.selectByJwcode(detail.getJwcode()); |
|
|
|
user.setBuyJb(user.getBuyJb().add(rechargeCoin)); |
|
|
|
user.setCoreJb(user.getCoreJb().add(taskCoin)); |
|
|
|
user.setFree6(user.getFree6().add(freeCoin)); |
|
|
|
userMapper.update(user); |
|
|
|
} |
|
|
|
return Result.success(); |
|
|
|
// |
|
|
|
// try { |
|
|
|
// auditService.edit(audit); |
|
|
|
// return Result.success(); |
|
|
|
// }catch (Exception e){ |
|
|
|
// log.warn(Arrays.toString(e.getStackTrace())); |
|
|
|
// return Result.error(e.getMessage()); |
|
|
|
// } |
|
|
|
} |
|
|
|
@PostMapping |
|
|
|
public Result search(@RequestBody Page page){ |
|
|
|