diff --git a/pom.xml b/pom.xml
index 2ea4374..ca2656e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,11 +20,23 @@
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
com.belerweb
pinyin4j
2.5.1
+
+ p6spy
+ p6spy
+ 3.8.2
+
org.apache.commons
commons-lang3
@@ -102,6 +114,22 @@
1.3.5
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.3.1
+
+
+ org.mybatis
+ mybatis-spring
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+
org.springframework.boot
spring-boot-starter-validation
@@ -203,6 +231,12 @@
io.netty
netty-all
+
+
+ com.alipay.sdk
+ alipay-sdk-java
+ 4.39.165.ALL
+
org.springframework.boot
spring-boot-starter-amqp
@@ -214,6 +248,11 @@
weixin-java-miniapp
3.8.0
+
+ junit
+ junit
+ test
+
@@ -273,4 +312,4 @@
-
\ No newline at end of file
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/alipayUtil/AlipayUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/alipayUtil/AlipayUtil.java
new file mode 100644
index 0000000..7617b8f
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/alipayUtil/AlipayUtil.java
@@ -0,0 +1,134 @@
+package com.chaozhanggui.system.cashierservice.alipayUtil;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.AlipayConfig;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.internal.util.AlipayEncrypt;
+import com.alipay.api.request.AlipaySystemOauthTokenRequest;
+import com.alipay.api.response.AlipaySystemOauthTokenResponse;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * 支付宝通用SDK工具类
+ *
+ * @author tankaikai
+ * @since 2024-09-23 16:15
+ */
+
+@Slf4j
+@Component
+public class AlipayUtil {
+
+ /**
+ * 网关地址 线上:https://openapi.alipay.com/gateway.do 沙箱:https://openapi.alipaydev.com/gateway.do
+ */
+ @Value("${alipay.sdk.config.serverUrl}")
+ private String serverUrl;
+ /**
+ * 应用ID
+ */
+ @Value("${alipay.sdk.config.appId}")
+ private String appId;
+ /**
+ * 应用私钥
+ */
+ @Value("${alipay.sdk.config.privateKey}")
+ private String privateKey;
+ /**
+ * 支付宝公钥
+ */
+ @Value("${alipay.sdk.config.alipayPublicKey}")
+ private String alipayPublicKey;
+ /**
+ * 支付宝公钥
+ */
+ @Value("${alipay.sdk.config.encryptKey}")
+ private String encryptKey;
+
+ /**
+ * 创建支付宝客户端
+ * @return AlipayClient
+ */
+ @SneakyThrows
+ public AlipayClient createClient() {
+ AlipayConfig alipayConfig = new AlipayConfig();
+ //设置网关地址
+ alipayConfig.setServerUrl(serverUrl);
+ //设置应用ID
+ alipayConfig.setAppId(appId);
+ //设置应用私钥
+ alipayConfig.setPrivateKey(privateKey);
+ //设置支付宝公钥
+ alipayConfig.setAlipayPublicKey(alipayPublicKey);
+ return new DefaultAlipayClient(alipayConfig);
+ }
+
+ /**
+ * 获取支付宝用户的openId
+ * @param code 用户信息授权码
+ * @return openId
+ */
+ public String getOpenId(String code) throws Exception{
+ AlipaySystemOauthTokenRequest req = new AlipaySystemOauthTokenRequest();
+ //SDK已经封装掉了公共参数,这里只需要传入业务参数
+ req.setCode(code);
+ req.setGrantType("authorization_code");
+ //此次只是参数展示,未进行字符串转义,实际情况下请转义
+ //req.setBizContent(" {" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }");
+ AlipaySystemOauthTokenResponse response;
+ try {
+ response = createClient().execute(req);
+ }catch (AlipayApiException e){
+ log.error("获取支付宝用户信息失败,错误码:{},错误信息:{}", e.getErrCode(), e.getErrMsg());
+ throw e;
+ }
+ log.info("获取支付宝用户信息成功,返回结果:{}", response.getBody());
+ //调用失败
+ if (!response.isSuccess()) {
+ log.error("获取支付宝用户信息失败,错误码:{},错误信息:{}", response.getSubCode(), response.getSubMsg());
+ throw new AlipayApiException(response.getSubCode(), response.getSubMsg());
+ }
+ //调用成功,则处理业务逻辑,为配合支付系统确定沿用支付宝的老标准使用userId
+ return response.getUserId();
+ }
+
+ /**
+ * 获取支付宝用户的手机号码
+ * @param encryptedData 密文
+ * @return mobile
+ */
+ public String getMobile(String encryptedData) throws Exception{
+ if(StrUtil.isEmpty(encryptedData)){
+ throw new AlipayApiException("加密数据不能为空");
+ }
+ try {
+ log.info("解密前的数据,返回结果:{}", encryptedData);
+ String resp = AlipayEncrypt.decryptContent(encryptedData, "AES", encryptKey, "UTF-8");
+ log.info("解密后的数据,返回结果:{}", resp);
+ boolean isJson = JSONUtil.isJson(resp);
+ if(!isJson){
+ throw new AlipayApiException("解密后的数据不是json格式");
+ }
+ JSONObject jsonObject = JSONUtil.parseObj(resp);
+ String code = jsonObject.getStr("code");
+ String msg = jsonObject.getStr("msg");
+ String mobile = jsonObject.getStr("mobile");
+ if("10000".equals(code)){
+ return mobile;
+ }else{
+ throw new AlipayApiException(code,msg);
+ }
+ }catch (AlipayApiException e){
+ log.error("获取支付宝用户的手机号码失败,错误码:{},错误信息:{}", e.getErrCode(), e.getErrMsg());
+ throw e;
+ }
+ }
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/AuthSource.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/AuthSource.java
new file mode 100644
index 0000000..11b952e
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/AuthSource.java
@@ -0,0 +1,35 @@
+package com.chaozhanggui.system.cashierservice.auth;
+
+/**
+ * 三方登录认证来源
+ * @author tankaikai
+ * @since 2024-09-23 17:51
+ */
+public enum AuthSource {
+ WECHAT("微信", "wechat"),
+ ALIPAY("支付宝", "alipay");
+
+ private String name;
+ private String value;
+
+ AuthSource(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java
index d2d0f9c..cb6cfc2 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java
@@ -49,6 +49,7 @@ public class LoginFilter implements Filter {
// "cashierService/login/**",//登录部分接口不校验
"cashierService/login/wx/**",//登录部分接口不校验
+ "cashierService/login/auth/**",//登录部分接口不校验
"cashierService/login/app/login",//登录部分接口不校验
"cashierService/product/queryProduct",
"cashierService/product/queryProductSku",
@@ -94,7 +95,7 @@ public class LoginFilter implements Filter {
return;
}
- //environment 环境标识 wx app 后续environment不可为空
+ //environment 环境标识 wx alipay app 后续environment不可为空
String environment = request.getHeader("environment");
// 判断用户TOKEN是否存在
@@ -130,7 +131,7 @@ public class LoginFilter implements Filter {
String userId = jsonObject1.getString("userId");
tokenKey=RedisCst.ONLINE_APP_USER.concat(userId);
//获取redis中的token
- }else if(environment.equals("wx")){
+ }else if(environment.equals("wx") || environment.equals("alipay")){
//获取当前登录人的用户id
String openId = jsonObject1.getString("openId");
if(StringUtils.isBlank(openId)){
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/config/RequestLoggingConfig.java b/src/main/java/com/chaozhanggui/system/cashierservice/config/RequestLoggingConfig.java
new file mode 100644
index 0000000..e5207cf
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/config/RequestLoggingConfig.java
@@ -0,0 +1,30 @@
+package com.chaozhanggui.system.cashierservice.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+import org.springframework.web.filter.CommonsRequestLoggingFilter;
+
+@Configuration
+public class RequestLoggingConfig {
+ @Bean
+ @Order(-9999)
+ public CommonsRequestLoggingFilter logFilter() {
+ CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter();
+ // 是否记录请求的查询参数信息
+ filter.setIncludeQueryString(true);
+ // 是否记录请求body内容
+ filter.setIncludePayload(true);
+ filter.setMaxPayloadLength(10000);
+ //是否记录请求header信息
+ filter.setIncludeHeaders(false);
+ // 是否记录请求客户端信息
+ filter.setIncludeClientInfo(true);
+ // 设置日期记录的前缀
+ filter.setBeforeMessagePrefix("\033[32;4m请求开始:");
+ filter.setBeforeMessageSuffix("\033[0m");
+ filter.setAfterMessagePrefix("\033[34m请求结束:");
+ filter.setAfterMessageSuffix("\033[0m");
+ return filter;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/constant/TableConstant.java b/src/main/java/com/chaozhanggui/system/cashierservice/constant/TableConstant.java
new file mode 100644
index 0000000..4a422df
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/constant/TableConstant.java
@@ -0,0 +1,6 @@
+package com.chaozhanggui.system.cashierservice.constant;
+
+public interface TableConstant {
+
+ String CART_SEAT_ID = "-999";
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java
index ae9f246..c826119 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java
@@ -1,12 +1,13 @@
package com.chaozhanggui.system.cashierservice.controller;
-import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopExtendMapper;
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
import com.chaozhanggui.system.cashierservice.entity.dto.WxMsgSubDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.DistrictVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
+import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.service.FileService;
@@ -174,6 +175,15 @@ public class CommonController {
return new Result(CodeEnum.SUCCESS, extendMapper.queryByShopIdAndAutoKey(Integer.valueOf(map.get("shopId").toString()),map.get("autokey")));
}
+ /**
+ * 交班
+ */
+ @PostMapping("common/handoverData")
+ public Result handoverData(@RequestBody Map map) throws Exception{
+ PushToClientChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(map),map.get("shopId"));
+ return Result.success(CodeEnum.SUCCESS);
+ }
+
// 检查手机号格式是否正确的方法
private boolean isValidPhoneNumber(String phone) {
return phone.matches("^1[3-9]\\d{9}$");
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java
index 8fd3de8..55dc30d 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java
@@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.controller;
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.AlipayApiException;
+import com.chaozhanggui.system.cashierservice.alipayUtil.AlipayUtil;
+import com.chaozhanggui.system.cashierservice.auth.AuthSource;
import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper;
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
@@ -16,10 +18,12 @@ import com.chaozhanggui.system.cashierservice.service.LoginService;
import com.chaozhanggui.system.cashierservice.service.OnlineUserService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
-import com.chaozhanggui.system.cashierservice.util.*;
+import com.chaozhanggui.system.cashierservice.util.IpUtil;
+import com.chaozhanggui.system.cashierservice.util.MD5Utils;
+import com.chaozhanggui.system.cashierservice.util.StringUtil;
+import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -60,28 +64,27 @@ public class LoginContoller {
@Autowired
RedisUtil redisUtil;
+ @Resource
+ AlipayUtil alipayUtil;
+
@RequestMapping("/wx/business/login")
- public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code,
- @RequestParam(value = "shopId", required = false) String shopId
- ) {
+ public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code, @RequestParam(value = "shopId", required = false) String shopId) {
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, businessAppId, businessSecrete);
String openid = SessionKeyOpenId.getString("openid");
- if(Objects.isNull(openid)){
+ if (Objects.isNull(openid)) {
return Result.fail("获取微信id失败");
}
- return loginService.wxBusinessLogin(openid,shopId);
+ return loginService.wxBusinessLogin(openid, shopId);
}
@GetMapping("/wx/business/openId")
- public Result getOpenId(
- @RequestParam String code
- ) {
+ public Result getOpenId(@RequestParam String code) {
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
String openid = SessionKeyOpenId.getString("openid");
- if(Objects.isNull(openid)){
+ if (Objects.isNull(openid)) {
return Result.fail("获取微信id失败");
}
@@ -95,50 +98,46 @@ public class LoginContoller {
* @param map
* @return
*/
- @RequestMapping("/wx/custom/login")
- public Result wxCustomLogin(HttpServletRequest request, @RequestBody Map map) {
+ @RequestMapping("/auth/custom/login")
+ public Result authCustomLogin(HttpServletRequest request, @RequestBody Map map) {
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
Result.fail("code不能为空");
}
- String code = map.get("code").toString();
- String rawData = map.get("rawData");
-// String signature = map.get("signature");
-// String encryptedData = map.get("encryptedData");
-// String ivStr = map.get("iv");
-// String phone = map.get("phone");
- // 用户非敏感信息:rawData
- // 签名:signature
- JSONObject rawDataJson = JSON.parseObject(rawData);
- // 1.接收小程序发送的code
- // 2.开发者服务器 登录凭证校验接口 appi + appsecret + code
- JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
- // 3.接收微信接口服务 获取返回的参数
- String openid = SessionKeyOpenId.getString("openid");
-// String sessionKey = SessionKeyOpenId.getString("session_key");
-
- // 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey)
-// String signature2 = DigestUtils.sha1Hex(rawData + sessionKey);
-// if (!signature.equals(signature2)) {
-// return Result.fail("签名校验失败");
-// }
-// String phone = "";
-// try{
-// String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
-// if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
-// }// phone =JSONObject.parseObject(data).get("phoneNumber").toString();
-// }catch (Exception e){
-// log.info("登录传参:获取手机号失败{}",e.getMessage());
-// }
- String nickName = rawDataJson.getString("nickName");
- String avatarUrl = rawDataJson.getString("avatarUrl");
- try {
- return loginService.wxCustomLogin(openid, avatarUrl, nickName, "", IpUtil.getIpAddr(request));
- } catch (Exception e) {
- e.printStackTrace();
+ // 三方登录来源 wechat、alipay
+ String source = map.getOrDefault("source",AuthSource.WECHAT.getValue());
+ String code = map.get("code");
+ if(AuthSource.WECHAT.getValue().equals(source)){
+ try {
+ // 1.接收小程序发送的code
+ // 2.开发者服务器 登录凭证校验接口 appi + appsecret + code
+ JSONObject wxResp = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
+ //Integer errCode = wxResp.getInteger("errcode");
+ log.info("微信获取openid响应报文:{}", wxResp.toJSONString());
+ boolean hasOpenId = wxResp.containsKey("openid");
+ if (!hasOpenId) {
+ return Result.fail("登录失败:" + wxResp.getString("errmsg"));
+ }
+ String a = "{\"width\":\"58\",\"printerNum\":\"1\",\"categoryList\":[{\"id\":30,\"name\":\"奶茶\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":35,\"name\":\"酒水饮料\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":65,\"name\":\"火锅\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":95,\"name\":\"串串\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":96,\"name\":\"烧烤\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null}],\"model\":\"normal\",\"feet\":\"0\",\"autoCut\":\"1\"}";
+ // 3.接收微信接口服务 获取返回的参数
+ String openid = wxResp.getString("openid");
+ return loginService.wxCustomLogin(openid, "", "", "", IpUtil.getIpAddr(request));
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("登录失败:",e);
+ }
+ }else if(AuthSource.ALIPAY.getValue().equals(source)){
+ try {
+ String openId = alipayUtil.getOpenId(code);
+ return loginService.alipayCustomLogin(openId);
+ }catch (AlipayApiException e){
+ log.error("登录失败:",e);
+ return Result.fail("登录失败:"+e.getErrMsg());
+ }catch (Exception e){
+ e.printStackTrace();
+ log.error("登录失败:",e);
+ }
}
-
return Result.fail("登录失败");
-
}
@@ -179,14 +178,28 @@ public class LoginContoller {
// return Result.fail("获取手机号失败,请重试!");
// }
@RequestMapping("getPhoneNumber")
- public Result getPhoneNumber(@RequestHeader String openId,@RequestBody Map map) {
-
+ public Result getPhoneNumber(@RequestHeader String openId, @RequestBody Map map) {
+ String encryptedData = map.get("encryptedData");
+ // 三方登录来源 wechat、alipay
+ String source = map.getOrDefault("source",AuthSource.WECHAT.getValue());
+ if (AuthSource.ALIPAY.getValue().equals(source)) {
+ try {
+ String mobile = alipayUtil.getMobile(encryptedData);
+ return Result.success(CodeEnum.SUCCESS, mobile);
+ }catch (AlipayApiException e){
+ log.error("获取手机号失败:",e);
+ return Result.fail("获取手机号失败:"+e.getErrMsg());
+ }catch (Exception e){
+ e.printStackTrace();
+ log.error("登录手机号失败:",e);
+ return Result.fail("获取手机号失败:未知错误");
+ }
+ }
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
Result.fail("code不能为空");
}
- String code = map.get("code").toString();
+ String code = map.get("code");
- String encryptedData = map.get("encryptedData");
String ivStr = map.get("iv");
if (StringUtils.isBlank(encryptedData) || StringUtils.isBlank(ivStr)) {
@@ -201,14 +214,14 @@ public class LoginContoller {
try {
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
// if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) {
- return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
+ return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
// }
// log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
// return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString());
}
- } catch (Exception e){
+ } catch (Exception e) {
// e.printStackTrace();
- log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,data);
+ log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},", sessionKey, encryptedData, ivStr, data);
}
return Result.fail("获取手机号失败,请重试!");
}
@@ -254,10 +267,8 @@ public class LoginContoller {
* @return
*/
@GetMapping("createCardNo")
- public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id,
- @RequestParam("shopId") String shopId
- ) {
- return loginService.createCardNo(id, openId,shopId);
+ public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id, @RequestParam("shopId") String shopId) {
+ return loginService.createCardNo(id, openId, shopId);
}
@GetMapping("/userInfo")
@@ -267,6 +278,7 @@ public class LoginContoller {
/**
* 更新用户信息
+ *
* @param token
* @param userInfo
* @return
@@ -281,16 +293,16 @@ public class LoginContoller {
}
@PostMapping(value = "/upPass")
- public Result upPass(@RequestHeader String token,@RequestBody UserPassDto passVo){
+ public Result upPass(@RequestHeader String token, @RequestBody UserPassDto passVo) {
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
String newPass = MD5Utils.MD5Encode(passVo.getNewPass(), "utf-8");
if (ObjectUtil.isNull(passVo.getCode())) {
String oldPass = MD5Utils.MD5Encode(passVo.getOldPass(), "utf-8");
- return loginService.upPass(userId,oldPass, newPass);
+ return loginService.upPass(userId, oldPass, newPass);
} else {
boolean tf = loginService.validate(passVo.getCode(), passVo.getPhone());
if (tf) {
- TbUserInfo userInfo=new TbUserInfo();
+ TbUserInfo userInfo = new TbUserInfo();
userInfo.setId(Integer.valueOf(userId));
userInfo.setPassword(newPass);
return loginService.upUserInfo(userInfo);
@@ -301,16 +313,16 @@ public class LoginContoller {
}
@PostMapping(value = "modityPass")
- public Result modityPass(@RequestHeader String token,@RequestBody UserPassDto passVo){
+ public Result modityPass(@RequestHeader String token, @RequestBody UserPassDto passVo) {
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
String newPass = MD5Utils.MD5Encode(passVo.getNewPass(), "utf-8");
if (ObjectUtil.isNull(passVo.getCode())) {
String oldPass = MD5Utils.MD5Encode(passVo.getOldPass(), "utf-8");
- return loginService.upPass(userId,oldPass, newPass);
+ return loginService.upPass(userId, oldPass, newPass);
} else {
boolean tf = loginService.validate(passVo.getCode(), passVo.getPhone());
if (tf) {
- TbUserInfo userInfo=new TbUserInfo();
+ TbUserInfo userInfo = new TbUserInfo();
userInfo.setId(Integer.valueOf(userId));
userInfo.setPassword(newPass);
return loginService.upUserInfo(userInfo);
@@ -359,12 +371,12 @@ public class LoginContoller {
}
//验证密码
String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8");
- return loginService.appLogin(authUserDto.getUsername(),openid, mdPasswordString);
+ return loginService.appLogin(authUserDto.getUsername(), openid, mdPasswordString);
} else {
// tf = true;
tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername());
if (tf) {
- return loginService.appLogin(authUserDto.getUsername(),openid, null);
+ return loginService.appLogin(authUserDto.getUsername(), openid, null);
} else {
return Result.fail("验证码输入有误");
}
@@ -393,29 +405,31 @@ public class LoginContoller {
/**
* 重置资金密码
+ *
* @param token
* @param map
* @return
*/
@RequestMapping("resetPwd")
- public Result resetPwd(@RequestHeader String token,@RequestBody Map map){
+ public Result resetPwd(@RequestHeader String token, @RequestBody Map map) {
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
- return loginService.resetPwd(userId,map);
+ return loginService.resetPwd(userId, map);
}
/**
* 修改密码
+ *
* @param token
* @param map
* @return
*/
@RequestMapping("mpdifyPwd")
- public Result mpdifyPwd(@RequestHeader String token,@RequestBody Map map){
+ public Result mpdifyPwd(@RequestHeader String token, @RequestBody Map map) {
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
- return loginService.modifyPwd(userId,map);
+ return loginService.modifyPwd(userId, map);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java
index 3ad44f8..03422d7 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java
@@ -4,9 +4,9 @@ package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
-import com.chaozhanggui.system.cashierservice.entity.Enum.PayTypeConstant;
import com.chaozhanggui.system.cashierservice.interceptor.RequestWrapper;
import com.chaozhanggui.system.cashierservice.service.PayService;
+import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,8 +14,8 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
-import java.util.Random;
@CrossOrigin(origins = "*")
@RestController
@@ -79,6 +79,7 @@ public class NotifyController {
&& !"0100".equals(object.getStr("payType"))
){
String orderNo=object.getStr("orderNumber");
+
return payService.callBackPay(orderNo);
}
}
@@ -86,6 +87,15 @@ public class NotifyController {
return null;
}
+ /**
+ * 支付取消
+ * @return 影响数量
+ */
+ @PostMapping("cancel")
+ public Result notifyCancel(@RequestBody HashMap data) {
+ return Result.successWithData(payService.cancelOrder(data.get("orderId")));
+ }
+
@RequestMapping("notifyfstCallBack")
public String notifyfstCallBack(HttpServletRequest request){
@@ -99,7 +109,11 @@ public class NotifyController {
if("TRADE_SUCCESS".equals(object.get("state").toString())){
String orderNo=object.get("mchOrderNo").toString();
String tradeNo=object.get("payOrderId").toString();
- return payService.callBackPayFST(tradeNo);
+ String payType=object.getStr("payType");
+ return payService.callBackPayFST(tradeNo,payType);
+ }else {
+ String tradeNo=object.get("payOrderId").toString();
+ return String.valueOf(payService.activateOrder(tradeNo));
}
}
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java
index 64491fc..879da9a 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java
@@ -1,14 +1,16 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
-import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
-import com.chaozhanggui.system.cashierservice.entity.dto.OrderDto;
+import com.alibaba.fastjson.JSONObject;
+import com.chaozhanggui.system.cashierservice.redis.RedisCst;
+import com.chaozhanggui.system.cashierservice.service.CartService;
import com.chaozhanggui.system.cashierservice.service.OrderService;
import com.chaozhanggui.system.cashierservice.sign.Result;
+import com.chaozhanggui.system.cashierservice.util.Utils;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
-import javax.annotation.Resource;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
@@ -19,19 +21,25 @@ import java.util.Map;
@RequestMapping("/order")
public class OrderController {
- @Resource
- private OrderService orderService;
+ private final OrderService orderService;
+ private final CartService cartService;
+ private final StringRedisTemplate stringRedisTemplate;
+
+ public OrderController(OrderService orderService, CartService cartService, StringRedisTemplate stringRedisTemplate) {
+ this.orderService = orderService;
+ this.cartService = cartService;
+ this.stringRedisTemplate = stringRedisTemplate;
+ }
/**
* 添加订单
* @return
*/
@PostMapping("/creatOrder")
- public Result createOrder(@RequestBody OrderDto shopTable){
- if (shopTable.getTableId() == null){
- return Result.fail("台桌号有误");
- }
- return orderService.createOrder(shopTable.getTableId(),shopTable.getShopId(),shopTable.getUserId());
+ public Result createOrder(@RequestHeader String environment, @RequestBody JSONObject jsonObject){
+ jsonObject.put("environment",environment);
+ return Utils.runFunAndCheckKey(() -> cartService.createOrder(jsonObject), stringRedisTemplate, RedisCst.getLockKey("CREATE_ORDER_KEY"));
+// return orderService.createOrder(shopTable.getTableId(),shopTable.getShopId(),shopTable.getUserId());
}
/**
@@ -39,7 +47,7 @@ public class OrderController {
* @param orderId
* @return
*/
- @GetMapping ("/orderInfo")
+// @GetMapping ("/orderInfo")
private Result orderInfo(@RequestParam(required = false) Integer orderId){
if (orderId==null) {
return Result.fail("请返回首页订单列表查看");
@@ -47,6 +55,19 @@ public class OrderController {
return orderService.orderInfo(orderId);
}
+
+ /**
+ * 订单详情
+ * @param orderId 订单id
+ * @return 订单信息
+ */
+ @GetMapping ("/orderInfo")
+ public Result getCartByOrderId(
+ @RequestParam Integer orderId
+ ){
+ return Result.successWithData(orderService.orderDetail(orderId));
+ }
+
@GetMapping("/orderList")
private Result orderList(@RequestParam Integer userId,@RequestParam Integer page,
@RequestParam Integer size, @RequestParam String status){
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
index 79db6f6..34e9417 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
import com.chaozhanggui.system.cashierservice.service.PayService;
import com.chaozhanggui.system.cashierservice.sign.Result;
@@ -40,8 +41,17 @@ public class PayController {
return Result.fail("订单号不允许为空");
}
+ if (!map.containsKey("payType")) {
+ return Result.fail("支付类型不允许为空");
+ }
+
+ String payType = map.get("payType");
+ if (StrUtil.isEmpty(payType)) {
+ return Result.fail("支付类型不允许为空");
+ }
+
try {
- return payService.payOrder(openId, map.get("orderId"), IpUtil.getIpAddr(request));
+ return payService.payOrder(openId, map.get("orderId"), payType, IpUtil.getIpAddr(request));
} catch (Exception e) {
e.printStackTrace();
}
@@ -77,6 +87,8 @@ public class PayController {
String userId = "";
if (environment.equals("wx") && payType.equals("wechatPay")) {
userId = TokenUtil.parseParamFromToken(token).getString("openId");
+ } else if("aliPay".equals(payType)){
+ userId = TokenUtil.parseParamFromToken(token).getString("openId");
} else {
userId = TokenUtil.parseParamFromToken(token).getString("userId");
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java
index ba8aec0..77fcd9a 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java
@@ -2,7 +2,12 @@ package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
+import com.chaozhanggui.system.cashierservice.constant.TableConstant;
+import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
+import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO;
+import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.service.CartService;
import com.chaozhanggui.system.cashierservice.service.ProductService;
@@ -10,8 +15,13 @@ import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
@CrossOrigin(origins = "*")
@@ -36,11 +46,15 @@ public class ProductController {
public Result queryShopIdByTableCode(
@RequestHeader("openId") String openId,
@RequestHeader("id") String userId,
- @RequestParam String lat,
- @RequestParam String lng,
- @RequestParam("code") String code
+ @RequestParam(required = false) String lat,
+ @RequestParam(required = false) String lng,
+ @RequestParam(required = false) String code,
+ @RequestParam(required = false) Integer shopId
) {
- return productService.queryShopIdByTableCode(userId, openId, code,lat,lng);
+ if (shopId == null && StrUtil.isBlank(code)) {
+ return Result.fail("参数缺失");
+ }
+ return productService.queryShopIdByTableCode(userId, openId, code,lat,lng, shopId);
}
/**
@@ -94,6 +108,32 @@ public class ProductController {
return cartService.createCart(jsonObject);
}
+ /**
+ * 餐位费选择
+ * @return 餐位费信息
+ */
+ @PostMapping("/choseCount")
+ public Result choseCount(@Validated @RequestBody ChoseCountDTO choseCountDTO) {
+ return Result.success(CodeEnum.SUCCESS, productService.choseCount(choseCountDTO));
+ }
+
+ @PostMapping("/choseEatModel")
+ public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) {
+ List cashierCartList = cartService.choseEatModel(choseEatModelDTO);
+ BigDecimal amount = BigDecimal.ZERO;
+ ArrayList cashierCarts = new ArrayList<>();
+ for (TbCashierCart item : cashierCartList) {
+ if (!TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
+ cashierCarts.add(item);
+ }
+ amount = amount.add(item.getTotalAmount());
+ }
+ HashMap data = new HashMap<>();
+ data.put("amount", amount);
+ data.put("info", cashierCarts);
+ return Result.success(CodeEnum.SUCCESS, data);
+ }
+
@PostMapping("cleanCart")
public Result cleanCart(@RequestBody JSONObject jsonObject) {
log.info("清空购物车数据:{}", jsonObject);
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java
new file mode 100644
index 0000000..77ae919
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java
@@ -0,0 +1,77 @@
+package com.chaozhanggui.system.cashierservice.controller;
+
+import cn.hutool.core.util.StrUtil;
+import com.chaozhanggui.system.cashierservice.entity.dto.BaseCallTableDTO;
+import com.chaozhanggui.system.cashierservice.entity.dto.CallSubMsgDTO;
+import com.chaozhanggui.system.cashierservice.entity.dto.CancelCallQueueDTO;
+import com.chaozhanggui.system.cashierservice.entity.dto.TakeNumberDTO;
+import com.chaozhanggui.system.cashierservice.service.TbCallService;
+import com.chaozhanggui.system.cashierservice.sign.Result;
+import lombok.AllArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 叫号
+ */
+@RestController
+@RequestMapping("/callTable")
+@AllArgsConstructor
+public class TbCallTableController {
+
+ private final TbCallService tbCallService;
+
+ @PostMapping("takeNumber")
+ public Result takeNumber(
+ @Validated @RequestBody TakeNumberDTO takeNumberDTO
+ ) {
+ return Result.successWithData(tbCallService.takeNumber(takeNumberDTO));
+ }
+
+ /**
+ * 排号列表
+ * @param openId openId
+ * @param shopId 店铺id
+ * @return data
+ */
+ @GetMapping("queue")
+ public Result get(
+ @RequestParam String openId,
+ @RequestParam Integer shopId,
+ @RequestParam(required = false) Integer queueId
+ ) {
+ return Result.successWithData(tbCallService.getList(shopId, openId, queueId));
+ }
+
+ @GetMapping
+ public Result getList(
+ @RequestParam Integer shopId
+ ) {
+ return Result.successWithData(tbCallService.getAllInfo(shopId));
+ }
+
+ @PostMapping("/cancel")
+ public Result cancel(
+ @Validated @RequestBody CancelCallQueueDTO cancelCallQueueDTO
+ ) {
+ return Result.successWithData(tbCallService.cancel(cancelCallQueueDTO));
+ }
+
+ @GetMapping("state")
+ public Result getState(
+ @RequestParam String openId,
+ @RequestParam Integer shopId,
+ @RequestParam(required = false) Integer queueId
+ ) {
+ return Result.successWithData(tbCallService.getState(openId, shopId, queueId));
+ }
+
+ @PostMapping("subMsg")
+ public Result subMsg(
+ @Validated @RequestBody CallSubMsgDTO subMsgDTO
+ ) {
+ return Result.successWithData(tbCallService.subMsg(subMsgDTO));
+ }
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java
index df4b1d5..dfbf581 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java
@@ -37,6 +37,9 @@ public interface TbActivateInRecordMapper {
int queryByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
List queryAllByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
+ int countCouponNum(@Param("userId") Integer userId);
+
+
/**
* 新增数据
*
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java
index 4f2e299..f620062 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java
@@ -56,5 +56,6 @@ public interface TbCashierCartMapper {
List selectByOrderId(@Param("orderId") String orderId,@Param("status") String status);
void updateStatusByTableId(@Param("tableId")String tableId,@Param("status") String status);
+ void updateStatusByOrderIdForMini(@Param("tableId")String tableId,@Param("status") String status);
void updateStatusById(@Param("id")Integer id,@Param("status") String status);
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java
index a87fe71..78baab9 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
+import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@@ -32,6 +33,8 @@ public interface TbShopUserMapper {
TbShopUser selectByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId);
TbShopUser selectPCByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId);
List selectAllByUserId(@Param("userId") String userId);
+ List selectVipByUserId(@Param("userId") Integer userId);
+ BigDecimal countAmount(@Param("userId") Integer userId);
List selectByUserId(@Param("userId") String userId, @Param("shopId") String shopId);
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/OrderUseTypeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/OrderUseTypeEnum.java
new file mode 100644
index 0000000..28707a3
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/OrderUseTypeEnum.java
@@ -0,0 +1,18 @@
+package com.chaozhanggui.system.cashierservice.entity.Enum;
+
+import lombok.Getter;
+
+/**
+ * 订餐用餐类型枚举
+ */
+@Getter
+public enum OrderUseTypeEnum {
+ TAKEOUT("takeout"),
+ DINE_IN_AFTER("dine-in-after"),
+ DINE_IN_BEFORE("dine-in-before");
+ private final String value;
+
+ OrderUseTypeEnum(String value) {
+ this.value = value;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/PlatformTypeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/PlatformTypeEnum.java
new file mode 100644
index 0000000..b23596d
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/PlatformTypeEnum.java
@@ -0,0 +1,13 @@
+package com.chaozhanggui.system.cashierservice.entity.Enum;
+
+import lombok.Getter;
+
+@Getter
+public enum PlatformTypeEnum {
+ MINI_APP("miniapp");
+ private final String value;
+
+ PlatformTypeEnum(String value) {
+ this.value = value;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoEatModelEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoEatModelEnum.java
new file mode 100644
index 0000000..9f9ee03
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoEatModelEnum.java
@@ -0,0 +1,18 @@
+package com.chaozhanggui.system.cashierservice.entity.Enum;
+
+import lombok.Getter;
+
+/**
+ * 店铺就餐类型
+ */
+@Getter
+public enum ShopInfoEatModelEnum {
+ TAKE_OUT("take-out"),
+ DINE_IN("dine-in");
+
+ private final String value;
+
+ ShopInfoEatModelEnum(String value) {
+ this.value = value;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoRegisterlEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoRegisterlEnum.java
new file mode 100644
index 0000000..5765104
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoRegisterlEnum.java
@@ -0,0 +1,20 @@
+package com.chaozhanggui.system.cashierservice.entity.Enum;
+
+import lombok.Getter;
+
+/**
+ * 店铺注册类型枚举
+ */
+@Getter
+public enum ShopInfoRegisterlEnum {
+ // 快餐版
+ MUNCHIES("munchies"),
+ // 餐饮版
+ RESTAURANT("restaurant");
+
+ private final String value;
+
+ ShopInfoRegisterlEnum(String value) {
+ this.value = value;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallQueue.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallQueue.java
new file mode 100644
index 0000000..943ac55
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallQueue.java
@@ -0,0 +1,213 @@
+package com.chaozhanggui.system.cashierservice.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 叫号排号表
+ * @TableName tb_call_queue
+ */
+@TableName(value ="tb_call_queue")
+@Data
+public class TbCallQueue implements Serializable {
+ /**
+ *
+ */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 叫号台桌类型id
+ */
+ private Integer callTableId;
+
+ /**
+ * 手机号
+ */
+ private String phone;
+
+ /**
+ * 姓名
+ */
+ private String name;
+
+ /**
+ * 店铺名称
+ */
+ private String shopName;
+
+ /**
+ * 店铺id
+ */
+ private Integer shopId;
+
+ /**
+ * -1已取消 0排队中 1叫号中 2已入座 3 已过号
+ */
+ private Integer state;
+
+ /**
+ * 排号时间
+ */
+ private Date createTime;
+
+ /**
+ * 叫号时间
+ */
+ private Date callTime;
+
+ /**
+ * 叫号次数
+ */
+ private Integer callCount;
+
+ /**
+ * 过号时间
+ */
+ private Date passTime;
+
+ /**
+ * 取消时间
+ */
+ private Date cancelTime;
+
+ /**
+ * 备注
+ */
+ private String note;
+
+ /**
+ *
+ */
+ private Integer userId;
+
+ /**
+ *
+ */
+ private String openId;
+
+ /**
+ * 订阅提醒 0未订阅 1已订阅
+ */
+ private Integer subState;
+
+ /**
+ * 确认时间
+ */
+ private Date confirmTime;
+
+ /**
+ * 叫号号码
+ */
+ private String callNum;
+
+ /**
+ * 创建年月日
+ */
+ private String createDay;
+
+ /**
+ * 是否已经顺延
+ */
+ private Integer isPostpone;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean equals(Object that) {
+ if (this == that) {
+ return true;
+ }
+ if (that == null) {
+ return false;
+ }
+ if (getClass() != that.getClass()) {
+ return false;
+ }
+ TbCallQueue other = (TbCallQueue) that;
+ return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+ && (this.getCallTableId() == null ? other.getCallTableId() == null : this.getCallTableId().equals(other.getCallTableId()))
+ && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone()))
+ && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
+ && (this.getShopName() == null ? other.getShopName() == null : this.getShopName().equals(other.getShopName()))
+ && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
+ && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
+ && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
+ && (this.getCallTime() == null ? other.getCallTime() == null : this.getCallTime().equals(other.getCallTime()))
+ && (this.getCallCount() == null ? other.getCallCount() == null : this.getCallCount().equals(other.getCallCount()))
+ && (this.getPassTime() == null ? other.getPassTime() == null : this.getPassTime().equals(other.getPassTime()))
+ && (this.getCancelTime() == null ? other.getCancelTime() == null : this.getCancelTime().equals(other.getCancelTime()))
+ && (this.getNote() == null ? other.getNote() == null : this.getNote().equals(other.getNote()))
+ && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
+ && (this.getOpenId() == null ? other.getOpenId() == null : this.getOpenId().equals(other.getOpenId()))
+ && (this.getSubState() == null ? other.getSubState() == null : this.getSubState().equals(other.getSubState()))
+ && (this.getConfirmTime() == null ? other.getConfirmTime() == null : this.getConfirmTime().equals(other.getConfirmTime()))
+ && (this.getCallNum() == null ? other.getCallNum() == null : this.getCallNum().equals(other.getCallNum()))
+ && (this.getCreateDay() == null ? other.getCreateDay() == null : this.getCreateDay().equals(other.getCreateDay()))
+ && (this.getIsPostpone() == null ? other.getIsPostpone() == null : this.getIsPostpone().equals(other.getIsPostpone()));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+ result = prime * result + ((getCallTableId() == null) ? 0 : getCallTableId().hashCode());
+ result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode());
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ result = prime * result + ((getShopName() == null) ? 0 : getShopName().hashCode());
+ result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
+ result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
+ result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+ result = prime * result + ((getCallTime() == null) ? 0 : getCallTime().hashCode());
+ result = prime * result + ((getCallCount() == null) ? 0 : getCallCount().hashCode());
+ result = prime * result + ((getPassTime() == null) ? 0 : getPassTime().hashCode());
+ result = prime * result + ((getCancelTime() == null) ? 0 : getCancelTime().hashCode());
+ result = prime * result + ((getNote() == null) ? 0 : getNote().hashCode());
+ result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
+ result = prime * result + ((getOpenId() == null) ? 0 : getOpenId().hashCode());
+ result = prime * result + ((getSubState() == null) ? 0 : getSubState().hashCode());
+ result = prime * result + ((getConfirmTime() == null) ? 0 : getConfirmTime().hashCode());
+ result = prime * result + ((getCallNum() == null) ? 0 : getCallNum().hashCode());
+ result = prime * result + ((getCreateDay() == null) ? 0 : getCreateDay().hashCode());
+ result = prime * result + ((getIsPostpone() == null) ? 0 : getIsPostpone().hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getSimpleName());
+ sb.append(" [");
+ sb.append("Hash = ").append(hashCode());
+ sb.append(", id=").append(id);
+ sb.append(", callTableId=").append(callTableId);
+ sb.append(", phone=").append(phone);
+ sb.append(", name=").append(name);
+ sb.append(", shopName=").append(shopName);
+ sb.append(", shopId=").append(shopId);
+ sb.append(", state=").append(state);
+ sb.append(", createTime=").append(createTime);
+ sb.append(", callTime=").append(callTime);
+ sb.append(", callCount=").append(callCount);
+ sb.append(", passTime=").append(passTime);
+ sb.append(", cancelTime=").append(cancelTime);
+ sb.append(", note=").append(note);
+ sb.append(", userId=").append(userId);
+ sb.append(", openId=").append(openId);
+ sb.append(", subState=").append(subState);
+ sb.append(", confirmTime=").append(confirmTime);
+ sb.append(", callNum=").append(callNum);
+ sb.append(", createDay=").append(createDay);
+ sb.append(", isPostpone=").append(isPostpone);
+ sb.append(", serialVersionUID=").append(serialVersionUID);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallTable.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallTable.java
new file mode 100644
index 0000000..a917dd6
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallTable.java
@@ -0,0 +1,149 @@
+package com.chaozhanggui.system.cashierservice.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ *
+ * @TableName tb_call_table
+ */
+@TableName(value ="tb_call_table")
+@Data
+public class TbCallTable implements Serializable {
+ /**
+ *
+ */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 名称
+ */
+ private String name;
+
+ /**
+ * 描述
+ */
+ private String note;
+
+ /**
+ * 等待时间分钟
+ */
+ private Integer waitTime;
+
+ /**
+ * 前缀
+ */
+ private String prefix;
+
+ /**
+ * 起始号码
+ */
+ private Integer start;
+
+ /**
+ * 临近几桌提醒
+ */
+ private Integer nearNum;
+
+ /**
+ * 0禁用 1使用
+ */
+ private Integer state;
+
+ /**
+ * 店铺id
+ */
+ private Integer shopId;
+
+ /**
+ * 二维码地址
+ */
+ private String qrcode;
+
+ /**
+ *
+ */
+ private Date createTime;
+
+ /**
+ *
+ */
+ private Date updateTime;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean equals(Object that) {
+ if (this == that) {
+ return true;
+ }
+ if (that == null) {
+ return false;
+ }
+ if (getClass() != that.getClass()) {
+ return false;
+ }
+ TbCallTable other = (TbCallTable) that;
+ return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+ && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
+ && (this.getNote() == null ? other.getNote() == null : this.getNote().equals(other.getNote()))
+ && (this.getWaitTime() == null ? other.getWaitTime() == null : this.getWaitTime().equals(other.getWaitTime()))
+ && (this.getPrefix() == null ? other.getPrefix() == null : this.getPrefix().equals(other.getPrefix()))
+ && (this.getStart() == null ? other.getStart() == null : this.getStart().equals(other.getStart()))
+ && (this.getNearNum() == null ? other.getNearNum() == null : this.getNearNum().equals(other.getNearNum()))
+ && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
+ && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
+ && (this.getQrcode() == null ? other.getQrcode() == null : this.getQrcode().equals(other.getQrcode()))
+ && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
+ && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ result = prime * result + ((getNote() == null) ? 0 : getNote().hashCode());
+ result = prime * result + ((getWaitTime() == null) ? 0 : getWaitTime().hashCode());
+ result = prime * result + ((getPrefix() == null) ? 0 : getPrefix().hashCode());
+ result = prime * result + ((getStart() == null) ? 0 : getStart().hashCode());
+ result = prime * result + ((getNearNum() == null) ? 0 : getNearNum().hashCode());
+ result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
+ result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
+ result = prime * result + ((getQrcode() == null) ? 0 : getQrcode().hashCode());
+ result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+ result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getSimpleName());
+ sb.append(" [");
+ sb.append("Hash = ").append(hashCode());
+ sb.append(", id=").append(id);
+ sb.append(", name=").append(name);
+ sb.append(", note=").append(note);
+ sb.append(", waitTime=").append(waitTime);
+ sb.append(", prefix=").append(prefix);
+ sb.append(", start=").append(start);
+ sb.append(", nearNum=").append(nearNum);
+ sb.append(", state=").append(state);
+ sb.append(", shopId=").append(shopId);
+ sb.append(", qrcode=").append(qrcode);
+ sb.append(", createTime=").append(createTime);
+ sb.append(", updateTime=").append(updateTime);
+ sb.append(", serialVersionUID=").append(serialVersionUID);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
index b74eb9a..d978055 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
@@ -1,5 +1,8 @@
package com.chaozhanggui.system.cashierservice.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -8,6 +11,7 @@ import java.math.BigDecimal;
@Data
public class TbCashierCart implements Serializable {
+ @TableId(type = IdType.AUTO)
private Integer id;
private String masterId;
@@ -59,7 +63,13 @@ public class TbCashierCart implements Serializable {
private Integer userId;
private String tableId;
private Byte isVip;
+ @TableField(exist = false)
private TbProductSpec tbProductSpec;
+ private String note;
+
+ private String platformType;
+ private String useType;
+ private Integer placeNum;
private static final long serialVersionUID = 1L;
@@ -70,4 +80,4 @@ public class TbCashierCart implements Serializable {
return "";
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java
index 8e9901e..4e1fd88 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java
@@ -23,6 +23,8 @@ public class TbMerchantThirdApply implements Serializable {
private String smallAppid;
+ private String alipaySmallAppid;
+
private String storeId;
@@ -117,4 +119,12 @@ public class TbMerchantThirdApply implements Serializable {
public void setStoreId(String storeId) {
this.storeId = storeId;
}
+
+ public String getAlipaySmallAppid() {
+ return alipaySmallAppid;
+ }
+
+ public void setAlipaySmallAppid(String alipaySmallAppid) {
+ this.alipaySmallAppid = alipaySmallAppid;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java
index 120e92f..d91d8db 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java
@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity;
+import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
@@ -37,7 +38,13 @@ public class TbOrderDetail implements Serializable {
private BigDecimal priceAmount;
private BigDecimal packAmount;
+ @TableField(exist = false)
private String remark;
+ private Integer cartId;
+ private Integer placeNum;
+ private String useType;
+ private String note;
+
private static final long serialVersionUID = 1L;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java
index 8a08964..186b8e6 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java
@@ -1,5 +1,8 @@
package com.chaozhanggui.system.cashierservice.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
@@ -8,6 +11,7 @@ import java.util.List;
@Data
public class TbOrderInfo implements Serializable {
+ @TableId(type = IdType.AUTO)
private Integer id;
//订单号
@@ -58,11 +62,15 @@ public class TbOrderInfo implements Serializable {
private Byte isVip;
private String memberId;
+ @TableField(exist = false)
private String userName;
+ @TableField(exist = false)
private String memberName;
+ @TableField(exist = false)
private String zdNo;
private String userId;
+ @TableField(exist = false)
private String imgUrl;
private Integer productScore;
@@ -97,16 +105,28 @@ public class TbOrderInfo implements Serializable {
private String masterId;
private String isBuyCoupon;
private String isUseCoupon;
+ @TableField(exist = false)
private Integer totalNumber;
+ @TableField(exist = false)
private List detailList;
+ @TableField(exist = false)
private String winnnerNo;
+ @TableField(exist = false)
private String isWinner;
+ @TableField(exist = false)
private String shopName;
private String useType;
+ // 下单次数
+ private Integer placeNum;
+
+ private Integer seatCount;
+ private BigDecimal seatAmount;
+
//根据状态返回 需付款 已付款 未付款 已退
+ @TableField(exist = false)
private String description;
public void setDescription(String shopName) {
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java
index 3bdee44..2518cdf 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java
@@ -35,6 +35,14 @@ public class TbPrintMachine implements Serializable {
private String productId;
+ private String receiptSize;
+ private String classifyPrint;
+ private String tablePrint;
+ private String printQty;
+ private String printMethod;
+ private String printType;
+ private String printReceipt;
+
private static final long serialVersionUID = 1L;
public Integer getId() {
@@ -164,4 +172,60 @@ public class TbPrintMachine implements Serializable {
public void setProductId(String productId) {
this.productId = productId == null ? null : productId.trim();
}
+
+ public String getReceiptSize() {
+ return receiptSize;
+ }
+
+ public void setReceiptSize(String receiptSize) {
+ this.receiptSize = receiptSize;
+ }
+
+ public String getClassifyPrint() {
+ return classifyPrint;
+ }
+
+ public void setClassifyPrint(String classifyPrint) {
+ this.classifyPrint = classifyPrint;
+ }
+
+ public String getTablePrint() {
+ return tablePrint;
+ }
+
+ public void setTablePrint(String tablePrint) {
+ this.tablePrint = tablePrint;
+ }
+
+ public String getPrintQty() {
+ return printQty;
+ }
+
+ public void setPrintQty(String printQty) {
+ this.printQty = printQty;
+ }
+
+ public String getPrintMethod() {
+ return printMethod;
+ }
+
+ public void setPrintMethod(String printMethod) {
+ this.printMethod = printMethod;
+ }
+
+ public String getPrintType() {
+ return printType;
+ }
+
+ public void setPrintType(String printType) {
+ this.printType = printType;
+ }
+
+ public String getPrintReceipt() {
+ return printReceipt;
+ }
+
+ public void setPrintReceipt(String printReceipt) {
+ this.printReceipt = printReceipt;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java
index ba7404d..e455026 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java
@@ -66,11 +66,6 @@ public class TbProduct implements Serializable {
private String typeEnum;
- /**
- * 是否共享库存
- */
- private Byte isDistribute;
-
private Byte isDel;
private Byte isStock;
@@ -140,6 +135,9 @@ public class TbProduct implements Serializable {
//是否可售 1 可售 0非可售
private Integer isSale = 1;
+ private Integer warnLine = 0;
+
+
public String getImages() {
return images;
@@ -403,13 +401,6 @@ public class TbProduct implements Serializable {
this.typeEnum = typeEnum == null ? null : typeEnum.trim();
}
- public Byte getIsDistribute() {
- return isDistribute;
- }
-
- public void setIsDistribute(Byte isDistribute) {
- this.isDistribute = isDistribute;
- }
public Byte getIsDel() {
return isDel;
@@ -683,4 +674,12 @@ public class TbProduct implements Serializable {
public void setIsSale(Integer isSale) {
this.isSale = isSale;
}
+
+ public Integer getWarnLine() {
+ return warnLine;
+ }
+
+ public void setWarnLine(Integer warnLine) {
+ this.warnLine = warnLine;
+ }
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java
index 325eda4..5005cce 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java
@@ -32,7 +32,6 @@ public class TbProductSku implements Serializable {
private String coverImg;
- private Integer warnLine;
private Double weight;
@@ -175,14 +174,6 @@ public class TbProductSku implements Serializable {
this.coverImg = coverImg == null ? null : coverImg.trim();
}
- public Integer getWarnLine() {
- return warnLine;
- }
-
- public void setWarnLine(Integer warnLine) {
- this.warnLine = warnLine;
- }
-
public Double getWeight() {
return weight;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java
index 4e94053..708a336 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java
@@ -112,6 +112,16 @@ public class TbShopInfo implements Serializable {
private String districts;
private String isCustom;
+ //是否开启桌位费 0否1是
+ private Integer isTableFee;
+ //桌位费
+ private BigDecimal tableFee;
+ //就餐模式 堂食 dine-in 外带 take-out
+ private String eatModel;
+ //程序码(零点八零首页)
+ private String smallQrcode;
+ //店铺收款码
+ private String paymentQrcode;
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java
index 9fd5e39..cea6cbe 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java
@@ -1,8 +1,12 @@
package com.chaozhanggui.system.cashierservice.entity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
import java.io.Serializable;
import java.math.BigDecimal;
+@Data
public class TbShopTable implements Serializable {
private Integer id;
@@ -36,144 +40,18 @@ public class TbShopTable implements Serializable {
private String qrcode;
+ @TableField(exist = false)
private String areaname;
+ @TableField(exist = false)
+ private Integer orderId;
- public String getAreaname() {
- return areaname;
- }
+ @TableField(exist = false)
+ private boolean isChoseCount;
- public void setAreaname(String areaname) {
- this.areaname = areaname;
- }
+ @TableField(exist = false)
+ private Integer seatNum;
- public String getQrcode() {
- return qrcode;
- }
- public void setQrcode(String qrcode) {
- this.qrcode = qrcode;
- }
- private static final long serialVersionUID = 1L;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name == null ? null : name.trim();
- }
-
- public Integer getShopId() {
- return shopId;
- }
-
- public void setShopId(Integer shopId) {
- this.shopId = shopId;
- }
-
- public Integer getMaxCapacity() {
- return maxCapacity;
- }
-
- public void setMaxCapacity(Integer maxCapacity) {
- this.maxCapacity = maxCapacity;
- }
-
- public Integer getSort() {
- return sort;
- }
-
- public void setSort(Integer sort) {
- this.sort = sort;
- }
-
- public Integer getAreaId() {
- return areaId;
- }
-
- public void setAreaId(Integer areaId) {
- this.areaId = areaId;
- }
-
- public Byte getIsPredate() {
- return isPredate;
- }
-
- public void setIsPredate(Byte isPredate) {
- this.isPredate = isPredate;
- }
-
- public BigDecimal getPredateAmount() {
- return predateAmount;
- }
-
- public void setPredateAmount(BigDecimal predateAmount) {
- this.predateAmount = predateAmount;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status == null ? null : status.trim();
- }
-
- public Byte getType() {
- return type;
- }
-
- public void setType(Byte type) {
- this.type = type;
- }
-
- public BigDecimal getAmount() {
- return amount;
- }
-
- public void setAmount(BigDecimal amount) {
- this.amount = amount;
- }
-
- public BigDecimal getPerhour() {
- return perhour;
- }
-
- public void setPerhour(BigDecimal perhour) {
- this.perhour = perhour;
- }
-
- public String getView() {
- return view;
- }
-
- public void setView(String view) {
- this.view = view == null ? null : view.trim();
- }
-
- public Long getCreatedAt() {
- return createdAt;
- }
-
- public void setCreatedAt(Long createdAt) {
- this.createdAt = createdAt;
- }
-
- public Long getUpdatedAt() {
- return updatedAt;
- }
-
- public void setUpdatedAt(Long updatedAt) {
- this.updatedAt = updatedAt;
- }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java
index 13243bf..e4d6a24 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java
@@ -4,6 +4,7 @@ import org.springframework.data.annotation.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
+import java.sql.Timestamp;
public class TbShopUser implements Serializable {
private String id;
@@ -73,7 +74,7 @@ public class TbShopUser implements Serializable {
@Transient
private String isUser;
-
+ private Timestamp joinTime;
@@ -352,4 +353,12 @@ public class TbShopUser implements Serializable {
public void setAddress(String address) {
this.address = address;
}
+
+ public Timestamp getJoinTime() {
+ return joinTime;
+ }
+
+ public void setJoinTime(Timestamp joinTime) {
+ this.joinTime = joinTime;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java
index e449864..6bb7f5a 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java
@@ -101,7 +101,11 @@ public class TbUserInfo implements Serializable {
private String pwd;
- private String custPhone="400-6666-389";
+ private String custPhone = "400-6666-389";
+ //优惠卷数量
+ private Integer couponAll = 0;
+ //储值数量
+ private BigDecimal balanceAll = BigDecimal.ZERO;
public String getAvatar() {
@@ -505,4 +509,20 @@ public class TbUserInfo implements Serializable {
public void setPwd(String pwd) {
this.pwd = pwd;
}
+
+ public Integer getCouponAll() {
+ return couponAll;
+ }
+
+ public void setCouponAll(Integer couponAll) {
+ this.couponAll = couponAll;
+ }
+
+ public BigDecimal getBalanceAll() {
+ return balanceAll;
+ }
+
+ public void setBalanceAll(BigDecimal balanceAll) {
+ this.balanceAll = balanceAll;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BaseCallTableDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BaseCallTableDTO.java
new file mode 100644
index 0000000..c431171
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BaseCallTableDTO.java
@@ -0,0 +1,13 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class BaseCallTableDTO {
+ @NotNull
+ private Integer callTableId;
+ @NotNull
+ private Integer shopId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallNumPrintDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallNumPrintDTO.java
new file mode 100644
index 0000000..ac37d31
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallNumPrintDTO.java
@@ -0,0 +1,9 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+@Data
+public class CallNumPrintDTO {
+ private Integer callQueueId;
+ private Integer shopId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallSubMsgDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallSubMsgDTO.java
new file mode 100644
index 0000000..2e823aa
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallSubMsgDTO.java
@@ -0,0 +1,16 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class CallSubMsgDTO {
+ @NotNull
+ private Integer queueId;
+ @NotEmpty
+ private String openId;
+ @NotNull
+ private Integer shopId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java
new file mode 100644
index 0000000..e0dd55a
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java
@@ -0,0 +1,13 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class CancelCallQueueDTO {
+ @NotNull
+ private Integer queueId;
+ @NotNull
+ private Integer shopId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseCountDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseCountDTO.java
new file mode 100644
index 0000000..3d64bd5
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseCountDTO.java
@@ -0,0 +1,18 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class ChoseCountDTO {
+ @NotNull
+ private Integer shopId;
+ @NotEmpty
+ private String tableId;
+ @NotNull
+ @Min(1)
+ private Integer num;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java
new file mode 100644
index 0000000..6760671
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java
@@ -0,0 +1,20 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class ChoseEatModelDTO {
+ @NotNull
+ private Integer shopId;
+ private String tableId;
+ @NotNull
+ @Max(1)
+ @Min(0)
+ // 0切换店内 1切换外带
+ private Integer type;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java
new file mode 100644
index 0000000..b1117c9
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java
@@ -0,0 +1,18 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class ShopEatTypeInfoDTO {
+ private boolean isTakeout;
+ private boolean isMunchies;
+ private boolean isDineInAfter;
+ private boolean isDineInBefore;
+ private TbShopInfo shopInfo;
+ private String useType;
+ private boolean isOpenTakeout;
+ private boolean isOpenDineIn;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TakeNumberDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TakeNumberDTO.java
new file mode 100644
index 0000000..a560f29
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TakeNumberDTO.java
@@ -0,0 +1,21 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class TakeNumberDTO extends BaseCallTableDTO{
+ @NotBlank
+ @Pattern(regexp = "^1\\d{10}$|^(0\\d{2,3}-?|\\(0\\d{2,3}\\))?[1-9]\\d{4,7}(-\\d{1,8})?$",message = "手机号码格式错误")
+ private String phone;
+ private String note;
+ private String name;
+ @NotBlank
+ private String openId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CallQueueInfoVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CallQueueInfoVO.java
new file mode 100644
index 0000000..9174ce6
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CallQueueInfoVO.java
@@ -0,0 +1,17 @@
+package com.chaozhanggui.system.cashierservice.entity.vo;
+
+import lombok.Data;
+
+@Data
+public class CallQueueInfoVO {
+ private Integer id;
+ private String tableName;
+ private String tableNote;
+ private Integer waitingCount;
+ private Integer waitTime;
+ private Integer state;
+ private String callNum;
+ private String shopState;
+ private String shopName;
+ private String logo;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java
index 03ee617..a5abc9e 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java
@@ -37,4 +37,9 @@ public class OrderVo {
private String outNumber;
+ private String useType;
+
+ private Integer shopId;
+ private String qrcode;
+
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java
index 8dfec49..a2c7723 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserCouponVo.java
@@ -14,7 +14,9 @@ public class UserCouponVo {
* 卷描述
*/
private String detail;
+ private String shopId;
private String shopName;
+ private String orderId;
/**
* 优惠金额
*/
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java
index b79a877..5e8bb65 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java
@@ -14,7 +14,11 @@ import java.util.List;
@WebFilter(urlPatterns = {"/cashierService/*"},filterName = "customFilter")
public class CustomFilter implements Filter {
- private static final List unFilterUrlList= Arrays.asList("/cashierService/notify/notifyCallBack","/cashierService/notify/memberInCallBack");
+ private static final List unFilterUrlList =
+ Arrays.asList(
+ "/cashierService/notify/notifyCallBack",
+ "/cashierService/notify/memberInCallBack"
+ );
private boolean isfilter(String url){
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpCashierCartMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpCashierCartMapper.java
new file mode 100644
index 0000000..8a630d5
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpCashierCartMapper.java
@@ -0,0 +1,19 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
+import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
+
+/**
+* @author Administrator
+* @description 针对表【tb_call_queue】的数据库操作Mapper
+* @createDate 2024-09-13 13:44:26
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
+*/
+public interface MpCashierCartMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderDetailMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderDetailMapper.java
new file mode 100644
index 0000000..50405a3
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderDetailMapper.java
@@ -0,0 +1,19 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
+import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
+
+/**
+* @author Administrator
+* @description 针对表【tb_call_queue】的数据库操作Mapper
+* @createDate 2024-09-13 13:44:26
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
+*/
+public interface MpOrderDetailMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderInfoMapper.java
new file mode 100644
index 0000000..0dc8d2f
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderInfoMapper.java
@@ -0,0 +1,19 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
+import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
+
+/**
+* @author Administrator
+* @description 针对表【tb_call_queue】的数据库操作Mapper
+* @createDate 2024-09-13 13:44:26
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
+*/
+public interface MpOrderInfoMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopInfoMapper.java
new file mode 100644
index 0000000..7f72780
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopInfoMapper.java
@@ -0,0 +1,22 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
+import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
+import com.chaozhanggui.system.cashierservice.entity.vo.CallQueueInfoVO;
+
+import java.util.List;
+
+/**
+* @author Administrator
+* @description 针对表【tb_call_queue】的数据库操作Mapper
+* @createDate 2024-09-13 13:44:26
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
+*/
+public interface MpShopInfoMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopTableMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopTableMapper.java
new file mode 100644
index 0000000..1409402
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopTableMapper.java
@@ -0,0 +1,19 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
+import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
+
+/**
+* @author Administrator
+* @description 针对表【tb_call_queue】的数据库操作Mapper
+* @createDate 2024-09-13 13:44:26
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
+*/
+public interface MpShopTableMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallQueueMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallQueueMapper.java
new file mode 100644
index 0000000..ba394aa
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallQueueMapper.java
@@ -0,0 +1,22 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.vo.CallQueueInfoVO;
+
+import java.util.List;
+
+/**
+* @author Administrator
+* @description 针对表【tb_call_queue】的数据库操作Mapper
+* @createDate 2024-09-13 13:44:26
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
+*/
+public interface TbCallQueueMapper extends BaseMapper {
+
+ List selectInfoByOpenId(Integer shopId, String openId, String today, Integer queueId);
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallTableMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallTableMapper.java
new file mode 100644
index 0000000..adefb7b
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallTableMapper.java
@@ -0,0 +1,18 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.chaozhanggui.system.cashierservice.entity.TbCallTable;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author Administrator
+* @description 针对表【tb_call_table】的数据库操作Mapper
+* @createDate 2024-09-13 13:44:34
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallTable
+*/
+public interface TbCallTableMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java
index 339735f..3a065d5 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java
@@ -3,11 +3,13 @@ package com.chaozhanggui.system.cashierservice.netty;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.netty.config.NettyChannelHandlerAdapter;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
+import com.chaozhanggui.system.cashierservice.util.ShopUtils;
import com.chaozhanggui.system.cashierservice.util.SpringUtils;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler.Sharable;
@@ -17,6 +19,8 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
@@ -35,7 +39,9 @@ import java.util.concurrent.ConcurrentHashMap;
public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
/**
- * [tableID-shopId, [userId, ctx]]
+ * 台桌下单为: TAKEOUT_TABLE_CART:shopId:tableID
+ * 店内自取为: DINE_IN_TABLE_CART:shopId:userId
+ * [shopId:tableID, [userId, ctx]]
*/
private static Map> webSocketMap = new HashMap<>();
@@ -51,6 +57,9 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
private RabbitProducer a;
//注入为空
public static RabbitProducer rabbitProducer;
+
+ private ShopUtils shopUtils = SpringUtils.getBean(ShopUtils.class);
+
@PostConstruct
public void b() {
rabbitProducer = this.a;
@@ -88,13 +97,14 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
// 遍历webSocketMap,查找并移除对应的ChannelHandlerContext
String key = ctxToUserIdMap.get(ctx);
if (StringUtils.isNotBlank(key)) {
- String[] split = key.split(":");
+ String[] split = key.split("-");
ConcurrentHashMap tableMap = webSocketMap.get(split[0]);
if (tableMap != null && !tableMap.isEmpty() && tableMap.size() > 0) {
tableMap.remove(split[1]);
if (tableMap.isEmpty() || tableMap.size() == 0) {
webSocketMap.remove(split[0]);
- redisUtils.deleteByKey(RedisCst.TABLE_CART.concat(split[0]));
+ // 删除购物车缓存
+ redisUtils.deleteByKey(split[0]);
}
}
}
@@ -133,12 +143,14 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
channelInactive(ctx);
return;
}
- String key = tableId + "-" + shopId;
- log.info("netty连接 接收到数据 建立连接参数 param:{}",jsonObject);
+
+ ShopEatTypeInfoDTO eatModel = shopUtils.getEatModel(tableId, shopId);
+ String tableCartKey = RedisCst.getTableCartKey(shopId, eatModel.isOpenDineIn() ? tableId : null, Integer.valueOf(userId));
+ log.info("netty连接 接收到数据 建立连接参数 key: {} param:{}", tableCartKey, jsonObject);
this.tableId=tableId;
this.shopId=shopId;
- if (webSocketMap.containsKey(key)) {
- ConcurrentHashMap userSocketMap = webSocketMap.get(key);
+ if (webSocketMap.containsKey(tableCartKey)) {
+ ConcurrentHashMap userSocketMap = webSocketMap.get(tableCartKey);
ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId);
if (channelHandlerContext != null) {
channelHandlerContext.close();
@@ -147,9 +159,9 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
} else {
ConcurrentHashMap userSocketMap = new ConcurrentHashMap<>();
userSocketMap.put(userId, ctx);
- webSocketMap.put(key,userSocketMap);
+ webSocketMap.put(tableCartKey,userSocketMap);
}
- ctxToUserIdMap.put(ctx, key + ":" + userId);
+ ctxToUserIdMap.put(ctx, tableCartKey + "-" + userId);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
jsonObject1.put("msg", "连接成功");
@@ -163,11 +175,13 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
log.info("netty连接 接收到接口数据:meg:{}",msg);
jsonObject.put("tableId", this.tableId);
jsonObject.put("shopId", this.shopId);
+ Integer userId = jsonObject.getInteger("userId");
if("sku".equals(type)){
- boolean exist = redisUtils.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)));
+ String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
+ boolean exist = redisUtils.exists(tableCartKey);
Integer num = 0;
if (exist){
- String message = redisUtils.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)));
+ String message = redisUtils.getMessage(tableCartKey);
JSONArray array = JSON.parseArray(message);
for (int i = 0; i < array.size(); i++) {
JSONObject object = array.getJSONObject(i);
@@ -226,11 +240,12 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
}
@Async
- public void AppSendInfo(String message, String tableId,String userId, boolean userFlag) {
- log.info("netty连接 发送消息 tableId:{} userId:{} userFlag:{} message:{}",tableId,userId,userFlag, JSONUtil.toJSONString(message));
+ public void AppSendInfo(String message, String redisKey,String userId, boolean userFlag) {
+ log.info("netty连接 发送消息 key:{} userId:{} userFlag:{} message:{}",redisKey,userId,userFlag, JSONUtil.toJSONString(message));
+ log.info("当前已连接队列信息: {}", webSocketMap);
if (userFlag) {
- if (webSocketMap.containsKey(tableId)) {
- ConcurrentHashMap webSockets = webSocketMap.get(tableId);
+ if (webSocketMap.containsKey(redisKey)) {
+ ConcurrentHashMap webSockets = webSocketMap.get(redisKey);
if(!webSockets.isEmpty()){
if (StringUtils.isNotBlank(userId)) {
ChannelHandlerContext ctx = webSockets.get(userId);
@@ -241,15 +256,15 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
}
}
} else {
- if (StringUtils.isEmpty(tableId)) {
+ if (StringUtils.isEmpty(redisKey)) {
// 向所有用户发送信息
for (ConcurrentHashMap value : webSocketMap.values()) {
for (ChannelHandlerContext ctx : value.values()) {
sendMesToApp(message,ctx);
}
}
- } else if (webSocketMap.containsKey(tableId)) {
- ConcurrentHashMap webSockets = webSocketMap.get(tableId);
+ } else if (webSocketMap.containsKey(redisKey)) {
+ ConcurrentHashMap webSockets = webSocketMap.get(redisKey);
if(!webSockets.isEmpty()) {
for (String user : webSockets.keySet()) {
ChannelHandlerContext ctx = webSockets.get(user);
@@ -261,10 +276,10 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
}
}
}else {
- log.info("netty连接 发送消息 桌码群发 tableId:{} 失败",tableId);
+ log.info("netty连接 发送消息 桌码群发 tableId:{} 失败",redisKey);
}
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java
index cedc930..b994d1a 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java
@@ -160,6 +160,19 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
});
}
+ @Async
+ public void AppSendInfo(String message, String shopId) {
+ log.info("长链接发送交班数据。");
+ ConcurrentHashMap webSockets = webSocketMap.get(shopId);
+ if (webSockets != null) {
+ for (ChannelHandlerContext ctx : webSockets.values()) {
+ sendMesToApp(message, ctx);
+ }
+ }
+ }
+
+
+ //发送打印消息 有重发机制
public void AppSendInfoV1(String shopId, String orderNo, JSONObject message) {
log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}", shopId, message.get("orderInfo"));
retryQueue.computeIfAbsent(shopId, k -> new ConcurrentLinkedQueue<>()).offer(message);
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java
index c3c1d16..2ad7144 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java
@@ -3,10 +3,12 @@ package com.chaozhanggui.system.cashierservice.rabbit;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.service.CartService;
+import com.chaozhanggui.system.cashierservice.util.ShopUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
@@ -26,6 +28,9 @@ public class CartConsumer {
private RedisUtil redisUtil;
@Autowired
private CartService cartService;
+ @Autowired
+ private ShopUtils shopUtils;
+
@RabbitHandler
@RabbitListener(queues = {"${queue}"})
public void listener(String message) {
@@ -34,6 +39,7 @@ public class CartConsumer {
JSONObject jsonObject = JSON.parseObject(message);
String tableId = jsonObject.getString("tableId");
String shopId = jsonObject.getString("shopId");
+ Integer userId = jsonObject.getInteger("userId");
if (jsonObject.getString("type").equals("initCart") ) {
cartService.initCart(jsonObject);
}
@@ -46,15 +52,7 @@ public class CartConsumer {
else if (jsonObject.getString("type").equals("queryCart") ) {
cartService.queryCart(jsonObject);
} else if(jsonObject.getString("type").equals("createOrder")){
- String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
- if (StringUtils.isEmpty(cartDetail)){
- log.info("createOrder购物车为空");
- throw new MsgException("购物车为空无法下单");
- }
- JSONArray array = JSON.parseArray(cartDetail);
- if (array.size() > 0){
- cartService.createOrder(jsonObject);
- }
+ cartService.createOrder(jsonObject);
}
// else if(jsonObject.getString("type").equals("clearCart")){
// cartService.clearCart(jsonObject);
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java
index 77299dc..c1cebdf 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java
@@ -3,7 +3,6 @@ package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
@@ -22,7 +21,10 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@@ -87,156 +89,160 @@ public class PrintMechineConsumer {
log.info("打印机列表,{}", ArrayUtil.toString(list));
log.info("待打印订单信息, {}", orderInfo);
- list.parallelStream().forEach(tbPrintMachineWithBLOBs->{
+ list.forEach(tbPrintMachineWithBLOBs -> {
if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) {
- log.error("非网络打印机:{},{}",tbPrintMachineWithBLOBs.getAddress(),tbPrintMachineWithBLOBs.getConnectionType());
+ log.error("非网络打印机:{},{}", tbPrintMachineWithBLOBs.getAddress(), tbPrintMachineWithBLOBs.getConnectionType());
return;
}
if (!"1".equals(tbPrintMachineWithBLOBs.getStatus().toString())) {
- log.error("打印机状态异常:{},{}",tbPrintMachineWithBLOBs.getAddress(),tbPrintMachineWithBLOBs.getStatus());
+ log.error("打印机状态异常:{},{}", tbPrintMachineWithBLOBs.getAddress(), tbPrintMachineWithBLOBs.getStatus());
return;
}
- JSONObject config = JSONObject.parseObject(tbPrintMachineWithBLOBs.getConfig());
- String model = config.getString("model");
+ String model = tbPrintMachineWithBLOBs.getPrintMethod();
- String printerNum = config.getString("printerNum");
+ String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1];
- String feet = config.getString("feet");
+ List categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
- String autoCut = config.getString("autoCut");
-
- List categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class);
-
- switch (tbPrintMachineWithBLOBs.getContentType()){
+ switch (tbPrintMachineWithBLOBs.getContentType()) {
case "yxyPrinter":
- yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos);
+ yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break;
case "fePrinter":
- fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos);
+ fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break;
}
});
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
}
/**
- * 博时结云打印机
+ * 仅打印制作单「厨房」
+ */
+ private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List categoryInfos) {
+ List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
+ log.info("一菜一品打印,待打印信息:{}", cashierCarts);
+ if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
+
+
+ cashierCarts.parallelStream().forEach(it -> {
+
+ // 取餐号不为空为代客下单
+ if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) {
+ log.info("--------------------代客下单 打印一菜一品");
+ printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
+ return;
+ }
+ log.info("--------------------非代客下单 打印一菜一品");
+
+ String categoryId;
+ if (ObjectUtil.isEmpty(it.getCategoryId())) {
+ categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+ } else {
+ categoryId = it.getCategoryId();
+ }
+
+
+ Long count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+
+ if (count > 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
+ String remark = "";
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
+ String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
+ PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
+ }
+ });
+ }
+ }
+
+ /**
+ * 仅打印结算单「前台」
+ */
+ private void onlyFrontDeskForYxy(String orderId, TbOrderInfo orderInfo, String printerNum, TbShopInfo shopInfo, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, List categoryInfos) {
+ List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
+ if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
+ List detailList = new ArrayList<>();
+ cashierCarts.parallelStream().forEach(it -> {
+ String categoryId;
+ if (ObjectUtil.isEmpty(it.getCategoryId())) {
+ categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+ } else {
+ categoryId = it.getCategoryId();
+ }
+
+
+ Long count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+
+ if (count > 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
+ String remark = "";
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
+
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
+ detailList.add(detail);
+ }
+ });
+
+ String balance = "0";
+
+ if ("deposit".equals(orderInfo.getPayType())) {
+ TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
+ if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
+ balance = user.getAmount().toPlainString();
+ }
+ }
+ if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
+
+ OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
+ detailPO.setOutNumber(orderInfo.getOutNumber());
+ String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
+ PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
+ }
+
+ }
+ }
+
+ /**
+ * 博时结云打印机
+ *
* @param tbPrintMachineWithBLOBs
* @param model
* @param orderInfo
* @param shopInfo
* @param printerNum
*/
- private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List categoryInfos){
- String orderId=orderInfo.getId().toString();
-
-
+ private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) {
+ String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
break;
case "cash": //小票打印机
- switch (model) {
- case "normal": //普通出单
- List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
- if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
- List detailList = new ArrayList<>();
- cashierCarts.parallelStream().forEach(it -> {
- String categoryId;
- if(ObjectUtil.isEmpty(it.getCategoryId())){
- categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
- } else {
- categoryId = it.getCategoryId();
- }
-
-
- Long count= categoryInfos.stream().filter(c->
- c.getId().toString().equals(categoryId)
- ).count();
-
- if(count>0){
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
- String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
- }
-
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
- detailList.add(detail);
- }
- });
-
- String balance = "0";
-
- if ("deposit".equals(orderInfo.getPayType())) {
- TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
- if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
- balance = user.getAmount().toPlainString();
- }
- }
- if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
-
- OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark());
- detailPO.setOutNumber(orderInfo.getOutNumber());
- String data= PrinterUtils.getCashPrintData(detailPO,"结算单");
- PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
- }
-
- }
-
- break;
- case "one": //一菜一品
- cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final");
- log.info("一菜一品打印,待打印信息:{}", cashierCarts);
- if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
-
-
- cashierCarts.parallelStream().forEach(it -> {
-
- // 取餐号不为空为代客下单
- if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) {
- log.info("--------------------代客下单 打印一菜一品");
- printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
- return;
- }
- log.info("--------------------非代客下单 打印一菜一品");
-
- String categoryId;
- if(ObjectUtil.isEmpty(it.getCategoryId())){
- categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
- } else {
- categoryId = it.getCategoryId();
- }
-
-
- Long count= categoryInfos.stream().filter(c->
- c.getId().toString().equals(categoryId)
- ).count();
-
- if(count>0){
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
- String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
- }
- String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
- PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
- }
- });
- }
- break;
- case "category": //分类出单
- break;
+ if ("normal".equals(model)) {
+ onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
+ } else if ("one".equals(model)) {
+ onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos);
+ } else if ("all".equals(model)) {
+ onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
+ onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos);
}
-
break;
case "kitchen": //出品打印机
break;
@@ -285,7 +291,7 @@ public class PrintMechineConsumer {
if (info != null) {
isReturn = it.getNum() - Integer.parseInt(info) < 0;
printerNum = it.getNum() - Integer.parseInt(info);
- }else {
+ } else {
printerNum = it.getNum();
}
@@ -352,38 +358,171 @@ public class PrintMechineConsumer {
}
}
+ /**
+ * 仅打印结算单「前台」
+ */
+ private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) {
+ if ("return".equals(orderInfo.getOrderType())) {
+ List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
+ if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
+ List detailList = new ArrayList<>();
+ tbOrderDetails.parallelStream().forEach(it -> {
+ String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+
+ Long count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+ log.info("获取当前类别是否未打印类别:{}", count);
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
+ String remark = "";
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
+ detailList.add(detail);
- private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List categoryInfos){
- String orderId=orderInfo.getId().toString();
+ });
+ String balance = "0";
+
+ if ("deposit".equals(orderInfo.getPayType())) {
+ TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
+ if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
+ balance = user.getAmount().toPlainString();
+ }
+ }
+
+
+ if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
+// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
+ OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
+
+ String printType = "退款单";
+
+ String data = PrinterUtils.getCashPrintData(detailPO, printType);
+ PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
+ }
+ }
+
+
+ } else {
+ List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
+
+ if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
+ List detailList = new ArrayList<>();
+ cashierCarts.parallelStream().forEach(it -> {
+ String categoryId;
+ if (ObjectUtil.isEmpty(it.getCategoryId())) {
+ categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+ } else {
+ categoryId = it.getCategoryId();
+ }
+
+
+ Long count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+
+ if (count > 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
+ String remark = "";
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
+ detailList.add(detail);
+ }
+
+ });
+
+ String balance = "0";
+
+ if ("deposit".equals(orderInfo.getPayType())) {
+ TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
+ if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
+ balance = user.getAmount().toPlainString();
+ }
+ }
+ if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
+ OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
+ String printType = "结算单";
+
+ if ("return".equals(orderInfo.getOrderType())) {
+ printType = "退款单";
+ }
+
+
+ FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
+ }
+
+ }
+ }
+ }
+
+ /**
+ * 仅打印制作单「厨房」
+ */
+ private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) {
+ List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
+ if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
+
+ cashierCarts.parallelStream().forEach(it -> {
+
+ String categoryId;
+ if (ObjectUtil.isEmpty(it.getCategoryId())) {
+ categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+ } else {
+ categoryId = it.getCategoryId();
+ }
+
+
+ Long count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+
+ if (count > 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
+ String remark = "";
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
+ FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
+ }
+ });
+ }
+ }
+
+
+ private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) {
+ String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
- List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
+ List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
- cashierCarts.parallelStream().forEach(it->{
+ cashierCarts.parallelStream().forEach(it -> {
String categoryId;
- if(ObjectUtil.isEmpty(it.getCategoryId())){
- categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+ if (ObjectUtil.isEmpty(it.getCategoryId())) {
+ categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
- Long count= categoryInfos.stream().filter(c->
+ Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
- if(count>0) {
+ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
- for(int i=0;i tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
- if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
- List detailList = new ArrayList<>();
- tbOrderDetails.parallelStream().forEach(it -> {
- String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
-
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
- log.info("获取当前类别是否未打印类别:{}", count);
-
-
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
- String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
- }
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
- detailList.add(detail);
-
- });
- String balance = "0";
-
- if ("deposit".equals(orderInfo.getPayType())) {
- TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
- if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
- balance = user.getAmount().toPlainString();
- }
- }
-
-
- if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
-// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
- OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
-
- String printType = "退款单";
-
- String data = PrinterUtils.getCashPrintData(detailPO, printType);
- PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
- }
- }
-
-
- } else {
- cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
-
- if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
- List detailList = new ArrayList<>();
- cashierCarts.parallelStream().forEach(it -> {
- String categoryId;
- if (ObjectUtil.isEmpty(it.getCategoryId())) {
- categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
- } else {
- categoryId = it.getCategoryId();
- }
-
-
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
-
- if (count > 0) {
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
- String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
- }
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
- detailList.add(detail);
- }
-
- });
-
- String balance = "0";
-
- if ("deposit".equals(orderInfo.getPayType())) {
- TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
- if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
- balance = user.getAmount().toPlainString();
- }
- }
- if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
- OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
- String printType = "结算单";
-
- if ("return".equals(orderInfo.getOrderType())) {
- printType = "退款单";
- }
-
-
- FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
- }
-
- }
- }
-
- break;
- case "one": //一菜一品
-
- cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
- if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
-
- cashierCarts.parallelStream().forEach(it -> {
-
- String categoryId;
- if (ObjectUtil.isEmpty(it.getCategoryId())) {
- categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
- } else {
- categoryId = it.getCategoryId();
- }
-
-
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
-
- if (count > 0) {
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
- String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
- }
- FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
- }
- });
- }
+ if ("normal".equals(model)) {
+ onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
+ } else if ("one".equals(model)) {
+ onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
+ } else if ("all".equals(model)) {
+ onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
+ onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
}
- break;
+ break;
case "kitchen": //出品打印机
break;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java
index 433333a..ec4aa74 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java
@@ -68,4 +68,17 @@ public interface RabbitConstants {
public static final String BALANCE_QUEUE_PUT="balance_queue_put";
public static final String BALANCE_ROUTINGKEY_PUT="balance_routingkey_put";
+
+
+ // 菜品打印
+ String EXCHANGE_PRINT = "exchange.print";
+ String ROUTING_KEY_PRINT_DISHES = "routing.dishes.print";
+
+ // 订单打印
+ String QUEUE_PRINT_PLACE = "queue.place.order.print";
+ String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print";
+
+ // 排队小票打印
+ String QUEUE_PRINT_CALL_TABLE = "queue.print.call.table";
+ String ROUTING_KEY_CALL_TABLE = "routing.call.table";
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java
index 45a477b..c5e3907 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java
@@ -1,19 +1,23 @@
package com.chaozhanggui.system.cashierservice.redis;
-/** 功能描述:redis前缀
-* @params:
-* @return:
-* @Author: wgc
-* @Date: 2020-12-19 15:02
-*/
+import cn.hutool.core.util.StrUtil;
+
+/**
+ * 功能描述:redis前缀
+ *
+ * @params:
+ * @return:
+ * @Author: wgc
+ * @Date: 2020-12-19 15:02
+ */
public class RedisCst {
- //在线用户
+ //在线用户
public static final String ONLINE_USER = "ONLINE_USER:";
public static final String PHONE_LIMIT = "PHONE_LIMIT:";
public static final String ONLINE_APP_USER = "ONLINE_APP_USER:";
public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:";
- public static final String TABLE_CART = "TABLE:CART:";
+// public static final String TABLE_CART = "TABLE:CART:";
public static final String ORDER_EXPIRED = "ORDER:EXPIRED:";
public static final String TABLE_ORDER = "TABLE:ORDER:";
public static final String PRODUCT = "PRODUCT:";
@@ -21,18 +25,65 @@ public class RedisCst {
public static final String INTEGRAL_COIN_KEY = "INTEGRAL:COIN:KEY";
public static final String COUPONS_COIN_KEY = "COUPONS:COIN:KEY";
- public static final String OUT_NUMBER="ORDER:NUMBER:";
+ public static final String OUT_NUMBER = "ORDER:NUMBER:";
// 创建订单锁
public static final String CREATE_ORDER_LOCK = "CREATE_ORDER_LOCK:";
public static final String SEND_STOCK_WARN_MSG = "SEND_STOCK_WARN_MSG:";
public static final String SONG_PAY_LOCK = "song_pay_lock:";
- public static final String ORDER_PRINT_PRO = "ORDER_PRINT_PRODUCT:";
- public static final String ORDER_PRINT = "ORDER_PRINT:";
+ public static final String ORDER_PRINT_PRO = "ORDER_PRINT_PRODUCT:";
+ public static final String ORDER_PRINT = "ORDER_PRINT:";
+ // 选择人数锁
+ public static final String CHOSE_TABLE_COUNT = "CHOSE_TABLE_COUNT";
- static String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:";
+ static final String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:";
+
+ // 排队取号全局号码
+ public static final String TABLE_CALL_NUMBER = "TABLE_CALL_NUMBER:";
+
+ // 全局锁
+ public static final String LOCK_KEY = "LOCK:";
+
+ // 外带购物车缓存
+ public static final String TAKEOUT_TABLE_CART = "TAKEOUT_TABLE_CART:";
+ // 店内就餐购物车缓存
+ public static final String DINE_IN_TABLE_CART = "DINE_IN_TABLE_CART:";
+ // 当前台桌人数
+ public static final String CURRENT_TABLE_SEAR_COUNT = "CURRENT_TABLE_SEAR_COUNT:";
public static String getCurrentOrderKey(String tableId, String shopId) {
- return CURRENT_TABLE_ORDER + shopId + ":" + tableId;
+ return CURRENT_TABLE_ORDER + shopId + ":" + tableId;
+ }
+
+ public static String getTableCallNumKey(Integer shopId, Integer callTableId) {
+ return TABLE_CALL_NUMBER + shopId + ":" + callTableId;
+ }
+
+ public static String getLockKey(String sign, Object... args) {
+ StringBuilder key = new StringBuilder(LOCK_KEY + ":" + sign + ":");
+ for (Object arg : args) {
+ key.append(":").append(arg.toString());
+ }
+ return key.toString();
+ }
+
+ public static String getTakeoutTableCartKey(String shopId, Object userId) {
+ return TAKEOUT_TABLE_CART + shopId + ":" + userId;
+// return DINE_IN_TABLE_CART + shopId + ":" + userId;
+ }
+
+ public static String getDineInTableCartKey(String shopId, String tableId) {
+ return DINE_IN_TABLE_CART + shopId + ":" + tableId;
+ }
+
+ public static String getTableCartKey(String shopId, String tableId, Object userId) {
+ if (StrUtil.isBlank(tableId)) {
+ return getTakeoutTableCartKey(shopId, userId);
+ }
+ return getDineInTableCartKey(shopId, tableId);
+ }
+
+ public static String getCurrentTableSeatCount(Object shopId, String tableId) {
+ return CURRENT_TABLE_SEAR_COUNT + (shopId + ":" + tableId);
}
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java
index f68534f..32c50c8 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java
@@ -1,23 +1,32 @@
package com.chaozhanggui.system.cashierservice.service;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.chaozhanggui.system.cashierservice.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.dao.*;
-import com.chaozhanggui.system.cashierservice.entity.*;
+import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
+import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum;
+import com.chaozhanggui.system.cashierservice.entity.*;
+import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO;
+import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
+import com.chaozhanggui.system.cashierservice.mapper.*;
import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
-import com.chaozhanggui.system.cashierservice.util.DateUtils;
-import com.chaozhanggui.system.cashierservice.util.JSONUtil;
-import com.chaozhanggui.system.cashierservice.util.LockUtils;
-import com.chaozhanggui.system.cashierservice.util.N;
+import com.chaozhanggui.system.cashierservice.util.*;
import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil;
import com.chaozhanggui.system.cashierservice.wxUtil.WxAccountUtil;
import lombok.extern.slf4j.Slf4j;
@@ -37,6 +46,7 @@ import java.time.Instant;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
/**
* @author lyf
@@ -96,14 +106,28 @@ public class CartService {
private final StringRedisTemplate stringRedisTemplate;
+ private final ShopUtils shopUtils;
+
@Autowired
private TbProskuConMapper tbProskuConMapper;
@Autowired
TbConsInfoMapper tbConsInfoMapper;
+ @Autowired
+ private MpShopInfoMapper mpShopInfoMapper;
+ @Autowired
+ private MpOrderInfoMapper mpOrderInfoMapper;
+ @Autowired
+ private MpCashierCartMapper mpCashierCartMapper;
+ @Autowired
+ private MpOrderDetailMapper mpOrderDetailMapper;
+ @Autowired
+ private MpShopTableMapper mpShopTableMapper;
+ @Autowired
+ private MQUtils mQUtils;
- public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate, StringRedisTemplate stringRedisTemplate) {
+ public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate, StringRedisTemplate stringRedisTemplate, ShopUtils shopUtils) {
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
this.wechatUtil = wechatUtil;
this.wxAccountUtil = wxAccountUtil;
@@ -112,45 +136,182 @@ public class CartService {
this.tbProductMapper = tbProductMapper;
this.redisTemplate = redisTemplate;
this.stringRedisTemplate = stringRedisTemplate;
+ this.shopUtils = shopUtils;
+ }
+
+
+ /**
+ * 获取当前台桌当前下单次数
+ *
+ * @param tableId 台桌id
+ * @param shopId 店铺id
+ * @param shopEatTypeInfoDTO 用餐类型
+ * @return 对应的次数,为order最后次数+1
+ */
+ private int getCurrentPlaceNum(String tableId, Object shopId, ShopEatTypeInfoDTO shopEatTypeInfoDTO) {
+ TbOrderInfo orderInfo = getCurrentOrder(shopEatTypeInfoDTO, tableId, shopId);
+ return orderInfo == null ? 1 : orderInfo.getPlaceNum() + 1;
+ }
+
+ private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO, String tableId, Object shopId) {
+ // 获取当前台桌最新订单,先付款模式不获取
+ if (eatTypeInfoDTO.isDineInBefore()) {
+ return null;
+ }
+ List orderInfoList = mpOrderInfoMapper.selectPage(new Page<>(1, 1), new LambdaQueryWrapper()
+ .eq(TbOrderInfo::getStatus, "unpaid")
+ .eq(TbOrderInfo::getUseType, eatTypeInfoDTO.getUseType())
+ .eq(TbOrderInfo::getShopId, shopId)
+ .eq(TbOrderInfo::getTableId, tableId)
+ .eq(TbOrderInfo::getTradeDay, DateUtils.getDay())
+ .orderByDesc(TbOrderInfo::getId)).getRecords();
+ return orderInfoList.isEmpty() ? null : orderInfoList.get(0);
}
public void initCart(JSONObject jsonObject) {
String tableId = jsonObject.getString("tableId");
String shopId = jsonObject.getString("shopId");
- String key = tableId + "-" + shopId;
+ Integer userId = jsonObject.getInteger("userId");
BigDecimal amount = BigDecimal.ZERO;
JSONArray array = new JSONArray();
- if (redisUtil.exists(RedisCst.TABLE_CART.concat(key))) {
- array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
- for (int i = 0; i < array.size(); i++) {
- JSONObject object = array.getJSONObject(i);
- TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
- if (cashierCart.getNumber() > 0) {
- amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
- }
+
+ ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.getEatModel(tableId, shopId);
+ if (!shopEatTypeInfoDTO.isOpenDineIn() && shopEatTypeInfoDTO.isOpenTakeout()) {
+ tableId = null;
+ }
+ String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
+ // 免除座位费,删除当前台桌座位费信息
+ TbShopInfo shopInfo = shopEatTypeInfoDTO.getShopInfo();
+ boolean ignoreTableFee = shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1;
+
+ TbCashierCart seatCartInfo = null;
+// if (redisUtil.exists(tableCartKey)) {
+// JSONArray jsonArray = JSON.parseArray(redisUtil.getMessage(tableCartKey));
+// for (int i = 0; i < jsonArray.size(); i++) {
+// JSONObject object = array.getJSONObject(i);
+// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
+// if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) {
+// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
+// }
+//
+// if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
+// seatCartInfo = cashierCart;
+// if (!ignoreTableFee) {
+// array.add(cashierCart);
+// }
+// }else {
+// array.add(cashierCart);
+// }
+// }
+// } else {
+
+ // 查询购物车所有信息
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper()
+ .eq(TbCashierCart::getShopId, shopId)
+ .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
+ .isNull(TbCashierCart::getOrderId)
+ .and(q -> q.isNull(TbCashierCart::getUseType).or().eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()))
+ .eq(TbCashierCart::getStatus, "create");
+
+ if (StrUtil.isNotBlank(tableId)) {
+ queryWrapper.eq(TbCashierCart::getTableId, tableId);
+ } else {
+ queryWrapper.eq(TbCashierCart::getUserId, userId);
}
- } else {
- List tbCashierCarts = cashierCartMapper.selectByShopIdAndTableId(shopId, tableId);
+
+ List tbCashierCarts = mpCashierCartMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(tbCashierCarts)) {
for (TbCashierCart cashierCart : tbCashierCarts) {
- array.add(cashierCart);
- if(cashierCart.getIsVip().equals((byte) 1)) continue;
- amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
+ if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
+ seatCartInfo = cashierCart;
+ }else {
+ array.add(cashierCart);
+ }
+ if (cashierCart.getIsVip().equals((byte) 1)) continue;
+ if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) {
+ amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
+ }
}
- redisUtil.saveMessage(RedisCst.TABLE_CART.concat(key), array.toString());
+ redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L);
}
+// }
+
+ if (ignoreTableFee && seatCartInfo != null) {
+ mpCashierCartMapper.deleteById(seatCartInfo.getId());
+ }else {
+ redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(seatCartInfo), 60 * 60 * 12L);
}
+
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
jsonObject1.put("msg", "成功");
jsonObject1.put("type", "addCart");
jsonObject1.put("data", array);
jsonObject1.put("amount", amount);
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false);
+ }
+
+ public void checkSeatInfo(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String tableId, Integer userId) {
+ TbShopInfo shopInfo = shopEatTypeInfoDTO.getShopInfo();
+ if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1) {
+ return;
+ }
+ if (!shopEatTypeInfoDTO.isTakeout()) {
+ // 查询购物车所有信息
+ LambdaQueryWrapper query = new LambdaQueryWrapper()
+ .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopInfo().getId())
+ .eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID)
+ .eq(TbCashierCart::getSkuId, TableConstant.CART_SEAT_ID)
+ .eq(TbCashierCart::getStatus, "create")
+ .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
+ .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
+ .eq(TbCashierCart::getTableId, tableId)
+ .orderByDesc(TbCashierCart::getId);
+ List cashierCartList = mpCashierCartMapper.selectList(query);
+ TbCashierCart cart = cashierCartList.isEmpty() ? null : cashierCartList.get(0);
+ if (cart != null) {
+ return;
+ }
+
+
+ String oldSeatInfo = redisUtil.getMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId));
+ TbCashierCart tbCashierCart = null;
+ if (StrUtil.isNotBlank(oldSeatInfo)) {
+ tbCashierCart = JSONObject.parseObject(oldSeatInfo, TbCashierCart.class);
+ }
+
+ if (tbCashierCart == null) {
+ tbCashierCart = new TbCashierCart();
+ tbCashierCart.setStatus("create");
+ tbCashierCart.setCreatedAt(System.currentTimeMillis());
+ tbCashierCart.setTableId(tableId);
+ tbCashierCart.setName("客座费");
+ tbCashierCart.setSalePrice(shopInfo.getTableFee());
+ tbCashierCart.setShopId(String.valueOf(shopEatTypeInfoDTO.getShopInfo().getId()));
+ tbCashierCart.setTradeDay(DateUtils.getDay());
+ tbCashierCart.setStatus("create");
+ tbCashierCart.setTotalAmount(shopInfo.getTableFee());
+ tbCashierCart.setPlaceNum(1);
+ tbCashierCart.setProductId("-999");
+ tbCashierCart.setSkuId("-999");
+ tbCashierCart.setPackFee(BigDecimal.ZERO);
+ tbCashierCart.setNumber(1);
+ tbCashierCart.setTotalNumber(1);
+ tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
+ tbCashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
+ tbCashierCart.setUserId(userId);
+ }
+ tbCashierCart.setId(null);
+
+ mpCashierCartMapper.insert(tbCashierCart);
+ redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(tbCashierCart), 60 * 60 * 12L);
+
+ }
}
/**
* 加入购物车
+ *
* @param jsonObject 商品信息
*/
public Result createCart(JSONObject jsonObject) {
@@ -162,150 +323,219 @@ public class CartService {
Integer type = jsonObject.getInteger("type");
Integer buyNum = jsonObject.getInteger("num");
Integer isVip = jsonObject.getInteger("isVip");
- if (StringUtils.isBlank(tableId) || StringUtils.isBlank(shopId) || StringUtils.isBlank(productId)
+ Integer userId = jsonObject.getInteger("userId");
+ // 商品备注
+ String note = jsonObject.getString("note");
+ if (StringUtils.isBlank(shopId) || StringUtils.isBlank(productId)
|| StringUtils.isBlank(skuId) || type == null || buyNum == null) {
return Result.fail("参数缺失");
}
- String key = tableId + "-" + shopId;
- TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId));
- if (tbProduct == null) {
- log.error("该商品不存在 productId:{}", productId);
- return Result.fail("该商品不存在");
- }
- // 判断商品是否已下架
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
- if (tbProductSkuWithBLOBs == null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) {
- rmCart(jsonObject, skuId, key);
- return Result.fail("商品已下架");
- }
- if (tbProduct.getIsStock() == 1) {
- // 1:共享库存 0:独立库存
- if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
+
+ boolean isSeatCart = "-999".equals(productId);
+ ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(tableId, shopId);
+ String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
+ // 检查客座费并设置
+ checkSeatInfo(shopEatTypeInfoDTO, tableId, userId);
+
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = null;
+ if (!isSeatCart) {
+ TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId));
+ if (tbProduct == null) {
+ log.error("该商品不存在 productId:{}", productId);
+ return Result.fail("该商品不存在");
+ }
+ // 判断商品是否已下架
+ tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
+ if (tbProductSkuWithBLOBs == null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) {
+ rmCart(jsonObject, skuId, tableCartKey);
+ return Result.fail("商品已下架");
+ }
+ if (tbProduct.getIsStock() == 1) {
if (tbProduct.getIsPauseSale() == 1) {//是否售罄
- rmCart(jsonObject, skuId, key);
- return Result.fail("该商品已售罄");
- }
- } else {
- if (tbProductSkuWithBLOBs.getIsPauseSale() == 1) {//是否售罄
- rmCart(jsonObject, skuId, key);
+ rmCart(jsonObject, skuId, tableCartKey);
return Result.fail("该商品已售罄");
}
}
- }
- List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId), Integer.valueOf(shopId), Integer.valueOf(productId));
- if (Objects.nonNull(proskuConList) && proskuConList.size() > 0) {
- for (TbProskuCon proskuCon : proskuConList) {
- if ("1".equals(proskuCon.getStatus())) {
- TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
- if ("1".equals(consInfo.getIsCheck())) {
- if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) {
- return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足"));
+ // 检查耗材
+ List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId), Integer.valueOf(shopId), Integer.valueOf(productId));
+ if (Objects.nonNull(proskuConList) && !proskuConList.isEmpty()) {
+ for (TbProskuCon proskuCon : proskuConList) {
+ if ("1".equals(proskuCon.getStatus())) {
+ TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
+ if ("1".equals(consInfo.getIsCheck())) {
+ if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) {
+ return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足"));
+ }
}
}
}
}
}
+
JSONArray jsonArray = new JSONArray();
+ ArrayList cashierCartArrayList = new ArrayList<>();
BigDecimal amount = BigDecimal.ZERO;
- try{
- if (redisUtil.exists(RedisCst.TABLE_CART.concat(key))) {
- JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(key)));
+ try {
+ if (redisUtil.exists(tableCartKey)) {
+ JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
if (Objects.isNull(array) || array.isEmpty()) {
if (type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId,
- jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip);
+ jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout());
jsonArray.add(cashierCart);
+ cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
+ cashierCartArrayList.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
+
}
} else {
boolean flag = true;
+
+ boolean hasSeat = false;
for (int i = 0; i < array.size(); i++) {
JSONObject object = array.getJSONObject(i);
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
+ cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
- if (cashierCart.getSkuId().equals(skuId) && cashierCart.getIsVip().intValue() == isVip) {
+ if (cashierCart.getSkuId().equals(skuId) && (isVip == null || cashierCart.getIsVip().intValue() == isVip)) {
cashierCart.setTotalNumber(buyNum);
cashierCart.setNumber(buyNum);
- if (type == 0 && isVip == 0 && tbProductSkuWithBLOBs.getSuit() != null
+ cashierCart.setNote(note);
+ if (tbProductSkuWithBLOBs != null && type == 0 && isVip != null && isVip == 0 && tbProductSkuWithBLOBs.getSuit() != null
&& tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) {
cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
continue;
}
+
+ if (isSeatCart) {
+ TbShopTable shopTable = shopTableMapper.selectQRcode(tableId);
+ if (cashierCart.getTotalNumber() > shopTable.getMaxCapacity()) {
+ return Result.fail("当前台桌最大人数未: " + shopTable.getMaxCapacity());
+ }
+ }
+
if (cashierCart.getNumber() > 0) {
- if (isVip == 1) {
+ // 设置备注
+ cashierCart.setNote(note);
+ // 设置打包费
+ if (shopEatTypeInfoDTO.isTakeout() && !isSeatCart) {
+ // 打包费
+ TbProduct product = productMapper.selectById(Integer.valueOf(productId));
+ cashierCart.setPackFee(product.getPackFee() != null ?
+ product.getPackFee().multiply(BigDecimal.valueOf(buyNum)) : BigDecimal.ZERO);
+
+ }
+ if (isVip != null && isVip == 1) {
cashierCart.setTotalAmount(BigDecimal.ZERO);
} else {
- cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
+ cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber())
+ .multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
}
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
- cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
+ mpCashierCartMapper.updateById(cashierCart);
} else {
- cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
+ mpCashierCartMapper.deleteById(cashierCart.getId());
continue;
}
flag = false;
}
jsonArray.add(cashierCart);
+ cashierCartArrayList.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
+
+ if ("-999".equals(cashierCart.getProductId())) {
+ hasSeat = true;
+ }
}
+
if (flag && type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId,
- jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip);
+ jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout());
jsonArray.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
}
+
}
} else {
if (type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId,
- jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip);
- jsonArray.add(cashierCart);
+ jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout());
+ if (!TableConstant.CART_SEAT_ID.equals(productId)) {
+ jsonArray.add(cashierCart);
+ }
+ cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
+ cashierCartArrayList.add(cashierCart);
if (isVip != 1) {
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
}
}
}
- }catch (MsgException e){
- if(e.getMessage().equals("商品起售库存不足")){
+ } catch (MsgException e) {
+ if (e.getMessage().equals("商品起售库存不足")) {
return Result.fail("商品起售库存不足");
}
}
- redisUtil.saveMessage(RedisCst.TABLE_CART.concat(key), jsonArray.toJSONString());
- JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("status", "success");
- jsonObject1.put("msg", "成功");
- jsonObject1.put("type", "addcart");
- jsonObject1.put("data", jsonArray);
- jsonObject1.put("amount", amount);
- jsonObject1.put("reqData", jsonObject);
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, "", false);
+
+ redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString(), 60 * 60 * 12L);
+ // 餐位费
+// Object seatCost = jsonArray.stream().findFirst().filter(info -> "-999".equals(((TbCashierCart) info).getProductId())).orElse(null);
+ TbCashierCart seatCost = cashierCartArrayList.stream().findFirst().filter(info -> "-999".equals(info.getProductId())).orElse(null);
+ HashMap data = new HashMap<>();
+ data.put("status", "success");
+ data.put("msg", "成功");
+ data.put("type", "addcart");
+ data.put("data", jsonArray);
+ data.put("seatFee", BeanUtil.copyProperties(seatCost, TbCashierCart.class));
+ data.put("amount", amount);
+ data.put("reqData", jsonObject);
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(data), tableCartKey, "", false);
} catch (Exception e) {
- log.error("长链接错误 createCart {}", e.getMessage());
+ log.error("长链接错误 createCar", e);
}
return Result.success(CodeEnum.SUCCESS);
}
- private void rmCart(JSONObject jsonObject,String skuId, String key) {
+ private List> formatCartStruct(List cashierCartList) {
+ // 根据placeNum进行分组
+ Map> groupedByPlaceNum = cashierCartList.stream()
+ .collect(Collectors.groupingBy(TbCashierCart::getPlaceNum));
+
+ ArrayList> list = new ArrayList<>();
+ groupedByPlaceNum.forEach((k, v) -> {
+ HashMap item = new HashMap<>();
+ item.put("placeNum", k);
+ item.put("placeTime", !v.isEmpty() ? v.get(0).getUpdatedAt() : null);
+ item.put("info", v);
+ list.add(item);
+ });
+ return list;
+ }
+
+ private void rmCart(JSONObject jsonObject, String skuId, String redisKey) {
JSONArray jsonArray = new JSONArray();
BigDecimal amount = BigDecimal.ZERO;
- if (redisUtil.exists(RedisCst.TABLE_CART.concat(key))) {
- JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(key)));
+ if (redisUtil.exists(redisKey)) {
+ JSONArray array = JSON.parseArray(redisUtil.getMessage(redisKey));
if (!Objects.isNull(array) && !array.isEmpty()) {
boolean flag = false;
for (int i = 0; i < array.size(); i++) {
JSONObject object = array.getJSONObject(i);
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
if (cashierCart.getSkuId().equals(skuId)) {
- cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
- flag = true;
- continue;
+ if (StrUtil.isNotBlank(cashierCart.getMasterId())) {
+ throw new MsgException("代客下单商品不支持操作");
+ } else {
+ cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
+ flag = true;
+ continue;
+ }
}
jsonArray.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
}
- redisUtil.saveMessage(RedisCst.TABLE_CART.concat(key), jsonArray.toJSONString());
+ redisUtil.saveMessage(redisKey, jsonArray.toJSONString());
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
jsonObject1.put("msg", "成功");
@@ -313,8 +543,8 @@ public class CartService {
jsonObject1.put("data", jsonArray);
jsonObject1.put("amount", amount);
jsonObject1.put("reqData", jsonObject);
- if(flag){
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, "", false);
+ if (flag) {
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), redisKey, "", false);
}
}
}
@@ -329,22 +559,9 @@ public class CartService {
* @param num 库存数
*/
private void updateProductStock(TbProduct product, TbProductSkuWithBLOBs productSku, Integer num) {
- String key = RedisCst.PRODUCT + product.getShopId() + ":product" + product.getId();
- double stock = num;
- if (product.getIsDistribute() == 1) {
- productMapper.updateStockById(product.getId().toString(), num);
- stock = (double) (product.getStockNumber() - num);
- } else {
- key = RedisCst.PRODUCT + product.getShopId() + ":" + productSku.getId();
- productSkuMapper.updateStockById(productSku.getId().toString(), num);
- stock = productSku.getStockNumber() - num;
- }
- if (num > 0) {
- redisUtil.getIncrNum(key, "1");
- } else {
- redisUtil.getIncrNum(key, "2");
- }
+ productMapper.updateStockById(product.getId().toString(), num);
+
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(productSku, product, num));
@@ -356,7 +573,7 @@ public class CartService {
* @param productSku sku
*/
private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer num) {
- if (productSku.getWarnLine() == null) {
+ if (product.getWarnLine() == null) {
return;
}
@@ -370,26 +587,20 @@ public class CartService {
return;
}
- if (productSku.getStockNumber() == null) {
- productSku.setStockNumber((double) 0);
- }
if (product.getStockNumber() == null) {
product.setStockNumber(0);
}
- if (
- (product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine())
- || (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
- ) {
+ if (product.getStockNumber() - num <= product.getWarnLine()) {
List shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType());
shopOpenIds.forEach(item -> {
String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId());
if (message == null) {
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
- product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num)
+ product.getStockNumber() - num
, item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopInfo.getId());
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
- }else {
+ } else {
log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId());
}
@@ -397,7 +608,8 @@ public class CartService {
}
}
- private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId,Integer isVip) throws Exception{
+ private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num,
+ String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception {
try {
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
String key = tableId + "-" + shopId;
@@ -406,28 +618,19 @@ public class CartService {
if (productSku.getSuit() != null && productSku.getSuit() > 1 && isVip != 1) {
if (product.getIsStock() == 1) {
boolean isSale = false;
- // 1:共享库存 0:独立库存
- if (Integer.valueOf(product.getIsDistribute()).equals(1)) {
- if (num > productSku.getSuit()) {
- if (num > product.getStockNumber()) isSale = true;
- }else {
- if (productSku.getSuit() > product.getStockNumber()) isSale = true;
- }
+ if (num > productSku.getSuit()) {
+ if (num > product.getStockNumber()) isSale = true;
} else {
- if (num > productSku.getSuit()) {
- if (num > productSku.getStockNumber()) isSale = true;
- }else {
- if (productSku.getSuit() > productSku.getStockNumber()) isSale = true;
- }
+ if (productSku.getSuit() > product.getStockNumber()) isSale = true;
}
if (isSale) {
throw new MsgException("商品起售库存不足");
}
}
- if(num > productSku.getSuit()){
+ if (num > productSku.getSuit()) {
cashierCart.setNumber(num);
cashierCart.setTotalNumber(num);
- }else {
+ } else {
cashierCart.setNumber(productSku.getSuit());
cashierCart.setTotalNumber(productSku.getSuit());
}
@@ -435,6 +638,7 @@ public class CartService {
cashierCart.setNumber(num);
cashierCart.setTotalNumber(num);
}
+ cashierCart.setNote(note);
cashierCart.setProductId(productId);
cashierCart.setSkuId(skuId);
cashierCart.setCoverImg(product.getCoverImg());
@@ -442,7 +646,7 @@ public class CartService {
cashierCart.setCategoryId(product.getCategoryId());
cashierCart.setShopId(shopId);
cashierCart.setUserId(userId);
- cashierCart.setTableId(tableId);
+ cashierCart.setTableId(StrUtil.isBlank(tableId) ? null : tableId);
cashierCart.setSkuName(productSku.getSpecSnap());
cashierCart.setIsPack("false");
cashierCart.setIsGift("false");
@@ -453,16 +657,21 @@ public class CartService {
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
cashierCart.setPackFee(BigDecimal.ZERO);
cashierCart.setRefundNumber(0);
- if(isVip==1){
+ cashierCart.setTradeDay(DateUtils.getDay());
+ // 打包费
+ if (isTakeout && product.getPackFee() != null) {
+ cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num)));
+ }
+ if (isVip == 1) {
cashierCart.setIsVip(Byte.parseByte("1"));
cashierCart.setTotalAmount(BigDecimal.ZERO);
cashierCart.setSalePrice(BigDecimal.ZERO);
- }else {
- cashierCart.setIsVip(Byte.parseByte("0"));
+ } else {
+ cashierCart.setIsVip((byte) 0);
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
}
- cashierCartMapper.insert(cashierCart);
-
+ cashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
+ mpCashierCartMapper.insert(cashierCart);
//修改耗材数据
// JSONObject jsonObject=new JSONObject();
@@ -479,13 +688,16 @@ public class CartService {
}
@Transactional(rollbackFor = Exception.class)
- public void createOrder(JSONObject jsonObject) {
+ public Result createOrder(JSONObject jsonObject) {
try {
+ JSONObject responseData = new JSONObject();
+
String shopId = jsonObject.getString("shopId");
String tableId = jsonObject.getString("tableId");
- String remark = StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark");
- String key = tableId + "-" + shopId;
- JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(key)));
+ String userId = jsonObject.getString("userId");
+ String sendType = jsonObject.getString("sendType");
+ String remark = StringUtils.isBlank(jsonObject.getString("remark")) ? "" : jsonObject.getString("remark");
+
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal packAMount = BigDecimal.ZERO;
BigDecimal originAmount = BigDecimal.ZERO;
@@ -499,111 +711,258 @@ public class CartService {
MsgException.throwException("生成订单错误");
}
- String userId = jsonObject.getString("userId");
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
if (tbUserInfo == null) {
MsgException.throwException("生成订单失败");
}
- TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
- boolean isVip= false;
- if (tbShopUser != null && tbShopUser.getIsVip().equals((byte) 1)) {
- isVip=true;
+
+ if (StrUtil.isBlank(sendType)) {
+ MsgException.throwException("用餐类型不为空");
}
+
+ // 获取当前下单次数和用餐类型
+ if ("takeself".equals(sendType)) {
+ tableId = null;
+ }
+ ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(tableId, shopId);
+ Integer currentPlaceNum = getCurrentPlaceNum(tableId, shopId, shopEatTypeInfoDTO);
+ String tableCartKey = RedisCst.getTableCartKey(shopId, shopEatTypeInfoDTO.isOpenDineIn() ? tableId : null, Integer.valueOf(userId));
+ JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
+ // 查询购物车所有信息
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper()
+ .eq(TbCashierCart::getShopId, shopId)
+ .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
+ .eq(TbCashierCart::getStatus, "create");
+
+ TbShopTable shopTable = null;
+ // 外带模式
+ if (shopEatTypeInfoDTO.isTakeout()) {
+ queryWrapper.eq(TbCashierCart::getUserId, userId);
+ // 台桌点单
+ } else {
+ String finalTableId = tableId;
+ queryWrapper.and(q -> {
+ q.eq(TbCashierCart::getTableId, finalTableId).or().eq(TbCashierCart::getUserId, userId);
+ }).and(q -> q.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()).or().isNull(TbCashierCart::getUseType));
+
+ shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper()
+ .eq(TbShopTable::getQrcode, tableId));
+ if (shopTable == null) {
+ throw new MsgException("台桌不存在");
+ }
+ }
+
+ // 所有订单信息
+ List cashierCartList = mpCashierCartMapper.selectList(queryWrapper);
+
+ if (cashierCartList.isEmpty()) {
+ responseData.put("status", "fail");
+ responseData.put("msg", "购物车为空");
+ responseData.put("data", new ArrayList<>());
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
+ return Result.fail("购物车为空");
+ }
+
+ // 就餐人数
+ ArrayList cashierIds = new ArrayList<>();
+
+ Integer seatNum = 0;
+ BigDecimal seatCost = BigDecimal.ZERO;
+ for (TbCashierCart tbCashierCart : cashierCartList) {
+ cashierIds.add(tbCashierCart.getId());
+ if ("-999".equals(tbCashierCart.getProductId())) {
+ seatNum = tbCashierCart.getNumber();
+ seatCost = tbCashierCart.getTotalAmount();
+ }
+
+ if (StringUtils.isNotEmpty(tbCashierCart.getOrderId())) {
+ orderId = Integer.valueOf(tbCashierCart.getOrderId());
+ }
+ }
+
+ // 校验是否选择人数
+ // 设置餐位费
+ TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
+ if (!shopEatTypeInfoDTO.isTakeout() && shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0
+ && (seatNum < 1 || cashierCartList.size() < 2)) {
+ log.info("消息推送");
+ responseData.put("msg", "购物车为空");
+ if (shopTable.getMaxCapacity() < seatNum) {
+ responseData.put("msg", "当前台桌最大人数为: " + shopTable.getMaxCapacity());
+ }
+ responseData.put("status", "fail");
+ responseData.put("type", jsonObject.getString("type"));
+ responseData.put("data", "");
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
+ return Result.fail(responseData.getString("msg"));
+ }
+
+
+ TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
+ boolean isVip = tbShopUser != null && tbShopUser.getIsVip().equals((byte) 1);
+
+ // 查询历史orderDetail
+ Integer finalOrderId = orderId;
+ List oldOrderDetailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper()
+ .eq(TbOrderDetail::getStatus, "unpaid")
+ .and(q -> q.in(TbOrderDetail::getCartId, cashierIds).or().eq(TbOrderDetail::getOrderId, finalOrderId))
+ .eq(TbOrderDetail::getShopId, shopId));
+ HashMap oldOrderDetailMap = new HashMap<>();
+ ArrayList removeOrderDetailList = new ArrayList<>();
+ ArrayList addOrderDetail = new ArrayList<>();
+
+ oldOrderDetailList.forEach(item -> {
+ oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item);
+ if (cashierIds.contains(item.getCartId())) {
+ oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item);
+ } else {
+ removeOrderDetailList.add(item);
+ }
+ });
+ boolean hasNewInfo = false;
+
+ // 外带模式去除餐位费
+ TbCashierCart seatCartInfo = null;
//校验 库存 耗材
- for (int i = 0; i < array.size(); i++) {
- JSONObject object = array.getJSONObject(i);
- TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
- if (cashierCart.getIsVip().equals((byte) 1)) {
+ for (TbCashierCart cart : cashierCartList) {
+ if (shopEatTypeInfoDTO.isTakeout() && "-999".equals(cart.getProductId())) {
+ seatCartInfo = cart;
+ continue;
+ }
+
+ // 设置打包费
+ if (shopEatTypeInfoDTO.isTakeout()) {
+ cart.setTableId("");
+ // 打包费
+ TbProduct product = productMapper.selectById(Integer.valueOf(cart.getProductId()));
+ cart.setPackFee(product.getPackFee() != null ?
+ product.getPackFee().multiply(BigDecimal.valueOf(cart.getNumber())) : BigDecimal.ZERO);
+ cart.setIsPack("true");
+ } else {
+ cart.setTableId(tableId);
+ cart.setPackFee(BigDecimal.ZERO);
+ }
+
+ if (cart.getIsVip().equals((byte) 1)) {
if (isVip) {
int i1 = activateInRecordService.queryByVipIdAndShopIdAndProId(
- Integer.valueOf(tbShopUser.getId()), Integer.valueOf(shopId), Integer.valueOf(cashierCart.getProductId()));
- if (i1 < cashierCart.getTotalNumber()) {
+ Integer.valueOf(tbShopUser.getId()), Integer.valueOf(shopId), Integer.valueOf(cart.getProductId()));
+ if (i1 < cart.getTotalNumber()) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
- jsonObject1.put("msg", "会员商品[" + cashierCart.getName() + "],可下单数量为" + i1);
+ jsonObject1.put("msg", "会员商品[" + cart.getName() + "],可下单数量为" + i1);
jsonObject1.put("data", new ArrayList<>());
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
- return;
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
+ continue;
}
} else {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "非会员用户不可下单会员商品");
jsonObject1.put("data", new ArrayList<>());
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
- return;
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
+ continue;
}
}
- TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
- TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId()));
-
- // 判断商品是否已下架
- if (tbProduct.getIsGrounding().equals(0)) {
- JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("status", "fail");
- jsonObject1.put("msg", "商品已下架:" + tbProduct1.getName());
- jsonObject1.put("data", new ArrayList<>());
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
- return;
- }
-
- log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
- CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cashierCart.getNumber()));
-
-
- log.info("开始修改库存,商品id:{},商品名:{}", tbProduct1.getId(), tbProduct1.getName());
- // 修改库存
- try {
- if (tbProduct1.getIsStock() == 1) {
- productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
- } else {
- productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
+ TbProductSkuWithBLOBs tbProduct;
+ if (!"-999".equals(cart.getProductId())) {
+ tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cart.getSkuId()));
+ TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId()));
+ // 判断商品是否已下架
+ if (tbProduct.getIsGrounding().equals(0)) {
+ JSONObject jsonObject1 = new JSONObject();
+ jsonObject1.put("status", "fail");
+ jsonObject1.put("msg", "商品已下架:" + tbProduct1.getName());
+ jsonObject1.put("data", new ArrayList<>());
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
+ continue;
}
- } catch (Exception e) {
- JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("status", "fail");
- jsonObject1.put("msg", tbProduct1.getName() + "库存不足");
- jsonObject1.put("data", new ArrayList<>());
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
- return;
- }
+ log.info("下单,开始校验库存预警,购物车id:{}", cart.getId());
+ CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cart.getNumber()));
- totalAmount = totalAmount.add(cashierCart.getTotalAmount());
- packAMount = packAMount.add(cashierCart.getPackFee());
- originAmount = originAmount.add(cashierCart.getTotalAmount());
- if (Objects.nonNull(tbProduct)) {
+ log.info("开始修改库存,商品id:{},商品名:{}", tbProduct1.getId(), tbProduct1.getName());
+ // 修改库存
+ try {
+ // 首次下单扣除库存
+ if (StrUtil.isBlank(cart.getOrderId())) {
+ if (tbProduct1.getIsStock() == 1) {
+ productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber());
+ } else {
+ productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber());
+ }
+ }
+
+ } catch (Exception e) {
+ JSONObject jsonObject1 = new JSONObject();
+ jsonObject1.put("status", "fail");
+ jsonObject1.put("msg", tbProduct1.getName() + "库存不足");
+ jsonObject1.put("data", new ArrayList<>());
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
+ throw new MsgException((String) jsonObject1.get("msg"));
+ }
saleAmount = saleAmount.add(tbProduct.getSalePrice());
- }
- TbOrderDetail orderDetail = new TbOrderDetail();
- orderDetail.setCreateTime(new Date());
- orderDetail.setNum(cashierCart.getNumber());
- orderDetail.setPrice(cashierCart.getSalePrice());
- if (cashierCart.getIsPack().equals("true")) {
- orderDetail.setPriceAmount(cashierCart.getTotalAmount().add(cashierCart.getPackFee()));
} else {
- orderDetail.setPriceAmount(cashierCart.getTotalAmount());
+ tbProduct = null;
+ saleAmount = saleAmount.add(shopEatTypeInfoDTO.getShopInfo().getTableFee());
}
- orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId()));
- orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId()));
- orderDetail.setProductSkuName(tbProduct.getSpecSnap());
- orderDetail.setProductName(cashierCart.getName());
+
+ totalAmount = totalAmount.add(cart.getTotalAmount());
+ packAMount = packAMount.add(cart.getPackFee());
+ originAmount = originAmount.add(cart.getTotalAmount());
+
+ TbOrderDetail orderDetail = oldOrderDetailMap.get(cart.getOrderId() + cart.getId());
+ if (orderDetail == null) {
+ orderDetail = new TbOrderDetail();
+ hasNewInfo = true;
+ addOrderDetail.add(orderDetail);
+ }
+ orderDetail.setCreateTime(new Date());
+ orderDetail.setNum(cart.getNumber());
+ orderDetail.setPrice(cart.getSalePrice());
+ if (cart.getIsPack().equals("true")) {
+ orderDetail.setPriceAmount(cart.getTotalAmount().add(cart.getPackFee()));
+ } else {
+ orderDetail.setPriceAmount(cart.getTotalAmount());
+ }
+ orderDetail.setProductId(Integer.valueOf(cart.getProductId()));
+ orderDetail.setProductSkuId(Integer.valueOf(cart.getSkuId()));
+ orderDetail.setProductSkuName(tbProduct == null ? null : tbProduct.getSpecSnap());
+ orderDetail.setProductName(cart.getName());
orderDetail.setShopId(jsonObject.getInteger("shopId"));
- orderDetail.setPackAmount(cashierCart.getPackFee());
- orderDetail.setProductImg(cashierCart.getCoverImg());
+ orderDetail.setPackAmount(cart.getPackFee());
+ orderDetail.setProductImg(cart.getCoverImg());
orderDetail.setStatus("unpaid");
- orderDetail.setIsVip(cashierCart.getIsVip());
- if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
- orderId = Integer.valueOf(cashierCart.getOrderId());
+ orderDetail.setIsVip(cart.getIsVip());
+ orderDetail.setCartId(cart.getId());
+ if (StringUtils.isNotEmpty(cart.getOrderId())) {
+ orderId = Integer.valueOf(cart.getOrderId());
}
+ orderDetail.setUseType(shopEatTypeInfoDTO.getUseType());
+ if (orderDetail.getPlaceNum() == null) {
+ orderDetail.setPlaceNum(currentPlaceNum);
+ }
+
+ // 设置下单次数
+ if (cart.getPlaceNum() == null) {
+ cart.setPlaceNum(currentPlaceNum);
+ }
+
orderDetails.add(orderDetail);
- if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
- orderId = Integer.valueOf(cashierCart.getOrderId());
+ cart.setStatus(shopEatTypeInfoDTO.isDineInAfter() ? "create" : "final");
+ cart.setUpdatedAt(DateUtil.current());
+
+ if (!TableConstant.CART_SEAT_ID.equals(cart.getProductId()) || !shopEatTypeInfoDTO.getUseType().equals(OrderUseTypeEnum.TAKEOUT.getValue())) {
+ cart.setUseType(shopEatTypeInfoDTO.getUseType());
+ }
+
+ if (cart.getId() != null) {
+ mpCashierCartMapper.updateById(cart);
+ } else {
+ mpCashierCartMapper.insert(cart);
}
- cashierCartMapper.updateStatusById(cashierCart.getId(), "final");
}
- //总金额
- TbShopTable shopTable = shopTableMapper.selectQRcode(jsonObject.getString("tableId"));
+
//生成订单
TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId);
@@ -618,25 +977,23 @@ public class CartService {
TbSystemCoupons systemCoupons = systemCouponsMapper.selectByPrimaryKey(couponsId);
if (Objects.isNull(systemCoupons) || !systemCoupons.getStatus().equals("0")) {
log.info("开始处理订单");
- JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("status", "fail");
- jsonObject1.put("msg", "优惠券已售空");
- jsonObject1.put("type", jsonObject.getString("type"));
- jsonObject1.put("data", "");
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
+ responseData.put("status", "fail");
+ responseData.put("msg", "优惠券已售空");
+ responseData.put("type", jsonObject.getString("type"));
+ responseData.put("data", "");
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
log.info("消息推送");
- return;
+ return Result.fail("优惠券已售空");
}
if (N.gt(systemCoupons.getCouponsAmount(), totalAmount)) {
log.info("开始处理订单");
- JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("status", "fail");
- jsonObject1.put("msg", "订单金额小于优惠价金额");
- jsonObject1.put("type", jsonObject.getString("type"));
- jsonObject1.put("data", "");
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
+ responseData.put("status", "fail");
+ responseData.put("msg", "订单金额小于优惠价金额");
+ responseData.put("type", jsonObject.getString("type"));
+ responseData.put("data", "");
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
log.info("消息推送");
- return;
+ return Result.fail("订单金额小于优惠价金额");
}
totalAmount = totalAmount.add(systemCoupons.getCouponsPrice()).subtract(systemCoupons.getCouponsAmount());
originAmount = originAmount.add(systemCoupons.getCouponsPrice());
@@ -665,21 +1022,19 @@ public class CartService {
isuseYhq = "true";
}
- if (Objects.nonNull(orderInfo)) {
+
+ if (orderInfo != null) {
log.info("订单状态:" + orderInfo.getStatus());
if (!"unpaid".equals(orderInfo.getStatus())) {
log.info("开始处理订单");
- JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("status", "fail");
- jsonObject1.put("msg", "订单正在支付中,请稍后再试");
- jsonObject1.put("type", jsonObject.getString("type"));
- jsonObject1.put("data", "");
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
+ responseData.put("status", "fail");
+ responseData.put("msg", "订单正在支付中,请稍后再试");
+ responseData.put("type", jsonObject.getString("type"));
+ responseData.put("data", "");
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
log.info("消息推送");
- return;
+ return Result.fail("订单正在支付中,请稍后再试");
}
-
- orderDetailMapper.deleteByOUrderId(orderId);
orderInfo.setUpdatedAt(System.currentTimeMillis());
orderInfo.setSettlementAmount(totalAmount);
orderInfo.setUserCouponId(couponId);
@@ -693,8 +1048,14 @@ public class CartService {
orderInfo.setIsUseCoupon(isuseYhq);
orderInfo.setRemark(remark);
orderInfo.setUserId(userId);
- orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
-
+ if (hasNewInfo) {
+ orderInfo.setPlaceNum(currentPlaceNum);
+ }
+ orderInfo.setUseType(shopEatTypeInfoDTO.getUseType());
+ orderInfo.setSeatCount(seatNum);
+ orderInfo.setSeatAmount(seatCost);
+ orderInfo.setSendType(sendType);
+ mpOrderInfoMapper.updateById(orderInfo);
} else {
orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount);
orderInfo.setMerchantId(String.valueOf(tbMerchantAccount.getId()));
@@ -705,6 +1066,10 @@ public class CartService {
orderInfo.setUserCouponAmount(couponAmount);
orderInfo.setRemark(remark);
orderInfo.setUserId(userId);
+ orderInfo.setPlaceNum(currentPlaceNum);
+ orderInfo.setUseType(shopEatTypeInfoDTO.getUseType());
+ orderInfo.setSeatCount(seatNum);
+ orderInfo.setSeatAmount(seatCost);
JSONObject object = new JSONObject();
String outNumber = redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")));
@@ -723,21 +1088,26 @@ public class CartService {
}
}
orderInfo.setOutNumber(number + "");
+ orderInfo.setSendType(sendType);
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")), object.toString());
- orderInfoMapper.insert(orderInfo);
+ mpOrderInfoMapper.insert(orderInfo);
orderId = orderInfo.getId();
-
-
}
+
for (TbOrderDetail orderDetail : orderDetails) {
- orderDetail.setOrderId(orderId);
- orderDetailMapper.insert(orderDetail);
+ orderDetail.setOrderId(orderInfo.getId());
+ if (orderDetail.getId() != null) {
+ mpOrderDetailMapper.updateById(orderDetail);
+ } else {
+ mpOrderDetailMapper.insert(orderDetail);
+ }
}
+
+ // 去除餐位费信息
+
List outRecords = new ArrayList<>();
- for (int i = 0; i < array.size(); i++) {
- JSONObject object = array.getJSONObject(i);
- TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
- if (cashierCart.getIsVip().equals((byte) 1)) {
+ for (TbCashierCart cashierCart : cashierCartList) {
+ if (!cashierCart.getProductId().equals("-999") && cashierCart.getIsVip().equals((byte) 1)) {
List actInRecords = activateInRecordService.queryAllByVipIdAndShopIdAndProId(
Integer.valueOf(tbShopUser.getId()), Integer.valueOf(orderInfo.getShopId()), Integer.valueOf(cashierCart.getProductId()));
Integer totalNumber = cashierCart.getTotalNumber();
@@ -759,14 +1129,39 @@ public class CartService {
}
cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setOrderId(orderId + "");
- cashierCart.setStatus("closed");
- cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
- object.put("updatedAt", System.currentTimeMillis());
- object.put("orderId", orderId + "");
-
-
+ if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) && !shopEatTypeInfoDTO.isDineInAfter())
+ || shopEatTypeInfoDTO.isDineInBefore()) {
+ cashierCart.setStatus("closed");
+ }
+ cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? currentPlaceNum : cashierCart.getPlaceNum());
+ mpCashierCartMapper.updateById(cashierCart);
}
- if(!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords);
+
+ cashierCartList = cashierCartList.stream().filter(item -> !"-999".equals(item.getProductId())).collect(Collectors.toList());
+
+
+ // 删除旧的餐位费信息
+// if (shopEatTypeInfoDTO.isTakeout() && seatCartInfo != null) {
+// cashierCartMapper.deleteByPrimaryKey(seatCartInfo.getId());
+// }
+
+ if (!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords);
+
+ // 打印票据
+ if (!addOrderDetail.isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) {
+ log.info("待打印菜品信息: {}", addOrderDetail);
+ mQUtils.printDishesTicket(orderInfo.getId(), false, addOrderDetail.toArray(new TbOrderDetail[0]));
+ }
+
+ if (!removeOrderDetailList.isEmpty()) {
+ log.info("待打印退菜菜品信息: {}", removeOrderDetailList);
+ // 退单票
+ mpOrderDetailMapper.deleteBatchIds(removeOrderDetailList.stream().map(TbOrderDetail::getId).collect(Collectors.toList()));
+ if (shopEatTypeInfoDTO.isDineInAfter()) {
+ mQUtils.printDishesTicket(orderInfo.getId(), true, removeOrderDetailList.toArray(new TbOrderDetail[0]));
+ }
+ }
+
// 发送mq消息
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("orderId", orderInfo.getId());
@@ -774,30 +1169,28 @@ public class CartService {
log.info("开始发送mq消息,消耗耗材,消息内容:{}", jsonObject2);
producer.cons(jsonObject2.toString());
- redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString());
+ redisUtil.saveMessage(tableCartKey, new JSONArray().toJSONString());
orderInfo.setDetailList(orderDetails);
- JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("status", "success");
- jsonObject1.put("msg", "成功");
- jsonObject1.put("type", jsonObject.getString("type"));
- jsonObject1.put("data", orderInfo);
- redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId));
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
- JSONObject jsonObject12 = new JSONObject();
- jsonObject12.put("status", "success");
- jsonObject12.put("msg", "成功");
- jsonObject12.put("type", "order");
- jsonObject12.put("amount", BigDecimal.ZERO);
+ responseData.put("status", "success");
+ responseData.put("msg", "成功");
+ responseData.put("type", jsonObject.getString("type"));
+ responseData.put("data", orderInfo);
+ redisUtil.deleteByKey(tableCartKey);
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
- jsonObject12.put("data", new JSONArray());
+ responseData.put("status", "success");
+ responseData.put("msg", "成功");
+ responseData.put("type", "order");
+ responseData.put("amount", BigDecimal.ZERO);
+ responseData.put("data", new JSONArray());
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
- PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), jsonObject.getString("userId"));
+ PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"));
+
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
+ List finalCashierCartList = cashierCartList;
ThreadUtil.execAsync(() -> {
ThreadUtil.sleep(5, TimeUnit.SECONDS);
- for (int i = 0; i < array.size(); i++) {
- JSONObject object = array.getJSONObject(i);
- TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
+ for (TbCashierCart cashierCart : finalCashierCartList) {
// 发送判断耗材是否耗尽消息
JSONObject objectMsg = new JSONObject();
objectMsg.put("skuId", Integer.valueOf(cashierCart.getSkuId()));
@@ -806,17 +1199,19 @@ public class CartService {
}
});
-
+ return Result.successWithData(orderInfo);
} catch (Exception e) {
log.info("长链接错误 createOrder{}", e.getMessage());
e.printStackTrace();
}
+
+ return Result.fail("失败");
}
private TbOrderInfo getOrder(BigDecimal totalAmount, BigDecimal packAMount,
TbShopTable shopTable, String merchantId, JSONObject jsonObject, BigDecimal originAmount) {
TbOrderInfo orderInfo = new TbOrderInfo();
- String orderNo = generateOrderNumber();
+ String orderNo = generateOrderNumber(jsonObject.getString("environment"));
orderInfo.setOrderNo(orderNo);
orderInfo.setSettlementAmount(totalAmount);
orderInfo.setPackFee(packAMount);
@@ -844,45 +1239,47 @@ public class CartService {
return orderInfo;
}
- public String generateOrderNumber() {
+ public String generateOrderNumber(String environment) {
String date = DateUtils.getSdfTimes();
Random random = new Random();
int randomNum = random.nextInt(900) + 100;
+ if ("alipay".equalsIgnoreCase(environment)) {
+ return "ALI" + date + randomNum;
+ }
return "WX" + date + randomNum;
}
public void clearCart(JSONObject jsonObject) {
try {
String shopId = jsonObject.getString("shopId");
-
-// List skuIds=new ArrayList<>();
-// if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
-// JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
-// if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
-// for (int i = 0; i < array.size(); i++) {
-// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(array.get(i).toString(), TbCashierCart.class);
-// redisUtil.secAdd(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), cashierCart.getNumber().toString());
-// productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber());
-// skuIds.add(cashierCart.getSkuId());
-
-// }
-// }
+ String tableId = jsonObject.getString("tableId");
+ Integer userId = TokenUtil.getUserId();
+ if (StrUtil.isNotBlank(tableId)) {
+ cashierCartMapper.updateStatusByOrderIdForMini(jsonObject.getString("tableId"), "closed");
+ } else {
+ mpCashierCartMapper.update(null, new LambdaUpdateWrapper()
+ .eq(TbCashierCart::getShopId, shopId)
+ .and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
+ .eq(TbCashierCart::getUserId, userId)
+// .ne(TbCashierCart::getProductId, "-999")
+ .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
+ .set(TbCashierCart::getStatus, "closed"));
+ }
+ String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
+// String message = redisUtil.getMessage(tableCartKey);
+// if (StrUtil.isNotBlank(message)) {
+// JSONArray jsonArray = JSONObject.parseArray(message);
+// List