| package com.matrix.system.shopXcx.api.action; | 
|   | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.biz.bean.BizUser; | 
|   | 
| import com.matrix.component.redis.RedisUserLoginUtils; | 
| import com.matrix.system.shopXcx.bean.ShopWxAcode; | 
| import com.matrix.component.tools.WxacodeUtil; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import java.util.Collections; | 
|   | 
| /** | 
|  * @description 获取<link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}">接口 | 
|  * @author jiangyouyao | 
|  * @date 2019-07-03 15:15 | 
|  */ | 
| @CrossOrigin(origins = "*", maxAge = 3600) | 
| @Controller | 
| @RequestMapping(value = "wxapi/getAcode") | 
| public class WxGetAcodeAction { | 
|     @Autowired | 
|     private RedisUserLoginUtils redisUserLoginUtils; | 
|     /** | 
|      * 获取微信二维码 | 
|      * @param | 
|      * @return | 
|      */ | 
|     @PostMapping("/getWxAcode") | 
|     @ResponseBody | 
|     public AjaxResult getWxAcode(@RequestBody ShopWxAcode wxAcode) { | 
|         BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); | 
|         String openId = loginUser.getOpenId(); | 
|         //String openId = "omfv64kVgvGpz6D8p4J3WZYuT6M4"; | 
|         try { | 
|             String wxacodeUrl = WxacodeUtil.getWxacode(wxAcode.getScene(), wxAcode.getPage(), wxAcode.getFileName()); | 
|             String substring = wxacodeUrl.substring(0, 5); | 
|             if("error".equals(substring)){ | 
|                 return new AjaxResult(AjaxResult.STATUS_FAIL, wxacodeUrl); | 
|             } | 
|             wxAcode.setWxacodeUrl(wxacodeUrl); | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|   | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, Collections.singletonList(wxAcode)); | 
|         return result; | 
|     } | 
| } |