合并代码

dev-discount
袁野 3 years ago
parent 3cace5aa50
commit 620fd4738c
  1. 192
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  2. 17
      hai-cweb/src/main/java/com/cweb/controller/WechatController.java
  3. 14
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  4. 37
      hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java
  5. 56
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  6. 43
      hai-service/src/main/java/com/hai/enum_type/OperatorEnum.java
  7. 17
      hai-service/src/main/java/com/hai/model/OutRechargeOrderDetailModel.java
  8. 11
      hai-service/src/main/java/com/hai/model/UserModel.java
  9. 12
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  10. 9
      hai-service/src/main/java/com/hai/service/OutRechargePriceService.java
  11. 6
      hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java
  12. 265
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  13. 16
      hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java
  14. 37
      hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java

@ -6,13 +6,10 @@ import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.security.AESEncodeUtil;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.*; import com.hai.common.utils.*;
import com.hai.config.RechargeConfig;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.DiscountUseScope;
import com.hai.model.*; import com.hai.model.*;
import com.hai.service.*; import com.hai.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -20,14 +17,13 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
@Controller @Controller
@ -45,20 +41,6 @@ public class OutRechargeOrderController {
@Resource @Resource
private OutRechargePriceService outRechargePriceService; private OutRechargePriceService outRechargePriceService;
@Resource
private SecConfigService secConfigService;
@Resource
private HighUserPayPasswordService highUserPayPasswordService;
@Resource
private HighDiscountUserRelService highDiscountUserRelService;
@Resource
private BsConfigService bsConfigService;
@Resource
private RechargeConfig rechargeConfig;
@RequestMapping(value="/addOrder",method = RequestMethod.POST) @RequestMapping(value="/addOrder",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ -72,169 +54,17 @@ public class OutRechargeOrderController {
if (StringUtils.isBlank(object.getString("rechargeContent")) || if (StringUtils.isBlank(object.getString("rechargeContent")) ||
StringUtils.isBlank(object.getString("regionId")) ||
object.getLong("goodsId") == null object.getLong("goodsId") == null
) { ) {
log.error("addOrder error!"); log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
OutRechargeOrder outRechargeOrder = new OutRechargeOrder(); object.put("userId" , userInfoModel.getHighUser().getId());
object.put("userName" , userInfoModel.getHighUser().getName());
// 产品id object.put("phone" , userInfoModel.getHighUser().getPhone());
Long goodsId = object.getLong("goodsId");
// 充值内容
String rechargeContent = object.getString("rechargeContent");
// 查询产品详情
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId , null);
Map<String, Object> listMap = new HashMap<>(); return ResponseMsgUtil.success(outRechargeOrderService.insertOrder(object));
listMap.put("productType", "3");
listMap.put("returnType", 1);
listMap.put("sourceId", goodsId);
// 查询产品积分抵扣比例
BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap);
// 判断充值系统是否关闭
if (!secConfigService.isConfig("RECHARGE" , "1")) {
log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, "");
}
HighDiscountUserRel highDiscountUserRel = null;
// 判断是否有优惠券
if (object.getLong("memDiscountId") != null) {
// 卡优惠券信息
highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId"));
if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) {
log.error("HighOrderController --> addOrder() error!", "优惠券状态错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误");
}
if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())
&& !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) {
log.error("HighOrderController --> addOrder() error!", "无法使用此优惠券");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券");
}
}
// 优惠券抵扣
if (highDiscountUserRel != null) {
outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName());
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) {
// 如果商品支付总额 小于 满减价格
if (outRechargePrice.getPayPrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) > 1) {
log.error("HighOrderController --> addOrder() error!", "订单未达到满减额度");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+highDiscountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券");
}
// 计算支付金额 = 商品支付总额 - 满减额度
BigDecimal payPrice = outRechargePrice.getPayPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// 如果总额小于0
if (payPrice.compareTo(new BigDecimal("0")) < 0) {
outRechargeOrder.setPayRealPrice(new BigDecimal("0"));
} else {
outRechargeOrder.setPayRealPrice(payPrice);
}
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) {
// 计算支付金额 = 商品支付总额 - 满减额度
BigDecimal payPrice = outRechargePrice.getPayPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// 如果总额小于0
if (payPrice.compareTo(new BigDecimal("0")) < 0) {
outRechargeOrder.setPayRealPrice(new BigDecimal("0"));
} else {
outRechargeOrder.setPayRealPrice(payPrice);
}
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) {
BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice();
// 订单总额 * 折扣
BigDecimal payPrice = outRechargePrice.getPayPrice().multiply(discountPrice);
outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getPayPrice().subtract(payPrice));
outRechargeOrder.setPayRealPrice(payPrice);
}
}
// 判断积分数量是否大于0
if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) {
// 判断用户积分是否够
if (object.getLong("integralNum") > userInfoModel.getHighUser().getGold()) {
log.error("HighOrderController --> addOrder() error!", "积分大于用户积分额度");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "用户积分" + userInfoModel.getHighUser().getGold());
}
// 积分抵扣金额
BigDecimal integralDeductionPrice = BigDecimal.valueOf(object.getLong("integralNum") / 100);
// 最高可抵扣金额
BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_DOWN);
// 判读积分是否大于限制额度
if (maxIntegralDeductionPrice.compareTo(integralDeductionPrice) > 0) {
log.error("HighOrderController --> addOrder() error!", "积分大于限制额度");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单最大抵扣积分数量" + object.getLong("integralNum"));
}
// 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额
if (bsProductDiscount.getDiscount().compareTo(new BigDecimal(100)) == 0 && integralDeductionPrice.compareTo(outRechargeOrder.getPayRealPrice()) == 0) {
// 查询用户支付密码
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId());
if (userPayPassword == null) {
log.error("orderToPay error!", "未设置支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
}
if (StringUtils.isBlank(object.getString("password"))) {
log.error("orderToPay error!", "未输入支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
}
// 校验支付密码
if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) {
log.error("orderToPay error!", "");
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
}
}
outRechargeOrder.setIntegralDeductionPrice(integralDeductionPrice);
outRechargeOrder.setPayRealPrice(outRechargeOrder.getPayRealPrice().subtract(outRechargeOrder.getIntegralDeductionPrice()));
}
outRechargeOrder.setUserId(userInfoModel.getHighUser().getId());
outRechargeOrder.setRechargeContent(rechargeContent);
outRechargeOrder.setRegionId(object.getString("regionId"));
outRechargeOrder.setUserName(userInfoModel.getHighUser().getName());
outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType());
outRechargeOrder.setUserPhone(userInfoModel.getHighUser().getPhone());
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setCreateTimed(new Date());
// 判断积分支付是否扣完金额
if (outRechargeOrder.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) {
// 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder.setRechargeStatus(201);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
outRechargeOrder.setPayStatus(102);
} else {
// 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder.setRechargeStatus(204);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
outRechargeOrder.setPayStatus(101);
}
outRechargeOrderService.insertOrder(outRechargeOrder);
return ResponseMsgUtil.success(outRechargeOrder);
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController -> addOrder() error!",e); log.error("HighOrderController -> addOrder() error!",e);
@ -249,7 +79,15 @@ public class OutRechargeOrderController {
public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) { public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) {
try { try {
return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(orderId)); OutRechargeOrderDetailModel rechargeOrderDetailModel = new OutRechargeOrderDetailModel();
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
BeanUtils.copyProperties(order, rechargeOrderDetailModel);
rechargeOrderDetailModel.setOutRechargePrice(outRechargePriceService.findByGoodsId(order.getGoodsId()));
return ResponseMsgUtil.success(rechargeOrderDetailModel);
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e); log.error("HighOrderController --> getOrderById() error!", e);
@ -265,7 +103,7 @@ public class OutRechargeOrderController {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId);
if (outRechargeOrder.getRechargeStatus() == 1) { if (outRechargeOrder.getPayStatus() == 101 && (outRechargeOrder.getRechargeStatus() != 201 || outRechargeOrder.getRechargeStatus() != 202)) {
outRechargeOrderService.cancelOrder(orderId); outRechargeOrderService.cancelOrder(orderId);
} else { } else {
log.error("orderToPay error!"); log.error("orderToPay error!");

@ -244,27 +244,18 @@ public class WechatController {
} }
} }
@RequestMapping(value = "/loginByTel", method = RequestMethod.POST) @RequestMapping(value = "/loginByTel", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据手机号码登陆") @ApiOperation(value = "根据手机号码登陆")
public ResponseData loginByTel(@RequestBody JSONObject body, public ResponseData loginByTel(@RequestParam(value = "phone", required = true) String phone,
HttpServletRequest request, HttpServletResponse response) { HttpServletRequest request, HttpServletResponse response) {
try { try {
if (body == null
|| StringUtils.isBlank(body.getString("phone"))
|| StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 根据手机号查询用户 // 根据手机号查询用户
HighUser user = highUserService.findByPhone(body.getString("phone")); HighUser user = highUserService.findByPhone(phone);
// 获取手机号验证码
String phoneSmsCode = (String) redisUtil.get("SMS_"+ body.getString("phone"));
// 验证码校验 // 验证码校验
if (StringUtils.isNotBlank(phoneSmsCode) && Objects.equals(phoneSmsCode,body.getString("smsCode"))) {
// 定义个人所有数据 // 定义个人所有数据
HighUserModel highUserModel = new HighUserModel(); HighUserModel highUserModel = new HighUserModel();
HighUser detailData = highUserService.getDetailDataByUser(user.getId()); HighUser detailData = highUserService.getDetailDataByUser(user.getId());
@ -273,9 +264,7 @@ public class WechatController {
SessionObject so = new SessionObject(user.getPhone(), 1, highUserModel); SessionObject so = new SessionObject(user.getPhone(), 1, highUserModel);
userCenter.save(request, response, so); userCenter.save(request, response, so);
return ResponseMsgUtil.success(so); return ResponseMsgUtil.success(so);
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误");
} catch (Exception e) { } catch (Exception e) {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

@ -226,9 +226,9 @@ public class CzOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
} }
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getRechargeStatus() != 1) { if (order.getPayStatus() != 101) {
log.error("orderToPay error!", "无法支付,订单不处于待支付状态"); log.error("orderToPayByWx error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
} }
@ -307,8 +307,8 @@ public class CzOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
} }
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getRechargeStatus() != 1) { if (order.getPayStatus() != 101) {
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
} }
@ -349,8 +349,8 @@ public class CzOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
} }
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getPayStatus() != 1) { if (order.getPayStatus() != 101) {
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
} }

