|
@@ -1,9 +1,8 @@
|
|
|
package com.zhongshu.card.server.core.service.pay;
|
|
package com.zhongshu.card.server.core.service.pay;
|
|
|
|
|
|
|
|
-import com.github.microservice.components.data.mongo.queue.service.ExecQueueService;
|
|
|
|
|
-import com.github.microservice.core.helper.ApplicationContextHolder;
|
|
|
|
|
import com.github.microservice.core.util.JsonUtil;
|
|
import com.github.microservice.core.util.JsonUtil;
|
|
|
import com.github.microservice.core.util.bean.BeanUtil;
|
|
import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
|
|
+import com.github.microservice.core.util.queue.ExecuteQueueUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.pay.client.model.AccountModel;
|
|
import com.github.microservice.pay.client.model.AccountModel;
|
|
|
import com.github.microservice.pay.client.model.PayProductParameter;
|
|
import com.github.microservice.pay.client.model.PayProductParameter;
|
|
@@ -36,7 +35,6 @@ import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
|
|
|
import com.zhongshu.card.server.core.model.pay.UnionFrictionlessPayFinishModel;
|
|
import com.zhongshu.card.server.core.model.pay.UnionFrictionlessPayFinishModel;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.paySetting.OrgPayAccountService;
|
|
import com.zhongshu.card.server.core.service.paySetting.OrgPayAccountService;
|
|
|
-import com.zhongshu.card.server.core.service.paySetting.ProjectMainPaySettingService;
|
|
|
|
|
import com.zhongshu.card.server.core.service.payment.PayCallService;
|
|
import com.zhongshu.card.server.core.service.payment.PayCallService;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
@@ -76,11 +74,6 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ShareOrderDao shareOrderDao;
|
|
ShareOrderDao shareOrderDao;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- ExecQueueService execQueueService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private ProjectMainPaySettingService projectMainPaySettingService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -88,7 +81,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
*
|
|
*
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public Object signApply(UnionApplySignParam param) {
|
|
|
|
|
|
|
+ public ResultContent signApply(UnionApplySignParam param) {
|
|
|
|
|
|
|
|
String projectOid = param.getProjectOid();
|
|
String projectOid = param.getProjectOid();
|
|
|
String userId = param.getUserId();
|
|
String userId = param.getUserId();
|
|
@@ -105,7 +98,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
|
|
String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
|
|
|
com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
|
|
com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
|
|
|
if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
- return accountModelResultContent;
|
|
|
|
|
|
|
+ return ResultContent.buildFail(accountModelResultContent.getMsg());
|
|
|
}
|
|
}
|
|
|
ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
String mid = conf.getMchId();
|
|
String mid = conf.getMchId();
|
|
@@ -151,7 +144,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
- private Object signApply(UnionApplySignParam param, String accountName, String userId, String mid) {
|
|
|
|
|
|
|
+ private ResultContent signApply(UnionApplySignParam param, String accountName, String userId, String mid) {
|
|
|
PayProductParameter<Object> payProductParameter = new PayProductParameter<>();
|
|
PayProductParameter<Object> payProductParameter = new PayProductParameter<>();
|
|
|
payProductParameter.setAccountName(accountName);
|
|
payProductParameter.setAccountName(accountName);
|
|
|
payProductParameter.setMeta(BeanUtil.bean2Map(param));
|
|
payProductParameter.setMeta(BeanUtil.bean2Map(param));
|
|
@@ -173,7 +166,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
userSignInfo.setExpireTime(System.currentTimeMillis() + 30 * 60 * 1000);
|
|
userSignInfo.setExpireTime(System.currentTimeMillis() + 30 * 60 * 1000);
|
|
|
userSignInfo.setExpire(false);
|
|
userSignInfo.setExpire(false);
|
|
|
chinaumsSenselessUserSignInfoDao.save(userSignInfo);
|
|
chinaumsSenselessUserSignInfoDao.save(userSignInfo);
|
|
|
- return signApplyResultContent;
|
|
|
|
|
|
|
+ return ResultContent.buildContent(signApplyResultContent.getContent());
|
|
|
} else {
|
|
} else {
|
|
|
return ResultContent.buildFail((String) resultMap.get("errMsg"));
|
|
return ResultContent.buildFail((String) resultMap.get("errMsg"));
|
|
|
}
|
|
}
|
|
@@ -181,18 +174,14 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
return ResultContent.buildFail("银联请求失败");
|
|
return ResultContent.buildFail("银联请求失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public boolean isSigned(String projectOid, String userId) {
|
|
|
|
|
-// String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
|
|
|
|
|
-// com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
|
|
|
|
|
-// if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
|
|
-// throw new RuntimeException(accountModelResultContent.getMsg());
|
|
|
|
|
-// }
|
|
|
|
|
-// ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
|
|
-// String mid = conf.getMchId();
|
|
|
|
|
- String mid = projectMainPaySettingService.getProjectPaymentMchId(projectOid, PaymentType.UnionFrictionlessPay);
|
|
|
|
|
- if (StringUtils.isEmpty(mid)) {
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ public boolean isSigned(String projectOid, String userId){
|
|
|
|
|
+ String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
|
|
|
|
|
+ com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
|
|
|
|
|
+ if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
|
|
+ throw new RuntimeException(accountModelResultContent.getMsg());
|
|
|
}
|
|
}
|
|
|
|
|
+ ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
|
|
+ String mid = conf.getMchId();
|
|
|
ChinaumsSenselessUserSignInfo topByUserIdAndMidAndExpire = chinaumsSenselessUserSignInfoDao.findTopByUserIdAndMidAndExpire(userId, mid, false);
|
|
ChinaumsSenselessUserSignInfo topByUserIdAndMidAndExpire = chinaumsSenselessUserSignInfoDao.findTopByUserIdAndMidAndExpire(userId, mid, false);
|
|
|
return topByUserIdAndMidAndExpire.getContractState().equals(ContractState.SIGNED);
|
|
return topByUserIdAndMidAndExpire.getContractState().equals(ContractState.SIGNED);
|
|
|
}
|
|
}
|
|
@@ -256,7 +245,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 添加 判断是否在平台外已经签约逻辑
|
|
//TODO 添加 判断是否在平台外已经签约逻辑
|
|
|
- public Object queryUserSignInfo(String userId, String projectOid) {
|
|
|
|
|
|
|
+ public ResultContent<ChinaumsSenselessUserSignInfoModel> queryUserSignInfo(String userId, String projectOid) {
|
|
|
if (StringUtils.isBlank(userId)) {
|
|
if (StringUtils.isBlank(userId)) {
|
|
|
userId = getCurrentUserId();
|
|
userId = getCurrentUserId();
|
|
|
}
|
|
}
|
|
@@ -269,7 +258,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
|
|
String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
|
|
|
com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
|
|
com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
|
|
|
if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
- return accountModelResultContent;
|
|
|
|
|
|
|
+ return ResultContent.buildFail(accountModelResultContent.getMsg());
|
|
|
}
|
|
}
|
|
|
ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
String mid = conf.getMchId();
|
|
String mid = conf.getMchId();
|
|
@@ -431,38 +420,34 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
payProductParameter.setMeta(BeanUtil.bean2Map(request));
|
|
payProductParameter.setMeta(BeanUtil.bean2Map(request));
|
|
|
com.github.microservice.pay.client.ret.ResultContent<Object> refundResultContent = senselessPayService.refund(payProductParameter);
|
|
com.github.microservice.pay.client.ret.ResultContent<Object> refundResultContent = senselessPayService.refund(payProductParameter);
|
|
|
if (!refundResultContent.getState().equals(ResultState.Success)) {
|
|
if (!refundResultContent.getState().equals(ResultState.Success)) {
|
|
|
- return ResultContent.buildFail("请求失败");
|
|
|
|
|
|
|
+ return ResultContent.buildFail(refundResultContent.getMsg());
|
|
|
}
|
|
}
|
|
|
Map bodyMap = JsonUtil.toObject(JsonUtil.toJson(refundResultContent.getContent()), Map.class);
|
|
Map bodyMap = JsonUtil.toObject(JsonUtil.toJson(refundResultContent.getContent()), Map.class);
|
|
|
|
|
|
|
|
if (bodyMap.get("respCode").equals("TARGET_PROCESSING")) {
|
|
if (bodyMap.get("respCode").equals("TARGET_PROCESSING")) {
|
|
|
- execQueueService.add(Map.of("refundOrderNo", refundOrderNo), 5, data -> {
|
|
|
|
|
- final ExpenseFlowDao expenseFlowDao = ApplicationContextHolder.getContext().getBean(ExpenseFlowDao.class);
|
|
|
|
|
- final ChinaumsSenselessPayService chinaumsSenselessPayService = ApplicationContextHolder.getContext().getBean(ChinaumsSenselessPayService.class);
|
|
|
|
|
- final PayCallService payCallService = ApplicationContextHolder.getContext().getBean(PayCallService.class);
|
|
|
|
|
- String number = (String) data.get("refundOrderNo");
|
|
|
|
|
- ExpenseFlow refundOrder = expenseFlowDao.findTopByRefundNo(number);
|
|
|
|
|
- if (refundOrder == null) {
|
|
|
|
|
- log.info("找不到退款单");
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- if (refundOrder.getRefundState().equals(RefundState.Refunded) || refundOrder.getRefundState().equals(RefundState.Fail)) {
|
|
|
|
|
- log.info("当前退款单状态为已退款或退款失败");
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- ResultContent<UnionFrictionlessPayFinishModel> refundQuery = chinaumsSenselessPayService.refundQuery(refundOrder.getProjectOid(), refundOrder.getUserId(), refundOrder.getShopOid(), refundOrderNo, true);
|
|
|
|
|
- if (!refundQuery.getState().equals(com.github.microservice.net.ResultState.Success)) {
|
|
|
|
|
|
|
+ UnionFrictionlessPayFinishModel unionFrictionlessPayFinishModel = ExecuteQueueUtil.execute(5, index->{
|
|
|
|
|
+ return Map.of(1, 1000L, 2, 1000L, 3, 1000L, 4, 2000L).getOrDefault(index, 3000L);
|
|
|
|
|
+ }, it->{
|
|
|
|
|
+ var result = new ExecuteQueueUtil.Result<UnionFrictionlessPayFinishModel>();
|
|
|
|
|
+
|
|
|
|
|
+ ResultContent<UnionFrictionlessPayFinishModel> refundQuery = refundQuery(projectOid, userId, oid, refundOrderNo, true);
|
|
|
|
|
+ if (!refundQuery.getState().equals(com.github.microservice.net.ResultState.Success)){
|
|
|
log.info("查询退款结果失败:{}", refundQuery.getMsg());
|
|
log.info("查询退款结果失败:{}", refundQuery.getMsg());
|
|
|
- return false;
|
|
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
- log.info("refundStatus:{}", refundQuery.getContent().getRefundStatus());
|
|
|
|
|
- if (refundQuery.getContent().getRefundStatus().equals("PROCESSING") || refundQuery.getContent().getRefundStatus().equals("UNKNOWN")) {
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ if (refundQuery.getContent().getRefundStatus().equals("SUCCESS") || refundQuery.getContent().getRefundStatus().equals("FAIL")){
|
|
|
|
|
+ result.setData(refundQuery.getContent());
|
|
|
|
|
+ result.setDone(true);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ long time = System.currentTimeMillis() - it.getStartTime();
|
|
|
|
|
+ if (time > 3000L){
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- ResultContent resultContent = payCallService.unionFrictionlessPayRefundFinish(refundQuery.getContent());
|
|
|
|
|
- return resultContent.getState().equals(com.github.microservice.net.ResultState.Success);
|
|
|
|
|
- }, System.currentTimeMillis() + 30 * 24 * 60 * 60 * 1000L);
|
|
|
|
|
- return ResultContent.buildContent(refundResultContent.getContent());
|
|
|
|
|
|
|
+ log.info("退款状态未知或退款中,继续查询,index:{}", it.getIndex());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ });
|
|
|
|
|
+ return ResultContent.buildContent(unionFrictionlessPayFinishModel);
|
|
|
}
|
|
}
|
|
|
return ResultContent.buildFail(bodyMap.get("respDesc").toString());
|
|
return ResultContent.buildFail(bodyMap.get("respDesc").toString());
|
|
|
}
|
|
}
|