|
|
@@ -29,6 +29,7 @@ import com.zhongshu.card.server.core.service.paySetting.OrgPayAccountService;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import io.micrometer.common.util.StringUtils;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -93,15 +94,28 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
case SIGNED -> {//已签约
|
|
|
return ResultContent.buildFail("签约已完成,请勿重复请求");
|
|
|
}
|
|
|
- case UNSIGNED, RESCISSION -> {//未签约,已解约
|
|
|
+ case UNSIGNED -> {//未签约,已解约
|
|
|
return signApply(param, accountName, userId, mid);
|
|
|
}
|
|
|
- case DELETING_CONTRACT, APPLY -> {
|
|
|
- return ResultContent.buildFail("正在签约中,请等待银行返回结果");
|
|
|
+ case RESCISSION ->{
|
|
|
+ chinaumsSenselessUserSignInfoDao.deleteById(userSignInfo.getId());
|
|
|
+ return signApply(param, accountName, userId, mid);
|
|
|
+ }
|
|
|
+ case APPLY -> {
|
|
|
+ if (System.currentTimeMillis() >= userSignInfo.getExpireTime()){
|
|
|
+ chinaumsSenselessUserSignInfoDao.deleteById(userSignInfo.getId());
|
|
|
+ ChinaumsSenselessUserSignInfo newUserSignInfo = new ChinaumsSenselessUserSignInfo();
|
|
|
+ newUserSignInfo.setContractState(ContractState.UNSIGNED);
|
|
|
+ return ResultContent.buildContent(newUserSignInfo);
|
|
|
+ }
|
|
|
+ return ResultContent.buildContent(toUserSignModel(userSignInfo));
|
|
|
}
|
|
|
case UNKNOWN ->{
|
|
|
return ResultContent.buildFail("未知状态,请联系管理人员");
|
|
|
}
|
|
|
+ case DELETING_CONTRACT ->{
|
|
|
+ return ResultContent.buildFail("解约中,请等待银行返回结果");
|
|
|
+ }
|
|
|
}
|
|
|
}else {
|
|
|
return signApply(param, accountName, userId, mid);
|
|
|
@@ -110,6 +124,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
return ResultContent.buildFail("数据不存在,请联系管理员");
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
private Object signApply(UnionApplySignParam param, String accountName, String userId, String mid) {
|
|
|
PayProductParameter<Object> payProductParameter = new PayProductParameter<>();
|
|
|
payProductParameter.setAccountName(accountName);
|
|
|
@@ -117,9 +132,10 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
com.github.microservice.pay.client.ret.ResultContent<Object> signApplyResultContent = senselessPayService.signApply(payProductParameter);
|
|
|
if (signApplyResultContent.getState().equals(ResultState.Success)){
|
|
|
Object content = signApplyResultContent.getContent();
|
|
|
- Map<String, Object> resultMap = BeanUtil.bean2Map(content);
|
|
|
- String errCode = (String) resultMap.get("errCode");
|
|
|
- if ("SUCCESS".equals(errCode)){
|
|
|
+ String json = JsonUtil.toJson(content);
|
|
|
+ Map resultMap = JsonUtil.toObject(json, Map.class);
|
|
|
+ String errMsg = (String) resultMap.get("errMsg");
|
|
|
+ if ("success".equals(errMsg)){
|
|
|
ChinaumsSenselessUserSignInfo userSignInfo = new ChinaumsSenselessUserSignInfo();
|
|
|
userSignInfo.setUserId(userId);
|
|
|
userSignInfo.setContractNo(param.getContractNo());
|
|
|
@@ -128,6 +144,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
userSignInfo.setRelateSsn((String) resultMap.get("relateSsn"));
|
|
|
userSignInfo.setCqpMpAppId((String) resultMap.get("cqpMpAppId"));
|
|
|
userSignInfo.setCqpMpPath((String) resultMap.get("cqpMpPath"));
|
|
|
+ userSignInfo.setExpireTime(System.currentTimeMillis() + 30*60*1000);
|
|
|
chinaumsSenselessUserSignInfoDao.save(userSignInfo);
|
|
|
return signApplyResultContent;
|
|
|
}else {
|
|
|
@@ -140,6 +157,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
/**
|
|
|
* 解约
|
|
|
*/
|
|
|
+ @SneakyThrows
|
|
|
public Object signCancel(String userId, String projectOid) {
|
|
|
if (StringUtils.isBlank(userId)){
|
|
|
userId = getCurrentUserId();
|
|
|
@@ -177,9 +195,15 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
payProductParameter.setMeta(Map.of("contractId", userSignInfo.getContractId()));
|
|
|
com.github.microservice.pay.client.ret.ResultContent<Object> objectResultContent = senselessPayService.signCancel(payProductParameter);
|
|
|
if (objectResultContent.getState().equals(ResultState.Success)){
|
|
|
- userSignInfo.setContractState(ContractState.DELETING_CONTRACT);
|
|
|
- chinaumsSenselessUserSignInfoDao.save(userSignInfo);
|
|
|
- return ResultContent.buildSuccess();
|
|
|
+ String json = JsonUtil.toJson(objectResultContent.getContent());
|
|
|
+ Map resultMap = JsonUtil.toObject(json, Map.class);
|
|
|
+ String errMsg = (String) resultMap.get("errMsg");
|
|
|
+ if ("success".equals(errMsg)){
|
|
|
+ userSignInfo.setContractState(ContractState.DELETING_CONTRACT);
|
|
|
+ chinaumsSenselessUserSignInfoDao.save(userSignInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+ return ResultContent.buildFail((String) resultMap.get("errMsg"));
|
|
|
}
|
|
|
return ResultContent.buildFail("解约失败");
|
|
|
}
|
|
|
@@ -187,6 +211,8 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
return ResultContent.buildFail("当前状态不可解约,请稍后再试");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //TODO 添加 判断是否在平台外已经签约逻辑
|
|
|
public Object queryUserSignInfo(String userId, String projectOid){
|
|
|
if (StringUtils.isBlank(userId)){
|
|
|
userId = getCurrentUserId();
|
|
|
@@ -218,13 +244,13 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
/**
|
|
|
* 支付
|
|
|
*/
|
|
|
- public Object senselessPay(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String remark) {
|
|
|
+ public ResultContent senselessPay(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String remark) {
|
|
|
|
|
|
//获取银联支付产品账户及需要签约的商户号
|
|
|
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)){
|
|
|
- return accountModelResultContent;
|
|
|
+ return ResultContent.buildFail(accountModelResultContent.getMsg());
|
|
|
}
|
|
|
ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
String mid = conf.getMchId();
|
|
|
@@ -245,7 +271,7 @@ public class ChinaumsSenselessPayService extends SuperService {
|
|
|
request.setAttachedData(remark);
|
|
|
payProductParameter.setMeta(BeanUtil.bean2Map(request));
|
|
|
com.github.microservice.pay.client.ret.ResultContent<Object> collectionResultContent = senselessPayService.collection(payProductParameter);
|
|
|
- return collectionResultContent;
|
|
|
+ return ResultContent.buildContent(collectionResultContent.getContent());
|
|
|
}
|
|
|
|
|
|
public Object refund(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String refundOrderNo, String remark) {
|