|
|
@@ -54,8 +54,10 @@ import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
+import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
|
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
import com.fs.erp.domain.*;
|
|
|
import com.fs.erp.dto.*;
|
|
|
import com.fs.erp.mapper.FsErpFinishPushMapper;
|
|
|
@@ -63,10 +65,7 @@ import com.fs.erp.service.IErpOrderService;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.enums.FsStoreOrderLogEnum;
|
|
|
-import com.fs.his.mapper.FsHfpayConfigMapper;
|
|
|
-import com.fs.his.mapper.FsStoreProductAttrValueMapper;
|
|
|
-import com.fs.his.mapper.FsUserMapper;
|
|
|
-import com.fs.his.mapper.FsUserWxMapper;
|
|
|
+import com.fs.his.mapper.*;
|
|
|
import com.fs.his.service.IFsExpressService;
|
|
|
import com.fs.his.service.IFsStoreProductService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
@@ -151,6 +150,12 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
@Autowired
|
|
|
private FsUserWxMapper fsUserWxMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MerchantAppConfigMapper merchantAppConfigMapper;
|
|
|
+
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
@@ -1284,9 +1289,21 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
//将钱退还给用户
|
|
|
List<LiveOrderPayment> payments = liveOrderPaymentMapper.selectLiveOrderPaymentByPay(5, order.getOrderId());
|
|
|
if (payments != null && !payments.isEmpty()) {
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+// String json = configService.selectConfigByKey("his.pay");
|
|
|
+// FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+
|
|
|
for (LiveOrderPayment payment : payments) {
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + payment.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);
|
|
|
+
|
|
|
if (payment.getPayMode() == null || "wx".equals(payment.getPayMode())) {
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
@@ -1488,9 +1505,25 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
//将钱退还给用户
|
|
|
List<LiveOrderPayment> payments = liveOrderPaymentMapper.selectLiveOrderPaymentByPay(5, order.getOrderId());
|
|
|
if (payments != null && !payments.isEmpty()) {
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+// String json = configService.selectConfigByKey("his.pay");
|
|
|
+// FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+
|
|
|
for (LiveOrderPayment payment : payments) {
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ Long merConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if(payment.getMerConfigId()!=null){
|
|
|
+ merConfigId=payment.getMerConfigId();
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(merConfigId);
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
+
|
|
|
if (payment.getPayMode() == null || "wx".equals(payment.getPayMode())) {
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
@@ -2982,8 +3015,19 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
FsUserScrm user = userMapper.selectFsUserById(Long.valueOf(liveOrder.getUserId()));
|
|
|
if(user == null) return R.error("用户不存在");
|
|
|
// String json = configService.selectConfigByKey("store.pay");
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
|
|
|
+// String json = configService.selectConfigByKey("his.pay");
|
|
|
+// FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(appId);
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + appId);
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+
|
|
|
+
|
|
|
String payCode = OrderCodeUtils.getOrderSn();
|
|
|
if(StringUtils.isEmpty(payCode)){
|
|
|
return R.error("订单生成失败,请重试");
|
|
|
@@ -2996,7 +3040,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
} else {
|
|
|
storePayment = new LiveOrderPayment();
|
|
|
storePayment.setStatus(1);
|
|
|
- storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setBusinessCode(liveOrder.getOrderCode());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(liveOrder.getPayMoney());
|
|
|
@@ -3008,6 +3052,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
storePayment.setOpenId(user.getMaOpenId());
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setBusinessId(liveOrder.getOrderId().toString());
|
|
|
+ storePayment.setAppId(appId);
|
|
|
+ storePayment.setMerConfigId(merchantAppConfig.getId());
|
|
|
liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
|
|
|
}
|
|
|
|
|
|
@@ -3084,16 +3130,28 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
if(user == null){
|
|
|
return R.error("未找到用户信息,请联系管理员!");
|
|
|
}
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+// String json = configService.selectConfigByKey("his.pay");
|
|
|
+// FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+ 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;
|
|
|
+ String appId = param.getAppId();
|
|
|
if(StringUtils.isNotEmpty(user.getMaOpenId())){
|
|
|
log.info("用户信息有openid:{}", user.getMaOpenId());
|
|
|
openId = user.getMaOpenId();
|
|
|
}else{
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
.eq(FsUserWx::getFsUserId, order.getUserId())
|
|
|
- .eq(FsUserWx::getAppId, fsPayConfig.getAppId());
|
|
|
+ .eq(FsUserWx::getAppId, appId);
|
|
|
FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
log.info("查到的openId信息:{}", fsUserWx);
|
|
|
openId = fsUserWx.getOpenId();
|
|
|
@@ -3159,7 +3217,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
LiveOrderPayment storePayment = new LiveOrderPayment();
|
|
|
storePayment.setCompanyId(order.getCompanyId());
|
|
|
storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
- storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setStatus(0);
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(order.getPayMoney());
|
|
|
@@ -3170,10 +3228,11 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
storePayment.setOpenId(openId);
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setBusinessId(String.valueOf(order.getOrderId()));
|
|
|
- storePayment.setAppId(param.getAppId());
|
|
|
+ storePayment.setAppId(appId);
|
|
|
+ storePayment.setMerConfigId(merchantAppConfig.getId());
|
|
|
liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
|
|
|
|
|
|
- if (fsPayConfig.getType().equals("hf")) {
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("hf")) {
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(storePayment.getOpenId());
|
|
|
@@ -3201,9 +3260,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
} else {
|
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
|
- } else if (fsPayConfig.getType().equals("wx")) {
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("wx")) {
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setAppId(appId);
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|