|
|
|
@@ -8,6 +8,7 @@ import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.domain.po.WxAppinfo; |
|
|
|
import com.iformall.enums.EnumAppType; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxAppinfoMapper; |
|
|
|
import com.iformall.service.WxAppinfoService; |
|
|
|
@@ -28,6 +29,7 @@ import java.io.FileInputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxAppinfoServiceImpl implements WxAppinfoService { |
|
|
|
@@ -70,12 +72,15 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void tokenUpdate(String appId) { |
|
|
|
WxAppinfo appinfo = wxAppinfoMapper.findByAppId(appId); |
|
|
|
if (appinfo == null) { |
|
|
|
logger.error("APPID Not found: ", appId); |
|
|
|
throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); |
|
|
|
public void tokenUpdate(String tenantId) { |
|
|
|
WxAppinfo appQ = new WxAppinfo(); |
|
|
|
appQ.setTenantId(tenantId); |
|
|
|
appQ.setType(EnumAppType.C.getCode()); |
|
|
|
List<WxAppinfo> appList = wxAppinfoMapper.findList(appQ); |
|
|
|
if (appList.size() <= 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
WxAppinfo appinfo = appList.get(0); |
|
|
|
// get access_token |
|
|
|
WxMaInMemoryConfig config = new WxMaInMemoryConfig(); |
|
|
|
config.setAppid(appinfo.getAppId()); |
|
|
|
@@ -128,15 +133,18 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportQrcode(HttpServletRequest request, HttpServletResponse response, |
|
|
|
String appId, int type, String pageUrl, String sceneParam, |
|
|
|
String tenantId, int type, String pageUrl, String sceneParam, |
|
|
|
int withText, String text1, String text2 ) { |
|
|
|
// type 0 有限二维码, 1 无限制二维码 |
|
|
|
// withText 0 不带字 1. 带下面的字,2 带下面的两行字 |
|
|
|
WxAppinfo appinfo = wxAppinfoMapper.findByAppId(appId); |
|
|
|
if (appinfo == null) { |
|
|
|
logger.error("APPID Not found: ", appId); |
|
|
|
WxAppinfo appQ = new WxAppinfo(); |
|
|
|
appQ.setTenantId(tenantId); |
|
|
|
appQ.setType(EnumAppType.C.getCode()); |
|
|
|
List<WxAppinfo> appList = wxAppinfoMapper.findList(appQ); |
|
|
|
if (appList.size() <= 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
WxAppinfo appinfo = appList.get(0); |
|
|
|
boolean autoColor = false; |
|
|
|
boolean isHyaline = true; |
|
|
|
WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); |
|
|
|
@@ -166,22 +174,24 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { |
|
|
|
} |
|
|
|
try { |
|
|
|
Date imgDate = new Date(); |
|
|
|
if(StringUtils.isBlank(sceneParam)) { |
|
|
|
final File wxCode = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); |
|
|
|
if(type == 0) { |
|
|
|
final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); |
|
|
|
if (type == 1) { |
|
|
|
QRCodeUtils.graphicsGeneration(wxCode, dest, text1); |
|
|
|
QRCodeUtils.graphicsGeneration(codeFile, dest, text1); |
|
|
|
} else if (type == 2) { |
|
|
|
QRCodeUtils.graphicsGeneration2(wxCode, dest, text1, text2); |
|
|
|
QRCodeUtils.graphicsGeneration2(codeFile, dest, text1, text2); |
|
|
|
} |
|
|
|
wxCode.renameTo(dest); |
|
|
|
org.apache.commons.io.FileUtils.copyFile(codeFile, dest); |
|
|
|
org.apache.commons.io.FileUtils.forceDelete(codeFile); |
|
|
|
} else { |
|
|
|
final File wxCode = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); |
|
|
|
final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); |
|
|
|
if (type == 1) { |
|
|
|
QRCodeUtils.graphicsGeneration(wxCode, dest, text1); |
|
|
|
QRCodeUtils.graphicsGeneration(codeFile, dest, text1); |
|
|
|
} else if (type == 2) { |
|
|
|
QRCodeUtils.graphicsGeneration2(wxCode, dest, text1, text2); |
|
|
|
QRCodeUtils.graphicsGeneration2(codeFile, dest, text1, text2); |
|
|
|
} |
|
|
|
wxCode.renameTo(dest); |
|
|
|
org.apache.commons.io.FileUtils.copyFile(codeFile, dest); |
|
|
|
org.apache.commons.io.FileUtils.forceDelete(codeFile); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (WxErrorException e) { |
|
|
|
@@ -191,7 +201,7 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
downFile(filepath, fileName, response, request); |
|
|
|
downFile(destPath, fileName, response, request); |
|
|
|
org.apache.commons.io.FileUtils.forceDelete(dest); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
|