|
|
|
@ -20,6 +20,7 @@ import com.hai.order.service.OrderService; |
|
|
|
|
import com.hai.order.type.OrderChildStatus; |
|
|
|
|
import com.hai.order.type.OrderPayType; |
|
|
|
|
import com.hai.order.type.OrderRefundOpUserType; |
|
|
|
|
import com.hai.order.utils.OrderUtil; |
|
|
|
|
import com.hai.service.*; |
|
|
|
|
import com.hai.service.pay.impl.GoodsOrderServiceImpl; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
@ -53,9 +54,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
@Resource |
|
|
|
|
private OrderService orderService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighGasOrderPushMapper highGasOrderPushMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighUserService highUserService; |
|
|
|
|
|
|
|
|
@ -65,12 +63,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
@Resource |
|
|
|
|
private OutRechargePriceService outRechargePriceService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GoodsOrderServiceImpl goodsOrderService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsIntegralRebateService bsIntegralRebateService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighDiscountUserRelService highDiscountUserRelService; |
|
|
|
|
|
|
|
|
@ -80,26 +72,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
@Resource |
|
|
|
|
private OutRechargeChildOrderService outRechargeChildOrderService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsRequestRecordService bsRequestRecordService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsConfigService bsConfigService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private SecConfigService secConfigService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighUserPayPasswordService highUserPayPasswordService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private ApiMerchantsService apiMerchantsService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private ApiAmountRecordService apiAmountRecordService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private ApiOrderRecordService apiOrderRecordService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsRechargeCodeService rechargeCodeService; |
|
|
|
@ -177,11 +149,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
return outRechargeOrderMapper.selectByExample(example); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<OutRechargeOrder> selectList() { |
|
|
|
|
return outRechargeOrderMapper.selectList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public OutRechargeOrder findByOrderId(Long orderId) { |
|
|
|
|
return outRechargeOrderMapper.selectByPrimaryKey(orderId); |
|
|
|
@ -207,203 +174,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
return outRechargeOrder; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// todo 接口已经废弃
|
|
|
|
|
@Override |
|
|
|
|
@Transactional( |
|
|
|
|
isolation = Isolation.SERIALIZABLE, |
|
|
|
|
propagation = Propagation.REQUIRES_NEW) |
|
|
|
|
public OutRechargeOrder insertOrder(JSONObject object) throws Exception { |
|
|
|
|
|
|
|
|
|
OutRechargeOrder outRechargeOrder = new OutRechargeOrder(); |
|
|
|
|
|
|
|
|
|
HighUser user = highUserService.findByUserId(object.getLong("userId")); |
|
|
|
|
public OutRechargeOrder findByOrderNoNotChild(String orderNo) { |
|
|
|
|
|
|
|
|
|
// 产品id
|
|
|
|
|
Long goodsId = object.getLong("goodsId"); |
|
|
|
|
|
|
|
|
|
// 充值内容
|
|
|
|
|
String rechargeContent = object.getString("rechargeContent"); |
|
|
|
|
|
|
|
|
|
// 查询产品详情
|
|
|
|
|
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId, null); |
|
|
|
|
|
|
|
|
|
Map<String, Object> listMap = new HashMap<>(); |
|
|
|
|
listMap.put("productType", "3"); |
|
|
|
|
listMap.put("returnType", 1); |
|
|
|
|
listMap.put("sourceId", goodsId); |
|
|
|
|
|
|
|
|
|
// 查询产品积分抵扣比例
|
|
|
|
|
BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap); |
|
|
|
|
|
|
|
|
|
// 判断充值系统是否关闭
|
|
|
|
|
if (!secConfigService.isConfig("RECHARGE", "1")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighDiscountUserRel highDiscountUserRel = null; |
|
|
|
|
// 判断是否有优惠券
|
|
|
|
|
if (object.getLong("memDiscountId") != null) { |
|
|
|
|
outRechargeOrder.setMemDiscountId(object.getLong("memDiscountId")); |
|
|
|
|
// 卡优惠券信息
|
|
|
|
|
highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId")); |
|
|
|
|
if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); |
|
|
|
|
} |
|
|
|
|
if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType()) |
|
|
|
|
&& !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
outRechargeOrder.setPayRealPrice(outRechargePrice.getPayPrice()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 优惠券抵扣
|
|
|
|
|
if (highDiscountUserRel != null) { |
|
|
|
|
|
|
|
|
|
outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName()); |
|
|
|
|
BigDecimal payPrice = new BigDecimal(0); |
|
|
|
|
|
|
|
|
|
// 卡卷类型 1:满减 2:抵扣 3:折扣
|
|
|
|
|
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) { |
|
|
|
|
// 如果商品支付总额 小于 满减价格
|
|
|
|
|
if (outRechargePrice.getRechargePrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) < 0) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到" + highDiscountUserRel.getHighDiscount().getDiscountCondition() + "元,无法使用此优惠券"); |
|
|
|
|
} |
|
|
|
|
// 计算支付金额 = 商品充值总额 - 满减额度
|
|
|
|
|
payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 卡卷类型 1:满减 2:抵扣 3:折扣
|
|
|
|
|
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) { |
|
|
|
|
// 计算支付金额 = 商品充值总额 - 满减额度
|
|
|
|
|
payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 卡卷类型 1:满减 2:抵扣 3:折扣
|
|
|
|
|
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { |
|
|
|
|
BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); |
|
|
|
|
// 订单总额 * 折扣
|
|
|
|
|
payPrice = outRechargePrice.getRechargePrice().multiply(discountPrice); |
|
|
|
|
outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getRechargePrice().subtract(payPrice)); |
|
|
|
|
outRechargeOrder.setPayRealPrice(payPrice); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 如果总额小于0
|
|
|
|
|
if (payPrice.compareTo(new BigDecimal("0")) < 0) { |
|
|
|
|
outRechargeOrder.setPayRealPrice(new BigDecimal("0")); |
|
|
|
|
} else { |
|
|
|
|
outRechargeOrder.setPayRealPrice(payPrice); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 判断积分数量是否大于0
|
|
|
|
|
if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) { |
|
|
|
|
|
|
|
|
|
// 判断用户积分是否够
|
|
|
|
|
if (object.getLong("integralNum") > user.getGold()) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户积分不足"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 积分抵扣金额
|
|
|
|
|
BigDecimal integralDeductionPrice = object.getBigDecimal("integralNum").divide(new BigDecimal(100).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
// 最高可抵扣金额
|
|
|
|
|
BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); |
|
|
|
|
// 判读积分是否大于限制额度
|
|
|
|
|
if (maxIntegralDeductionPrice.compareTo(integralDeductionPrice) < 0) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单最大抵扣积分金额:" + maxIntegralDeductionPrice); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额
|
|
|
|
|
if (bsProductDiscount.getDiscount().compareTo(new BigDecimal(100)) == 0 && integralDeductionPrice.compareTo(outRechargeOrder.getPayRealPrice()) == 0) { |
|
|
|
|
// 查询用户支付密码
|
|
|
|
|
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(object.getLong("userId")); |
|
|
|
|
if (userPayPassword == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isBlank(object.getString("password"))) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); |
|
|
|
|
} |
|
|
|
|
// 校验支付密码
|
|
|
|
|
if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
outRechargeOrder.setIntegralDeductionPrice(integralDeductionPrice); |
|
|
|
|
outRechargeOrder.setPayRealPrice(outRechargeOrder.getPayRealPrice().subtract(outRechargeOrder.getIntegralDeductionPrice())); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
outRechargeOrder.setUserId(user.getId()); |
|
|
|
|
outRechargeOrder.setIntegralNum(object.getBigDecimal("integralNum")); |
|
|
|
|
outRechargeOrder.setRechargeContent(rechargeContent); |
|
|
|
|
outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId()); |
|
|
|
|
outRechargeOrder.setUserName(user.getName()); |
|
|
|
|
outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType()); |
|
|
|
|
outRechargeOrder.setUserPhone(user.getPhone()); |
|
|
|
|
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); |
|
|
|
|
outRechargeOrder.setCreateTimed(new Date()); |
|
|
|
|
outRechargeOrder.setGoodsId(goodsId); |
|
|
|
|
outRechargeOrder.setWhetherRebate(false); |
|
|
|
|
outRechargeOrder.setMerchId(object.getString("mchId")); |
|
|
|
|
outRechargeOrder.setRechargePrice(outRechargePrice.getRechargePrice()); |
|
|
|
|
if (object.getLong("memDiscountId") != null) { |
|
|
|
|
outRechargeOrder.setPayPrice(outRechargePrice.getRechargePrice()); |
|
|
|
|
} else { |
|
|
|
|
outRechargeOrder.setPayPrice(outRechargePrice.getPayPrice()); |
|
|
|
|
} |
|
|
|
|
outRechargeOrder.setType(1); |
|
|
|
|
outRechargeOrder.setOrderPrice(outRechargePrice.getRechargePrice()); |
|
|
|
|
outRechargeOrder.setOperatorName(OperatorEnum.getNameByType(outRechargePrice.getOperatorType())); |
|
|
|
|
outRechargeOrder.setOperatorType(outRechargePrice.getOperatorType()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断积分支付是否扣完金额
|
|
|
|
|
if (outRechargeOrder.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { |
|
|
|
|
// 201:充值中 202:充值成功 203:充值失败 204:未充值
|
|
|
|
|
outRechargeOrder.setRechargeStatus(204); |
|
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
|
outRechargeOrder.setPayStatus(102); |
|
|
|
|
outRechargeOrder.setPayTime(new Date()); |
|
|
|
|
outRechargeOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); |
|
|
|
|
} else { |
|
|
|
|
// 201:充值中 202:充值成功 203:充值失败 204:未充值
|
|
|
|
|
outRechargeOrder.setRechargeStatus(204); |
|
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
|
outRechargeOrder.setPayStatus(101); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 使用优惠券
|
|
|
|
|
if (outRechargeOrder.getMemDiscountId() != null) { |
|
|
|
|
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); |
|
|
|
|
discountUserRel.setUseTime(new Date()); // 使用时间
|
|
|
|
|
discountUserRel.setStatus(2); //状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
highDiscountUserRelService.updateDiscountUserRel(discountUserRel); |
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(discountUserRel.getDiscountAgentCodeId()); |
|
|
|
|
code.setStatus(3); |
|
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outRechargeOrderMapper.insert(outRechargeOrder); |
|
|
|
|
OutRechargeOrderExample example = new OutRechargeOrderExample(); |
|
|
|
|
example.createCriteria().andOrderNoEqualTo(orderNo); |
|
|
|
|
|
|
|
|
|
if (outRechargeOrder.getIntegralNum() != null) { |
|
|
|
|
String remark = "话费订单" + outRechargeOrder.getOrderNo() + "下单,使用积分:" + object.getInteger("integralNum"); |
|
|
|
|
highUserService.goldHandle(outRechargeOrder.getUserId(), outRechargeOrder.getIntegralNum().intValue(), 2, 2, outRechargeOrder.getId() , remark); |
|
|
|
|
} |
|
|
|
|
List<OutRechargeOrder> list = outRechargeOrderMapper.selectByExample(example); |
|
|
|
|
|
|
|
|
|
if (outRechargeOrder.getPayStatus() == 102) { |
|
|
|
|
pollRequest(outRechargeOrder); |
|
|
|
|
if (list.size() == 0) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return outRechargeOrder; |
|
|
|
|
|
|
|
|
|
return list.get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -574,9 +357,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
isolation = Isolation.READ_COMMITTED, |
|
|
|
|
timeout = 25, |
|
|
|
|
rollbackFor = Exception.class) |
|
|
|
|
public void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception { |
|
|
|
|
public void refundOrder(Long orderId) throws Exception { |
|
|
|
|
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); |
|
|
|
|
|
|
|
|
|
log.info("发起话费订单退款" + outRechargeOrder.getOrderNo() + ""); |
|
|
|
|
|
|
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
|
if (outRechargeOrder.getPayStatus() != 102) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
@ -584,7 +369,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
|
|
|
|
|
// 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值
|
|
|
|
|
if (outRechargeOrder.getRechargeStatus() == 202) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款z"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 订单处理
|
|
|
|
@ -599,192 +384,104 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
outRechargeOrder.setRefundTime(new Date()); |
|
|
|
|
outRechargeOrderService.updateOrder(outRechargeOrder); |
|
|
|
|
|
|
|
|
|
// 充值订单记录修改状态
|
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
outRechargeChildOrderService.updateOrder(childOrder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { |
|
|
|
|
public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) throws Exception { |
|
|
|
|
|
|
|
|
|
// 查询充值产品
|
|
|
|
|
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null); |
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
object.put("rechargePrice" , outRechargeOrder.getRechargePrice()); |
|
|
|
|
object.put("rechargeMobile" , outRechargeOrder.getRechargeContent()); |
|
|
|
|
object.put("productId" , outRechargeOrder.getGoodsId()); |
|
|
|
|
object.put("parentOrderId" , outRechargeOrder.getId()); |
|
|
|
|
|
|
|
|
|
// 判断参数是否为空
|
|
|
|
|
if ( |
|
|
|
|
object.getBigDecimal("rechargePrice") == null || |
|
|
|
|
object.getString("rechargeMobile") == null || |
|
|
|
|
object.getInteger("productId") == null || |
|
|
|
|
object.getLong("parentOrderId") == null |
|
|
|
|
) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 定义子订单对象
|
|
|
|
|
OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); |
|
|
|
|
|
|
|
|
|
// 查询是否存在充值中的订单
|
|
|
|
|
// 定义子订单请求map
|
|
|
|
|
Map<String, Object> childOrderMap102 = new HashMap<>(); |
|
|
|
|
// 补充下单参数
|
|
|
|
|
object = prepaidRechargeOrderHandle(object); |
|
|
|
|
|
|
|
|
|
// 组装查询子订单数据
|
|
|
|
|
childOrderMap102.put("parent_order_id", outRechargeOrder.getId()); |
|
|
|
|
childOrderMap102.put("status", 102); |
|
|
|
|
// 查询子订单
|
|
|
|
|
List<OutRechargeChildOrder> childOrderList102 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap102); |
|
|
|
|
// 补充子订单参数
|
|
|
|
|
childOrder.setParentOrderId(object.getLong("parentOrderId")); |
|
|
|
|
childOrder.setRechargePlatform(object.getInteger("rechargePlatform")); |
|
|
|
|
childOrder.setStatus(102); |
|
|
|
|
childOrder.setOrderNo("CZ" + OrderUtil.generateOrderNo()); |
|
|
|
|
childOrder.setUpdateTime(new Date()); |
|
|
|
|
childOrder.setCreateTime(new Date()); |
|
|
|
|
|
|
|
|
|
if (childOrderList102.size() > 0) { |
|
|
|
|
return; |
|
|
|
|
// 尖椒充值
|
|
|
|
|
if (object.getInteger("rechargePlatform") == 1) { |
|
|
|
|
object.put("out_order_id", childOrder.getOrderNo()); |
|
|
|
|
object.put("amount", object.getBigDecimal("rechargePrice")); |
|
|
|
|
object.put("mobile", object.getString("rechargeMobile")); |
|
|
|
|
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl()); |
|
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); |
|
|
|
|
childOrder.setExt1(returnObject.toJSONString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询充值子订单列表
|
|
|
|
|
// 定义子订单请求map
|
|
|
|
|
Map<String, Object> childOrderMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
// 组装查询子订单数据
|
|
|
|
|
childOrderMap.put("parent_order_id", outRechargeOrder.getId()); |
|
|
|
|
// 查询子订单
|
|
|
|
|
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap); |
|
|
|
|
|
|
|
|
|
// 定义新的子订单对象
|
|
|
|
|
OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); |
|
|
|
|
// 龙阅
|
|
|
|
|
if (object.getInteger("rechargePlatform") == 2) { |
|
|
|
|
|
|
|
|
|
// 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停
|
|
|
|
|
int platformType = 0; |
|
|
|
|
|
|
|
|
|
// 判断子订单是否存在充值中订单
|
|
|
|
|
if (childOrderList.size() > 0) { |
|
|
|
|
// 修改之前的自订单充值记录
|
|
|
|
|
childOrder = childOrderList.get(0); |
|
|
|
|
|
|
|
|
|
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 99 未配置平台查询方法
|
|
|
|
|
Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder); |
|
|
|
|
if (status == 0 || status == 3 || status == 99) { |
|
|
|
|
return; |
|
|
|
|
} else if (status == 1) { |
|
|
|
|
completeOrder(childOrder.getOrderNo()); |
|
|
|
|
if (object.getString("code") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 修改充值记录状态
|
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
childOrder.setUpdateTime(new Date()); |
|
|
|
|
outRechargeChildOrderService.updateOrder(childOrder); |
|
|
|
|
object.put("out_trade_num", childOrder.getOrderNo()); |
|
|
|
|
object.put("product_id", object.getString("code")); |
|
|
|
|
object.put("mobile", object.getString("rechargeMobile")); |
|
|
|
|
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl()); |
|
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); |
|
|
|
|
childOrder.setExt1(returnObject.toJSONString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取充值平台
|
|
|
|
|
platformType = getRechargePlatformType(); |
|
|
|
|
// 畅停充值
|
|
|
|
|
if (object.getInteger("rechargePlatform") == 4) { |
|
|
|
|
|
|
|
|
|
// 定义下单请求数据对象
|
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
|
|
|
|
|
// 定义新充值订单号
|
|
|
|
|
String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); |
|
|
|
|
|
|
|
|
|
// 查询平台
|
|
|
|
|
String string = outRechargePrice.getRechargePlatform().substring(1,outRechargePrice.getRechargePlatform().length()-1); |
|
|
|
|
String[] rechargePlatform = string.split("-"); |
|
|
|
|
|
|
|
|
|
// 判断平台只定义一个那么类型就是唯一
|
|
|
|
|
if (string.length() == 1) { |
|
|
|
|
platformType = Integer.parseInt(string); |
|
|
|
|
} else { |
|
|
|
|
// 如果平台充值记录暂无 则充值第一个
|
|
|
|
|
if (platformType == 0) { |
|
|
|
|
platformType = Integer.parseInt(rechargePlatform[0]); |
|
|
|
|
} else { |
|
|
|
|
// 获取上一条充值平台的下一个平台内容
|
|
|
|
|
platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]); |
|
|
|
|
if (object.getString("code") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
object.put("orderid", childOrder.getOrderNo()); |
|
|
|
|
object.put("product_id", object.getString("code")); |
|
|
|
|
object.put("phone", object.getString("rechargeMobile")); |
|
|
|
|
object.put("price", object.getBigDecimal("rechargePrice")); |
|
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object); |
|
|
|
|
childOrder.setExt1(returnObject.toJSONString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 定义查询充值产品编码
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("type" , 1); |
|
|
|
|
|
|
|
|
|
for (String s : rechargePlatform) { |
|
|
|
|
// 尖椒充值
|
|
|
|
|
if (s.equals("1") && platformType == 1) { |
|
|
|
|
object.put("out_order_id", orderNo); |
|
|
|
|
object.put("amount", outRechargePrice.getRechargePrice()); |
|
|
|
|
object.put("mobile", outRechargeOrder.getRechargeContent()); |
|
|
|
|
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl()); |
|
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); |
|
|
|
|
object.put("return_content", returnObject); |
|
|
|
|
if (returnObject.getLong("code") == 200) { |
|
|
|
|
childOrder.setStatus(102); |
|
|
|
|
} else { |
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
} |
|
|
|
|
childOrder.setRechargePlatform(1); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// 龙阅充值
|
|
|
|
|
if (s.equals("2") && platformType == 2) { |
|
|
|
|
|
|
|
|
|
map.put("sourceId" , outRechargePrice.getId()); |
|
|
|
|
map.put("rechargePlatform" , platformType); |
|
|
|
|
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); |
|
|
|
|
object.put("out_trade_num", orderNo); |
|
|
|
|
object.put("product_id", rechargeCode.getGoodsId()); |
|
|
|
|
object.put("mobile", outRechargeOrder.getRechargeContent()); |
|
|
|
|
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl()); |
|
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); |
|
|
|
|
object.put("return_content", returnObject); |
|
|
|
|
if (returnObject.getLong("errno") == 0) { |
|
|
|
|
childOrder.setStatus(102); |
|
|
|
|
} else { |
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
} |
|
|
|
|
childOrder.setRechargePlatform(2); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// 城宇充值
|
|
|
|
|
if (s.equals("3") && platformType == 3) { |
|
|
|
|
|
|
|
|
|
map.put("sourceId" , outRechargePrice.getId()); |
|
|
|
|
map.put("rechargePlatform" , platformType); |
|
|
|
|
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); |
|
|
|
|
object.put("agentOrderId", orderNo); |
|
|
|
|
object.put("productId", rechargeCode.getGoodsId()); |
|
|
|
|
object.put("mobile", outRechargeOrder.getRechargeContent()); |
|
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByCy(object); |
|
|
|
|
object.put("return_content", returnObject); |
|
|
|
|
if (returnObject.getBoolean("success")) { |
|
|
|
|
childOrder.setStatus(102); |
|
|
|
|
} else { |
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
} |
|
|
|
|
childOrder.setRechargePlatform(3); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// 畅停充值
|
|
|
|
|
if (s.equals("4") && platformType == 4) { |
|
|
|
|
|
|
|
|
|
map.put("sourceId" , outRechargePrice.getId()); |
|
|
|
|
map.put("rechargePlatform" , platformType); |
|
|
|
|
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); |
|
|
|
|
object.put("orderid", orderNo); |
|
|
|
|
object.put("product_id", rechargeCode.getGoodsId()); |
|
|
|
|
object.put("phone", outRechargeOrder.getRechargeContent()); |
|
|
|
|
object.put("price", outRechargeOrder.getRechargePrice()); |
|
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object); |
|
|
|
|
object.put("return_content", returnObject); |
|
|
|
|
if (returnObject.getLong("code") != null && returnObject.getLong("code") == 200) { |
|
|
|
|
childOrder.setStatus(102); |
|
|
|
|
} else { |
|
|
|
|
childOrder.setStatus(103); |
|
|
|
|
} |
|
|
|
|
childOrder.setRechargePlatform(4); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
childOrder.setOrderNo(orderNo); |
|
|
|
|
childOrder.setCreateTime(new Date()); |
|
|
|
|
childOrder.setParentOrderId(outRechargeOrder.getId()); |
|
|
|
|
childOrder.setUpdateTime(new Date()); |
|
|
|
|
outRechargeChildOrderService.insertOrder(childOrder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 判断是否充值提交成功
|
|
|
|
|
if (childOrder.getStatus() == 102) { |
|
|
|
|
outRechargeOrder.setRechargeStatus(201); |
|
|
|
|
outRechargeOrder.setPayStatus(102); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (childOrder.getStatus() == 103) { |
|
|
|
|
outRechargeOrder.setRechargeStatus(205); |
|
|
|
|
outRechargeOrder.setPayStatus(102); |
|
|
|
|
@Override |
|
|
|
|
public void prepaidRechargeHandle(OutRechargeOrder outRechargeOrder) throws Exception { |
|
|
|
|
|
|
|
|
|
// 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成
|
|
|
|
|
int orderStatus = orderWhetherRecharge(outRechargeOrder); |
|
|
|
|
|
|
|
|
|
if (orderStatus == 1) { |
|
|
|
|
getPrepaidRechargeApi(outRechargeOrder); |
|
|
|
|
} |
|
|
|
|
if (orderStatus == 2) { |
|
|
|
|
refundOrder(outRechargeOrder.getId()); |
|
|
|
|
} |
|
|
|
|
if (orderStatus == 4) { |
|
|
|
|
HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); |
|
|
|
|
highOrder.setExceptionStatus(true); |
|
|
|
|
highOrder.setExceptionContent("话费订单存在多条重复记录"); |
|
|
|
|
highOrderService.updateOrder(highOrder); |
|
|
|
|
} |
|
|
|
|
if (orderStatus == 5) { |
|
|
|
|
completeOrder(outRechargeOrder.getOrderNo()); |
|
|
|
|
} |
|
|
|
|
outRechargeOrderService.updateOrder(outRechargeOrder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -831,8 +528,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editOutRechargeOrder(HighOrder orderData) { |
|
|
|
|
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderData.getOrderNo()); |
|
|
|
|
public void editOutRechargeOrder(HighOrder orderData , OutRechargeOrder outRechargeOrder) { |
|
|
|
|
|
|
|
|
|
// 201:充值中 202:充值成功 203:充值失败 204:未充值
|
|
|
|
|
outRechargeOrder.setRechargeStatus(201); |
|
|
|
@ -855,43 +551,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void rechargeOrderHandle(String orderNo) throws Exception { |
|
|
|
|
|
|
|
|
|
// 定义话费充值业务订单模型 or 充值记录订单模型
|
|
|
|
|
OutRechargeOrder outRechargeOrder = findByOrderNo(orderNo); |
|
|
|
|
OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); |
|
|
|
|
|
|
|
|
|
// 状态需要支付状态为已充值 并且 充值状态不为 充值成功
|
|
|
|
|
if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { |
|
|
|
|
|
|
|
|
|
// 判断充值记录是否存在
|
|
|
|
|
if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) { |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder(); |
|
|
|
|
outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); |
|
|
|
|
outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId()); |
|
|
|
|
outRechargeChildOrder.setUpdateTime(new Date()); |
|
|
|
|
outRechargeChildOrder.setCreateTime(new Date()); |
|
|
|
|
outRechargeChildOrderService.insertOrder(outRechargeChildOrder); |
|
|
|
|
// 话费退款
|
|
|
|
|
refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); |
|
|
|
|
} else { |
|
|
|
|
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
|
|
|
|
|
Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder); |
|
|
|
|
if (status == 2 || status == -1) { |
|
|
|
|
refundOrder(outRechargeOrder.getId() , childOrder); |
|
|
|
|
} else if (status == 1) { |
|
|
|
|
completeOrder(childOrder.getOrderNo()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Integer getRechargeOrderLegality(OutRechargeChildOrder childOrder) throws Exception { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception { |
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
// 龙阅
|
|
|
|
|
if (childOrder.getRechargePlatform() == 2) { |
|
|
|
@ -953,12 +614,175 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
return 99; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取当前最新的充值平台
|
|
|
|
|
private Integer getRechargePlatformType() { |
|
|
|
|
OutRechargeChildOrder outRechargeChildOrder = outRechargeChildOrderService.findOutRechargeChildOrderByDesc(); |
|
|
|
|
|
|
|
|
|
if (outRechargeChildOrder != null) { |
|
|
|
|
return outRechargeChildOrder.getRechargePlatform(); |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author Sum1Dream |
|
|
|
|
* @Name prepaidRechargeOrderHandle |
|
|
|
|
* @Description // 充值订单下单数据操作
|
|
|
|
|
* @Date 18:54 2023/3/28 |
|
|
|
|
* @Param [object] |
|
|
|
|
* @Return com.alibaba.fastjson.JSONObject |
|
|
|
|
*/ |
|
|
|
|
private JSONObject prepaidRechargeOrderHandle(JSONObject object) { |
|
|
|
|
|
|
|
|
|
if (object.getLong("productId") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "产品编码为空"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询充值产品
|
|
|
|
|
OutRechargePrice outRechargePrice = outRechargePriceService.findByGoodsId(object.getLong("productId")); |
|
|
|
|
|
|
|
|
|
if (outRechargePrice == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知产品编码"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停
|
|
|
|
|
Integer platformType = getRechargePlatformType(); |
|
|
|
|
|
|
|
|
|
// 截取可平台字符串
|
|
|
|
|
String rechargePlatformString = outRechargePrice.getRechargePlatform().substring(1,outRechargePrice.getRechargePlatform().length()-1); |
|
|
|
|
String[] rechargePlatform = rechargePlatformString.split("-"); |
|
|
|
|
|
|
|
|
|
if (rechargePlatform.length == 1) { |
|
|
|
|
platformType = Integer.parseInt(rechargePlatformString); |
|
|
|
|
} |
|
|
|
|
if (rechargePlatform.length > 1) { |
|
|
|
|
// 如果平台充值记录暂无 则充值第一个
|
|
|
|
|
if (platformType == null) { |
|
|
|
|
platformType = Integer.parseInt(rechargePlatform[0]); |
|
|
|
|
} else { |
|
|
|
|
// 获取上一条充值平台的下一个平台内容
|
|
|
|
|
platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String , Object> rechargeCodeMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
rechargeCodeMap.put("sourceId" , outRechargePrice.getId()); |
|
|
|
|
rechargeCodeMap.put("rechargePlatform" , platformType); |
|
|
|
|
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(rechargeCodeMap); |
|
|
|
|
|
|
|
|
|
object.put("code" , rechargeCode.getGoodsId()); |
|
|
|
|
object.put("rechargePlatform" , platformType); |
|
|
|
|
|
|
|
|
|
return object; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author Sum1Dream |
|
|
|
|
* @Name orderWhetherRecharge |
|
|
|
|
* @Description // 订单是否可以充值
|
|
|
|
|
* @Date 16:11 2023/3/28 |
|
|
|
|
* @Param [childOrder] |
|
|
|
|
* @Return java.lang.Integer 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 |
|
|
|
|
*/ |
|
|
|
|
private Integer orderWhetherRecharge(OutRechargeOrder rechargeOrder) throws Exception { |
|
|
|
|
|
|
|
|
|
// 查询子订单
|
|
|
|
|
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrderByOrderId(rechargeOrder.getId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 充值订单充值时间
|
|
|
|
|
Date rechargeTime = rechargeOrder.getCreateTimed(); |
|
|
|
|
Date currentTime = new Date(); |
|
|
|
|
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); |
|
|
|
|
|
|
|
|
|
// 判断订单是否存在充值完成订单
|
|
|
|
|
Map<String , Object> childMap = new HashMap<>(); |
|
|
|
|
childMap.put("parent_order_id", rechargeOrder.getId()); |
|
|
|
|
childMap.put("status", 101); |
|
|
|
|
List<OutRechargeChildOrder> childOrders101 = outRechargeChildOrderService.getListRechargeChildOrder(childMap); |
|
|
|
|
|
|
|
|
|
// 判断充值成功是否存在多个 存在返回异常
|
|
|
|
|
if (childOrders101.size() > 1) { |
|
|
|
|
return 4; |
|
|
|
|
} |
|
|
|
|
// 判断是否存在充值成功的订单
|
|
|
|
|
if (childOrders101.size() == 1) { |
|
|
|
|
return 5; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询充值中的订单
|
|
|
|
|
childMap.put("status", 102); |
|
|
|
|
List<OutRechargeChildOrder> childOrders102 = outRechargeChildOrderService.getListRechargeChildOrder(childMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 充值中的订单存在多个 返回异常
|
|
|
|
|
if (childOrders102.size() > 1) { |
|
|
|
|
return 4; |
|
|
|
|
} |
|
|
|
|
// 只存在一个充值中的订单需要查询当前充值中的订单状态
|
|
|
|
|
if (childOrders102.size() == 1) { |
|
|
|
|
|
|
|
|
|
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
|
|
|
|
|
Integer status = getRechargeOrderLegality(childOrders102.get(0)); |
|
|
|
|
if (status == 2 || status == -1) { |
|
|
|
|
// 修改充值订单状态
|
|
|
|
|
rechargeChildOrderHandle(childOrders102.get(0) , 103); |
|
|
|
|
// 如果订单记录超过5条退款 反之继续充值
|
|
|
|
|
if (childOrderList.size() > 4) { |
|
|
|
|
return 2; |
|
|
|
|
} else { |
|
|
|
|
// 如果订单记录超过71小时 反之继续充值
|
|
|
|
|
return hours > 71 ? 2 : 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 充值订单为充值成功
|
|
|
|
|
if (status == 1) { |
|
|
|
|
// 修改充值订单状态
|
|
|
|
|
rechargeChildOrderHandle(childOrders102.get(0) , 101); |
|
|
|
|
return 5; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 没有充值中的订单 查询所有订单中最新的一条订单状态
|
|
|
|
|
if (childOrders102.size() == 0) { |
|
|
|
|
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
|
|
|
|
|
Integer status = getRechargeOrderLegality(childOrderList.get(0)); |
|
|
|
|
if (status == 2 || status == -1) { |
|
|
|
|
// 修改充值订单状态
|
|
|
|
|
rechargeChildOrderHandle(childOrderList.get(0) , 103); |
|
|
|
|
// 如果订单记录超过5条退款 反之继续充值
|
|
|
|
|
if (childOrderList.size() > 4) { |
|
|
|
|
return 2; |
|
|
|
|
} else { |
|
|
|
|
// 如果订单记录超过71小时 反之继续充值
|
|
|
|
|
return hours > 71 ? 2 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (status == 1) { |
|
|
|
|
// 修改充值订单状态
|
|
|
|
|
rechargeChildOrderHandle(childOrderList.get(0) , 101); |
|
|
|
|
return 5; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return 3; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author Sum1Dream |
|
|
|
|
* @Name rechargeChildOrderHandle |
|
|
|
|
* @Description // 处理子订单
|
|
|
|
|
* @Date 18:50 2023/3/28 |
|
|
|
|
* @Param [rechargeChildOrder] |
|
|
|
|
* @Return void |
|
|
|
|
*/ |
|
|
|
|
private void rechargeChildOrderHandle(OutRechargeChildOrder rechargeChildOrder , Integer status) { |
|
|
|
|
rechargeChildOrder.setUpdateTime(new Date()); |
|
|
|
|
rechargeChildOrder.setStatus(status); |
|
|
|
|
outRechargeChildOrderService.updateOrder(rechargeChildOrder); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|