|
|
@@ -2,6 +2,11 @@ package com.zhongshu.card.server.core.service.paySetting;
|
|
|
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
+import com.github.microservice.pay.client.model.AccountModel;
|
|
|
+import com.github.microservice.pay.client.product.miniApp.weChat.conf.WeChatMiniAppConf;
|
|
|
+import com.github.microservice.pay.client.ret.ResultState;
|
|
|
+import com.github.microservice.pay.client.service.PayProductAccountService;
|
|
|
+import com.github.microservice.pay.client.type.PayProductChannelType;
|
|
|
import com.github.microservice.types.payment.PayFieldType;
|
|
|
import com.github.microservice.types.payment.PaymentType;
|
|
|
import com.zhongshu.card.client.model.paySetting.payConfig.LaKaLaCollectionConfig;
|
|
|
@@ -59,6 +64,9 @@ public class ProjectPaySettingServiceImpl extends SuperService {
|
|
|
@Autowired
|
|
|
PayChannelConfigDao payChannelConfigDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PayProductAccountService payProductAccountService;
|
|
|
+
|
|
|
/**
|
|
|
* 关联支付渠道
|
|
|
*
|
|
|
@@ -152,6 +160,8 @@ public class ProjectPaySettingServiceImpl extends SuperService {
|
|
|
}
|
|
|
paySetting.setState(state);
|
|
|
projectPaySettingDao.save(paySetting);
|
|
|
+
|
|
|
+ upsertPayAccount(paySetting.getProjectOid(), paySetting.getChannelType());
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -360,6 +370,7 @@ public class ProjectPaySettingServiceImpl extends SuperService {
|
|
|
projectPaySettingInfoDao.save(first);
|
|
|
}
|
|
|
}
|
|
|
+ upsertPayAccount(projectOid, paymentType);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -468,4 +479,58 @@ public class ProjectPaySettingServiceImpl extends SuperService {
|
|
|
return ResultContent.buildSuccess(paySettingInfo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新/初始支付中心的数据
|
|
|
+ *
|
|
|
+ * @param projectOid
|
|
|
+ * @param paymentType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent upsertPayAccount(String projectOid, PaymentType paymentType) {
|
|
|
+ ProjectPaySettingInfo entity = projectPaySettingInfoDao.findTopByProjectOidAndChannelTypeAndIsDefault(
|
|
|
+ projectOid, paymentType, Boolean.TRUE);
|
|
|
+
|
|
|
+ AccountModel accountModel = new AccountModel();
|
|
|
+ Boolean disable = Boolean.FALSE;
|
|
|
+ accountModel.setName(projectOid);
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ if (paymentType == PaymentType.WeChat) {
|
|
|
+ accountModel.setProductChannelType(PayProductChannelType.WeChatMiniAppPay);
|
|
|
+ WeChatMiniAppConf appConf = new WeChatMiniAppConf();
|
|
|
+ WxPayConfigModel model = (WxPayConfigModel) entity.getPayConfig();
|
|
|
+ appConf.setAppId(model.getAppId());
|
|
|
+ appConf.setMchId(model.getMchId());
|
|
|
+ appConf.setMchSerialNo(model.getMchSerialNo());
|
|
|
+ appConf.setPriKeyPath(model.getPrivateKeyStr());
|
|
|
+ appConf.setApiV3KeyPath(model.getApiV3Key());
|
|
|
+ accountModel.setConf(appConf);
|
|
|
+ }
|
|
|
+ ProjectPaySetting paySetting = projectPaySettingDao.findTopByProjectOidAndChannelType(projectOid, paymentType);
|
|
|
+ if (ObjectUtils.isNotEmpty(paySetting)
|
|
|
+ && paySetting.getState() != null && paySetting.getState() == DataState.Enable) {
|
|
|
+ ProjectPaySetting projectPaySetting = entity.getProjectPaySetting();
|
|
|
+ if (ObjectUtils.isNotEmpty(projectPaySetting) && projectPaySetting.getState() != null && projectPaySetting.getState() == DataState.Enable) {
|
|
|
+ // 可用
|
|
|
+ disable = Boolean.FALSE;
|
|
|
+ } else {
|
|
|
+ // 不可用
|
|
|
+ disable = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 不可用
|
|
|
+ disable = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 不可用
|
|
|
+ disable = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ accountModel.setDisable(disable);
|
|
|
+ com.github.microservice.pay.client.ret.ResultContent<Void> resultContent = payProductAccountService.upsert(accountModel);
|
|
|
+ if (resultContent.getState() == ResultState.Success) {
|
|
|
+ log.info("更新支付产品账户成功...");
|
|
|
+ } else {
|
|
|
+ log.error("更新支付产品账户出错: {}", resultContent.getMsg());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
}
|