|
@@ -4,6 +4,9 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.kym.common.R;
|
|
import com.kym.common.R;
|
|
|
import com.kym.common.annotation.ApiLog;
|
|
import com.kym.common.annotation.ApiLog;
|
|
|
|
|
+import com.kym.common.config.WxConfig;
|
|
|
|
|
+import com.kym.common.enums.WxApi;
|
|
|
|
|
+import com.kym.common.utils.HttpUtil;
|
|
|
import com.kym.entity.admin.vo.StationVo;
|
|
import com.kym.entity.admin.vo.StationVo;
|
|
|
import com.kym.entity.enplus.response.EnResponse;
|
|
import com.kym.entity.enplus.response.EnResponse;
|
|
|
import com.kym.entity.miniapp.ChargeOrder;
|
|
import com.kym.entity.miniapp.ChargeOrder;
|
|
@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -40,12 +44,16 @@ public class ChargerController {
|
|
|
|
|
|
|
|
private final EnNotifyService enNotifyService;
|
|
private final EnNotifyService enNotifyService;
|
|
|
|
|
|
|
|
- public ChargerController(StationService stationService, EnPlusService enPlusService, ChargeService chargeService, ChargeOrderService chargeOrderService, EnNotifyService enNotifyService) {
|
|
|
|
|
|
|
+ private final WxConfig wxConfig;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public ChargerController(StationService stationService, EnPlusService enPlusService, ChargeService chargeService, ChargeOrderService chargeOrderService, EnNotifyService enNotifyService, WxConfig wxConfig) {
|
|
|
this.stationService = stationService;
|
|
this.stationService = stationService;
|
|
|
this.enPlusService = enPlusService;
|
|
this.enPlusService = enPlusService;
|
|
|
this.chargeService = chargeService;
|
|
this.chargeService = chargeService;
|
|
|
this.chargeOrderService = chargeOrderService;
|
|
this.chargeOrderService = chargeOrderService;
|
|
|
this.enNotifyService = enNotifyService;
|
|
this.enNotifyService = enNotifyService;
|
|
|
|
|
+ this.wxConfig = wxConfig;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -93,7 +101,7 @@ public class ChargerController {
|
|
|
|
|
|
|
|
@ApiLog("取消预约充电")
|
|
@ApiLog("取消预约充电")
|
|
|
@GetMapping("/cancelBooking")
|
|
@GetMapping("/cancelBooking")
|
|
|
- R<?> cancelBooking(){
|
|
|
|
|
|
|
+ R<?> cancelBooking() {
|
|
|
chargeService.cancelBooking();
|
|
chargeService.cancelBooking();
|
|
|
return R.success();
|
|
return R.success();
|
|
|
}
|
|
}
|
|
@@ -150,6 +158,22 @@ public class ChargerController {
|
|
|
return R.success(chargeOrderService.orderDetailForApp(startChargeSeq));
|
|
return R.success(chargeOrderService.orderDetailForApp(startChargeSeq));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 图片二维码识别
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param imgUrl
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/qrCode")
|
|
|
|
|
+ R<?> qrCode(String imgUrl) {
|
|
|
|
|
+ var accessTokenJson = HttpUtil.getJson(WxApi.WX_GET_ACCESS_TOKEN.getApi(), Map.of("appid", wxConfig.getAppid(), "secret", wxConfig.getSecret()));
|
|
|
|
|
+ var accessToken = accessTokenJson.getString("access_token");
|
|
|
|
|
+ // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/img-ocr/img/scanQRCode.html
|
|
|
|
|
+ // 问候微信API文档撰写祖宗十八代,这里img_url也是url传参!!!
|
|
|
|
|
+ var res = HttpUtil.post(WxApi.WX_QR_CODE.getApi().replace("ACCESS_TOKEN", accessToken).concat("&img_url=%s".formatted(imgUrl)), Map.of(), JSONObject.class);
|
|
|
|
|
+ return R.success(res);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//====================================================以上是请求EN+接口==============================================================
|
|
//====================================================以上是请求EN+接口==============================================================
|
|
|
|
|
|
|
|
// 【我们请求en+时,数据都要加密验签;en+推送给我们的数据,需要验签解密,响应不需要加密。】
|
|
// 【我们请求en+时,数据都要加密验签;en+推送给我们的数据,需要验签解密,响应不需要加密。】
|