提交代码

dev-discount
胡锐 3 years ago
parent afc7683b70
commit e516380bda
  1. 63
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  2. 7
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  3. 26
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java

@ -2,6 +2,7 @@ package com.cweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.cweb.config.SysConst;
import com.cweb.config.WxMsgConfig;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -19,6 +20,8 @@ import com.hai.common.security.UserCenter;
import com.hai.common.utils.*;
import com.hai.dao.SecDictionaryMapper;
import com.hai.entity.*;
import com.hai.enum_type.GoodsType;
import com.hai.enum_type.PayType;
import com.hai.model.HighUserModel;
import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData;
@ -350,6 +353,66 @@ public class OutRechargeOrderController {
}
}
@RequestMapping(value="/orderToGoldPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "订单支付发起金币支付")
public ResponseData orderToGoldPay(@RequestBody String reqBodyStr,HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
Long orderId = jsonObject.getLong("orderId");
String password = jsonObject.getString("password");
if (orderId == null) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询用户支付密码
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(password)) {
log.error("orderToPay error!", "未输入支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
}
// 校验支付密码是否一直
if (!AESEncodeUtil.aesEncrypt(password).equals(userPayPassword.getPassword())) {
log.error("orderToPay error!", "");
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
}
// 订单
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
if (order == null) {
log.error("hltUnionCardPay error!", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
if (order.getStatus() != 1) {
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
}
outRechargeOrderService.goldPayOrder(userInfoModel.getHighUser().getId(), order.getId());
return ResponseMsgUtil.success("支付成功");
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/orderToRefund", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "订单退款")

@ -113,4 +113,11 @@ public interface OutRechargeOrderService {
* @param orderId
*/
void hltUnionCardPay(Long userCardId, Long orderId);
/**
* 积分支付
* @param userId
* @param orderId
*/
void goldPayOrder(Long userId, Long orderId);
}

@ -16,6 +16,7 @@ import com.hai.model.OutOrderModel;
import com.hai.model.OutRechargeOrderModel;
import com.hai.model.OutUserOrderModel;
import com.hai.service.HighUserCardService;
import com.hai.service.HighUserService;
import com.hai.service.OutRechargeOrderService;
import io.swagger.models.auth.In;
import org.apache.commons.collections4.MapUtils;
@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@ -44,6 +46,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
@Resource
private HighUserService highUserService;
@Override
public List<OutRechargeOrder> getListRechargeOrder(Map<String, String> map) {
OutRechargeOrderExample example = new OutRechargeOrderExample();
@ -302,4 +307,25 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
e.printStackTrace();
}
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void goldPayOrder(Long userId, Long orderId) {
OutRechargeOrder order = findByOrderId(orderId);
if(order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
// 查询用户
HighUser highUser = highUserService.findByUserId(userId);
// 金币 1:100
Integer goldNum = new BigDecimal(order.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue();
highUserService.goldHandle(userId, goldNum, 2, 2, order.getId());
order.setPayRealPrice(order.getPayPrice()); // 实付金额
order.setStatus(2);
order.setPayType(3);
order.setPayTime(new Date()); // 支付时间
updateOrder(order);
}
}

Loading…
Cancel
Save