|
@@ -30,7 +30,9 @@ import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
|
import com.fs.company.domain.Company;
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
|
|
+import com.fs.company.domain.RechargeRecord;
|
|
|
import com.fs.company.mapper.CompanyConfigMapper;
|
|
import com.fs.company.mapper.CompanyConfigMapper;
|
|
|
|
|
+import com.fs.company.mapper.RechargeRecordMapper;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
@@ -53,14 +55,18 @@ import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.his.service.IFsUserWxService;
|
|
import com.fs.his.service.IFsUserWxService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.hisStore.config.StoreConfig;
|
|
import com.fs.hisStore.config.StoreConfig;
|
|
|
|
|
+import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
|
|
|
+import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.hisStore.param.*;
|
|
import com.fs.hisStore.param.*;
|
|
|
import com.fs.hisStore.vo.FsStorePaymentUsetVo;
|
|
import com.fs.hisStore.vo.FsStorePaymentUsetVo;
|
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
|
|
+import com.fs.live.domain.LiveOrder;
|
|
|
import com.fs.live.domain.LiveOrderPayment;
|
|
import com.fs.live.domain.LiveOrderPayment;
|
|
|
|
|
+import com.fs.live.mapper.LiveOrderMapper;
|
|
|
import com.fs.live.mapper.LiveOrderPaymentMapper;
|
|
import com.fs.live.mapper.LiveOrderPaymentMapper;
|
|
|
import com.fs.pay.pay.dto.WxJspayDTO;
|
|
import com.fs.pay.pay.dto.WxJspayDTO;
|
|
|
import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
|
|
import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
|
|
@@ -126,7 +132,14 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
private LiveOrderPaymentMapper liveOrderPaymentMapper;
|
|
private LiveOrderPaymentMapper liveOrderPaymentMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsUserScrmService userService;
|
|
private IFsUserScrmService userService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RechargeRecordMapper rechargeRecordMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStoreOrderScrmMapper storeOrderScrmMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private LiveOrderMapper liveOrderMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICompanyUserService companyUserService;
|
|
private ICompanyUserService companyUserService;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -1148,7 +1161,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
String json = configService.selectConfigByKey("his.pay");
|
|
String json = configService.selectConfigByKey("his.pay");
|
|
|
PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
payConfig.setType(payConfigDTO.getType());
|
|
payConfig.setType(payConfigDTO.getType());
|
|
|
- } else {
|
|
|
|
|
|
|
+ }else if(!(PaymentMethodEnum.CZ_PAY == payOrderParam.getPaymentMethod())){
|
|
|
if (StringUtils.isBlank(payOrderParam.getAppId())) {
|
|
if (StringUtils.isBlank(payOrderParam.getAppId())) {
|
|
|
throw new IllegalArgumentException("appId不能为空");
|
|
throw new IllegalArgumentException("appId不能为空");
|
|
|
}
|
|
}
|
|
@@ -1183,20 +1196,85 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 创建记录 TODO 根据type创建支付
|
|
|
|
|
FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
|
|
FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
|
|
|
if (payOrderParam.getBusinessType().getPrefix().equals("live")) {
|
|
if (payOrderParam.getBusinessType().getPrefix().equals("live")) {
|
|
|
LiveOrderPayment liveOrderPayment = createLiveStorePayment(payConfig, user, payOrderParam);
|
|
LiveOrderPayment liveOrderPayment = createLiveStorePayment(payConfig, user, payOrderParam);
|
|
|
BeanUtils.copyProperties(liveOrderPayment, storePayment);
|
|
BeanUtils.copyProperties(liveOrderPayment, storePayment);
|
|
|
|
|
+ if (PaymentMethodEnum.CZ_PAY == payOrderParam.getPaymentMethod()) {
|
|
|
|
|
+ LiveOrder liveOrder = liveOrderMapper.selectLiveOrderByOrderId(liveOrderPayment.getBusinessId());
|
|
|
|
|
+ Company company = companyService.selectCompanyById(liveOrder.getCompanyId());
|
|
|
|
|
+ user.setRechargeBalance(user.getRechargeBalance().multiply(liveOrder.getPayMoney()));
|
|
|
|
|
+ userService.updateFsUser(user);
|
|
|
|
|
+ return R.ok().put("data",createConsumptionRecord(
|
|
|
|
|
+ liveOrder.getOrderId(),
|
|
|
|
|
+ liveOrder.getOrderCode(),
|
|
|
|
|
+ user.getUserId(),
|
|
|
|
|
+ user.getNickName(),
|
|
|
|
|
+ storePayment.getPayMoney(),
|
|
|
|
|
+ company.getCompanyId(),
|
|
|
|
|
+ company.getCompanyName())
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
storePayment = createStorePaymentScrm(payConfig, user, payOrderParam);
|
|
storePayment = createStorePaymentScrm(payConfig, user, payOrderParam);
|
|
|
|
|
+ if (PaymentMethodEnum.CZ_PAY == payOrderParam.getPaymentMethod()) {
|
|
|
|
|
+ FsStoreOrderScrm fsStoreOrderScrm = storeOrderScrmMapper.selectFsStoreOrderById(storePayment.getOrderId());
|
|
|
|
|
+ Company company = companyService.selectCompanyById(fsStoreOrderScrm.getCompanyId());
|
|
|
|
|
+ user.setRechargeBalance(user.getRechargeBalance().multiply(storePayment.getPayMoney()));
|
|
|
|
|
+ userService.updateFsUser(user);
|
|
|
|
|
+ return R.ok().put("data",createConsumptionRecord(
|
|
|
|
|
+ fsStoreOrderScrm.getId(),
|
|
|
|
|
+ fsStoreOrderScrm.getOrderCode(),
|
|
|
|
|
+ user.getUserId(),
|
|
|
|
|
+ user.getNickName(),
|
|
|
|
|
+ storePayment.getPayMoney(),
|
|
|
|
|
+ company.getCompanyId(),
|
|
|
|
|
+ company.getCompanyName())
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
// 根据配置类型创建第三方支付订单
|
|
// 根据配置类型创建第三方支付订单
|
|
|
return createThirdPartyPaymentScrm(payConfig, storePayment, user, payOrderParam);
|
|
return createThirdPartyPaymentScrm(payConfig, storePayment, user, payOrderParam);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 订单支付成功后,增加消费记录
|
|
|
|
|
+ * @param orderId 订单ID
|
|
|
|
|
+ * @param orderNo 订单编号
|
|
|
|
|
+ * @param userId 用户ID
|
|
|
|
|
+ * @param userName 用户姓名
|
|
|
|
|
+ * @param amount 消费金额
|
|
|
|
|
+ * @param companyId 公司ID
|
|
|
|
|
+ * @param companyName 公司名称
|
|
|
|
|
+ * @return 影响行数
|
|
|
|
|
+ */
|
|
|
|
|
+ public int createConsumptionRecord(Long orderId, String orderNo, Long userId,
|
|
|
|
|
+ String userName, BigDecimal amount,
|
|
|
|
|
+ Long companyId, String companyName) {
|
|
|
|
|
+ RechargeRecord record = new RechargeRecord();
|
|
|
|
|
+ record.setUserId(userId);
|
|
|
|
|
+ record.setUserName(userName);
|
|
|
|
|
+ record.setTotalAmount(amount);
|
|
|
|
|
+ record.setTransactionId(generateTransactionId());
|
|
|
|
|
+ record.setOrderId(orderId);
|
|
|
|
|
+ record.setOrderNo(orderNo);
|
|
|
|
|
+ record.setBusinessType(1); // 1-消费
|
|
|
|
|
+ record.setCompanyId(companyId);
|
|
|
|
|
+ record.setCompanyName(companyName);
|
|
|
|
|
+ record.setRemark("订单消费");
|
|
|
|
|
+ record.setCreateTime(new Date());
|
|
|
|
|
+ record.setDelFlag("0");
|
|
|
|
|
+
|
|
|
|
|
+ return rechargeRecordMapper.insertRechargeRecord(record);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成交易流水号
|
|
|
|
|
+ * @return 交易流水号
|
|
|
|
|
+ */
|
|
|
|
|
+ private String generateTransactionId() {
|
|
|
|
|
+ return "TXN" + System.currentTimeMillis() + UUID.randomUUID().toString().substring(0, 8).toUpperCase();
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* 直播订单支付信息
|
|
* 直播订单支付信息
|
|
|
*
|
|
*
|
|
@@ -1212,9 +1290,15 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
LiveOrderPayment storePayment = new LiveOrderPayment();
|
|
LiveOrderPayment storePayment = new LiveOrderPayment();
|
|
|
- storePayment.setStatus(0);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (PaymentMethodEnum.CZ_PAY == payOrderParam.getPaymentMethod()){
|
|
|
|
|
+ storePayment.setStatus(1);
|
|
|
|
|
+ storePayment.setPayMode("cz");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ storePayment.setStatus(0);
|
|
|
|
|
+ storePayment.setPayMode(payConfig.getType());
|
|
|
|
|
+ }
|
|
|
storePayment.setAppId(payConfig.getAppId());
|
|
storePayment.setAppId(payConfig.getAppId());
|
|
|
- storePayment.setPayMode(payConfig.getType());
|
|
|
|
|
storePayment.setBusinessCode(payOrderParam.getOrderCode());
|
|
storePayment.setBusinessCode(payOrderParam.getOrderCode());
|
|
|
storePayment.setPayCode(payCode);
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(payOrderParam.getAmount());
|
|
storePayment.setPayMoney(payOrderParam.getAmount());
|
|
@@ -1436,10 +1520,15 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
|
|
FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
|
|
|
- storePayment.setStatus(0);
|
|
|
|
|
|
|
+ if (PaymentMethodEnum.CZ_PAY == payOrderParam.getPaymentMethod()){
|
|
|
|
|
+ storePayment.setStatus(1);
|
|
|
|
|
+ storePayment.setPayMode("cz");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ storePayment.setStatus(0);
|
|
|
|
|
+ storePayment.setPayMode(payConfig.getType());
|
|
|
|
|
+ }
|
|
|
storePayment.setAppId(payConfig.getAppId());
|
|
storePayment.setAppId(payConfig.getAppId());
|
|
|
storePayment.setOrderId(payOrderParam.getOrderId());
|
|
storePayment.setOrderId(payOrderParam.getOrderId());
|
|
|
- storePayment.setPayMode(payConfig.getType());
|
|
|
|
|
storePayment.setBusinessCode(payOrderParam.getOrderCode());
|
|
storePayment.setBusinessCode(payOrderParam.getOrderCode());
|
|
|
storePayment.setPayCode(payCode);
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(payOrderParam.getAmount());
|
|
storePayment.setPayMoney(payOrderParam.getAmount());
|