|
@@ -1,14 +1,24 @@
|
|
|
package org.dromara.backstage.business.self;
|
|
package org.dromara.backstage.business.self;
|
|
|
|
|
|
|
|
import cn.hutool.core.codec.Base64;
|
|
import cn.hutool.core.codec.Base64;
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.dromara.backstage.consumption.domain.bo.XfCreditAccountBackBo;
|
|
|
|
|
+import org.dromara.backstage.consumption.domain.vo.XfCreditAccountBackVo;
|
|
|
|
|
+import org.dromara.backstage.consumption.service.IXfCreditAccountBackService;
|
|
|
|
|
+import org.dromara.backstage.domain.convert.YcVoConvert;
|
|
|
|
|
+import org.dromara.backstage.payment.domain.bo.WxOrderBo;
|
|
|
|
|
+import org.dromara.backstage.payment.domain.vo.WxOrderVo;
|
|
|
|
|
+import org.dromara.backstage.payment.service.IWxOrderService;
|
|
|
import org.dromara.backstage.task.AsyncTaskService;
|
|
import org.dromara.backstage.task.AsyncTaskService;
|
|
|
import org.dromara.common.core.api.ReturnResult;
|
|
import org.dromara.common.core.api.ReturnResult;
|
|
|
|
|
+import org.dromara.common.core.enums.CreditStatusEnum;
|
|
|
import org.dromara.common.core.enums.CreditTypeEnum;
|
|
import org.dromara.common.core.enums.CreditTypeEnum;
|
|
|
import org.dromara.common.core.enums.ResultCodeEnum;
|
|
import org.dromara.common.core.enums.ResultCodeEnum;
|
|
|
import org.dromara.common.core.exception.ApiException;
|
|
import org.dromara.common.core.exception.ApiException;
|
|
@@ -17,7 +27,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.text.MessageFormat;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -43,6 +55,8 @@ public class SelfBusiness {
|
|
|
@Value("${third-api.pay-api}")
|
|
@Value("${third-api.pay-api}")
|
|
|
String payApi;
|
|
String payApi;
|
|
|
private final AsyncTaskService asyncTaskService;
|
|
private final AsyncTaskService asyncTaskService;
|
|
|
|
|
+ private final IWxOrderService wxOrderService;
|
|
|
|
|
+ private final IXfCreditAccountBackService creditAccountBackService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取短信平台token
|
|
* 获取短信平台token
|
|
@@ -55,7 +69,7 @@ public class SelfBusiness {
|
|
|
String loginUrl = smsApi + "sms/api/v1/login";
|
|
String loginUrl = smsApi + "sms/api/v1/login";
|
|
|
// String loginUrl = "https://ykt.hnswdx.gov.cn/sms/api/v1/login";
|
|
// String loginUrl = "https://ykt.hnswdx.gov.cn/sms/api/v1/login";
|
|
|
HttpRequest req = HttpUtil.createPost(loginUrl);
|
|
HttpRequest req = HttpUtil.createPost(loginUrl);
|
|
|
- try(HttpResponse res = req.execute()) {
|
|
|
|
|
|
|
+ try(HttpResponse res = req.body(JSONUtil.toJsonStr(mapAccount)).execute()) {
|
|
|
ReturnResult result = JSONUtil.toBean(res.body(), ReturnResult.class);
|
|
ReturnResult result = JSONUtil.toBean(res.body(), ReturnResult.class);
|
|
|
log.info("[短信平台登录]-{}", JSONUtil.toJsonStr(result));
|
|
log.info("[短信平台登录]-{}", JSONUtil.toJsonStr(result));
|
|
|
if(result.isSuccess()){
|
|
if(result.isSuccess()){
|
|
@@ -99,6 +113,58 @@ public class SelfBusiness {
|
|
|
return createQrCode(creditType, userId, userXm, deptId, deptName, mobile, dealValue, callBackUrl);
|
|
return createQrCode(creditType, userId, userXm, deptId, deptName, mobile, dealValue, callBackUrl);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据人员Id和部门Id查询第三方支付订单的支付情况
|
|
|
|
|
+ * @param deptId 部门Id
|
|
|
|
|
+ * @param userId 人员Id
|
|
|
|
|
+ * @return 支付结果
|
|
|
|
|
+ */
|
|
|
|
|
+ public ReturnResult queryPayResultByUserAndDept(Long deptId,Long userId){
|
|
|
|
|
+ WxOrderBo bo = new WxOrderBo();
|
|
|
|
|
+ bo.setUserId(userId);
|
|
|
|
|
+ bo.setDeptId(deptId);
|
|
|
|
|
+
|
|
|
|
|
+ List<WxOrderVo> vos = wxOrderService.queryList(bo);
|
|
|
|
|
+ if(CollectionUtil.isEmpty(vos)){
|
|
|
|
|
+ return ReturnResult.failure(ResultCodeEnum.DATA_NOT_FOUND,
|
|
|
|
|
+ MessageFormat.format("无对应的支付订单,部门Id:{0},人员Id:{1}", deptId, userId));
|
|
|
|
|
+ }
|
|
|
|
|
+ String errMsg = String.format("[支付结果查询]-[deptId:%s,userId:%s]-[订单尚未支付成功]", deptId, userId);
|
|
|
|
|
+ WxOrderVo vo = vos.stream().filter(p-> ObjectUtil.equals(p.getCreditStatus(),"Y")).findFirst()
|
|
|
|
|
+ .orElseThrow(() -> new ApiException(errMsg));
|
|
|
|
|
+
|
|
|
|
|
+ return ReturnResult.success(YcVoConvert.ycWxOrderConvert(vo));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据第三方订单号查询订单入账结果
|
|
|
|
|
+ * @param orderSn 订单号
|
|
|
|
|
+ * @return 入账结果
|
|
|
|
|
+ */
|
|
|
|
|
+ public ReturnResult getCreditBackByOrderSn(String orderSn){
|
|
|
|
|
+ XfCreditAccountBackBo bo = new XfCreditAccountBackBo();
|
|
|
|
|
+ bo.setOriginalId(orderSn);
|
|
|
|
|
+ List<XfCreditAccountBackVo> vos = creditAccountBackService.queryList(bo);
|
|
|
|
|
+ if(CollectionUtil.isEmpty(vos)){
|
|
|
|
|
+ return ReturnResult.failure(ResultCodeEnum.DATA_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ObjectUtil.notEqual((vos.get(0).getCreditStatus()), CreditStatusEnum.SUCCESS.code())) {
|
|
|
|
|
+ return ReturnResult.failure(ResultCodeEnum.DATA_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ReturnResult.success();
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 请求生成微信收款二维码
|
|
|
|
|
+ * @param creditType 交易类型
|
|
|
|
|
+ * @param userId 人员Id
|
|
|
|
|
+ * @param userXm 人员姓名
|
|
|
|
|
+ * @param deptId 部门Id
|
|
|
|
|
+ * @param deptName 部门名称
|
|
|
|
|
+ * @param mobile 手机号
|
|
|
|
|
+ * @param dealValue 充值金额
|
|
|
|
|
+ * @param callBackUrl 回调地址
|
|
|
|
|
+ * @return 二维码
|
|
|
|
|
+ */
|
|
|
private ReturnResult createQrCode(CreditTypeEnum creditType, String userId, String userXm, String deptId, String deptName, String mobile, BigDecimal dealValue, String callBackUrl){
|
|
private ReturnResult createQrCode(CreditTypeEnum creditType, String userId, String userXm, String deptId, String deptName, String mobile, BigDecimal dealValue, String callBackUrl){
|
|
|
String sendUrl = payApi + "?title=" + CreditTypeEnum.WECHAT_RECHARGE.message() + "&userId=" + userId
|
|
String sendUrl = payApi + "?title=" + CreditTypeEnum.WECHAT_RECHARGE.message() + "&userId=" + userId
|
|
|
+ "&name=" + userXm
|
|
+ "&name=" + userXm
|