|
|
@@ -1,26 +1,38 @@
|
|
|
package org.jeecg.modules.pos.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
+import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.util.JwtUtil;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.common.util.CommonUtils;
|
|
|
+import org.jeecg.common.util.TenantContextHolder;
|
|
|
import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.business.entity.BusHotel;
|
|
|
import org.jeecg.modules.business.service.IBusHotelService;
|
|
|
+import org.jeecg.modules.mall.entity.MallUserInfo;
|
|
|
+import org.jeecg.modules.mall.entity.WxAppConfig;
|
|
|
+import org.jeecg.modules.mall.ma.WxMaInRedisConfigStorage;
|
|
|
+import org.jeecg.modules.mall.service.IWxAppConfigService;
|
|
|
import org.jeecg.modules.pos.entity.*;
|
|
|
import org.jeecg.modules.pos.service.*;
|
|
|
|
|
|
@@ -36,6 +48,9 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
@@ -67,6 +82,11 @@ public class PosTableController extends JeecgController<PosTable, IPosTableServi
|
|
|
private IPosTableTypeService posTableTypeService;
|
|
|
@Autowired
|
|
|
private IPosOrderGoodsService posOrderGoodsService;
|
|
|
+ @Resource
|
|
|
+ private IWxAppConfigService wxAppConfigService;
|
|
|
+ @Resource
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
|
@@ -155,10 +175,40 @@ public class PosTableController extends JeecgController<PosTable, IPosTableServi
|
|
|
throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ 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=", 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.save(posTable);
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 桌台用餐下单
|
|
|
*
|