|
@@ -45,11 +45,9 @@ import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.*;
|
|
import com.fs.common.utils.*;
|
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
|
-import com.fs.company.domain.Company;
|
|
|
|
|
-import com.fs.company.domain.CompanyDept;
|
|
|
|
|
-import com.fs.company.domain.CompanyMoneyLogs;
|
|
|
|
|
-import com.fs.company.domain.CompanyUser;
|
|
|
|
|
|
|
+import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.CompanyMoneyLogsMapper;
|
|
import com.fs.company.mapper.CompanyMoneyLogsMapper;
|
|
|
|
|
+import com.fs.company.mapper.RechargeRecordMapper;
|
|
|
import com.fs.company.service.ICompanyDeptService;
|
|
import com.fs.company.service.ICompanyDeptService;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
import com.fs.company.service.ICompanyUserService;
|
|
@@ -57,9 +55,11 @@ import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
|
|
+import com.fs.course.domain.FsUserCompanyUser;
|
|
|
import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
|
|
+import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
|
import com.fs.erp.domain.*;
|
|
import com.fs.erp.domain.*;
|
|
|
import com.fs.erp.dto.*;
|
|
import com.fs.erp.dto.*;
|
|
|
import com.fs.erp.mapper.FsErpFinishPushMapper;
|
|
import com.fs.erp.mapper.FsErpFinishPushMapper;
|
|
@@ -168,13 +168,17 @@ import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
|
|
|
public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
|
|
|
|
|
private final RedisCache redisCache;
|
|
private final RedisCache redisCache;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsUserCompanyUserMapper fsUserCompanyUserMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private LiveOrderMapper baseMapper;
|
|
private LiveOrderMapper baseMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsUserWxMapper fsUserWxMapper;
|
|
private FsUserWxMapper fsUserWxMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RocketMQTemplate rocketMQTemplate;
|
|
private RocketMQTemplate rocketMQTemplate;
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RechargeRecordMapper rechargeRecordMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
|
|
private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
|
|
|
|
|
|
|
@@ -1468,7 +1472,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
SysConfig sysConfig = configService.selectConfigByConfigKey("app.config");
|
|
SysConfig sysConfig = configService.selectConfigByConfigKey("app.config");
|
|
|
AppConfig config = new Gson().fromJson(sysConfig.getConfigValue(), AppConfig.class);
|
|
AppConfig config = new Gson().fromJson(sysConfig.getConfigValue(), AppConfig.class);
|
|
|
for (LiveOrderPayment payment : payments) {
|
|
for (LiveOrderPayment payment : payments) {
|
|
|
- if (order.getPayType().equals("99")){
|
|
|
|
|
|
|
+ if (order.getPayType().equals("99")||order.getPayType().equals("5")){
|
|
|
payment.setAppId(config.getAppId());
|
|
payment.setAppId(config.getAppId());
|
|
|
}
|
|
}
|
|
|
// payment.setAppId(config.getAppId());
|
|
// payment.setAppId(config.getAppId());
|
|
@@ -1477,11 +1481,11 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
if ("wxApp".equals(payment.getPayMode())){
|
|
if ("wxApp".equals(payment.getPayMode())){
|
|
|
payType = "wx";
|
|
payType = "wx";
|
|
|
}
|
|
}
|
|
|
- MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
-
|
|
|
|
|
- FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
|
|
|
|
if (payment.getPayMode() == null || "wx".equals(payment.getPayMode())) {
|
|
if (payment.getPayMode() == null || "wx".equals(payment.getPayMode())) {
|
|
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
+
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(fsPayConfig.getAppId());
|
|
payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
@@ -1514,6 +1518,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
return R.error("退款请求失败" + e.getErrCodeDes());
|
|
return R.error("退款请求失败" + e.getErrCodeDes());
|
|
|
}
|
|
}
|
|
|
} else if (payment.getPayMode() != null && "hf".equals(payment.getPayMode())) {
|
|
} else if (payment.getPayMode() != null && "hf".equals(payment.getPayMode())) {
|
|
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
+
|
|
|
String huifuId = "";
|
|
String huifuId = "";
|
|
|
if (payment.getAppId() != null) {
|
|
if (payment.getAppId() != null) {
|
|
|
if (merchantAppConfig != null) {
|
|
if (merchantAppConfig != null) {
|
|
@@ -1584,6 +1591,15 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
throw new CustomException("退款请求失败" + e);
|
|
throw new CustomException("退款请求失败" + e);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ }else if (payment.getPayMode()!=null&&payment.getPayMode().equals("cz")) {
|
|
|
|
|
+ LiveOrderPayment paymentMap = new LiveOrderPayment();
|
|
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
|
|
+ liveOrderPaymentMapper.updateLiveOrderPayment(paymentMap);
|
|
|
|
|
+ FsUserScrm fsUserScrm = userService.selectFsUserById(Long.valueOf(order.getUserId()));
|
|
|
|
|
+ processLiveRechargePayment(payment,fsUserScrm,order);
|
|
|
} else {
|
|
} else {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return R.error("支付类型异常");
|
|
return R.error("支付类型异常");
|
|
@@ -1614,7 +1630,68 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理直播储值支付
|
|
|
|
|
+ * @param liveOrderPayment 直播订单支付信息
|
|
|
|
|
+ * @param user 用户信息
|
|
|
|
|
+ * @return 支付处理结果
|
|
|
|
|
+ */
|
|
|
|
|
+ private R processLiveRechargePayment(LiveOrderPayment liveOrderPayment, FsUserScrm user,LiveOrder liveOrder) {
|
|
|
|
|
+ // 查询直播订单信息
|
|
|
|
|
+ Company company = companyService.selectCompanyById(liveOrder.getCompanyId());
|
|
|
|
|
+
|
|
|
|
|
+ // 创建消费记录
|
|
|
|
|
+ return R.ok().put("data", createConsumptionRecord(
|
|
|
|
|
+ liveOrder.getOrderId(),
|
|
|
|
|
+ liveOrder.getOrderCode(),
|
|
|
|
|
+ user.getUserId(),
|
|
|
|
|
+ user.getNickName(),
|
|
|
|
|
+ liveOrderPayment.getPayMoney(),
|
|
|
|
|
+ company
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 订单支付成功后,增加消费记录
|
|
|
|
|
+ * @param orderId 订单ID
|
|
|
|
|
+ * @param orderNo 订单编号
|
|
|
|
|
+ * @param userId 用户ID
|
|
|
|
|
+ * @param userName 用户姓名
|
|
|
|
|
+ * @param amount 消费金额
|
|
|
|
|
+ * @return 影响行数
|
|
|
|
|
+ */
|
|
|
|
|
+ public int createConsumptionRecord(Long orderId, String orderNo, Long userId,
|
|
|
|
|
+ String userName, BigDecimal amount,Company company
|
|
|
|
|
+ ) {
|
|
|
|
|
+ RechargeRecord record = new RechargeRecord();
|
|
|
|
|
+ record.setUserId(userId);
|
|
|
|
|
+ record.setUserName(userName);
|
|
|
|
|
+ record.setTotalAmount(amount);
|
|
|
|
|
+ record.setTransactionId(generateTransactionId());
|
|
|
|
|
+ record.setOrderId(orderId);
|
|
|
|
|
+ record.setOrderNo(orderNo);
|
|
|
|
|
+ record.setBusinessType(2); // 1-消费
|
|
|
|
|
+ if (ObjectUtil.isEmpty(company)){
|
|
|
|
|
+ record.setRemark("直播订单退款,自主下单没有归属公司");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ record.setCompanyId(company.getCompanyId());
|
|
|
|
|
+ record.setCompanyName(company.getCompanyName());
|
|
|
|
|
+ record.setRemark("直播订单退款");
|
|
|
|
|
+ }
|
|
|
|
|
+ record.setCreateTime(new Date());
|
|
|
|
|
+ record.setDelFlag("0");
|
|
|
|
|
+
|
|
|
|
|
+ return rechargeRecordMapper.insertRechargeRecord(record);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成交易流水号
|
|
|
|
|
+ * @return 交易流水号
|
|
|
|
|
+ */
|
|
|
|
|
+ private String generateTransactionId() {
|
|
|
|
|
+ return "TTK" + System.currentTimeMillis() + UUID.randomUUID().toString().substring(0, 8).toUpperCase();
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* 封装微信参数
|
|
* 封装微信参数
|
|
|
*
|
|
*
|
|
@@ -1748,7 +1825,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
AppConfig config = new Gson().fromJson(sysConfig.getConfigValue(), AppConfig.class);
|
|
AppConfig config = new Gson().fromJson(sysConfig.getConfigValue(), AppConfig.class);
|
|
|
|
|
|
|
|
for (LiveOrderPayment payment : payments) {
|
|
for (LiveOrderPayment payment : payments) {
|
|
|
- if (order.getPayType().equals("99")){
|
|
|
|
|
|
|
+ if (order.getPayType().equals("99")||order.getPayType().equals("5")){
|
|
|
payment.setAppId(config.getAppId());
|
|
payment.setAppId(config.getAppId());
|
|
|
}
|
|
}
|
|
|
if (StringUtils.isBlank(payment.getAppId())) {
|
|
if (StringUtils.isBlank(payment.getAppId())) {
|
|
@@ -1758,10 +1835,10 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
if ("wxApp".equals(payment.getPayMode())){
|
|
if ("wxApp".equals(payment.getPayMode())){
|
|
|
payType = "wx";
|
|
payType = "wx";
|
|
|
}
|
|
}
|
|
|
- MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
- FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
|
|
|
|
if (payment.getPayMode() == null || "wx".equals(payment.getPayMode())) {
|
|
if (payment.getPayMode() == null || "wx".equals(payment.getPayMode())) {
|
|
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(payment.getAppId());
|
|
payConfig.setAppId(payment.getAppId());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
@@ -1792,6 +1869,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
return R.error("退款请求失败" + e.getErrCodeDes());
|
|
return R.error("退款请求失败" + e.getErrCodeDes());
|
|
|
}
|
|
}
|
|
|
} else if (payment.getPayMode() != null && "hf".equals(payment.getPayMode())) {
|
|
} else if (payment.getPayMode() != null && "hf".equals(payment.getPayMode())) {
|
|
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
String huifuId = "";
|
|
String huifuId = "";
|
|
|
if (payment.getAppId() != null) {
|
|
if (payment.getAppId() != null) {
|
|
|
if (merchantAppConfig == null){
|
|
if (merchantAppConfig == null){
|
|
@@ -1863,6 +1942,14 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
throw new CustomException("退款请求失败" + e);
|
|
throw new CustomException("退款请求失败" + e);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ }else if (payment.getPayMode()!=null&&payment.getPayMode().equals("cz")) {
|
|
|
|
|
+// TODO 储值退款
|
|
|
|
|
+ LiveOrderPayment paymentMap = new LiveOrderPayment();
|
|
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
|
|
+ liveOrderPaymentMapper.updateLiveOrderPayment(paymentMap);
|
|
|
} else {
|
|
} else {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return R.error("支付类型异常");
|
|
return R.error("支付类型异常");
|
|
@@ -4365,6 +4452,12 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
// if (StringUtils.isEmpty(orderKey)) {
|
|
// if (StringUtils.isEmpty(orderKey)) {
|
|
|
// return R.error("订单已过期");
|
|
// return R.error("订单已过期");
|
|
|
// }
|
|
// }
|
|
|
|
|
+ FsUserCompanyUser fsUserCompanyUser = fsUserCompanyUserMapper.selectFsUserCompanyUserByUserId(Long.valueOf(liveOrder.getUserId()));
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(fsUserCompanyUser)){
|
|
|
|
|
+ liveOrder.setCompanyId(fsUserCompanyUser.getCompanyId());
|
|
|
|
|
+ liveOrder.setCompanyUserId(fsUserCompanyUser.getCompanyUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (liveOrder.getLiveId() == null) return R.error("直播ID不能为空");
|
|
if (liveOrder.getLiveId() == null) return R.error("直播ID不能为空");
|
|
|
if (liveOrder.getProductId() == null) return R.error("购物商品ID不能为空");
|
|
if (liveOrder.getProductId() == null) return R.error("购物商品ID不能为空");
|
|
|
if (liveOrder.getUserName() == null) return R.error("用户名不能为空");
|
|
if (liveOrder.getUserName() == null) return R.error("用户名不能为空");
|
|
@@ -4451,8 +4544,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
|
|
|
|
|
LiveUserFirstEntry liveUserFirstEntry = liveUserFirstEntryService.selectEntityByLiveIdUserId(liveOrder.getLiveId(), Long.parseLong(liveOrder.getUserId()));
|
|
LiveUserFirstEntry liveUserFirstEntry = liveUserFirstEntryService.selectEntityByLiveIdUserId(liveOrder.getLiveId(), Long.parseLong(liveOrder.getUserId()));
|
|
|
if (ObjectUtil.isNotEmpty(liveUserFirstEntry)) {
|
|
if (ObjectUtil.isNotEmpty(liveUserFirstEntry)) {
|
|
|
- liveOrder.setCompanyId(liveUserFirstEntry.getCompanyId());
|
|
|
|
|
- liveOrder.setCompanyUserId(liveUserFirstEntry.getCompanyUserId());
|
|
|
|
|
|
|
+// liveOrder.setCompanyId(liveUserFirstEntry.getCompanyId());
|
|
|
|
|
+// liveOrder.setCompanyUserId(liveUserFirstEntry.getCompanyUserId());
|
|
|
liveOrder.setTuiUserId(liveUserFirstEntry.getCompanyUserId());
|
|
liveOrder.setTuiUserId(liveUserFirstEntry.getCompanyUserId());
|
|
|
}
|
|
}
|
|
|
String orderSn = OrderCodeUtils.getOrderSn();
|
|
String orderSn = OrderCodeUtils.getOrderSn();
|