@ -383,27 +383,22 @@ public class UnionPayController {
// 转换成JSON格式 // 转换成JSON格式
JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1)); JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1));
// if (StringUtils.isNotBlank(body.getString("tradetrace"))) { if (StringUtils.isNotBlank(body.getString("tradetrace"))) {
// OutRechargeOrder order = outRechargeOrderService.findByOrderNo(body.getString("tradetrace")); OutRechargeOrder order = outRechargeOrderService.findByOrderNo(body.getString("tradetrace"));
// if (order == null) { if (order == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// } }
//
// order.setPaySerialNo(body.getString("wtorderid")); // 支付流水号 order.setPaySerialNo(body.getString("wtorderid")); // 支付流水号
// order.setPayRealPrice(order.getPayPrice()); // 实付金额 order.setPayRealPrice(order.getPayRealPrice()); // 实付金额
//
// order.setStatus(2); order.setPayStatus(102);
// order.setPayType(4); order.setRechargeStatus(204);
// order.setPayTime(new Date()); // 支付时间 order.setPayType(4);
// if (order.getRechargeType() == 1) { order.setPayTime(new Date()); // 支付时间
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() , order.getRechargeType()); outRechargeOrderService.updateOrder(order);
// if (object.getInteger("code") != 200) { outRechargeOrderService.pollRequest(order);
// order.setRechargeStatus(1); }
// order.setAbnormalMsg(object.getString("message"));
// }
// }
// outRechargeOrderService.updateOrder(order);
// }
} }
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());

