| package com.matrix.system.shopXcx.api.action; | 
|   | 
| import com.matrix.system.hive.bean.SysVipInfo; | 
| import com.matrix.component.redis.RedisUserLoginUtils; | 
| import com.matrix.component.tools.WxacodeUtil; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.system.shopXcx.api.WeChatApiTools; | 
| import com.matrix.system.shopXcx.bean.ShopWxAcode; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import java.util.Collections; | 
|   | 
| /** | 
|  * @description 获取 | 
|  * @author jiangyouyao | 
|  * @date 2019-07-03 15:15 | 
|  */ | 
| @CrossOrigin(origins = "*", maxAge = 3600) | 
| @Controller | 
| @RequestMapping(value = "wxapi/getAcode") | 
| public class WxGetAcodeAction { | 
|     @Autowired | 
|     private RedisUserLoginUtils redisUserLoginUtils; | 
|     @Autowired | 
|     WeChatApiTools weChatApiTools; | 
|     /** | 
|      * 获取微信二维码 | 
|      * @param | 
|      * @return | 
|      */ | 
|     @PostMapping("/getWxAcode") | 
|     @ResponseBody | 
|     public AjaxResult getWxAcode(@RequestBody ShopWxAcode wxAcode) { | 
|         SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
|         String openId = loginUser.getOpenId(); | 
|         try { | 
|             String wxacodeUrl = WxacodeUtil.getWxacode(wxAcode.getScene(), wxAcode.getPage(), wxAcode.getFileName(), | 
|                     weChatApiTools.getAppid(loginUser.getCompanyId()),weChatApiTools.getSecret(loginUser.getCompanyId())); | 
|             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; | 
|     } | 
| } |