|
|
@@ -230,35 +230,35 @@ public class PosTableController extends JeecgController<PosTable, IPosTableServi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- posTable.setId(UUIDGenerator.generate());
|
|
|
- LambdaQueryWrapper<WxAppConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(WxAppConfig::getTenantId, posTable.getTenantId());
|
|
|
- WxAppConfig wxApp = wxAppConfigService.getOne(lambdaQueryWrapper);
|
|
|
- if (wxApp == null) {
|
|
|
- throw new JeecgBootException("没有找到此appid");
|
|
|
- }
|
|
|
- //获取小程序二维码
|
|
|
- try {
|
|
|
- WxMaInRedisConfigStorage configStorage = new WxMaInRedisConfigStorage(redisTemplate);
|
|
|
- configStorage.setAppid(wxApp.getAppId());
|
|
|
- configStorage.setSecret(wxApp.getAppSecret());
|
|
|
- WxMaService wxMaService = new WxMaServiceImpl();
|
|
|
- wxMaService.setWxMaConfig(configStorage);
|
|
|
-
|
|
|
- File file = wxMaService.getQrcodeService().createQrcode("page/dc/index?id=" + posTable.getId(), 430);
|
|
|
- try {
|
|
|
- MultipartFile cMultiFile = new MockMultipartFile("file", file.getName(), null, new FileInputStream(file));
|
|
|
- String path = CommonUtils.upload(cMultiFile, "temp", CommonConstant.UPLOAD_TYPE_OSS);
|
|
|
- posTable.setQrCode(path);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- } catch (WxErrorException e) {
|
|
|
- e.printStackTrace();
|
|
|
-
|
|
|
- throw new JeecgBootException("获取小程序二维码失败:" + e.getMessage());
|
|
|
- }
|
|
|
+// posTable.setId(UUIDGenerator.generate());
|
|
|
+// LambdaQueryWrapper<WxAppConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+// lambdaQueryWrapper.eq(WxAppConfig::getTenantId, posTable.getTenantId());
|
|
|
+// WxAppConfig wxApp = wxAppConfigService.getOne(lambdaQueryWrapper);
|
|
|
+// if (wxApp == null) {
|
|
|
+// throw new JeecgBootException("没有找到此appid");
|
|
|
+// }
|
|
|
+// //获取小程序二维码
|
|
|
+// try {
|
|
|
+// WxMaInRedisConfigStorage configStorage = new WxMaInRedisConfigStorage(redisTemplate);
|
|
|
+// configStorage.setAppid(wxApp.getAppId());
|
|
|
+// configStorage.setSecret(wxApp.getAppSecret());
|
|
|
+// WxMaService wxMaService = new WxMaServiceImpl();
|
|
|
+// wxMaService.setWxMaConfig(configStorage);
|
|
|
+//
|
|
|
+// File file = wxMaService.getQrcodeService().createQrcode("page/dc/index?id=" + posTable.getId(), 430);
|
|
|
+// try {
|
|
|
+// MultipartFile cMultiFile = new MockMultipartFile("file", file.getName(), null, new FileInputStream(file));
|
|
|
+// String path = CommonUtils.upload(cMultiFile, "temp", CommonConstant.UPLOAD_TYPE_OSS);
|
|
|
+// posTable.setQrCode(path);
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// } catch (WxErrorException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+//
|
|
|
+// throw new JeecgBootException("获取小程序二维码失败:" + e.getMessage());
|
|
|
+// }
|
|
|
});
|
|
|
posTableService.saveBatch(posTables);
|
|
|
return Result.OK("添加成功!");
|
|
|
@@ -358,6 +358,55 @@ public class PosTableController extends JeecgController<PosTable, IPosTableServi
|
|
|
return Result.OK(posTable);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成二维码
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "pos_table-通过id查询")
|
|
|
+ @ApiOperation(value = "生成二维码", notes = "生成二维码")
|
|
|
+ @GetMapping(value = "/generateQRCode")
|
|
|
+ public Result<PosTable> generateQRCode (@RequestParam(name = "id", required = true) String id) {
|
|
|
+ PosTable posTable = posTableService.getById(id);
|
|
|
+ if (posTable == null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(posTable.getQrCode())) {
|
|
|
+ LambdaQueryWrapper<WxAppConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(WxAppConfig::getTenantId, posTable.getTenantId());
|
|
|
+ WxAppConfig wxApp = wxAppConfigService.getOne(lambdaQueryWrapper);
|
|
|
+ if (wxApp == null) {
|
|
|
+ throw new JeecgBootException("没有找到此appid");
|
|
|
+ }
|
|
|
+ //获取小程序二维码
|
|
|
+ try {
|
|
|
+ WxMaInRedisConfigStorage configStorage = new WxMaInRedisConfigStorage(redisTemplate);
|
|
|
+ configStorage.setAppid(wxApp.getAppId());
|
|
|
+ configStorage.setSecret(wxApp.getAppSecret());
|
|
|
+ WxMaService wxMaService = new WxMaServiceImpl();
|
|
|
+ wxMaService.setWxMaConfig(configStorage);
|
|
|
+
|
|
|
+ File file = wxMaService.getQrcodeService().createQrcode("page/dc/index?id=" + posTable.getId(), 430);
|
|
|
+ try {
|
|
|
+ MultipartFile cMultiFile = new MockMultipartFile("file", file.getName(), null, new FileInputStream(file));
|
|
|
+ String path = CommonUtils.upload(cMultiFile, "temp", CommonConstant.UPLOAD_TYPE_OSS);
|
|
|
+ posTable.setQrCode(path);
|
|
|
+ posTableService.updateById(posTable);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ throw new JeecgBootException("获取小程序二维码失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.OK(posTable);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出excel
|
|
|
*
|
|
|
@@ -390,6 +439,38 @@ public class PosTableController extends JeecgController<PosTable, IPosTableServi
|
|
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
|
List<PosTable> posTables = this.posTableService.listByIds(Arrays.asList(ids.split(",")));
|
|
|
for (PosTable posTable : posTables) {
|
|
|
+ if (StringUtils.isBlank(posTable.getQrCode())) {
|
|
|
+ LambdaQueryWrapper<WxAppConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(WxAppConfig::getTenantId, posTable.getTenantId());
|
|
|
+ WxAppConfig wxApp = wxAppConfigService.getOne(lambdaQueryWrapper);
|
|
|
+ if (wxApp == null) {
|
|
|
+ throw new JeecgBootException("没有找到此appid");
|
|
|
+ }
|
|
|
+ //获取小程序二维码
|
|
|
+ try {
|
|
|
+ WxMaInRedisConfigStorage configStorage = new WxMaInRedisConfigStorage(redisTemplate);
|
|
|
+ configStorage.setAppid(wxApp.getAppId());
|
|
|
+ configStorage.setSecret(wxApp.getAppSecret());
|
|
|
+ WxMaService wxMaService = new WxMaServiceImpl();
|
|
|
+ wxMaService.setWxMaConfig(configStorage);
|
|
|
+
|
|
|
+ File file = wxMaService.getQrcodeService().createQrcode("page/dc/index?id=" + posTable.getId(), 430);
|
|
|
+ try {
|
|
|
+ MultipartFile cMultiFile = new MockMultipartFile("file", file.getName(), null, new FileInputStream(file));
|
|
|
+ String path = CommonUtils.upload(cMultiFile, "temp", CommonConstant.UPLOAD_TYPE_OSS);
|
|
|
+ posTable.setQrCode(path);
|
|
|
+ posTableService.updateById(posTable);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ throw new JeecgBootException("获取小程序二维码失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isNotBlank(posTable.getQrCode())) {
|
|
|
URL url3 = null;
|
|
|
try {
|