@ -6,9 +6,11 @@ import com.hai.config.QianZhuConfig;
import com.hai.config.WxOrderConfig; import com.hai.config.WxOrderConfig;
import com.hai.entity.HighChildOrder; import com.hai.entity.HighChildOrder;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.entity.OutRechargeChildOrder;
import com.hai.entity.OutRechargeOrder; import com.hai.entity.OutRechargeOrder;
import com.hai.model.OrderRefundModel; import com.hai.model.OrderRefundModel;
import com.hai.service.HighOrderService; import com.hai.service.HighOrderService;
import com.hai.service.OutRechargeChildOrderService;
import com.hai.service.OutRechargeOrderService; import com.hai.service.OutRechargeOrderService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -38,6 +40,9 @@ public class HighOrderSchedule {
@Resource @Resource
private OutRechargeOrderService outRechargeOrderService; private OutRechargeOrderService outRechargeOrderService;
@Resource
private OutRechargeChildOrderService rechargeChildOrderService;
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 取消订单 15分钟 * @Description 取消订单 15分钟
@ -79,6 +84,57 @@ public class HighOrderSchedule {
} }
} }
/**
* @Author Sum1Dream
* @name cancelOrder.java
* @Description // 定时发起
* @Date 14:18 2022/5/31
* @Param []
* @return void
*/
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void initRechargeOrder() {
Map<String, String> map = new HashMap<>();
map.put("status" , String.valueOf(102));
map.put("rechargeStatus" , String.valueOf(204));
List<OutRechargeOrder> orderList = outRechargeOrderService.getListRechargeOrder(map);
if (orderList != null && orderList.size() > 0) {
for (OutRechargeOrder order : orderList) {
try {
// 查询充值子订单
Map<String, Object> childOrderMap = new HashMap<>();
childOrderMap.put("parent_order_id" , order.getId());
childOrderMap.put("status" , 102);
List<OutRechargeChildOrder> childOrderList = rechargeChildOrderService.getListRechargeChildOrder(childOrderMap);
if (childOrderList.size() == 0) {
Date rechargeTime = order.getCreateTimed();
Date currentTime = new Date();
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60));
// 判断快充 并且 充值时间小于6
if (order.getRechargeType() == 1 && hours < 6) {
outRechargeOrderService.pollRequest(order);
return;
}
// 判断慢充 并且 充值时间小于72
if (order.getRechargeType() == 2 && hours < 72) {
outRechargeOrderService.pollRequest(order);
return;
}
outRechargeOrderService.rechargeOrderToRefund(order.getId());
}
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
}
}
}
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 处理话费充值订单 * @Description 处理话费充值订单

