|
|
@@ -1,5 +1,6 @@
|
|
|
package com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.app.stream.StreamHelper;
|
|
|
@@ -21,6 +22,9 @@ import com.zhongshu.payment.client.payModel.commn.PayOrderParam;
|
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.*;
|
|
|
import com.github.microservice.types.unionFrictionlessPayType.ContractState;
|
|
|
import com.github.microservice.types.unionFrictionlessPayType.UnionUserOpenType;
|
|
|
+import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.SignInParam;
|
|
|
+import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.UserRescissionParam;
|
|
|
+import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.UserSignQueryParam;
|
|
|
import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.UnionUserOpenInfoDao;
|
|
|
import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.UnionUserOpenInfo;
|
|
|
import com.zhongshu.payment.server.core.service.org.CollectionIdService;
|
|
|
@@ -35,7 +39,10 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 银联无感支付服务
|
|
|
@@ -133,17 +140,32 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
}
|
|
|
SignResponse response = (SignResponse) requestAPI;
|
|
|
log.info("response: {}", JSONUtil.toJsonStr(response));
|
|
|
+ unionUserOpenInfo.setResult(response);
|
|
|
+
|
|
|
unionUserOpenInfoDao.save(unionUserOpenInfo);
|
|
|
return ResultContent.buildSuccess(response);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 商户解约
|
|
|
+ * 解约
|
|
|
*
|
|
|
- * @param param
|
|
|
+ * @param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent rescission(SignInParam param) {
|
|
|
+ public ResultContent rescission(UserRescissionParam param) {
|
|
|
+ String userId = param.getUserId();
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
+ return ResultContent.buildFail("userId不能为空");
|
|
|
+ }
|
|
|
+ UnionUserOpenInfo unionUserOpenInfo = unionUserOpenInfoDao.findTopByContractId(param.getContractId());
|
|
|
+ if (ObjectUtils.isEmpty(unionUserOpenInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format("签约信息不存在:%s", param.getContractId()));
|
|
|
+ }
|
|
|
+ ContractState contractState = unionUserOpenInfo.getContractState();
|
|
|
+ if (contractState != ContractState.SIGNED) {
|
|
|
+ return ResultContent.buildFail("该用户未签约");
|
|
|
+ }
|
|
|
+
|
|
|
RescissionParam rescissionParam = new RescissionParam();
|
|
|
rescissionParam.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.rescission);
|
|
|
@@ -318,4 +340,31 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
return ResultContent.buildFail("暂未实现");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询签约的信息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent<List<UnionUserOpenInfoModel>> getUserSign(UserSignQueryParam param) {
|
|
|
+ String userId = param.getUserId();
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
+ return ResultContent.buildFail("userId 为空");
|
|
|
+ }
|
|
|
+ List<UnionUserOpenInfo> list = unionUserOpenInfoDao.findByUserId(userId);
|
|
|
+ List<UnionUserOpenInfoModel> models = new ArrayList<>();
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ models = list.stream().map(this::toModel).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(models);
|
|
|
+ }
|
|
|
+
|
|
|
+ public UnionUserOpenInfoModel toModel(UnionUserOpenInfo entity) {
|
|
|
+ UnionUserOpenInfoModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = new UnionUserOpenInfoModel();
|
|
|
+ BeanUtil.copyProperties(entity, model);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
}
|