|
|
@@ -17,6 +17,12 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alipay.api.AlipayClient;
|
|
|
+import com.alipay.api.DefaultAlipayClient;
|
|
|
+import com.alipay.api.diagnosis.DiagnosisUtils;
|
|
|
+import com.alipay.api.domain.AlipayTradeAppPayModel;
|
|
|
+import com.alipay.api.request.AlipayTradeAppPayRequest;
|
|
|
+import com.alipay.api.response.AlipayTradeAppPayResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.constant.FsConstants;
|
|
|
@@ -33,6 +39,8 @@ import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.core.config.WxPayProperties;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
+import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.dto.PackageConfigDTO;
|
|
|
@@ -47,6 +55,7 @@ import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.utils.HttpUtil;
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.*;
|
|
|
+import com.fs.hisStore.domain.FsPayConfigScrm;
|
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
|
@@ -74,6 +83,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
import com.google.gson.Gson;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -84,12 +94,15 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
/**
|
|
|
* 套餐订单Service业务层处理
|
|
|
*
|
|
|
* @author fs
|
|
|
* @date 2023-08-25
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
{
|
|
|
@@ -98,6 +111,11 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
private WxPayService wxPayService;
|
|
|
@Autowired
|
|
|
private WxPayProperties wxPayProperties;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
|
|
|
+ @Autowired
|
|
|
+ private MerchantAppConfigMapper merchantAppConfigMapper;
|
|
|
@Autowired
|
|
|
IPayService payService;
|
|
|
@Autowired
|
|
|
@@ -866,7 +884,6 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3,orderId);
|
|
|
if(payments!=null&&payments.size()==1){
|
|
|
FsStorePayment payment=payments.get(0);
|
|
|
- String json=configService.selectConfigByKey("his.pay");
|
|
|
if(payment.getPayMode().equals("wx")){
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(wxPayProperties.getAppId());
|
|
|
@@ -964,7 +981,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public R payment(FsPackageOrderDoPayParam param) {
|
|
|
+ public R payment(FsPackageOrderDoPayParam param, HttpServletRequest request) {
|
|
|
//更新订单状态
|
|
|
FsPackageOrder fsPackageOrder=fsPackageOrderMapper.selectFsPackageOrderByOrderId(param.getOrderId());
|
|
|
if(!fsPackageOrder.getStatus().equals(FsPackageOrderStatusEnum.STATUS_1.getValue())){
|
|
|
@@ -979,36 +996,57 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
|
|
|
FsUser user=userService.selectFsUserByUserId(param.getUserId());
|
|
|
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
//金牛多小程序支付
|
|
|
String openId = null;
|
|
|
String appId = param.getAppId();
|
|
|
- if (StringUtils.isNotBlank(appId)) {
|
|
|
- //查询fs_user_wx的openId
|
|
|
- Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
- .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
- .eq(FsUserWx::getAppId, appId);
|
|
|
- FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
- if (fsUserWx != null) {
|
|
|
- openId = fsUserWx.getOpenId();
|
|
|
- }
|
|
|
+ if (request.getHeader("sourcetype") != null && "APP".equals(request.getHeader("sourcetype"))) {
|
|
|
+ FsUser fsUser = fsUserService.selectFsUserByUserId(param.getUserId().longValue());
|
|
|
+ openId = fsUser.getAppOpenId();
|
|
|
} else {
|
|
|
- appId = payConfigDTO.getAppId();
|
|
|
- openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
- if (StringUtils.isBlank(openId)){
|
|
|
+ if (StringUtils.isNotBlank(appId)) {
|
|
|
+ //查询fs_user_wx的openId
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
.eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
.eq(FsUserWx::getAppId, appId);
|
|
|
FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
- if (Objects.nonNull(fsUserWx)){
|
|
|
+ if (fsUserWx != null) {
|
|
|
openId = fsUserWx.getOpenId();
|
|
|
}
|
|
|
+ } else {
|
|
|
+ appId = fsCoursePlaySourceConfig.getAppid();
|
|
|
+ openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
+ if (StringUtils.isBlank(openId)){
|
|
|
+ Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
+ .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
+ .eq(FsUserWx::getAppId, appId);
|
|
|
+ FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
+ if (Objects.nonNull(fsUserWx)){
|
|
|
+ openId = fsUserWx.getOpenId();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(user!=null&& StringUtils.isNotEmpty(openId)){
|
|
|
+ if (user != null
|
|
|
+ && (
|
|
|
+ StringUtils.isNotEmpty(openId)
|
|
|
+ || "appPay".equals(merchantAppConfig.getMerchantType())
|
|
|
+ || ("hf".equals(merchantAppConfig.getMerchantType()) && "ali".equals(param.getPayType()))
|
|
|
+ )) {
|
|
|
if(fsPackageOrder.getPayMoney().compareTo(new BigDecimal(0))==1){
|
|
|
String payCode = OrderCodeUtils.getOrderSn();
|
|
|
if(StringUtils.isEmpty(payCode)){
|
|
|
@@ -1016,12 +1054,12 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
}
|
|
|
FsStorePayment storePayment=new FsStorePayment();
|
|
|
storePayment.setStatus(0);
|
|
|
- storePayment.setPayMode(payConfigDTO.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(fsPackageOrder.getPayMoney());
|
|
|
storePayment.setCreateTime(new Date());
|
|
|
- storePayment.setPayTypeCode("weixin");
|
|
|
+ storePayment.setPayTypeCode(!"appPay".equals(merchantAppConfig.getMerchantType()) ? "weixin" : param.getPayType());
|
|
|
storePayment.setBusinessType(3);
|
|
|
storePayment.setCompanyId(fsPackageOrder.getCompanyId());
|
|
|
storePayment.setCompanyUserId(fsPackageOrder.getCompanyUserId());
|
|
|
@@ -1030,12 +1068,11 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setStoreId(fsPackageOrder.getStoreId());
|
|
|
storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
|
|
|
+ storePayment.setMerchantId(merchantAppConfig.getId());
|
|
|
if(storePaymentService.insertFsStorePayment(storePayment)>0){
|
|
|
- if (payConfigDTO.getType().equals("wx")) {
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("wx")) {
|
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
|
|
|
- FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
|
|
|
payConfig.setAppId(appId);
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
@@ -1060,7 +1097,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
e.printStackTrace();
|
|
|
throw new CustomException("支付失败" + e.getMessage());
|
|
|
}
|
|
|
- } else if (payConfigDTO.getType().equals("yb")) {
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("yb")) {
|
|
|
WxJspayDTO p = new WxJspayDTO();
|
|
|
// 使用setter方法为对象赋值
|
|
|
p.setPayMoney(storePayment.getPayMoney().toString());
|
|
|
@@ -1081,7 +1118,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
} else {
|
|
|
throw new CustomException("支付失败");
|
|
|
}
|
|
|
- } else if (payConfigDTO.getType().equals("tz")) {
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("tz")) {
|
|
|
PayCreateOrder o = new PayCreateOrder();
|
|
|
o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
|
|
|
o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
|
|
|
@@ -1106,10 +1143,10 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
mt.setTradeNo(result.getBody().getOrderFlowNo());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
|
|
|
- }else if (payConfigDTO.getType().equals("hf")) {
|
|
|
+ }else if (merchantAppConfig.getMerchantType().equals("hf")) {
|
|
|
logger.info("创建汇付订单");
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
- o.setTradeType("T_MINIAPP");
|
|
|
+ o.setTradeType(StringUtils.isEmpty(param.getPayType()) || param.getPayType().equals("wx") ? "T_MINIAPP" : "A_NATIVE");
|
|
|
o.setOpenid(openId);
|
|
|
o.setReqSeqId("package-"+storePayment.getPayCode());
|
|
|
o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
@@ -1132,6 +1169,61 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
mt.setAppId(appId);
|
|
|
storePaymentService.updateFsStorePayment(mt);
|
|
|
return R.ok().put("isPay", 0).put("data", result).put("type", "hf");
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("appPay") && "wx".equals(param.getPayType())) {
|
|
|
+ //创建微信订单
|
|
|
+ WxPayConfig payConfig = new WxPayConfig();
|
|
|
+ payConfig.setAppId(appId);
|
|
|
+ payConfig.setMchId(fsPayConfig.getWxAppMchId());
|
|
|
+ payConfig.setMchKey(fsPayConfig.getWxAppMchKey());
|
|
|
+ payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setKeyPath(null);
|
|
|
+ payConfig.setNotifyUrl(fsPayConfig.getWxAppNotifyUrl());
|
|
|
+ wxPayService.setConfig(payConfig);
|
|
|
+ WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
+ orderRequest.setBody("套餐包订单支付");
|
|
|
+ orderRequest.setOutTradeNo("package-"+storePayment.getPayCode());
|
|
|
+ orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));
|
|
|
+ orderRequest.setTradeType("APP");
|
|
|
+ orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(request));
|
|
|
+ orderRequest.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
|
|
|
+ //调用统一下单接口,获取"预支付交易会话标识"
|
|
|
+ try {
|
|
|
+ Object result = wxPayService.createOrder(orderRequest);
|
|
|
+ return R.ok().put("data",result).put("type","wxApp").put("isPay",0);
|
|
|
+ } catch (WxPayException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CustomException("支付失败"+e.getMessage());
|
|
|
+ }
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("appPay") && "ali".equals(param.getPayType())) {
|
|
|
+ // 实例化客户端
|
|
|
+ AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", fsPayConfig.getAliAppId(), fsPayConfig.getAliPrivateKey(), "json", "utf-8", fsPayConfig.getAliPublicKey(), "RSA2");
|
|
|
+
|
|
|
+ // 构造请求参数以调用接口
|
|
|
+ AlipayTradeAppPayRequest aliRequest = new AlipayTradeAppPayRequest();
|
|
|
+ AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
|
|
|
+ // 商户订单号
|
|
|
+ model.setOutTradeNo("package-" + storePayment.getPayCode());
|
|
|
+ // 订单总金额
|
|
|
+ model.setTotalAmount(storePayment.getPayMoney().toString());
|
|
|
+ // 订单标题r
|
|
|
+ model.setSubject("套餐包订单支付");
|
|
|
+
|
|
|
+ aliRequest.setBizModel(model);
|
|
|
+ aliRequest.setNotifyUrl(fsPayConfig.getAliNotifyUrl());
|
|
|
+
|
|
|
+ try {
|
|
|
+ AlipayTradeAppPayResponse result = alipayClient.sdkExecute(aliRequest);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(result);
|
|
|
+ log.error("支付宝支付调用失败 诊断链接:{}", diagnosisUrl);
|
|
|
+ throw new CustomException(result.getSubMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok().put("isPay", 0).put("data", result).put("type", "aliPay");
|
|
|
+ } catch (Exception e){
|
|
|
+ log.info("支付宝支付异常: {}", e);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1211,8 +1303,18 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
if(StringUtils.isEmpty(payCode)){
|
|
|
return R.error("订单生成失败,请重试");
|
|
|
}
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
String openId = null;
|
|
|
String appId = param.getAppId();
|
|
|
if (StringUtils.isNotBlank(appId)) {
|
|
|
@@ -1225,7 +1327,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
openId = fsUserWx.getOpenId();
|
|
|
}
|
|
|
} else {
|
|
|
- appId = payConfigDTO.getAppId();
|
|
|
+ appId = merchantAppConfig.getAppId();
|
|
|
openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
if (StringUtils.isBlank(openId)){
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
@@ -1240,7 +1342,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
|
|
|
FsStorePayment storePayment=new FsStorePayment();
|
|
|
storePayment.setStatus(0);
|
|
|
- storePayment.setPayMode(payConfigDTO.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(fsPackageOrder.getPayMoney());
|
|
|
@@ -1254,11 +1356,12 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setStoreId(fsPackageOrder.getStoreId());
|
|
|
storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
|
|
|
+ storePayment.setMerchantId(merchantAppConfig.getId());
|
|
|
if(storePaymentService.insertFsStorePayment(storePayment)>0){
|
|
|
|
|
|
- if (payConfigDTO.getType().equals("yb")) {
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("yb")) {
|
|
|
return R.error("支付暂不可用!");
|
|
|
- } else if (payConfigDTO.getType().equals("tz")) {
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("tz")) {
|
|
|
PayCreateOrder o = new PayCreateOrder();
|
|
|
o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
|
|
|
o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
|
|
|
@@ -1279,7 +1382,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
mt.setTradeNo(result.getBody().getOrderFlowNo());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
|
|
|
- }else if (payConfigDTO.getType().equals("hf")) {
|
|
|
+ }else if (merchantAppConfig.getMerchantType().equals("hf")) {
|
|
|
logger.info("创建汇付订单");
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("A_NATIVE");
|
|
|
@@ -1320,8 +1423,19 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
//如果存在优惠券 判断优惠券是否已使用
|
|
|
FsUser user=userService.selectFsUserByUserId(param.getUserId());
|
|
|
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+// PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
|
|
|
String openId = null;
|
|
|
String appId = param.getAppId();
|
|
|
@@ -1335,7 +1449,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
openId = fsUserWx.getOpenId();
|
|
|
}
|
|
|
} else {
|
|
|
- appId = payConfigDTO.getAppId();
|
|
|
+ appId = merchantAppConfig.getAppId();
|
|
|
openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
if (StringUtils.isBlank(openId)){
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
@@ -1358,7 +1472,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
}
|
|
|
FsStorePayment storePayment=new FsStorePayment();
|
|
|
storePayment.setStatus(0);
|
|
|
- storePayment.setPayMode(payConfigDTO.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(fsPackageOrder.getPayMoney());
|
|
|
@@ -1372,10 +1486,11 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setStoreId(fsPackageOrder.getStoreId());
|
|
|
storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
|
|
|
+ storePayment.setMerchantId(merchantAppConfig.getId());
|
|
|
if(storePaymentService.insertFsStorePayment(storePayment)>0){
|
|
|
- if (payConfigDTO.getType().equals("yb")) {
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("yb")) {
|
|
|
return R.error("支付暂不可用!");
|
|
|
- } else if (payConfigDTO.getType().equals("tz")) {
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("tz")) {
|
|
|
PayCreateOrder o = new PayCreateOrder();
|
|
|
o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
|
|
|
o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
|
|
|
@@ -1396,7 +1511,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
mt.setTradeNo(result.getBody().getOrderFlowNo());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
|
|
|
- }else if (payConfigDTO.getType().equals("hf")) {
|
|
|
+ }else if (merchantAppConfig.getMerchantType().equals("hf")) {
|
|
|
logger.info("创建汇付订单");
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_JSAPI");
|
|
|
@@ -1439,8 +1554,19 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
//如果存在优惠券 判断优惠券是否已使用
|
|
|
FsUser user=userService.selectFsUserByUserId(param.getUserId());
|
|
|
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+// PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
|
|
|
//金牛多小程序支付
|
|
|
String openId = null;
|
|
|
@@ -1455,7 +1581,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
openId = fsUserWx.getOpenId();
|
|
|
}
|
|
|
} else {
|
|
|
- appId = payConfigDTO.getAppId();
|
|
|
+ appId = merchantAppConfig.getAppId();
|
|
|
openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
if (StringUtils.isBlank(openId)){
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
@@ -1478,7 +1604,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
// PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
FsStorePayment storePayment=new FsStorePayment();
|
|
|
storePayment.setStatus(0);
|
|
|
- storePayment.setPayMode(payConfigDTO.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(fsPackageOrder.getPayMoney());
|
|
|
@@ -1492,11 +1618,12 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setStoreId(fsPackageOrder.getStoreId());
|
|
|
storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
|
|
|
+ storePayment.setMerchantId(merchantAppConfig.getId());
|
|
|
if(storePaymentService.insertFsStorePayment(storePayment)>0){
|
|
|
|
|
|
- if (payConfigDTO.getType().equals("yb")) {
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("yb")) {
|
|
|
return R.error("支付暂不可用!");
|
|
|
- } else if (payConfigDTO.getType().equals("tz")) {
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("tz")) {
|
|
|
PayCreateOrder o = new PayCreateOrder();
|
|
|
o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
|
|
|
o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
|
|
|
@@ -1517,7 +1644,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
|
|
|
mt.setTradeNo(result.getBody().getOrderFlowNo());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
|
|
|
- }else if (payConfigDTO.getType().equals("hf")) {
|
|
|
+ }else if (merchantAppConfig.getMerchantType().equals("hf")) {
|
|
|
logger.info("创建汇付订单");
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("A_NATIVE");
|