|
|
|
@ -2,6 +2,7 @@ package com.example.demo.serviceImpl.coin; |
|
|
|
|
|
|
|
import com.example.demo.Util.GoldTistV2; |
|
|
|
import com.example.demo.Util.SimpleIdGenerator; |
|
|
|
import com.example.demo.config.GlobalExceptionHandler; |
|
|
|
import com.example.demo.domain.entity.User; |
|
|
|
import com.example.demo.domain.entity.UserGoldRecord; |
|
|
|
import com.example.demo.domain.vo.coin.*; |
|
|
|
@ -60,7 +61,13 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public boolean auditOrder(String token, String orderCode, Integer auditId, Integer action,String rejectReason,BigDecimal price,String linkId) throws Exception { |
|
|
|
if (linkId== null){ |
|
|
|
linkId=orderCode; |
|
|
|
} |
|
|
|
UserGoldRecord order=auditMapper.selectOrderByOrderCode(orderCode); |
|
|
|
if (price== null){ |
|
|
|
price= BigDecimal.valueOf(order.getPermanentGold()); |
|
|
|
} |
|
|
|
Date date =new Date(); |
|
|
|
//状态为0待审核或4第一次红包退款失败的订单才能审核 |
|
|
|
if (order == null || (order.getAuditStatus() != 0 && order.getAuditStatus() !=4)) { |
|
|
|
@ -151,6 +158,8 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
if (order.getAuditStatus()!=4){ |
|
|
|
try { |
|
|
|
String result = redService.checkRed(price, linkId); |
|
|
|
// 设置到全局上下文 |
|
|
|
AuditContext.setRedCheckResult(result); |
|
|
|
} catch (RedCheckException e) { |
|
|
|
// 业务失败(flag=false) |
|
|
|
int num = e.getNum(); |
|
|
|
@ -207,12 +216,9 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
GoldTistV2.addCoinNew(order.getJwcode().toString(), 59, //退款任务+永久金币-充值 |
|
|
|
(double) (order.getTaskGold()+order.getPermanentGold() ) /100,SimpleIdGenerator.generateId(), |
|
|
|
order.getRemark(),(double) order.getPermanentGold() / 100, auditName, "退款金币充值");} |
|
|
|
//金币退款的原价为充值的永久金币 |
|
|
|
if (order.getRefundType().equals("金币退款")){ |
|
|
|
price= BigDecimal.valueOf(order.getPermanentGold()); |
|
|
|
} |
|
|
|
|
|
|
|
//额外扣金币抵扣红包 |
|
|
|
if (order.getAuditStatus()==4&&price!= null&&linkId!= null){ |
|
|
|
if (order.getAuditStatus()==4){ |
|
|
|
int type = 1; //红包充值累计 |
|
|
|
GoldUser user = userMapper.selectUser(order.getJwcode().toString()); |
|
|
|
// 检查用户余额是否足够抵扣红包差额 |
|
|
|
@ -260,9 +266,18 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
redMapper.update(order.getJwcode(),type,order.getPrice()); |
|
|
|
} |
|
|
|
|
|
|
|
if (!redService.checkRed(price, linkId).equals("old")){ |
|
|
|
|
|
|
|
//link扣除已有红包 |
|
|
|
redService.consumeRed(linkId);} |
|
|
|
if (!AuditContext.getRedCheckResult().equals("old")){ |
|
|
|
redService.consumeRed(linkId); |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
Exception e = new Exception("旧订单退款"); |
|
|
|
String title = "旧订单退款"; |
|
|
|
String detail= (order.getJwcode()).toString()+"金币订单号"+orderCode; |
|
|
|
GlobalExceptionHandler.sendFeishuAlert(e, title, detail); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@ -396,6 +411,7 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
public class AuditContext { |
|
|
|
|
|
|
|
private static final ThreadLocal<String> FAIL_MSG = new ThreadLocal<>(); |
|
|
|
private static final ThreadLocal<String> RED_CHECK_RESULT = new ThreadLocal<>(); |
|
|
|
|
|
|
|
public static void setFailMsg(String msg) { |
|
|
|
FAIL_MSG.set(msg); |
|
|
|
@ -404,9 +420,16 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
public static String getFailMsg() { |
|
|
|
return FAIL_MSG.get(); |
|
|
|
} |
|
|
|
public static void setRedCheckResult(String result) { |
|
|
|
RED_CHECK_RESULT.set(result); |
|
|
|
} |
|
|
|
|
|
|
|
public static String getRedCheckResult() { |
|
|
|
return RED_CHECK_RESULT.get(); |
|
|
|
} |
|
|
|
public static void clear() { |
|
|
|
FAIL_MSG.remove(); |
|
|
|
RED_CHECK_RESULT.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|