package com.hai.openApi.config; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.RedisUtil; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; @Component public class BlxConfig { @Resource private RedisUtil redisUtil; /** * @Author Sum1Dream * @Name generateJw * @Description // 获取token * @Date 10:42 2023/7/11 * @Param [] * @Return java.lang.String */ public String generateJw() { Object token = redisUtil.get("BlxToken"); if (token == null) { Map map = new HashMap<>(); map.put("organizeCode" , "dhy"); JSONObject object = HttpsUtils.doGet("https://vertical-formats-gateway.blx.bodata.cn:18443/admin/api/generateJwt" , map); return object.getString("data"); } return token.toString(); } /** * @Author Sum1Dream * @Name queryCouponPage * @Description // 获取比邻星停车券列表 * @Date 10:57 2023/7/11 * @Param [] * @Return com.alibaba.fastjson.JSONObject */ public JSONObject queryCouponPage() { Map map = new HashMap<>(); map.put("rows" , "20"); map.put("currPage" , "1"); Map header = new HashMap<>(); header.put("token" , generateJw()); return HttpsUtils.doPost("https://vertical-formats-gateway.blx.bodata.cn:18443/admin/api/qureyCouponPage" , map , header); } /** * @Author Sum1Dream * @Name sendCoupon * @Description // 发放券 * @Date 11:01 2023/7/11 * @Param [object] * @Return com.alibaba.fastjson.JSONObject */ public JSONObject sendCoupon(JSONObject object) { Map map = new HashMap<>(); map.put("couponCode" , object.getString("couponCode")); map.put("receiverPhone" , object.getString("receiverPhone")); map.put("receiverCount" , object.getInteger("receiverCount")); Map header = new HashMap<>(); header.put("token" , generateJw()); return HttpsUtils.doPost("https://vertical-formats-gateway.blx.bodata.cn:18443/admin/api/qureyCouponPage" , map , header); } }