@ -0,0 +1,43 @@
package com.hai.enum_type;
import java.util.Objects;
/**
* 订单状态
* @author hurui
*/
public enum OperatorEnum {
type1(1 , "电信运营商"),
type2(2 , "移动运营商"),
type3(3 , "联通运营商"),
;
private Integer type;
private String name;
OperatorEnum(int type , String name) {
this.type = type;
this.name = name;
}
public static String getNameByType(Integer type) {
for (OperatorEnum ele : values()) {
if(Objects.equals(type,ele.getType())) return ele.getName();
}
return null;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -0,0 +1,17 @@
package com.hai.model;
import com.hai.entity.OutRechargeOrder;
import com.hai.entity.OutRechargePrice;
public class OutRechargeOrderDetailModel extends OutRechargeOrder {
// 产品模型
private OutRechargePrice outRechargePrice;
public OutRechargePrice getOutRechargePrice() {
return outRechargePrice;
}
public void setOutRechargePrice(OutRechargePrice outRechargePrice) {
this.outRechargePrice = outRechargePrice;
}
}

@ -20,6 +20,9 @@ public class UserModel {
// 待支付数量 // 待支付数量
private Integer unpaid; private Integer unpaid;
// 充值订单待支付数量
private Integer rechargeOrderNum;
// 是否设置支付密码 // 是否设置支付密码
private Boolean isSetPayPwd; private Boolean isSetPayPwd;
@ -114,4 +117,12 @@ public class UserModel {
public void setIsSetHltCard(Boolean setHltCard) { public void setIsSetHltCard(Boolean setHltCard) {
isSetHltCard = setHltCard; isSetHltCard = setHltCard;
} }
public Integer getRechargeOrderNum() {
return rechargeOrderNum;
}
public void setRechargeOrderNum(Integer rechargeOrderNum) {
this.rechargeOrderNum = rechargeOrderNum;
}
} }

@ -49,7 +49,7 @@ public interface OutRechargeOrderService {
* @Param [outRechargeOrder] * @Param [outRechargeOrder]
* @return void * @return void
**/ **/
void insertOrder(OutRechargeOrder outRechargeOrder) throws Exception; OutRechargeOrder insertOrder(JSONObject object) throws Exception;
/*** /***
* @Author Sum1Dream * @Author Sum1Dream
@ -165,4 +165,14 @@ public interface OutRechargeOrderService {
*/ */
void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception; void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception;
/**
* @Author Sum1Dream
* @name rechargeOrderNum.java
* @Description // 查询充值订单待支付数量
* @Date 17:49 2022/5/30
* @Param [java.lang.Long]
* @return java.lang.Integer
*/
Integer rechargeOrderNum(Long userId);
} }

@ -37,6 +37,15 @@ public interface OutRechargePriceService {
**/ **/
OutRechargePriceModel findById(Long id , Integer platformId); OutRechargePriceModel findById(Long id , Integer platformId);
/**
* @Author Sum1Dream
* @Description //查询详情 Administrator
* @Date 17:40 2021/6/12
* @Param [id]
* @return com.hai.entity.OutRechargePrice
**/
OutRechargePrice findByGoodsId(Long goodsId);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Description //新增 Administrator * @Description //新增 Administrator

@ -40,6 +40,9 @@ public class HighUserServiceImpl implements HighUserService {
@Resource @Resource
private HighUserCouponService highUserCouponService; private HighUserCouponService highUserCouponService;
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource @Resource
private HighUserCardService highUserCardService; private HighUserCardService highUserCardService;
@ -98,6 +101,7 @@ public class HighUserServiceImpl implements HighUserService {
} }
user.setUnusedCouponNum(highUserCouponService.getCouponList(userId, 1).size()); //未使用卡卷数量 user.setUnusedCouponNum(highUserCouponService.getCouponList(userId, 1).size()); //未使用卡卷数量
user.setUnpaid(highOrderService.countOrderByUserId(userId , 1)); user.setUnpaid(highOrderService.countOrderByUserId(userId , 1));
user.setRechargeOrderNum(outRechargeOrderService.rechargeOrderNum(userId));
user.setUnusedDiscount(highOrderService.countUnusedDiscountByUserId(userId , 1)); user.setUnusedDiscount(highOrderService.countUnusedDiscountByUserId(userId , 1));
user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userId)); user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userId));
user.setIsSetHltCard(highUserCardService.isBindHtlCard(userId)); user.setIsSetHltCard(highUserCardService.isBindHtlCard(userId));
@ -218,7 +222,7 @@ public class HighUserServiceImpl implements HighUserService {
} }
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation= Propagation.REQUIRED)
public void goldHandle(Long userId, Integer goldNum, Integer goldType, Integer resType, Long resId) { public void goldHandle(Long userId, Integer goldNum, Integer goldType, Integer resType, Long resId) {
// 查询用户信息 // 查询用户信息
HighUser user = highUserMapper.selectByPrimaryKey(userId); HighUser user = highUserMapper.selectByPrimaryKey(userId);

@ -7,12 +7,15 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.security.AESEncodeUtil;
import com.hai.common.utils.*; import com.hai.common.utils.*;
import com.hai.config.*; import com.hai.config.*;
import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighGasOrderPushMapper;
import com.hai.dao.OutRechargeOrderMapper; import com.hai.dao.OutRechargeOrderMapper;
import com.hai.dao.OutRechargeOrderMapperExt; import com.hai.dao.OutRechargeOrderMapperExt;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.DiscountUseScope;
import com.hai.enum_type.OperatorEnum;
import com.hai.enum_type.OrderPushType; import com.hai.enum_type.OrderPushType;
import com.hai.enum_type.RechargePayType; import com.hai.enum_type.RechargePayType;
import com.hai.model.*; import com.hai.model.*;
@ -28,12 +31,14 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -76,6 +81,17 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource @Resource
private BsRequestRecordService bsRequestRecordService; private BsRequestRecordService bsRequestRecordService;
@Resource
private BsConfigService bsConfigService;
@Resource
private SecConfigService secConfigService;
@Resource
private HighUserPayPasswordService highUserPayPasswordService;
@Override @Override
public List<OutRechargeOrder> getListRechargeOrder(Map<String, String> map) { public List<OutRechargeOrder> getListRechargeOrder(Map<String, String> map) {
OutRechargeOrderExample example = new OutRechargeOrderExample(); OutRechargeOrderExample example = new OutRechargeOrderExample();
@ -105,6 +121,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone")); criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone"));
} }
if (MapUtils.getInteger(map, "status") != null) {
criteria.andPayStatusEqualTo(MapUtils.getInteger(map, "status"));
}
if (MapUtils.getInteger(map, "rechargeStatus") != null) {
criteria.andRechargeStatusEqualTo(MapUtils.getInteger(map, "rechargeStatus"));
}
if (StringUtils.isNotBlank(map.get("payTimeS")) && StringUtils.isNotBlank(map.get("payTimeE"))) { if (StringUtils.isNotBlank(map.get("payTimeS")) && StringUtils.isNotBlank(map.get("payTimeE"))) {
criteria.andPayTimeBetween( criteria.andPayTimeBetween(
@ -134,8 +157,167 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(
public void insertOrder(OutRechargeOrder outRechargeOrder) throws Exception { 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"));
// 产品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_DOWN));
// 最高可抵扣金额
BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_DOWN);
// 判读积分是否大于限制额度
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(object.getLong("userId"));
outRechargeOrder.setIntegralNum(object.getBigDecimal("integralNum"));
outRechargeOrder.setRechargeContent(rechargeContent);
outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId());
outRechargeOrder.setUserName(object.getString("username"));
outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType());
outRechargeOrder.setUserPhone(object.getString("phone"));
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setCreateTimed(new Date());
outRechargeOrder.setGoodsId(goodsId);
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) { if (outRechargeOrder.getMemDiscountId() != null) {
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId());
@ -147,16 +329,22 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
code.setStatus(3); code.setStatus(3);
highDiscountAgentCodeService.updateCode(code); highDiscountAgentCodeService.updateCode(code);
} }
if (outRechargeOrder.getIntegralNum() != null) {
highUserService.goldHandle(outRechargeOrder.getUserId(), outRechargeOrder.getIntegralNum().intValue(), 2, 2, outRechargeOrder.getId());
}
outRechargeOrderMapper.insert(outRechargeOrder); outRechargeOrderMapper.insert(outRechargeOrder);
if (outRechargeOrder.getRechargeStatus() == 201 && outRechargeOrder.getPayStatus() == 102) { if (outRechargeOrder.getPayStatus() == 102) {
pollRequest(outRechargeOrder); pollRequest(outRechargeOrder);
} }
return outRechargeOrder;
} }
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void updateOrder(OutRechargeOrder outRechargeOrder) { public void updateOrder(OutRechargeOrder outRechargeOrder) {
outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder); outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder);
} }
@ -366,13 +554,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号 order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
order.setPayRealPrice(order.getPayRealPrice()); // 实付金额 order.setPayRealPrice(order.getPayRealPrice()); // 实付金额
outRechargeOrderService.pollRequest(order);
order.setPayStatus(102); order.setPayStatus(102);
order.setRechargeStatus(201); order.setRechargeStatus(204);
order.setLaborUnionCard(userCard.getCardNo()); order.setLaborUnionCard(userCard.getCardNo());
order.setPayType(3); order.setPayType(3);
order.setPayTime(new Date()); // 支付时间 order.setPayTime(new Date()); // 支付时间
updateOrder(order); updateOrder(order);
outRechargeOrderService.pollRequest(order);
} }
@Override @Override
@ -387,7 +576,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void rechargeOrderToRefund(Long orderId) throws Exception { public void rechargeOrderToRefund(Long orderId) throws Exception {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
@ -396,8 +584,26 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
} }
// 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值
if (order.getRechargeStatus() == 201) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态");
}
// 1:支付宝 2:微信 3:汇联通工会卡 4:银联 5:银联分期
if (order.getPayType() == null) {
// 退还积分
if (order.getIntegralNum() != null) {
highUserService.goldHandle(order.getUserId(), order.getIntegralNum().intValue(), 1, 3, order.getId());
if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) {
order.setPayStatus(105);
order.setRechargeStatus(203);
order.setRefundTime(new Date());
outRechargeOrderService.updateOrder(order);
}
}
} else {
// 微信退款 // 微信退款
if (order.getPayType() == 1) { if (order.getPayType() == 2) {
Map<String,String> param = new HashMap<>(); Map<String,String> param = new HashMap<>();
param.put("appid", "wx637bd6f7314daa46"); param.put("appid", "wx637bd6f7314daa46");
param.put("mch_id", "1289663601"); param.put("mch_id", "1289663601");
@ -428,7 +634,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
// 工会卡退款 // 工会卡退款
if (order.getPayType() == 2) { if (order.getPayType() == 3) {
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo());
if (jsonObject == null) { if (jsonObject == null) {
@ -451,8 +657,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
} }
// 银联退款 // 银联退款
if (order.getPayType() == 4) { if (order.getPayType() == 4) {
// 订单退款 // 订单退款
@ -467,6 +671,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
order.setRefundFee(order.getPayRealPrice()); order.setRefundFee(order.getPayRealPrice());
outRechargeOrderService.updateOrder(order); outRechargeOrderService.updateOrder(order);
} }
}
if (order.getMemDiscountId() != null) { if (order.getMemDiscountId() != null) {
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
@ -514,7 +720,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception {
// 查询充值产品 // 查询充值产品
@ -552,14 +757,20 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
for (String s : rechargePlatform) { for (String s : rechargePlatform) {
// 尖椒充值 // 尖椒充值
if (s.equals("1") && type == 2) { if (s.equals("1") && (type == 2 || type == 0)) {
object.put("out_order_id" ,orderNo ); object.put("out_order_id" ,orderNo );
object.put("amount" , outRechargePrice.getRechargePrice()); object.put("amount" , outRechargePrice.getRechargePrice());
object.put("mobile" , outRechargeOrder.getRechargeContent()); object.put("mobile" , outRechargeOrder.getRechargeContent());
if (outRechargePrice.getRechargeType() == 1) { if (outRechargePrice.getRechargeType() == 1) {
object.put("is_fast" , 1); object.put("is_fast" , 1);
} }
RechargeConfig.rechargeOrderByJj(object); JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
object.put("return_content" , returnObject);
if (returnObject != null && returnObject.getLong("code") == 200) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
rechargePlatformType = 1; rechargePlatformType = 1;
break; break;
} }
@ -567,7 +778,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
object.put("out_trade_num" , orderNo); object.put("out_trade_num" , orderNo);
object.put("product_id" , outRechargePrice.getGoodsId()); object.put("product_id" , outRechargePrice.getGoodsId());
object.put("mobile" , outRechargeOrder.getRechargeContent()); object.put("mobile" , outRechargeOrder.getRechargeContent());
RechargeConfig.rechargeOrderByLy(object); JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
object.put("return_content" , returnObject);
if (returnObject != null && returnObject.getLong("errno") == 0) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
rechargePlatformType = 2; rechargePlatformType = 2;
break; break;
} }
@ -576,7 +793,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
childOrder.setOrderNo(orderNo); childOrder.setOrderNo(orderNo);
childOrder.setCreateTime(new Date()); childOrder.setCreateTime(new Date());
childOrder.setParentOrderId(outRechargeOrder.getId()); childOrder.setParentOrderId(outRechargeOrder.getId());
childOrder.setStatus(102);
childOrder.setRechargePlatform(rechargePlatformType); childOrder.setRechargePlatform(rechargePlatformType);
childOrder.setUpdateTime(new Date()); childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.insertOrder(childOrder); outRechargeChildOrderService.insertOrder(childOrder);
@ -586,7 +802,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
requestRecord.setCreateTime(new Date()); requestRecord.setCreateTime(new Date());
requestRecord.setUpdateTime(new Date()); requestRecord.setUpdateTime(new Date());
requestRecord.setOrderNo(orderNo); requestRecord.setOrderNo(orderNo);
requestRecord.setRequestContent(String.valueOf(object)); requestRecord.setRequestContent(object.toJSONString());
requestRecord.setOperatorId(0L); requestRecord.setOperatorId(0L);
requestRecord.setOperatorName("系统生成"); requestRecord.setOperatorName("系统生成");
requestRecord.setSourceId(childOrder.getId().toString()); requestRecord.setSourceId(childOrder.getId().toString());
@ -594,6 +810,21 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
bsRequestRecordService.insertRequestRecord(requestRecord); bsRequestRecordService.insertRequestRecord(requestRecord);
// 判断是否充值提交成功
if (childOrder.getStatus() == 102) {
outRechargeOrder.setRechargeStatus(201);
outRechargeOrderService.updateOrder(outRechargeOrder);
}
}
@Override
public Integer rechargeOrderNum(Long userId) {
OutRechargeOrderExample example = new OutRechargeOrderExample();
OutRechargeOrderExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andPayStatusEqualTo(101);
return outRechargeOrderMapper.selectByExample(example).size();
} }
} }

@ -90,6 +90,22 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
return outRechargePriceModel; return outRechargePriceModel;
} }
@Override
public OutRechargePrice findByGoodsId(Long goodsId) {
OutRechargePriceExample example = new OutRechargePriceExample();
OutRechargePriceExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(goodsId).andStatusEqualTo(1);
List<OutRechargePrice> list = outRechargePriceMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)

