|
@@ -6,6 +6,7 @@ import com.wechat.pay.java.service.payments.jsapi.model.*;
|
|
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.wxservice_server.config.exception.BizException;
|
|
@@ -14,10 +15,14 @@ import thyyxxk.wxservice_server.constant.OrderType;
|
|
|
import thyyxxk.wxservice_server.dao.WxApiDao;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
import thyyxxk.wxservice_server.entity.appointment.DoctorInfo;
|
|
|
+import thyyxxk.wxservice_server.entity.hrgresponse.NongPayResponse;
|
|
|
+import thyyxxk.wxservice_server.entity.hrgresponse.SourcesResponse;
|
|
|
import thyyxxk.wxservice_server.entity.wxapi.JsApiSHA1;
|
|
|
import thyyxxk.wxservice_server.entity.wxapi.GenMzPayQrcodeParam;
|
|
|
import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
|
|
|
import thyyxxk.wxservice_server.entity.wxapi.WxPyQrcdPrm;
|
|
|
+import thyyxxk.wxservice_server.factory.thmz.model.NongPayRequest;
|
|
|
+import thyyxxk.wxservice_server.factory.thmz.model.QueryReceiptRequest;
|
|
|
import thyyxxk.wxservice_server.factory.wechatpay.WeChatPayService;
|
|
|
import thyyxxk.wxservice_server.factory.wechatpay.model.NativePayResponse;
|
|
|
import thyyxxk.wxservice_server.factory.wechatpay.model.WechatPayGlobalRequest;
|
|
@@ -43,6 +48,8 @@ public class WxApiService {
|
|
|
this.savePayResultService = savePayResultService;
|
|
|
this.template = template;
|
|
|
}
|
|
|
+ @Value("${thyy.api-addr.nong-api}")
|
|
|
+ private String nongApi;
|
|
|
|
|
|
public JSONObject getAuthorization(String code) {
|
|
|
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" +
|
|
@@ -67,10 +74,11 @@ public class WxApiService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<WxPayOrder> createPayOrder(WxPayOrder order) {
|
|
|
+ order.setTotalFee(new BigDecimal(0.01));
|
|
|
WxPayOrder existOrder = getExistOrder(order);
|
|
|
if (null != existOrder) {
|
|
|
if (existOrder.getTradeState() == Transaction.TradeStateEnum.SUCCESS
|
|
|
- && existOrder.getCashpayAmt().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ && existOrder.getCashpayAmt().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
|
|
|
"您已支付过一笔相同金额的订单,请勿重复支付。");
|
|
|
}
|
|
@@ -103,6 +111,12 @@ public class WxApiService {
|
|
|
order.setSerialNo(response.getNonceStr());
|
|
|
order.setSignType(response.getSignType());
|
|
|
order.setPaySign(response.getPaySign());
|
|
|
+// order.setAppId("1");
|
|
|
+// order.setPrepayId("1");
|
|
|
+// order.setTimeStamp("1");
|
|
|
+// order.setSerialNo("1");
|
|
|
+// order.setSignType("1");
|
|
|
+// order.setPaySign("1");
|
|
|
}
|
|
|
if (null == order.getFundpayAmt()) {
|
|
|
order.setFundpayAmt(BigDecimal.ZERO);
|
|
@@ -129,6 +143,10 @@ public class WxApiService {
|
|
|
return ResultVoUtil.success(order);
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<Integer> updatePayNo(String payOrderId,String mchOrderNo,String tradeNo) {
|
|
|
+ return ResultVoUtil.success(dao.updatePayNo(payOrderId,mchOrderNo,tradeNo));
|
|
|
+ }
|
|
|
+
|
|
|
private WxPayOrder getExistOrder(WxPayOrder order) {
|
|
|
if (order.getOrderType() == OrderType.CLINIC_REGISTER.getCode() ||
|
|
|
order.getOrderType() == OrderType.REGISTRATION.getCode()) {
|
|
@@ -148,6 +166,28 @@ public class WxApiService {
|
|
|
return ResultVoUtil.success(response);
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<Transaction.TradeStateEnum> queryNongOrderState(String tradeNo) {
|
|
|
+ WxPayOrder order = dao.selectOrderByTradeNo(tradeNo);
|
|
|
+ if (order == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
|
|
|
+ }
|
|
|
+ String url = nongApi + "NongPay/query?type=0&mchOrderNo="+order.getMchOrderNo();
|
|
|
+ NongPayResponse response = template.getForObject(url, NongPayResponse.class);
|
|
|
+ if (response.getCode() == 9003 && (Integer) response.getData().get("state") == 2) {
|
|
|
+ dao.updatePayStatusAndPayTime(order.getTradeNo(), Transaction.TradeStateEnum.SUCCESS,DateUtil.formatDatetime(new Date((Long)response.getData().get("successTime"))));
|
|
|
+ return ResultVoUtil.success(Transaction.TradeStateEnum.SUCCESS);
|
|
|
+ } else {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络服务错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<Map<String, Object>> queryNongOrderPayOrder(NongPayRequest nongPayRequest) {
|
|
|
+ String url = nongApi + "NongPay/unifiedOrder";
|
|
|
+ NongPayResponse response = template.postForObject(url, nongPayRequest, NongPayResponse.class);
|
|
|
+ return ResultVoUtil.success(response.getData());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public String queryOrderState(String tradeNo) {
|
|
|
try {
|
|
|
while (TradeVectorUtil.tradeNoBeingQuery(tradeNo) || TradeVectorUtil.tradeNoBeingRefund(tradeNo)) {
|