|
|
@@ -2,8 +2,11 @@ package org.dromara.backstage.business.payments;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.egzosn.pay.common.util.DateUtils;
|
|
|
import com.egzosn.pay.spring.boot.core.PayServiceManager;
|
|
|
import com.egzosn.pay.spring.boot.core.bean.MerchantPayOrder;
|
|
|
@@ -16,11 +19,12 @@ import org.dromara.backstage.payment.domain.vo.PayOrderVo;
|
|
|
import org.dromara.backstage.payment.service.IPayOrderService;
|
|
|
import org.dromara.backstage.payment.util.Img2Base64Util;
|
|
|
import org.dromara.backstage.payment.util.QRCodeUtil;
|
|
|
+import org.dromara.common.core.api.ReturnResult;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.enums.BalanceUpdateEnum;
|
|
|
import org.dromara.common.core.enums.CreditStatusEnum;
|
|
|
import org.dromara.common.core.enums.CreditTypeEnum;
|
|
|
-import org.dromara.common.core.utils.SpringUtils;
|
|
|
+import org.dromara.common.core.enums.ResultCodeEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -46,6 +50,7 @@ public class ThirdPayBusiness {
|
|
|
private final IPayOrderService payOrderService;
|
|
|
private final PayOrderBusiness payOrderBusiness;
|
|
|
private final WechatPayConfig wechatPayConfig;
|
|
|
+ //private final PayServiceManager manager;
|
|
|
|
|
|
/**
|
|
|
* 生成充值收款二维码
|
|
|
@@ -182,33 +187,44 @@ public class ThirdPayBusiness {
|
|
|
}
|
|
|
|
|
|
public R<Map<String,String>> createWechatQrCode(PayOrderVo vo) throws Exception {
|
|
|
- String orderSn = vo.getOrderId().toString();
|
|
|
- String callBackUrl = vo.getBackUrl() + orderSn;
|
|
|
- BigDecimal amount = vo.getReceiptMoney();
|
|
|
- Map<String, String> mapCode = new HashMap<>();
|
|
|
- mapCode.put("orderSn", vo.getOrderId().toString());
|
|
|
-
|
|
|
- String detailsId = "2";
|
|
|
- String wayTrade = "NATIVE";
|
|
|
- Map<String, Object> addition = new HashMap<String, Object>();
|
|
|
- addition.put("callBackUrl", callBackUrl);
|
|
|
-
|
|
|
- MerchantPayOrder payOrder = new MerchantPayOrder(detailsId, wayTrade, vo.getTitle(), "摘要",
|
|
|
- vo.getReceiptMoney(), orderSn);
|
|
|
- payOrder.setAddition(JSONObject.toJSONString(addition));
|
|
|
-
|
|
|
- PayServiceManager manager = SpringUtils.getBean(PayServiceManager.class);
|
|
|
- // 存放在二维码中的内容
|
|
|
- String text = manager.getQrPay(payOrder);
|
|
|
- // String text = "";
|
|
|
- // 嵌入二维码的图片路径
|
|
|
- String imgPath = wechatPayConfig.getQrCodeEmbed();
|
|
|
- // 生成的二维码的路径及名称
|
|
|
- String destPath = wechatPayConfig.getQrCodeDir() + "/"+ DateUtils.formatDate(new Date(), "yyyy/MM/dd/HHmmssSSS-") + amount + ".jpg";
|
|
|
- // 生成二维码
|
|
|
- QRCodeUtil.encode(text, imgPath, destPath, true);
|
|
|
- mapCode.put("qrCode", Img2Base64Util.getImgStr(destPath));
|
|
|
-
|
|
|
- return R.ok(mapCode);
|
|
|
+ String sendUrl = "http://localhost:8083/pay/qrCode";
|
|
|
+ HttpRequest req = HttpUtil.createPost(sendUrl);
|
|
|
+ req.body(JSONUtil.toJsonStr(vo));
|
|
|
+ try(HttpResponse res = req.execute()){
|
|
|
+ JSONObject object = JSONUtil.parseObj(res.body());
|
|
|
+ //return JSONUtil.toBean(res.body(), ReturnResult.class);
|
|
|
+ return R.ok();
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("[生成微信收款码错误]-[{0}]",e);
|
|
|
+ return R.fail("[生成微信收款码错误]");
|
|
|
+ }
|
|
|
+ //String orderSn = vo.getOrderId().toString();
|
|
|
+ //String callBackUrl = vo.getBackUrl() + orderSn;
|
|
|
+ //BigDecimal amount = vo.getReceiptMoney();
|
|
|
+ //Map<String, String> mapCode = new HashMap<>();
|
|
|
+ //mapCode.put("orderSn", vo.getOrderId().toString());
|
|
|
+ //
|
|
|
+ //String detailsId = "2";
|
|
|
+ //String wayTrade = "NATIVE";
|
|
|
+ //Map<String, Object> addition = new HashMap<>();
|
|
|
+ //addition.put("callBackUrl", callBackUrl);
|
|
|
+ //
|
|
|
+ //MerchantPayOrder payOrder = new MerchantPayOrder(detailsId, wayTrade, vo.getTitle(), "摘要",
|
|
|
+ // vo.getReceiptMoney(), orderSn);
|
|
|
+ //payOrder.setAddition(JSONObject.toJSONString(addition));
|
|
|
+ //
|
|
|
+ ////PayServiceManager manager = SpringUtils.getBean(PayServiceManager.class);
|
|
|
+ //// 存放在二维码中的内容
|
|
|
+ ////String text = manager.getQrPay(payOrder);
|
|
|
+ // String text = "1234567890123456890";
|
|
|
+ //// 嵌入二维码的图片路径
|
|
|
+ //String imgPath = wechatPayConfig.getQrCodeEmbed();
|
|
|
+ //// 生成的二维码的路径及名称
|
|
|
+ //String destPath = wechatPayConfig.getQrCodeDir() + "/"+ DateUtils.formatDate(new Date(), "yyyy/MM/dd/HHmmssSSS-") + amount + ".jpg";
|
|
|
+ //// 生成二维码
|
|
|
+ //QRCodeUtil.encode(text, imgPath, destPath, true);
|
|
|
+ //mapCode.put("qrCode", Img2Base64Util.getImgStr(destPath));
|
|
|
+
|
|
|
+ //return R.ok(mapCode);
|
|
|
}
|
|
|
}
|