|
|
|
@ -58,7 +58,7 @@ 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) { |
|
|
|
public boolean auditOrder(String token, String orderCode, Integer auditId, Integer action,String rejectReason,BigDecimal price,String linkId) throws Exception { |
|
|
|
UserGoldRecord order=auditMapper.selectOrderByOrderCode(orderCode); |
|
|
|
Date date =new Date(); |
|
|
|
//状态为0待审核或4第一次红包退款失败的订单才能审核 |
|
|
|
@ -119,8 +119,6 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
auditMapper.updateFirstRecharge(order.getJwcode());//设置首充时间为当前时间 |
|
|
|
} |
|
|
|
auditMapper.updateUserGold(update); |
|
|
|
|
|
|
|
|
|
|
|
//累充 |
|
|
|
try { |
|
|
|
BigDecimal sum = BigDecimal.valueOf( |
|
|
|
@ -138,7 +136,6 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
log.warn("精网号发送失败,主流程继续 | jwcode={}", order.getJwcode(), e); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//erp增加充值数据 |
|
|
|
|
|
|
|
GoldTistV2.addCoinNew(order.getJwcode().toString(), 64, //充值永久金币 |
|
|
|
@ -150,17 +147,23 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
|
|
|
|
}else if (order.getType()==2) { //退款 |
|
|
|
//对非强制退款订单进行退红包校验 |
|
|
|
if (order.getAuditStatus()!=4){ |
|
|
|
if (order.getAuditStatus()!=4&&price!= null&&linkId!= null){ |
|
|
|
try { |
|
|
|
redService.checkRed(price, linkId); |
|
|
|
} catch (RedCheckException e) { |
|
|
|
// 业务失败(flag=false) |
|
|
|
int num = e.getNum(); |
|
|
|
log.error("红包退票失败,还需扣除金币数: {}", num); |
|
|
|
String logMsg = String.format( |
|
|
|
"红包退票失败,orderId=%s,还需扣除金币数=%d", |
|
|
|
linkId, num |
|
|
|
); |
|
|
|
|
|
|
|
log.error(logMsg); |
|
|
|
updateOrder.setAuditStatus(4); |
|
|
|
updateOrder.setRedDiff(BigDecimal.valueOf(num)); |
|
|
|
updateOrder.setRedDiff(BigDecimal.valueOf(num* 100L)); |
|
|
|
auditMapper.updateOrder(updateOrder); |
|
|
|
throw e; // 或者包装后再抛 |
|
|
|
AuditContext.setFailMsg(logMsg); |
|
|
|
return false; |
|
|
|
} catch (Exception e) { |
|
|
|
// 网络异常 / 系统异常 |
|
|
|
log.error("红包接口调用异常", e); |
|
|
|
@ -194,10 +197,8 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
// 执行审核更新 |
|
|
|
redMapper.update(order.getJwcode(),type,order.getPrice()); |
|
|
|
}//金币充值退款 |
|
|
|
|
|
|
|
|
|
|
|
else if (oldOrder.getType()==0){ |
|
|
|
int type = 1; |
|
|
|
|
|
|
|
if(order.getTaskGold()==0){ //无任务金币统一走免费+永久 |
|
|
|
GoldTistV2.addCoinNew(order.getJwcode().toString(), 58, //退款免费+永久金币-充值 |
|
|
|
(double) (order.getFreeDecember()+order.getFreeJune()+order.getPermanentGold() ) /100, |
|
|
|
@ -206,8 +207,11 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
GoldTistV2.addCoinNew(order.getJwcode().toString(), 59, //退款任务+永久金币-充值 |
|
|
|
(double) (order.getTaskGold()+order.getPermanentGold() ) /100, |
|
|
|
order.getRemark(),(double) order.getPermanentGold() / 100, auditName, "退款金币充值");} |
|
|
|
|
|
|
|
//额外扣金币抵扣红包 |
|
|
|
if (order.getAuditStatus()==4){ |
|
|
|
|
|
|
|
if (order.getAuditStatus()==4&&price!= null&&linkId!= null){ |
|
|
|
int type = 1; //红包充值累计 |
|
|
|
GoldUser user = userMapper.selectUser(order.getJwcode().toString()); |
|
|
|
// 检查用户余额是否足够抵扣红包差额 |
|
|
|
if (order.getRedDiff().compareTo(user.getNowSumGold()) > 0) { |
|
|
|
@ -248,10 +252,14 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
consumeUser.setAdminId(order.getAdminId()); |
|
|
|
consumeUser.setRemark(order.getRemark()); |
|
|
|
consumeUser.setPrice(order.getPrice()); |
|
|
|
|
|
|
|
} // 执行审核更新 |
|
|
|
// 执行金币抵扣红包 |
|
|
|
redService.updateRed(consumeUser); |
|
|
|
//link扣除已有红包 |
|
|
|
redService.consumeRed(linkId); |
|
|
|
// 执行审核更新 |
|
|
|
redMapper.update(order.getJwcode(),type,order.getPrice()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -381,4 +389,21 @@ public class AuditServiceImpl implements AuditService { |
|
|
|
gold.setTaskGolds(BigDecimal.valueOf(taskGoldSum)); |
|
|
|
return gold; |
|
|
|
} |
|
|
|
public class AuditContext { |
|
|
|
|
|
|
|
private static final ThreadLocal<String> FAIL_MSG = new ThreadLocal<>(); |
|
|
|
|
|
|
|
public static void setFailMsg(String msg) { |
|
|
|
FAIL_MSG.set(msg); |
|
|
|
} |
|
|
|
|
|
|
|
public static String getFailMsg() { |
|
|
|
return FAIL_MSG.get(); |
|
|
|
} |
|
|
|
|
|
|
|
public static void clear() { |
|
|
|
FAIL_MSG.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |