优化话费定时任务代码

dev-discount
袁野 2 years ago
parent ff9a904401
commit 46ad424ee7
  1. 9
      hai-service/src/main/java/com/hai/config/WeChatQrcodeUtils.java

@ -11,6 +11,7 @@ import com.google.zxing.qrcode.QRCodeReader;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.RedisUtil; import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.enum_type.ActionNameEnum;
import com.hai.model.TextMessage; import com.hai.model.TextMessage;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
@ -104,13 +105,13 @@ public class WeChatQrcodeUtils {
} }
// 创建微信二维码 // 创建微信二维码
public JSONObject createWxQrCode(String sceneStr) { public JSONObject createWxQrCode(String sceneStr , String actionName) {
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
JSONObject objectScene = new JSONObject(); JSONObject objectScene = new JSONObject();
JSONObject objectActionInfo = new JSONObject(); JSONObject objectActionInfo = new JSONObject();
objectScene.put("scene_str" , sceneStr); objectScene.put("scene_str" , sceneStr);
objectActionInfo.put("scene" , objectScene); objectActionInfo.put("scene" , objectScene);
object.put("action_name" , "QR_STR_SCENE"); object.put("action_name" , actionName);
object.put("expire_seconds" , 2592000); object.put("expire_seconds" , 2592000);
object.put("action_info" , objectActionInfo); object.put("action_info" , objectActionInfo);
return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getWxToken(), object); return HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getWxToken(), object);
@ -343,7 +344,7 @@ public class WeChatQrcodeUtils {
String sceneId = "type=" + type + "&code=" + code + "&encryptType=" + encryptType; String sceneId = "type=" + type + "&code=" + code + "&encryptType=" + encryptType;
// 获取二维码参数 // 获取二维码参数
JSONObject wxQr = createWxQrCode(sceneId); JSONObject wxQr = createWxQrCode(sceneId , ActionNameEnum.actionName1.getName());
return wxQr.getString("url"); return wxQr.getString("url");
} }
@ -354,7 +355,7 @@ public class WeChatQrcodeUtils {
String sceneId = "type=" + type + "&code=" + code; String sceneId = "type=" + type + "&code=" + code;
// 获取二维码参数 // 获取二维码参数
JSONObject wxQr = createWxQrCode(sceneId); JSONObject wxQr = createWxQrCode(sceneId , ActionNameEnum.actionName1.getName());
return wxQr.getString("url"); return wxQr.getString("url");
} }

Loading…
Cancel
Save