|
@@ -6,9 +6,12 @@ import java.time.ZoneId;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
@@ -24,14 +27,12 @@ import com.fs.course.param.FsUserVipOrderCreateUParam;
|
|
import com.fs.course.param.FsUserVipOrderParam;
|
|
import com.fs.course.param.FsUserVipOrderParam;
|
|
import com.fs.course.param.FsUserVipOrderPayUParam;
|
|
import com.fs.course.param.FsUserVipOrderPayUParam;
|
|
import com.fs.course.vo.FsUserVipOrderListPVO;
|
|
import com.fs.course.vo.FsUserVipOrderListPVO;
|
|
-import com.fs.his.domain.FsPayConfig;
|
|
|
|
-import com.fs.his.domain.FsStorePayment;
|
|
|
|
-import com.fs.his.domain.FsStorePaymentError;
|
|
|
|
-import com.fs.his.domain.FsUser;
|
|
|
|
|
|
+import com.fs.his.domain.*;
|
|
import com.fs.his.dto.PayConfigDTO;
|
|
import com.fs.his.dto.PayConfigDTO;
|
|
import com.fs.his.mapper.FsStorePaymentErrorMapper;
|
|
import com.fs.his.mapper.FsStorePaymentErrorMapper;
|
|
import com.fs.his.mapper.FsStorePaymentMapper;
|
|
import com.fs.his.mapper.FsStorePaymentMapper;
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
|
+import com.fs.his.mapper.FsUserWxMapper;
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
@@ -111,6 +112,8 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IPayService payService;
|
|
private IPayService payService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private FsUserWxMapper fsUserWxMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -229,13 +232,26 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
|
|
return R.error("非法操作");
|
|
return R.error("非法操作");
|
|
}
|
|
}
|
|
FsUser user = userMapper.selectFsUserByUserId(param.getUserId());
|
|
FsUser user = userMapper.selectFsUserByUserId(param.getUserId());
|
|
- if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())) {
|
|
|
|
|
|
+
|
|
|
|
+ String json = configService.selectConfigByKey("his.pay");
|
|
|
|
+ PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
|
+
|
|
|
|
+ String openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
|
+ if (StringUtils.isBlank(openId)){
|
|
|
|
+ Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
|
+ .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
|
+ .eq(FsUserWx::getAppId, payConfigDTO.getAppId());
|
|
|
|
+ FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
|
+ if (Objects.nonNull(fsUserWx)){
|
|
|
|
+ openId = fsUserWx.getOpenId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(user!=null&& StringUtils.isNotEmpty(openId)) {
|
|
if (order.getPayMoney().compareTo(new BigDecimal(0)) == 0) {
|
|
if (order.getPayMoney().compareTo(new BigDecimal(0)) == 0) {
|
|
this.payConfirm(order.getOrderCode(), "", "", "", 2);
|
|
this.payConfirm(order.getOrderCode(), "", "", "", 2);
|
|
return R.ok().put("isPay", 1);
|
|
return R.ok().put("isPay", 1);
|
|
} else {
|
|
} else {
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
|
- PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
|
String payCode = OrderCodeUtils.getOrderSn();
|
|
String payCode = OrderCodeUtils.getOrderSn();
|
|
if(StringUtils.isEmpty(payCode)){
|
|
if(StringUtils.isEmpty(payCode)){
|
|
return R.error("订单生成失败,请重试");
|
|
return R.error("订单生成失败,请重试");
|
|
@@ -250,7 +266,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
|
|
storePayment.setPayTypeCode("weixin");
|
|
storePayment.setPayTypeCode("weixin");
|
|
storePayment.setBusinessType(5);
|
|
storePayment.setBusinessType(5);
|
|
storePayment.setRemark("会员开通订单支付");
|
|
storePayment.setRemark("会员开通订单支付");
|
|
- storePayment.setOpenId(user.getMaOpenId());
|
|
|
|
|
|
+ storePayment.setOpenId(openId);
|
|
storePayment.setUserId(user.getUserId());
|
|
storePayment.setUserId(user.getUserId());
|
|
storePayment.setBusinessId(order.getOrderId().toString());
|
|
storePayment.setBusinessId(order.getOrderId().toString());
|
|
if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
|
|
if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
|
|
@@ -268,7 +284,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
|
|
payConfig.setNotifyUrl(wxPayProperties.getNotifyUrl());
|
|
payConfig.setNotifyUrl(wxPayProperties.getNotifyUrl());
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
- orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
|
|
|
|
|
|
+ orderRequest.setOpenid(openId);//公众号支付提供用户openid
|
|
orderRequest.setBody("会员开通订单支付");
|
|
orderRequest.setBody("会员开通订单支付");
|
|
orderRequest.setOutTradeNo("appvip-" + storePayment.getPayCode());
|
|
orderRequest.setOutTradeNo("appvip-" + storePayment.getPayCode());
|
|
orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
@@ -290,7 +306,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
|
|
p.setLowOrderId("appvip-" + storePayment.getPayCode());
|
|
p.setLowOrderId("appvip-" + storePayment.getPayCode());
|
|
p.setBody("会员开通订单支付");
|
|
p.setBody("会员开通订单支付");
|
|
p.setIsMinipg("1");
|
|
p.setIsMinipg("1");
|
|
- p.setOpenId(user.getMaOpenId());
|
|
|
|
|
|
+ p.setOpenId(openId);
|
|
p.setAttach("");
|
|
p.setAttach("");
|
|
p.setStoreid("0");
|
|
p.setStoreid("0");
|
|
CreateWxOrderResult wxOrder = payService.createWxOrder(p);
|
|
CreateWxOrderResult wxOrder = payService.createWxOrder(p);
|
|
@@ -314,7 +330,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
|
|
}
|
|
}
|
|
o.setPayerName("微信用户" + phone);
|
|
o.setPayerName("微信用户" + phone);
|
|
o.setGoodsInfo("会员开通订单支付"); // 订单信息
|
|
o.setGoodsInfo("会员开通订单支付"); // 订单信息
|
|
- o.setOpenId(user.getMaOpenId());
|
|
|
|
|
|
+ o.setOpenId(openId);
|
|
o.setOrderType(5);
|
|
o.setOrderType(5);
|
|
o.setOrderId(order.getOrderId().toString());
|
|
o.setOrderId(order.getOrderId().toString());
|
|
TzBankResult<PayCreateOrderResult> result = tzBankService.createOrder(o);
|
|
TzBankResult<PayCreateOrderResult> result = tzBankService.createOrder(o);
|
|
@@ -326,7 +342,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
|
|
} else if (payConfigDTO.getType().equals("hf")) {
|
|
} else if (payConfigDTO.getType().equals("hf")) {
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
o.setTradeType("T_MINIAPP");
|
|
o.setTradeType("T_MINIAPP");
|
|
- o.setOpenid(user.getMaOpenId());
|
|
|
|
|
|
+ o.setOpenid(openId);
|
|
o.setReqSeqId("appvip-" + storePayment.getPayCode());
|
|
o.setReqSeqId("appvip-" + storePayment.getPayCode());
|
|
o.setTransAmt(storePayment.getPayMoney().toString());
|
|
o.setTransAmt(storePayment.getPayMoney().toString());
|
|
o.setGoodsDesc("会员开通订单支付");
|
|
o.setGoodsDesc("会员开通订单支付");
|