|
|
@@ -7,9 +7,6 @@ import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.egzosn.pay.common.util.DateUtils;
|
|
|
-import com.egzosn.pay.spring.boot.core.PayServiceManager;
|
|
|
-import com.egzosn.pay.spring.boot.core.bean.MerchantPayOrder;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.backstage.payment.config.WechatPayConfig;
|
|
|
@@ -17,19 +14,13 @@ import org.dromara.backstage.payment.domain.bo.PayOrderBo;
|
|
|
import org.dromara.backstage.payment.domain.bo.PurseInOutBo;
|
|
|
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.enums.ResultCodeEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.text.MessageFormat;
|
|
|
-import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -188,43 +179,25 @@ public class ThirdPayBusiness {
|
|
|
|
|
|
public R<Map<String,String>> createWechatQrCode(PayOrderVo vo) throws Exception {
|
|
|
String sendUrl = "http://localhost:8083/pay/qrCode";
|
|
|
+ vo.setBackUrl("http://localhost:8001/dev-api/self/teacher/api/v1/wechat/recharge/result/");
|
|
|
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();
|
|
|
+ String resCode = object.getStr("code");
|
|
|
+ String resMessage = object.getStr("message");
|
|
|
+ String resData = object.getStr("data");
|
|
|
+ if (ObjectUtil.equals(resCode, "200")) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("orderSn",vo.getOrderId().toString());
|
|
|
+ map.put("qrCode", resData);
|
|
|
+
|
|
|
+ return R.ok(map);
|
|
|
+ }
|
|
|
+ return R.fail(String.format("[生成微信收款码错误]-[%s]",resMessage));
|
|
|
}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);
|
|
|
}
|
|
|
}
|