@ -55,8 +55,8 @@ public class RechargeOrderServiceImpl implements PayService {
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void paySuccess(Map<String, String> map, String payType) throws Exception { public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) { if (payType.equals("Alipay")) {
// 支付宝支付 todo 暂未开发 // 支付宝支付 todo 暂未开发
return; return;
@ -64,11 +64,23 @@ public class RechargeOrderServiceImpl implements PayService {
if (payType.equals("WechatPay")) { if (payType.equals("WechatPay")) {
// 查询订单信息 // 查询订单信息
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(map.get("out_trade_no")); OutRechargeOrder order = outRechargeOrderService.findByOrderNo(map.get("out_trade_no"));
// if (order != null && order.getStatus() == 1) { // 推送订单记录
// order.setPaySerialNo(map.get("transaction_id")); // 支付流水号 HighGasOrderPush highGasOrderPush = new HighGasOrderPush();
// order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额 highGasOrderPush.setType(OrderPushType.type2.getType());
// order.setPayTime(new Date()); // 支付时间 highGasOrderPush.setOrderNo(order.getOrderNo());
// order.setStatus(2); // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 highGasOrderPush.setCreateTime(new Date());
highGasOrderPush.setRequestContent(order.getOrderNo());
highGasOrderPush.setReturnContent(String.valueOf(map));
highGasOrderPushMapper.insert(highGasOrderPush);
if (order.getPayStatus() == 101) {
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
order.setPayTime(new Date()); // 支付时间
// 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
order.setPayStatus(102);
order.setRechargeStatus(204);
order.setPayType(2);
outRechargeOrderService.updateOrder(order);
// if (order.getRechargeType() == 1) { // if (order.getRechargeType() == 1) {
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() , order.getRechargeType()); // JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() , order.getRechargeType());
// if (object.getInteger("code") != 200) { // if (object.getInteger("code") != 200) {
@ -76,16 +88,9 @@ public class RechargeOrderServiceImpl implements PayService {
// order.setAbnormalMsg(object.getString("message")); // order.setAbnormalMsg(object.getString("message"));
// } // }
// } // }
// outRechargeOrderService.updateOrder(order); outRechargeOrderService.pollRequest(order);
// // 推送订单记录
// HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); }
// highGasOrderPush.setType(OrderPushType.type2.getType());
// highGasOrderPush.setOrderNo(order.getOrderNo());
// highGasOrderPush.setCreateTime(new Date());
// highGasOrderPush.setRequestContent(order.getOrderNo());
// highGasOrderPush.setReturnContent(String.valueOf(map));
// highGasOrderPushMapper.insert(highGasOrderPush);
// }
} }
} }

Loading…
Cancel
Save