|
@ -17,6 +17,8 @@ import org.springframework.util.ObjectUtils; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
import java.time.Month; |
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
@ -41,9 +43,74 @@ public class AuditController { |
|
|
return Result.error(e.getMessage()); |
|
|
return Result.error(e.getMessage()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@PostMapping("/edit") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @PostMapping("/edit") |
|
|
|
|
|
// public Result edit(@RequestBody Audit audit) { |
|
|
|
|
|
// log.info("Starting edit for audit: {}", audit); |
|
|
|
|
|
// try { |
|
|
|
|
|
// // 执行 edit 操作 |
|
|
|
|
|
// auditService.edit(audit); |
|
|
|
|
|
// log.info("Audit service edit completed."); |
|
|
|
|
|
// |
|
|
|
|
|
// // 判断是否满足条件 |
|
|
|
|
|
// if (audit.getStatus() == 1) { |
|
|
|
|
|
// log.info("Audit status is 1."); |
|
|
|
|
|
// |
|
|
|
|
|
// if (audit.getRefundId() != null) { |
|
|
|
|
|
// log.info("Refund ID: {}", audit.getRefundId()); |
|
|
|
|
|
// |
|
|
|
|
|
// Detail detail = detailMapper.selectByRefundId(audit.getRefundId()); |
|
|
|
|
|
// if (detail != null) { |
|
|
|
|
|
// log.info("Detail found: {}", detail); |
|
|
|
|
|
// |
|
|
|
|
|
// BigDecimal rechargeCoin = detail.getRechargeCoin(); |
|
|
|
|
|
// BigDecimal taskCoin = detail.getTaskCoin(); |
|
|
|
|
|
// BigDecimal freeCoin = detail.getFreeCoin(); |
|
|
|
|
|
// log.info("RechargeCoin: {}, TaskCoin: {}, FreeCoin: {}", rechargeCoin, taskCoin, freeCoin); |
|
|
|
|
|
// |
|
|
|
|
|
// User user = userMapper.selectByJwcode(detail.getJwcode()); |
|
|
|
|
|
// if (user != null) { |
|
|
|
|
|
// log.info("User found: {}", user); |
|
|
|
|
|
// |
|
|
|
|
|
// // 更新用户金币信息 |
|
|
|
|
|
// user.setBuyJb(user.getBuyJb().add(rechargeCoin)); |
|
|
|
|
|
// user.setCoreJb(user.getCoreJb().add(taskCoin)); |
|
|
|
|
|
// user.setFree6(user.getFree6().add(freeCoin)); |
|
|
|
|
|
// log.info("Updated User: {}", user); |
|
|
|
|
|
// |
|
|
|
|
|
// // 更新用户 |
|
|
|
|
|
// userMapper.update(user); |
|
|
|
|
|
// log.info("User updated successfully."); |
|
|
|
|
|
// } else { |
|
|
|
|
|
// log.warn("No user found for jwcode: {}", detail.getJwcode()); |
|
|
|
|
|
// } |
|
|
|
|
|
// } else { |
|
|
|
|
|
// log.warn("No detail found for refund ID: {}", audit.getRefundId()); |
|
|
|
|
|
// } |
|
|
|
|
|
// } else { |
|
|
|
|
|
// log.warn("Refund ID is null for audit: {}", audit); |
|
|
|
|
|
// } |
|
|
|
|
|
// } else { |
|
|
|
|
|
// log.info("Audit status is not 1, skipping user update."); |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// return Result.success(); |
|
|
|
|
|
// } catch (Exception e) { |
|
|
|
|
|
// log.error("Error during edit operation", e); |
|
|
|
|
|
// return Result.error("Error during edit operation: " + e.getMessage()); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/edit") |
|
|
public Result edit(@RequestBody Audit audit){ |
|
|
public Result edit(@RequestBody Audit audit){ |
|
|
|
|
|
|
|
|
|
|
|
//先执行auditService.edit(audit); |
|
|
|
|
|
//然后创建一个类,去接收这个audit,如果status=1 |
|
|
|
|
|
//根据退款ID找到detail表中的记录获取到他的三种金币 |
|
|
|
|
|
//把金币加到user表中对应的金币中 |
|
|
|
|
|
|
|
|
auditService.edit(audit); |
|
|
auditService.edit(audit); |
|
|
if(audit.getStatus() == 1 && audit.getRefundId()!=null){ |
|
|
if(audit.getStatus() == 1 && audit.getRefundId()!=null){ |
|
|
Detail detail = detailMapper.selectByRefundId(audit.getRefundId()); |
|
|
Detail detail = detailMapper.selectByRefundId(audit.getRefundId()); |
|
@ -54,10 +121,29 @@ public class AuditController { |
|
|
User user = userMapper.selectByJwcode(detail.getJwcode()); |
|
|
User user = userMapper.selectByJwcode(detail.getJwcode()); |
|
|
user.setBuyJb(user.getBuyJb().add(rechargeCoin)); |
|
|
user.setBuyJb(user.getBuyJb().add(rechargeCoin)); |
|
|
user.setCoreJb(user.getCoreJb().add(taskCoin)); |
|
|
user.setCoreJb(user.getCoreJb().add(taskCoin)); |
|
|
user.setFree6(user.getFree6().add(freeCoin)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
Month currentMonth = now.getMonth(); |
|
|
|
|
|
|
|
|
|
|
|
// 判断月份范围并返回对应值 |
|
|
|
|
|
if (currentMonth.getValue() <= 6) { |
|
|
|
|
|
user.setFree6(user.getFree6().add(freeCoin)); // 在1月到6月时返回的值 |
|
|
|
|
|
} else { |
|
|
|
|
|
user.setFree12(user.getFree12().add(freeCoin)); // 在7月到12月时返回的值 |
|
|
|
|
|
} |
|
|
userMapper.update(user); |
|
|
userMapper.update(user); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return Result.success(); |
|
|
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 |
|
|
@PostMapping |
|
|
public Result search(@RequestBody Page page){ |
|
|
public Result search(@RequestBody Page page){ |
|
|