|
|
@@ -13,7 +13,10 @@ import com.github.microservice.stream.model.OrderStateModel;
|
|
|
import com.github.microservice.stream.model.SignModel;
|
|
|
import com.github.microservice.types.OrderState;
|
|
|
import com.github.microservice.types.RefundStatus;
|
|
|
+import com.github.microservice.types.unionFrictionlessPayType.WithDrawOpenState;
|
|
|
+import com.github.microservice.types.unionFrictionlessPayType.WithDrawState;
|
|
|
import com.zhongshu.card.client.model.org.OrgUserDetailParam;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
|
|
|
import com.zhongshu.card.client.model.org.OrganizationUserModel;
|
|
|
import com.zhongshu.card.client.model.org.UserCountModel;
|
|
|
import com.zhongshu.card.client.service.feign.OrganizationFeignService;
|
|
|
@@ -27,8 +30,10 @@ import com.zhongshu.payment.client.payModel.commn.ClosePayOrderParam;
|
|
|
import com.zhongshu.payment.client.payModel.commn.CreateOrderParam;
|
|
|
import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
|
|
|
import com.zhongshu.payment.client.payModel.commn.PayOrderParam;
|
|
|
-import com.zhongshu.payment.client.payModel.cooperator.CooperatorParam;
|
|
|
+import com.zhongshu.payment.client.payModel.cooperator.*;
|
|
|
import com.zhongshu.payment.client.payModel.cooperator.model.*;
|
|
|
+import com.zhongshu.payment.client.payModel.cooperator.platmatModel.ShopBalanceModel;
|
|
|
+import com.zhongshu.payment.client.payModel.cooperator.platmatModel.ShopOpenWithDrawModel;
|
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.*;
|
|
|
import com.github.microservice.types.unionFrictionlessPayType.ContractState;
|
|
|
import com.github.microservice.types.unionFrictionlessPayType.UnionUserOpenType;
|
|
|
@@ -38,8 +43,11 @@ import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.Us
|
|
|
import com.zhongshu.payment.client.types.TradeType;
|
|
|
import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
|
|
|
import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.ShopOpenWithDrawDao;
|
|
|
+import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.ShopWithDrawRecordDao;
|
|
|
import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.UnionUserOpenInfoDao;
|
|
|
import com.zhongshu.payment.server.core.dataConfig.TimeConfig;
|
|
|
+import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.ShopOpenWithDraw;
|
|
|
+import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.ShopWithDrawRecord;
|
|
|
import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.UnionUserOpenInfo;
|
|
|
import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
|
|
|
import com.zhongshu.payment.server.core.service.org.CollectionIdService;
|
|
|
@@ -116,6 +124,12 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
@Autowired
|
|
|
ShopOpenWithDrawDao shopOpenWithDrawDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ShopWithDrawRecordDao shopWithDrawRecordDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CooperatorService cooperatorService;
|
|
|
+
|
|
|
/**
|
|
|
* 发起签约
|
|
|
*
|
|
|
@@ -720,7 +734,12 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent queryWithdrawBalance(CooperatorParam param) {
|
|
|
+ public ResultContent<ShopBalanceModel> queryWithdrawBalance(ShopIdParam param) {
|
|
|
+ String shopId = param.getShopId();
|
|
|
+ ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopId);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
QueryWithdrawBalanceParam requestParam = new QueryWithdrawBalanceParam();
|
|
|
requestParam.setMchntNo(getMchntNo(param.getShopId()));
|
|
|
requestParam.setSysId(withdrawConfig.getSysid());
|
|
|
@@ -733,7 +752,11 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
|
}
|
|
|
QueryWithdrawBalanceResponse response = (QueryWithdrawBalanceResponse) requestAPI;
|
|
|
- return ResultContent.buildSuccess();
|
|
|
+ ShopBalanceModel balanceModel = new ShopBalanceModel();
|
|
|
+ balanceModel.setShopId(shopId);
|
|
|
+ BigDecimal amount = new BigDecimal(response.getT0WithdrawAmt());
|
|
|
+ balanceModel.setAmount(amount);
|
|
|
+ return ResultContent.buildSuccess(balanceModel);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -742,23 +765,56 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent processWithdraw(CooperatorParam param) {
|
|
|
+ public ResultContent processWithdraw(ShopProcessWithdrawParam param) {
|
|
|
+ String shopId = param.getShopId();
|
|
|
+ ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopId);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
+ // 提现金额
|
|
|
+ BigDecimal withdrawAmt = BigDecimal.valueOf(param.getWithdrawAmt());
|
|
|
+
|
|
|
ProcessWithdrawParam requestParam = new ProcessWithdrawParam();
|
|
|
- requestParam.setMchntNo(getMchntNo(param.getShopId()));
|
|
|
+ requestParam.setMchntNo(getMchntNo(shopId));
|
|
|
requestParam.setSysId(withdrawConfig.getSysid());
|
|
|
requestParam.setAppType(withdrawConfig.getAppType());
|
|
|
String sysOrderId = collectionIdService.getNextNo();
|
|
|
requestParam.setSysOrderId(sysOrderId);
|
|
|
-
|
|
|
+ requestParam.setNotifyUrl(payConfig.getNotifyUrl() + "/" + sysOrderId);
|
|
|
+ requestParam.setWithdrawAmt(withdrawAmt.toPlainString()); // 提现金额
|
|
|
+ requestParam.setRemark(param.getRemark());
|
|
|
+ requestParam.setPostscript("提现");
|
|
|
+
|
|
|
+ // 商户信息
|
|
|
+ OrganizationSimpleModel shopInfo = resultContent.getContent();
|
|
|
+ // 提现记录数据
|
|
|
+ ShopWithDrawRecord drawRecord = new ShopWithDrawRecord();
|
|
|
+ drawRecord.setShopId(shopId);
|
|
|
+ drawRecord.setShopName(shopInfo.getName());
|
|
|
+ drawRecord.setMchntNo(getMchntNo(shopId));
|
|
|
+ drawRecord.setUserId(getCurrentUserId());
|
|
|
+ drawRecord.setWithDrawState(WithDrawState.WithDrawing);
|
|
|
+ drawRecord.setSysOrderId(sysOrderId);
|
|
|
+ drawRecord.setWithdrawAmt(withdrawAmt);
|
|
|
+ drawRecord.setTimes();
|
|
|
+ drawRecord.setRequestParam(requestParam);
|
|
|
+ drawRecord.setRemark(param.getRemark());
|
|
|
+ drawRecord.setSysId(requestParam.getSysId());
|
|
|
|
|
|
String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.processWithdraw);
|
|
|
SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
|
|
|
(url, requestParam, ProcessWithdrawResponse.class);
|
|
|
+ drawRecord.setResponse(requestAPI);
|
|
|
if (requestAPI.isFailed()) {
|
|
|
+ drawRecord.setWithDrawState(WithDrawState.Fail);
|
|
|
+ drawRecord.setDesc(String.format("提现失败,%s", requestAPI.getMsg()));
|
|
|
+ shopWithDrawRecordDao.save(drawRecord);
|
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
|
}
|
|
|
ProcessWithdrawResponse response = (ProcessWithdrawResponse) requestAPI;
|
|
|
- return ResultContent.buildSuccess();
|
|
|
+ drawRecord.setSsn(response.getSsn());
|
|
|
+ shopWithDrawRecordDao.save(drawRecord);
|
|
|
+ return ResultContent.buildSuccess(drawRecord);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -767,9 +823,16 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent queryOrderStatus(CooperatorParam param) {
|
|
|
+ public ResultContent<QueryOrderStatusResponse> queryOrderStatus(WithQueryParam param) {
|
|
|
+ ShopWithDrawRecord drawRecord = shopWithDrawRecordDao.findTopBySysOrderId(param.getSysOrderId());
|
|
|
+ if (ObjectUtils.isEmpty(drawRecord)) {
|
|
|
+ return ResultContent.buildFail(String.format("订单号不存在:%s", param.getSysOrderId()));
|
|
|
+ }
|
|
|
QueryOrderStatusParam requestParam = new QueryOrderStatusParam();
|
|
|
-
|
|
|
+ requestParam.setMchntNo(drawRecord.getMchntNo());
|
|
|
+ requestParam.setSysOrderId(drawRecord.getSysOrderId());
|
|
|
+ requestParam.setTransDate(DateUtils.paresTime(drawRecord.getCreateTime(), DateUtils.pattern1));
|
|
|
+ requestParam.setSysId(drawRecord.getSysId());
|
|
|
String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.queryOrderStatus);
|
|
|
SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
|
|
|
(url, requestParam, QueryOrderStatusResponse.class);
|
|
|
@@ -777,7 +840,74 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
|
}
|
|
|
QueryOrderStatusResponse response = (QueryOrderStatusResponse) requestAPI;
|
|
|
- return ResultContent.buildSuccess();
|
|
|
+
|
|
|
+ return ResultContent.buildSuccess(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询开通收钱吧 状态 业务
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent<ShopOpenWithDrawModel> getCooperatorOpenInfo(WithDrawOpenParam param) {
|
|
|
+ String shopOid = param.getShopOid();
|
|
|
+ ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopOid);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
+ ShopOpenWithDraw shopOpenWithDraw = shopOpenWithDrawDao.findTopByShopId(shopOid);
|
|
|
+ if (ObjectUtils.isEmpty(shopOpenWithDraw)) {
|
|
|
+ shopOpenWithDraw = new ShopOpenWithDraw();
|
|
|
+ OrganizationSimpleModel simpleModel = resultContent.getContent();
|
|
|
+ shopOpenWithDraw.setShopId(shopOid);
|
|
|
+ shopOpenWithDraw.setShopName(simpleModel.getName());
|
|
|
+ shopOpenWithDraw.setMchntNo(getMchntNo(shopOid));
|
|
|
+ shopOpenWithDraw.setWithDrawOpenState(WithDrawOpenState.UnOpen);
|
|
|
+ shopOpenWithDrawDao.save(shopOpenWithDraw);
|
|
|
+ }
|
|
|
+ if (shopOpenWithDraw.getWithDrawOpenState() == WithDrawOpenState.UnOpen) {
|
|
|
+ ResultContent<QueryWithdrawAuthstatusResponse> responseResultContent = queryWithdrawAuthstatus(param);
|
|
|
+ if (responseResultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(responseResultContent.getMsg());
|
|
|
+ }
|
|
|
+ QueryWithdrawAuthstatusResponse authstatusResponse = responseResultContent.getContent();
|
|
|
+ shopOpenWithDraw.setStatus(authstatusResponse.getStatus());
|
|
|
+ shopOpenWithDrawDao.save(shopOpenWithDraw);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(toModel(shopOpenWithDraw));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商户开通 收钱吧 提现功能
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent<ShopOpenWithDrawModel> cooperatorOpen(WithDrawOpenParam param) {
|
|
|
+ String shopOid = param.getShopOid();
|
|
|
+ ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopOid);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
+ ShopOpenWithDraw shopOpenWithDraw = shopOpenWithDrawDao.findTopByShopId(shopOid);
|
|
|
+ if (ObjectUtils.isEmpty(shopOpenWithDraw)) {
|
|
|
+ return ResultContent.buildFail(String.format("未查询到开通记录:%s", shopOid));
|
|
|
+ }
|
|
|
+ if (shopOpenWithDraw.getWithDrawOpenState() == WithDrawOpenState.UnOpen) {
|
|
|
+ ResultContent<OpenWithdrawResponse> responseResultContent = openWithdraw(param);
|
|
|
+ if (responseResultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(responseResultContent.getMsg());
|
|
|
+ }
|
|
|
+ OpenWithdrawResponse response = responseResultContent.getContent();
|
|
|
+ shopOpenWithDraw.setType(response.getType());
|
|
|
+ if (response.getStatus().equals("01")) {
|
|
|
+ // 满足开通条件
|
|
|
+ shopOpenWithDraw.setWithDrawOpenState(WithDrawOpenState.Open);
|
|
|
+ }
|
|
|
+ shopOpenWithDrawDao.save(shopOpenWithDraw);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(toModel(shopOpenWithDraw));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -786,8 +916,15 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent queryWithdrawAuthstatus(CooperatorParam param) {
|
|
|
+ public ResultContent<QueryWithdrawAuthstatusResponse> queryWithdrawAuthstatus(WithDrawOpenParam param) {
|
|
|
+ String shopId = param.getShopOid();
|
|
|
+ ResultContent<OrganizationSimpleModel> resultContent = organizationFeignService.getDetail(shopId);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
QueryWithdrawAuthstatusParam requestParam = new QueryWithdrawAuthstatusParam();
|
|
|
+ requestParam.setMchntNo(getMchntNo(shopId));
|
|
|
+ requestParam.setSysId(withdrawConfig.getSysid());
|
|
|
|
|
|
String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.queryWithdrawAuthstatus);
|
|
|
SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
|
|
|
@@ -796,7 +933,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
|
}
|
|
|
QueryWithdrawAuthstatusResponse response = (QueryWithdrawAuthstatusResponse) requestAPI;
|
|
|
- return ResultContent.buildSuccess();
|
|
|
+ return ResultContent.buildSuccess(response);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -805,7 +942,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent openWithdraw(CooperatorParam param) {
|
|
|
+ public ResultContent<OpenWithdrawResponse> openWithdraw(WithDrawOpenParam param) {
|
|
|
OpenWithdrawParam requestParam = new OpenWithdrawParam();
|
|
|
String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.openWithdraw);
|
|
|
SuperCooperatorResponseModel requestAPI = unionRequestService.requestCooperatorAPI
|
|
|
@@ -814,7 +951,6 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
|
}
|
|
|
OpenWithdrawResponse response = (OpenWithdrawResponse) requestAPI;
|
|
|
-
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -904,4 +1040,8 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
+ public ShopOpenWithDrawModel toModel(ShopOpenWithDraw entity) {
|
|
|
+ return cooperatorService.toModel(entity);
|
|
|
+ }
|
|
|
+
|
|
|
}
|