Accept Merge Request #258: (test -> dev)

Merge Request: 创建预发布环境

Created By: @谭凯凯
Accepted By: @谭凯凯
URL: https://g-cphe0354.coding.net/p/shouyinjixitong/d/wx-cashier-service/git/merge/258?initial=true
This commit is contained in:
谭凯凯
2024-10-21 17:36:47 +08:00
committed by Coding
92 changed files with 4415 additions and 1469 deletions

41
pom.xml
View File

@@ -20,11 +20,23 @@
</properties>
<dependencies>
<!--Spring boot 测试-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId >pinyin4j</artifactId>
<version >2.5.1</version >
</dependency>
<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>3.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@@ -102,6 +114,22 @@
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
@@ -203,6 +231,12 @@
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<!-- 支付宝服务端通用SDK -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.39.165.ALL</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
@@ -214,6 +248,11 @@
<artifactId>weixin-java-miniapp</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -273,4 +312,4 @@
</plugins>
</build>
</project>
</project>

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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)){

View File

@@ -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;
}
}

View File

@@ -0,0 +1,6 @@
package com.chaozhanggui.system.cashierservice.constant;
public interface TableConstant {
String CART_SEAT_ID = "-999";
}

View File

@@ -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<String, String> 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}$");

View File

@@ -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<String, String> map) {
@RequestMapping("/auth/custom/login")
public Result authCustomLogin(HttpServletRequest request, @RequestBody Map<String, String> 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<String, String> map) {
public Result getPhoneNumber(@RequestHeader String openId, @RequestBody Map<String, String> 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<String, Object> map){
public Result resetPwd(@RequestHeader String token, @RequestBody Map<String, Object> 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<String, Object> map){
public Result mpdifyPwd(@RequestHeader String token, @RequestBody Map<String, Object> map) {
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
return loginService.modifyPwd(userId,map);
return loginService.modifyPwd(userId, map);
}

View File

@@ -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<String, Integer> 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));
}
}
}

View File

@@ -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){

View File

@@ -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");
}

View File

@@ -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<TbCashierCart> cashierCartList = cartService.choseEatModel(choseEatModelDTO);
BigDecimal amount = BigDecimal.ZERO;
ArrayList<TbCashierCart> cashierCarts = new ArrayList<>();
for (TbCashierCart item : cashierCartList) {
if (!TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
cashierCarts.add(item);
}
amount = amount.add(item.getTotalAmount());
}
HashMap<String, Object> 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);

View File

@@ -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));
}
}

View File

@@ -37,6 +37,9 @@ public interface TbActivateInRecordMapper {
int queryByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
List<TbActivateInRecord> queryAllByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
int countCouponNum(@Param("userId") Integer userId);
/**
* 新增数据
*

View File

@@ -56,5 +56,6 @@ public interface TbCashierCartMapper {
List<TbCashierCart> 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);
}
}

View File

@@ -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<TbShopUser> selectAllByUserId(@Param("userId") String userId);
List<TbShopUser> selectVipByUserId(@Param("userId") Integer userId);
BigDecimal countAmount(@Param("userId") Integer userId);
List<ShopUserListVo> selectByUserId(@Param("userId") String userId, @Param("shopId") String shopId);

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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 "";
}
}
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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<TbOrderDetail> 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) {

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
@Data
public class CallNumPrintDTO {
private Integer callQueueId;
private Integer shopId;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -37,4 +37,9 @@ public class OrderVo {
private String outNumber;
private String useType;
private Integer shopId;
private String qrcode;
}

View File

@@ -14,7 +14,9 @@ public class UserCouponVo {
* 卷描述
*/
private String detail;
private String shopId;
private String shopName;
private String orderId;
/**
* 优惠金额
*/

View File

@@ -14,7 +14,11 @@ import java.util.List;
@WebFilter(urlPatterns = {"/cashierService/*"},filterName = "customFilter")
public class CustomFilter implements Filter {
private static final List<String> unFilterUrlList= Arrays.asList("/cashierService/notify/notifyCallBack","/cashierService/notify/memberInCallBack");
private static final List<String> unFilterUrlList =
Arrays.asList(
"/cashierService/notify/notifyCallBack",
"/cashierService/notify/memberInCallBack"
);
private boolean isfilter(String url){

View File

@@ -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<TbCashierCart> {
}

View File

@@ -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<TbOrderDetail> {
}

View File

@@ -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<TbOrderInfo> {
}

View File

@@ -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<TbShopInfo> {
}

View File

@@ -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<TbShopTable> {
}

View File

@@ -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<TbCallQueue> {
List<CallQueueInfoVO> selectInfoByOpenId(Integer shopId, String openId, String today, Integer queueId);
}

View File

@@ -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<TbCallTable> {
}

View File

@@ -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<String, ConcurrentHashMap<String, ChannelHandlerContext>> 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<String, ChannelHandlerContext> 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<String, ChannelHandlerContext> userSocketMap = webSocketMap.get(key);
if (webSocketMap.containsKey(tableCartKey)) {
ConcurrentHashMap<String, ChannelHandlerContext> 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<String, ChannelHandlerContext> 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<String, ChannelHandlerContext> webSockets = webSocketMap.get(tableId);
if (webSocketMap.containsKey(redisKey)) {
ConcurrentHashMap<String, ChannelHandlerContext> 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<String, ChannelHandlerContext> value : webSocketMap.values()) {
for (ChannelHandlerContext ctx : value.values()) {
sendMesToApp(message,ctx);
}
}
} else if (webSocketMap.containsKey(tableId)) {
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(tableId);
} else if (webSocketMap.containsKey(redisKey)) {
ConcurrentHashMap<String, ChannelHandlerContext> 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);
}
}
}
}
}
}

View File

@@ -160,6 +160,19 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte
});
}
@Async
public void AppSendInfo(String message, String shopId) {
log.info("长链接发送交班数据。");
ConcurrentHashMap<String, ChannelHandlerContext> 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);

View File

@@ -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);

View File

@@ -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<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
String autoCut = config.getString("autoCut");
List<CategoryInfo> 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<CategoryInfo> categoryInfos) {
List<TbCashierCart> 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<CategoryInfo> categoryInfos) {
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> 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<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
break;
case "cash": //小票打印机
switch (model) {
case "normal": //普通出单
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> 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<CategoryInfo> categoryInfos) {
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> 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<CategoryInfo> 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<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> 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<CategoryInfo> categoryInfos) {
List<TbCashierCart> 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<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
List<TbCashierCart> 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<it.getNumber();i++){
for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
}
@@ -393,138 +532,15 @@ public class PrintMechineConsumer {
break;
case "cash": //小票打印机
switch (model) {
case "normal": //普通出单
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> 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<OrderDetailPO.Detail> 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;
}

View File

@@ -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";
}

View File

@@ -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);
}
}

View File

@@ -2,7 +2,7 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
@@ -46,9 +46,7 @@ public class CloudPrinterService {
private TbOrderDetailMapper tbOrderDetailMapper;
public Result printReceipt(String type,String orderId,Boolean ispre){
public Result printReceipt(String type, String orderId, Boolean ispre) {
try {
@@ -71,7 +69,7 @@ public class CloudPrinterService {
return Result.fail("此店铺没有对应的打印机设备");
}
list.parallelStream().forEach(tbPrintMachineWithBLOBs->{
list.parallelStream().forEach(tbPrintMachineWithBLOBs -> {
if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) {
log.error("非网络打印机");
return;
@@ -82,29 +80,25 @@ public class CloudPrinterService {
return;
}
JSONObject config = JSONObject.parseObject(tbPrintMachineWithBLOBs.getConfig());
String model = config.getString("model");
String printerNum = config.getString("printerNum");
String model = tbPrintMachineWithBLOBs.getPrintMethod();
String feet = config.getString("feet");
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1];
String autoCut = config.getString("autoCut");
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
List<CategoryInfo> 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;
}
});
return Result.success(CodeEnum.SUCCESS);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
@@ -112,145 +106,285 @@ public class CloudPrinterService {
}
/**
* 仅打印结算单「前台」
*/
private void onlyFrontDeskForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> 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());
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
}
/**
* 仅打印制作单「厨房」
*/
private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
List<TbCashierCart> 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();
}
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);
}
});
}
}
/**
* 博时结云打印机
* 博时结云打印机
*
* @param tbPrintMachineWithBLOBs
* @param model
* @param orderInfo
* @param shopInfo
* @param printerNum
*/
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
break;
case "cash": //小票打印机
switch (model) {
case "normal": //普通出单
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> 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());
String data= PrinterUtils.getCashPrintData(detailPO,"结算单");
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
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();
}
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, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
} else if ("one".equals(model)) {
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
} else if ("all".equals(model)) {
onlyFrontDeskForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
}
break;
case "kitchen": //出品打印机
break;
}
}
/**
* 仅打印结算单「前台」
*/
private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> 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<CategoryInfo> 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<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> 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<CategoryInfo> categoryInfos) {
List<TbCashierCart> 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<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
List<TbCashierCart> 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<it.getNumber();i++){
for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
}
@@ -260,136 +394,13 @@ public class CloudPrinterService {
break;
case "cash": //小票打印机
switch (model) {
case "normal": //普通出单
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> 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<OrderDetailPO.Detail> 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;
case "kitchen": //出品打印机
@@ -398,6 +409,4 @@ public class CloudPrinterService {
}
}

View File

@@ -1,14 +1,14 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.entity.TbShopOpenId;
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
import com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;
@Service
@@ -37,6 +38,9 @@ public class LoginService {
@Autowired
private TbShopUserMapper tbShopUserMapper;
@Autowired
private TbActivateInRecordMapper inRecordMapper;
@Autowired
private TbShopTableMapper tbShopTableMapper;
@@ -141,34 +145,72 @@ public class LoginService {
}
private void buildNewUserInfo(TbUserInfo userInfo) {
userInfo = new TbUserInfo();
userInfo.setAmount(BigDecimal.ZERO);
userInfo.setChargeAmount(BigDecimal.ZERO);
userInfo.setLineOfCredit(BigDecimal.ZERO);
userInfo.setConsumeNumber(0);
userInfo.setConsumeAmount(BigDecimal.ZERO);
userInfo.setTotalScore(0);
userInfo.setLockScore(0);
userInfo.setHeadImg("");
userInfo.setNickName("");
userInfo.setTelephone("");
userInfo.setStatus(Byte.parseByte("1"));
userInfo.setParentType("PERSON");
userInfo.setIsResource(Byte.parseByte("0"));
userInfo.setIsOnline(Byte.parseByte("0"));
userInfo.setIsVip(Byte.parseByte("0"));
userInfo.setIsAttentionMp(Byte.parseByte("0"));
userInfo.setIsPwd("0");
userInfo.setPwd(MD5Utils.md5("123456"));
userInfo.setCreatedAt(System.currentTimeMillis());
userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setUpdatedAt(System.currentTimeMillis());
}
public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) {
TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId);
if (ObjectUtil.isNull(userInfo)) {
userInfo = new TbUserInfo();
userInfo.setAmount(BigDecimal.ZERO);
userInfo.setChargeAmount(BigDecimal.ZERO);
userInfo.setLineOfCredit(BigDecimal.ZERO);
userInfo.setConsumeNumber(0);
userInfo.setConsumeAmount(BigDecimal.ZERO);
userInfo.setTotalScore(0);
userInfo.setLockScore(0);
buildNewUserInfo(userInfo);
userInfo.setHeadImg(ObjectUtil.isNotNull(headImage) ? headImage : "");
userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户");
userInfo.setTelephone(ObjectUtil.isNotNull(telephone) ? telephone : "");
userInfo.setMiniAppOpenId(openId);
userInfo.setStatus(Byte.parseByte("1"));
userInfo.setParentType("PERSON");
userInfo.setIsResource(Byte.parseByte("0"));
userInfo.setIsOnline(Byte.parseByte("0"));
userInfo.setIsVip(Byte.parseByte("0"));
userInfo.setSourcePath("WECHAT-APP");
userInfo.setIsAttentionMp(Byte.parseByte("0"));
userInfo.setSearchWord("||微信用户");
userInfo.setIsPwd("0");
userInfo.setPwd(MD5Utils.md5("123456"));
userInfo.setCreatedAt(System.currentTimeMillis());
userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setMiniAppOpenId(openId);
tbUserInfoMapper.insert(userInfo);
} else {
userInfo.setUpdatedAt(System.currentTimeMillis());
userInfo.setLastLogInAt(System.currentTimeMillis());
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
}
//生成token 信息
String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName());
Map<String, Object> map = new HashMap<>();
map.put("token", token);
map.put("userInfo", userInfo);
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(openId), JSON.toJSONString(map), 60 * 60 * 24 * 30L);
log.info("登录传参 结果:" + JSONUtil.toJSONString(map));
return Result.success(CodeEnum.SUCCESS, map);
}
/**
* 支付宝用户登录
* @param openId
* @return
*/
public Result alipayCustomLogin(String openId) {
TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId);
if (ObjectUtil.isNull(userInfo)) {
userInfo = new TbUserInfo();
buildNewUserInfo(userInfo);
userInfo.setNickName("支付宝用户");
userInfo.setSourcePath("ALIPAY-APP");
userInfo.setSearchWord("||支付宝用户");
userInfo.setMiniAppOpenId(openId);
tbUserInfoMapper.insert(userInfo);
} else {
userInfo.setUpdatedAt(System.currentTimeMillis());
@@ -460,6 +502,9 @@ public class LoginService {
if (tbUserInfo == null) {
return Result.success(CodeEnum.ENCRYPT, new ArrayList());
}
tbUserInfo.setBalanceAll(tbShopUserMapper.countAmount(userId));
tbUserInfo.setCouponAll(inRecordMapper.countCouponNum(userId));
return Result.success(CodeEnum.ENCRYPT, tbUserInfo);
}
@@ -477,6 +522,7 @@ public class LoginService {
TbShopUser tbShopUserSM = tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(), shopId);
if (tbShopUserSM != null) {
tbShopUserSM.setIsVip(Byte.parseByte("1"));
tbShopUserSM.setJoinTime(new Timestamp(System.currentTimeMillis()));
tbShopUserSM.setTelephone(phone);
tbShopUserSM.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUserSM);
@@ -499,6 +545,7 @@ public class LoginService {
shopUser.setTelephone(userInfo.getTelephone());
shopUser.setAmount(BigDecimal.ZERO);
shopUser.setIsVip(Byte.parseByte("1"));
shopUser.setJoinTime(new Timestamp(System.currentTimeMillis()));
shopUser.setCreditAmount(BigDecimal.ZERO);
shopUser.setConsumeAmount(BigDecimal.ZERO);
shopUser.setConsumeNumber(0);

View File

@@ -1,11 +1,21 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.OrderVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpShopInfoMapper;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
@@ -25,11 +35,10 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* @author 12847
@@ -78,6 +87,15 @@ public class OrderService {
@Autowired
private TbOrderInfoMapper tbOrderInfoMapper;
@Autowired
private MpCashierCartMapper mpCashierCartMapper;
@Autowired
private MpOrderDetailMapper mpOrderDetailMapper;
@Autowired
private MpOrderInfoMapper mpOrderInfoMapper;
@Autowired
private MpShopInfoMapper mpShopInfoMapper;
/**
* 创建订单
*
@@ -208,6 +226,8 @@ public class OrderService {
orderVo.setOrderId(orderInfo.getId());
orderVo.setSendType(orderInfo.getSendType());
orderVo.setOutNumber(orderInfo.getOutNumber());
orderVo.setUseType(orderInfo.getUseType());
orderVo.setShopId(Integer.valueOf(orderInfo.getShopId()));
return Result.success(CodeEnum.ENCRYPT, orderVo);
}
@@ -233,7 +253,9 @@ public class OrderService {
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
shopName = tbShopInfo.getShopName();
orderInfo.setDescription(shopName);
List<TbOrderDetail> list = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
List<TbOrderDetail> list = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.ne(TbOrderDetail::getProductId, TableConstant.CART_SEAT_ID));
int num = 0;
for (TbOrderDetail orderDetail : list) {
num = num + orderDetail.getNum();
@@ -432,4 +454,88 @@ public class OrderService {
}
return Result.success(CodeEnum.SUCCESS);
}
public Object orderDetail(Integer orderId) {
TbOrderInfo orderInfo = mpOrderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getId, orderId));
if (orderInfo == null) {
return Result.fail("订单不存在");
}
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
if (tbShopInfo == null) {
return Result.fail("店铺不存在");
}
LambdaQueryWrapper<TbOrderDetail> queryWrapper = new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getShopId, orderInfo.getShopId())
.ne(TbOrderDetail::getProductId, TableConstant.CART_SEAT_ID)
.eq(TbOrderDetail::getOrderId, orderId);
List<TbOrderDetail> list = mpOrderDetailMapper.selectList(queryWrapper);
AtomicReference<TbOrderDetail> mealCashierCart = new AtomicReference<>();
list.forEach(item -> {
item.setPlaceNum(item.getPlaceNum() == null ? 0 : item.getPlaceNum());
if (item.getProductId() == -999) {
mealCashierCart.set(item);
}
});
// 根据placeNum进行分组
Map<Integer, List<TbOrderDetail>> groupedByPlaceNum = list.stream()
.collect(Collectors.groupingBy(TbOrderDetail::getPlaceNum));
ArrayList<HashMap<String, Object>> dataList = new ArrayList<>();
groupedByPlaceNum.forEach((k, v) -> {
HashMap<String, Object> item = new HashMap<>();
item.put("placeNum", k);
item.put("placeTime", v.isEmpty() ? null : DateUtil.format(v.get(0).getCreateTime(), "HH:mm:ss"));
BigDecimal totalPrice = BigDecimal.ZERO;
for (TbOrderDetail d : v) {
totalPrice = totalPrice.add(d.getPriceAmount());
}
item.put("info", v);
item.put("totalAmount", totalPrice);
dataList.add(item);
});
TbShopTable tbShopTable = shopTableMapper.selectQRcode(orderInfo.getTableId());
OrderVo orderVo = new OrderVo();
orderVo.setName(tbShopInfo.getShopName());
orderVo.setStatus(orderInfo.getStatus());
//TODO 增加商家二维码
orderVo.setShopQrcode(tbShopInfo.getShopQrcode());
orderVo.setDetails(list);
orderVo.setOrderNo(orderInfo.getOrderNo());
orderVo.setTime(orderInfo.getCreatedAt());
if (orderInfo.getStatus().equals("paying") || orderInfo.getStatus().equals("unpaid")) {
long totalSeconds = orderInfo.getCreatedAt() + 15 * 60 * 1000l - System.currentTimeMillis();
if(totalSeconds>0){
orderVo.setExpiredMinutes(totalSeconds/1000 / 60);
orderVo.setExpiredSeconds(totalSeconds/1000 % 60);
}
}
orderVo.setPayAmount(orderInfo.getOrderAmount());
orderVo.setTableName(tbShopTable == null ? "" : tbShopTable.getName());
orderVo.setOrderType(orderInfo.getOrderType());
orderVo.setOrderId(orderInfo.getId());
orderVo.setSendType(orderInfo.getSendType());
orderVo.setOutNumber(orderInfo.getOutNumber());
orderVo.setUseType(orderInfo.getUseType());
orderVo.setShopId(Integer.valueOf(orderInfo.getShopId()));
TbShopInfo shopInfo = mpShopInfoMapper.selectById(orderInfo.getShopId());
orderVo.setQrcode(shopInfo == null ? null : shopInfo.getShopQrcode());
Map<String, Object> map = new HashMap<>();
// 餐位费
map.put("seatFee", mealCashierCart);
map.put("detailList", dataList);
map.put("orderInfo", orderInfo);
map.putAll(BeanUtil.beanToMap(orderVo, false, false));
map.put("createdAt", DateUtil.formatDateTime(DateUtil.date(orderInfo.getCreatedAt())));
map.put("paidTime", orderInfo.getPaidTime() == null ? null : DateUtil.formatDateTime(DateUtil.date(orderInfo.getPaidTime())));
return map;
}
}

View File

@@ -2,13 +2,21 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
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.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.model.PayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter;
@@ -35,12 +43,12 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
@@ -161,14 +169,42 @@ public class PayService {
private MQUtils mQUtils;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private ShopUtils shopUtils;
@Autowired
private MpOrderDetailMapper mpOrderDetailMapper;
@Autowired
private MpOrderInfoMapper mpOrderInfoMapper;
@Autowired
private MpCashierCartMapper mpCashierCartMapper;
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
this.shopSongOrderService = shopSongOrderService;
}
@Transactional(rollbackFor = Exception.class)
public Result payOrderTest(String openId, String orderId, String payType, String ip) throws Exception {
//thirdUrl;
String appId = "66e3dd399a7621f45a6293c1";
String reqbody = "茉莉蜜茶";
BigDecimal money = new BigDecimal("0.10");
long amount = money.setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue();
payType = "ALIPAY";
String smallAppid = "2021004145625815";
openId = "2088812533865205";
ip = "1.80.208.76";
String timesSS = DateUtils.getsdfTimesSS();
String storeId = "S2409148611";
//callFSTBack
//null
String appToken = "jVQs9aBIFOj1mh2ioDp5RLiNBLcQoRnhniH9xlyc3ZKmDcwOpDargyEIYASCePtbA4hyJ5aeH841HfBA4rEKFsxl5AJjGcQa7qT28qU0SPN6v9dNzKYK1eTyvSw6mNBh";
PublicResp<WxScanPayResp> wxScanPayResp = thirdPayService.scanpay(thirdUrl, appId, reqbody, reqbody, amount, payType, smallAppid, openId, ip, timesSS, storeId, callFSTBack, null, appToken);
ObjectMapper mapper = new ObjectMapper();
return Result.success(CodeEnum.SUCCESS, mapper.readTree(wxScanPayResp.getObjData().getPayInfo()));
}
@Transactional(rollbackFor = Exception.class)
public Result payOrder(String openId, String orderId, String ip) throws Exception {
public Result payOrder(String openId, String orderId, String payType, String ip) throws Exception {
if (ObjectUtil.isEmpty(openId) || Objects.isNull(openId)) {
return Result.fail("付款用户[userId]参数不能为空");
@@ -179,7 +215,7 @@ public class PayService {
if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus())) {
return Result.fail("订单状态异常,不允许支付");
}
if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
if (!OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(orderInfo.getUseType()) && System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。");
}
@@ -187,7 +223,6 @@ public class PayService {
return Result.fail("没有对应的商户");
}
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
return Result.fail("购物车信息不存在");
@@ -198,13 +233,16 @@ public class PayService {
body.append(cashierCart.getName());
}
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail("支付通道不存在");
}
if ("aliPay".equals(payType) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) {
return Result.fail("店铺未配置支付宝小程序appId");
}
String userId = String.valueOf(TokenUtil.getUserId());
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
if (ObjectUtil.isEmpty(payment) || payment == null) {
payment = new TbOrderPayment();
@@ -212,8 +250,12 @@ public class PayService {
payment.setAmount(orderInfo.getOrderAmount());
payment.setPaidAmount(orderInfo.getPayAmount());
payment.setHasRefundAmount(BigDecimal.ZERO);
payment.setPayName("微信支付");
payment.setPayType("wechatPay");
if ("wechatPay".equals(payType)) {
payment.setPayName("微信支付");
} else if ("aliPay".equals(payType)) {
payment.setPayName("支付宝支付");
}
payment.setPayType(payType);
payment.setReceived(payment.getAmount());
payment.setChangeFee(BigDecimal.ZERO);
payment.setMemberId(orderInfo.getMemberId());
@@ -222,6 +264,12 @@ public class PayService {
payment.setCreatedAt(System.currentTimeMillis());
tbOrderPaymentMapper.insert(payment);
} else {
if (payType.equals("wechatPay")) {
payment.setPayName("微信支付");
} else if (payType.equals("aliPay")) {
payment.setPayName("支付宝支付");
}
payment.setPayType(payType);
payment.setUpdatedAt(System.currentTimeMillis());
tbOrderPaymentMapper.updateByPrimaryKey(payment);
}
@@ -253,12 +301,11 @@ public class PayService {
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
orderInfo.setStatus("paying");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setUserId(userId);
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
String key = RedisCst.TABLE_CART.concat(orderInfo.getTableId()).concat("-").concat(orderInfo.getShopId());
//清除缓存购物车数据
redisUtil.deleteByKey(key);
redisUtil.deleteByKey(RedisCst.getTableCartKey(orderInfo.getTableId(), orderInfo.getTableId(), orderInfo.getUserId()));
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
jsonObject1.put("msg", "成功");
@@ -281,10 +328,27 @@ public class PayService {
reqbody = body.toString();
}
PublicResp<WxScanPayResp> publicResp = thirdPayService.scanpay(thirdUrl, thirdApply.getAppId(),
reqbody, reqbody,
String smallAppid = thirdApply.getSmallAppid();
String appId = thirdApply.getAppId();
String appToken = thirdApply.getAppToken();
if ("aliPay".equals(payType)){
smallAppid = thirdApply.getAlipaySmallAppid();
}
String convertPayType = "aliPay".equals(payType) ? "ALIPAY" : "WECHAT";
PublicResp<WxScanPayResp> publicResp = thirdPayService.scanpay(thirdUrl,
appId,
reqbody,
reqbody,
payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),
"WECHAT", thirdApply.getSmallAppid(), openId, ip, DateUtils.getsdfTimesSS(), thirdApply.getStoreId(), callFSTBack, null, thirdApply.getAppToken());
convertPayType,
smallAppid,
openId,
ip,
DateUtils.getsdfTimesSS(),
thirdApply.getStoreId(),
callFSTBack,
null,
appToken);
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
WxScanPayResp wxScanPayResp = publicResp.getObjData();
@@ -294,12 +358,11 @@ public class PayService {
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
orderInfo.setStatus("paying");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setUserId(userId);
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
String key = RedisCst.TABLE_CART.concat(orderInfo.getTableId()).concat("-").concat(orderInfo.getShopId());
//清除缓存购物车数据
redisUtil.deleteByKey(key);
redisUtil.deleteByKey(RedisCst.getTableCartKey(orderInfo.getShopId(), orderInfo.getTableId(), orderInfo.getUserId()));
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
jsonObject1.put("msg", "成功");
@@ -334,11 +397,10 @@ public class PayService {
return Result.fail("订单信息不存在");
}
if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
if (!OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(orderInfo.getUseType()) && System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) {
return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。");
}
TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
if (ObjectUtil.isEmpty(userInfo)) {
return Result.fail("未获取到用户信息");
@@ -398,16 +460,22 @@ public class PayService {
orderInfo.setMemberId(memberId);
orderInfo.setPayType("deposit");
orderInfo.setStatus("closed");
orderInfo.setPaidTime(System.currentTimeMillis());
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateStatusByOrderId(orderId, "final");
int cartCount = mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getOrderId, orderId)
.eq(TbCashierCart::getUseType, orderInfo.getUseType())
.in(TbCashierCart::getStatus, "create", "closed")
.set(TbCashierCart::getStatus, "final"));
mpOrderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>().eq(TbOrderDetail::getId, orderId)
.eq(TbOrderDetail::getUseType, orderInfo.getUseType())
.eq(TbOrderDetail::getStatus, "unpaid")
.set(TbOrderDetail::getStatus, "closed"));
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(),"closed");
outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(), "closed");
log.info("更新购物车:{}", cartCount);
JSONObject jsonObject = new JSONObject();
@@ -417,7 +485,16 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(orderId);
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId());
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getStatus, "closed"));
// 打印消息
if (!shopEatTypeInfoDTO.isDineInAfter()) {
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
}
mQUtils.printPlaceTicket(orderInfo.getId(), false);
// producer.printMechine(orderId);
sendOrderToClient(orderInfo);
// 发送mq消息并保存库存记录
@@ -427,13 +504,13 @@ public class PayService {
mQUtils.sendStockSaleMsg(data);
JSONObject baObj=new JSONObject();
baObj.put("userId",userInfo.getId());
baObj.put("shopId",user.getShopId());
baObj.put("amount",orderInfo.getOrderAmount());
baObj.put("balance",user.getAmount());
baObj.put("type","消费");
baObj.put("time",flow.getCreateTime());
JSONObject baObj = new JSONObject();
baObj.put("userId", userInfo.getId());
baObj.put("shopId", user.getShopId());
baObj.put("amount", orderInfo.getOrderAmount());
baObj.put("balance", user.getAmount());
baObj.put("type", "消费");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
// 为代客下单清楚当前台桌最新订单
@@ -528,6 +605,11 @@ public class PayService {
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail("支付通道不存在");
}
if ("aliPay".equals(payType) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) {
return Result.fail("店铺未配置支付宝小程序appId");
}
StringBuffer body = new StringBuffer();
body.append(orderInfo.getProName());
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderInfo.getOrderNo());
@@ -605,14 +687,21 @@ public class PayService {
} else {
reqbody = body.toString();
}
String smallAppid = thirdApply.getSmallAppid();
String appId = thirdApply.getAppId();
String appToken = thirdApply.getAppToken();
if ("aliPay".equals(payType)){
smallAppid = thirdApply.getAlipaySmallAppid();
}
String convertPayType = "aliPay".equals(payType) ? "ALIPAY" : "WECHAT";
PublicResp<WxScanPayResp> publicResp = thirdPayService.scanpay(
thirdUrl,
thirdApply.getAppId(),
appId,
reqbody,
reqbody,
payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),
"WECHAT",
thirdApply.getSmallAppid(),
convertPayType,
smallAppid,
userId,
ip,
// orderInfo.getOrderNo(),
@@ -620,7 +709,7 @@ public class PayService {
thirdApply.getStoreId(),
callBackGroupurl,
null,
thirdApply.getAppToken());
appToken);
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
WxScanPayResp wxScanPayResp = publicResp.getObjData();
@@ -705,6 +794,8 @@ public class PayService {
orderInfo.setPayType("wx_lite");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPaidTime(System.currentTimeMillis());
orderInfo.setUserId(String.valueOf(TokenUtil.getUserId()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
@@ -717,7 +808,16 @@ public class PayService {
log.info("发送打印数据");
producer.printMechine(orderInfo.getId() + "");
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId());
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getStatus, "closed"));
// 打印消息
if (!shopEatTypeInfoDTO.isDineInAfter()) {
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
}
mQUtils.printPlaceTicket(orderInfo.getId(), false);
// producer.printMechine(orderInfo.getId() + "");
return Result.success(CodeEnum.SUCCESS, orderId);
case "2": //退款成功
@@ -738,7 +838,8 @@ public class PayService {
}
}
} else {
PublicResp<OrderStatusQueryResp> publicResp = thirdPayService.queryOrder(thirdUrl, thirdApply.getAppId(), payment.getTradeNumber(), null, thirdApply.getAppToken());
PublicResp<OrderStatusQueryResp> publicResp = thirdPayService.queryOrder(thirdUrl, thirdApply.getAppId(),
payment.getTradeNumber(), null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
String cartStatus = "";
@@ -757,6 +858,8 @@ public class PayService {
orderInfo.setPayType("wx_lite");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPaidTime(System.currentTimeMillis());
orderInfo.setUserId(String.valueOf(TokenUtil.getUserId()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
@@ -769,7 +872,16 @@ public class PayService {
log.info("发送打印数据");
producer.printMechine(orderInfo.getId() + "");
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId());
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getStatus, "closed"));
// 打印消息
if (!shopEatTypeInfoDTO.isDineInAfter()) {
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
}
mQUtils.printPlaceTicket(orderInfo.getId(), false);
// producer.printMechine(orderInfo.getId() + "");
sendOrderToClient(orderInfo);
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
return Result.success(CodeEnum.SUCCESS, orderId);
@@ -901,12 +1013,13 @@ public class PayService {
//更新子单状态
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(orderInfo.getId(), "closed");
outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(),"closed");
outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(), "closed");
//修改主单状态
orderInfo.setStatus("closed");
orderInfo.setPayType("wx_lite");
orderInfo.setPayOrderNo(payOrderNO);
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPaidTime(System.currentTimeMillis());
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
@@ -918,7 +1031,16 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
log.info("发送打印数据");
producer.printMechine(orderInfo.getId() + "");
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId());
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getStatus, "closed"));
// 打印消息
if (!shopEatTypeInfoDTO.isDineInAfter()) {
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
}
mQUtils.printPlaceTicket(orderInfo.getId(), false);
// producer.printMechine(orderInfo.getId() + "");
sendOrderToClient(orderInfo);
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
@@ -942,27 +1064,41 @@ public class PayService {
@Transactional(rollbackFor = Exception.class)
public String callBackPayFST(String payOrderNO) {
public String callBackPayFST(String payOrderNO,String payType) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPayOrderNo(payOrderNO);
if (ObjectUtil.isEmpty(orderInfo)) {
return "订单信息不存在";
}
if ("paying".equals(orderInfo.getStatus())) {
int cartCount = tbCashierCartMapper.updateStatusByOrderId(orderInfo.getId().toString(), "final");
int cartCount = mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getOrderId, orderInfo.getId())
.eq(TbCashierCart::getUseType, orderInfo.getUseType())
.in(TbCashierCart::getStatus, "create", "closed")
.set(TbCashierCart::getStatus, "final"));
log.info("更新购物车:{}", cartCount);
//更新子单状态
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(orderInfo.getId(), "closed");
mpOrderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>().eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getUseType, orderInfo.getUseType())
.in(TbOrderDetail::getStatus, "unpaid")
.set(TbOrderDetail::getStatus, "closed"));
//修改主单状态
orderInfo.setStatus("closed");
orderInfo.setPayType("wx_lite");
if("alipay".equalsIgnoreCase(payType)){
orderInfo.setPayType("ali_lite");
}else if("wechat".equalsIgnoreCase(payType)){
orderInfo.setPayType("wx_lite");
}
orderInfo.setPayOrderNo(payOrderNO);
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPaidTime(System.currentTimeMillis());
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(),"closed");
outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(), "closed");
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", 0);
@@ -972,7 +1108,16 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
log.info("发送打印数据");
producer.printMechine(orderInfo.getId() + "");
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId());
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getStatus, "closed"));
// 打印消息
if (!shopEatTypeInfoDTO.isDineInAfter()) {
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
}
mQUtils.printPlaceTicket(orderInfo.getId(), false);
// producer.printMechine(orderInfo.getId() + "");
JSONObject coupons = new JSONObject();
coupons.put("type", "buy");
coupons.put("orderId", orderInfo.getId().toString());
@@ -1114,6 +1259,7 @@ public class PayService {
if (!"1".equals(tbShopUser.getIsVip().toString())) {
tbShopUser.setIsVip(Byte.parseByte("1"));
tbShopUser.setJoinTime(new Timestamp(System.currentTimeMillis()));
}
//修改客户资金
@@ -1133,7 +1279,7 @@ public class PayService {
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
//会员活动
giveActivate(tbShopUser,memberIn.getAmount(),flow.getId());
giveActivate(tbShopUser, memberIn.getAmount(), flow.getId());
JSONObject jsonObject = new JSONObject();
jsonObject.put("shopId", memberIn.getShopId());
@@ -1143,14 +1289,14 @@ public class PayService {
return "success";
}
public BigDecimal giveActivate(TbShopUser tbShopUser, BigDecimal memAmount,Integer flowId){
public BigDecimal giveActivate(TbShopUser tbShopUser, BigDecimal memAmount, Integer flowId) {
TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memAmount);
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1) {
List<TbActivateProduct> tbActivateProducts = actProductMapper.queryAllByActivateId(activate.getId());
List<TbActivateInRecord> actGiveRecords = new ArrayList<>();
for (TbActivateProduct actPro : tbActivateProducts) {
TbActivateInRecord record = new TbActivateInRecord(Integer.valueOf(tbShopUser.getId()), actPro.getProductId(), actPro.getNum(), Integer.valueOf(tbShopUser.getShopId()), activate.getId(),flowId);
TbActivateInRecord record = new TbActivateInRecord(Integer.valueOf(tbShopUser.getId()), actPro.getProductId(), actPro.getNum(), Integer.valueOf(tbShopUser.getShopId()), activate.getId(), flowId);
actGiveRecords.add(record);
}
activateInRecordMapper.insertBatch(actGiveRecords);
@@ -1212,6 +1358,7 @@ public class PayService {
tbShopUser.setTelephone(userInfo.getTelephone());
tbShopUser.setCode(RandomUtil.randomNumbers(8));
tbShopUser.setIsVip(Byte.parseByte("1"));
tbShopUser.setJoinTime(new Timestamp(System.currentTimeMillis()));
}
//修改客户资金
@@ -1232,7 +1379,7 @@ public class PayService {
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
//会员活动
BigDecimal awardAmount= giveActivate(tbShopUser,memberIn.getAmount(),flow.getId());
BigDecimal awardAmount = giveActivate(tbShopUser, memberIn.getAmount(), flow.getId());
JSONObject jsonObject = new JSONObject();
jsonObject.put("shopId", memberIn.getShopId());
jsonObject.put("type", "wxMemberIn");
@@ -1240,14 +1387,13 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
JSONObject baObj=new JSONObject();
JSONObject baObj = new JSONObject();
baObj.put("userId", tbShopUser.getUserId());
baObj.put("shopId",tbShopUser.getShopId());
baObj.put("amount",ObjectUtil.isNull(awardAmount)?memberIn.getAmount():memberIn.getAmount().add(awardAmount));
baObj.put("balance",tbShopUser.getAmount());
baObj.put("type","充值");
baObj.put("time",flow.getCreateTime());
baObj.put("shopId", tbShopUser.getShopId());
baObj.put("amount", ObjectUtil.isNull(awardAmount) ? memberIn.getAmount() : memberIn.getAmount().add(awardAmount));
baObj.put("balance", tbShopUser.getAmount());
baObj.put("type", "充值");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
return "SUCCESS";
@@ -1282,7 +1428,6 @@ public class PayService {
}
public Result paySongOrder(String openId, String shopId, Integer orderId, String ip, TbMerchantThirdApply thirdApply) throws JsonProcessingException {
if (ObjectUtil.isEmpty(openId) || Objects.isNull(openId)) {
return Result.fail("付款用户[openId]参数不能为空");
@@ -1352,6 +1497,26 @@ public class PayService {
}
/**
* 重新激活支付中的订单
*
* @param tradeNo
* @return
*/
public int activateOrder(String tradeNo) {
return mpOrderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getOrderNo, tradeNo)
.eq(TbOrderInfo::getStatus, "paying")
.set(TbOrderInfo::getStatus, "unpaid"));
}
public int cancelOrder(Integer orderId) {
return mpOrderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getId, orderId)
.eq(TbOrderInfo::getStatus, "paying")
.set(TbOrderInfo::getStatus, "unpaid"));
}
// public Result returnOrder(){
//

View File

@@ -1,17 +1,29 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
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.dto.HomeDto;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopInfoEatModelEnum;
import com.chaozhanggui.system.cashierservice.entity.dto.*;
import com.chaozhanggui.system.cashierservice.entity.vo.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper;
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.*;
@@ -22,6 +34,7 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -83,25 +96,77 @@ public class ProductService {
@Resource
private TbActivateInRecordService activateInRecordService;
public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng) {
if (StringUtils.isBlank(code)) return Result.fail("桌码信息为空");
private final ShopUtils shopUtils;
@Autowired
private MpShopTableMapper mpShopTableMapper;
@Autowired
private MpCashierCartMapper mpCashierCartMapper;
@Autowired
private MpOrderInfoMapper mpOrderInfoMapper;
@Autowired
private RedisUtil redisUtil;
@Autowired
private StringRedisTemplate stringRedisTemplate;
public ProductService(ShopUtils shopUtils) {
this.shopUtils = shopUtils;
}
private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO, String tableId, Object shopId) {
// 获取当前台桌最新订单,先付款模式不获取
if (eatTypeInfoDTO.isDineInBefore()) {
return null;
}
List<TbOrderInfo> orderInfoList = mpOrderInfoMapper.selectPage(new Page<>(1, 1), new LambdaQueryWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getStatus, "unpaid")
.eq(TbOrderInfo::getUseType, eatTypeInfoDTO.getUseType())
.eq(TbOrderInfo::getShopId, shopId)
.gt(TbOrderInfo::getCreatedAt, DateUtil.date().getTime() - 1000 * 60 * 60 * 24)
.eq(TbOrderInfo::getTableId, tableId)
.orderByDesc(TbOrderInfo::getId)).getRecords();
return orderInfoList.isEmpty() ? null : orderInfoList.get(0);
}
public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng, Integer shopId) {
if (StringUtils.isBlank(lat) || lat.equals("undefined")) {
lat = "34.343207";
lng = "108.939645";
}
TbShopTable tbShopTable = tbShopTableMapper.selectQRcode(code);
if (tbShopTable == null) {
return Result.fail("台桌信息不存在");
TbShopTable tbShopTable = null;
if (StrUtil.isNotBlank(code)) {
tbShopTable = tbShopTableMapper.selectQRcode(code);
if (tbShopTable == null) {
return Result.fail("台桌信息不存在");
}
}
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopTable.getShopId());
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId != null ? shopId : tbShopTable.getShopId());
String distance = LocationUtils.getDistanceString(
Double.parseDouble(lng), Double.parseDouble(lat),
Double.parseDouble(shopInfo.getLng()), Double.parseDouble(shopInfo.getLat()));
ConcurrentMap<String, Object> concurrentMap = new ConcurrentHashMap<>();
concurrentMap.put("shopTableInfo", tbShopTable);
// 获取当前台桌最新订单id
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.getEatModel(code, shopInfo.getId());
if (tbShopTable != null) {
if (shopEatTypeInfoDTO.isOpenDineIn()) {
TbOrderInfo order = getCurrentOrder(shopEatTypeInfoDTO, code, shopInfo.getId());
tbShopTable.setOrderId(order == null ? null : order.getId());
TbCashierCart seatCartInfo = getSeatCartInfo(tbShopTable.getShopId(), tbShopTable.getQrcode(), shopEatTypeInfoDTO);
tbShopTable.setChoseCount((shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee().equals(1)) || (seatCartInfo != null && (seatCartInfo.getNumber() != null)));
tbShopTable.setSeatNum(seatCartInfo != null ? seatCartInfo.getNumber() : 0);
}else {
shopEatTypeInfoDTO.setUseType(OrderUseTypeEnum.TAKEOUT.getValue());
TbOrderInfo order = getCurrentOrder(shopEatTypeInfoDTO, code, shopInfo.getId());
tbShopTable.setOrderId(order == null ? null : order.getId());
tbShopTable.setChoseCount(true);
}
}
concurrentMap.put("shopTableInfo", tbShopTable == null ? "" : tbShopTable);
concurrentMap.put("storeInfo", shopInfo);
concurrentMap.put("distance", distance);
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, tbShopTable.getShopId().toString());
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId != null ? shopId.toString() : tbShopTable.getShopId().toString());
try {
if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
@@ -122,7 +187,7 @@ public class ProductService {
shopUser.setConsumeNumber(0);
shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1"));
shopUser.setShopId(tbShopTable.getShopId().toString());
shopUser.setShopId(shopId != null ? shopId.toString() : tbShopTable.getShopId().toString());
shopUser.setUserId(userId);
shopUser.setMiniOpenId(openId);
shopUser.setCreatedAt(System.currentTimeMillis());
@@ -338,7 +403,7 @@ public class ProductService {
spec.put("isGrounding", true);
TbProductSku sku = (TbProductSku) spec.get("info");
if (sku != null) {
tbProduct.setIsPauseSale(tbProduct.getIsDistribute() == 1 ? tbProduct.getIsPauseSale() : sku.getIsPauseSale().byteValue());
tbProduct.setIsPauseSale(sku.getIsPauseSale().byteValue());
checkPauseSale(tbProduct, new ArrayList<>(Collections.singletonList(sku)), true);
spec.put("isPauseSale", tbProduct.getIsPauseSale());
}else {
@@ -355,7 +420,7 @@ public class ProductService {
itemMap.put("isGrounding", false);
TbProductSku sku = unGroundingMap.get("specSnap");
if (sku != null) {
tbProduct.setIsPauseSale(tbProduct.getIsDistribute() == 1 ? tbProduct.getIsPauseSale() : sku.getIsPauseSale().byteValue());
tbProduct.setIsPauseSale(sku.getIsPauseSale().byteValue());
checkPauseSale(tbProduct, Collections.singletonList(sku), true);
itemMap.put("isPauseSale", tbProduct.getIsPauseSale());
}else {
@@ -390,6 +455,8 @@ public class ProductService {
public List<TbProduct> handleDate(List<TbProduct> products,boolean check,Integer isSale,boolean isVip){
if (!CollectionUtils.isEmpty(products)) {
products.parallelStream().forEach(it -> {
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
if(check){
List<TbProductGroup> tbProductGroups = tbProductGroupMapper.selectByProductId(it.getShopId(), it.getId().toString());
for (TbProductGroup g : tbProductGroups) {
@@ -403,12 +470,11 @@ public class ProductService {
}else {
it.setIsSale(isSale);
}
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
//购物车数量
it.setCartNumber("0");
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
//判断库存及耗材
checkPauseSale(it,tbProductSkus, false);
@@ -443,33 +509,13 @@ public class ProductService {
public void checkPauseSale(TbProduct tbProduct, List<TbProductSku> skus, boolean isSingle) {
if (tbProduct.getIsStock() == 1) {//库存开关 1开启
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {//共享库存 1开启
if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) {
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
return;
}
if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) {
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
return;
}
if (isSingle && tbProduct.getIsPauseSale() == 1) {
return;
}
} else {
if (isSingle && !skus.stream().filter(res -> res.getIsPauseSale().equals(1)).collect(Collectors.toList()).isEmpty()) {
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
return;
}
if (!tbProduct.getTypeEnum().equals("sku")) {
if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)){
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
return;
}
} else {
skus.removeIf(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0);
if (CollectionUtils.isEmpty(skus)) {
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
return;
}
}
if (isSingle && tbProduct.getIsPauseSale() == 1) {
return;
}
Iterator<TbProductSku> iterator = skus.iterator();
while (iterator.hasNext()) {
@@ -790,39 +836,133 @@ public class ProductService {
* @param buyNum 购买数量
*/
public void updateStock(TbProduct tbProduct, TbProductSkuWithBLOBs tbProductSkuWithBLOBs, Integer buyNum) {
if (tbProduct.getIsDistribute() == 1) {
if (tbProductMapper.decrStock(String.valueOf(tbProduct.getId()), buyNum) < 1) {
throw new MsgException("库存修改失败,请稍后再试");
}
} else {
if (tbProductSkuMapper.decrStock(String.valueOf(tbProductSkuWithBLOBs.getId()), buyNum) < 1) {
throw new MsgException("库存修改失败,请稍后再试");
}
if (tbProductMapper.decrStock(String.valueOf(tbProduct.getId()), buyNum) < 1) {
throw new MsgException("库存修改失败,请稍后再试");
}
}
public void updateStock(String id, Integer skuId, Integer buyNum, boolean isDistribute) {
if (isDistribute) {
if (tbProductMapper.decrStock(String.valueOf(id), buyNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
} else {
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), buyNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
public void updateStock(String id, Integer skuId, Integer buyNum) {
if (tbProductMapper.decrStock(String.valueOf(id), buyNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
}
public void updateStockAndNoCheck(String id, Integer skuId, Integer buyNum, boolean isDistribute) {
if (isDistribute) {
if (tbProductMapper.decrStockUnCheck(String.valueOf(id), buyNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
} else {
if (tbProductSkuMapper.decrStockUnCheck(String.valueOf(skuId), buyNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
public void updateStockAndNoCheck(String id, Integer skuId, Integer buyNum) {
if (tbProductMapper.decrStockUnCheck(String.valueOf(id), buyNum) < 1) {
throw new MsgException("库存不足,下单失败");
}
}
public TbCashierCart choseCount(ChoseCountDTO choseCountDTO) {
return Utils.runFunAndCheckKey(() -> {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseCountDTO.getTableId(), choseCountDTO.getShopId());
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(choseCountDTO.getShopId());
if (shopInfo == null) throw new MsgException("店铺信息不存在");
if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1) {
throw new MsgException("当前店铺无需选择餐位费");
}
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, choseCountDTO.getTableId()));
if (shopTable == null) {
throw new MsgException("台桌不存在");
}
if (shopTable.getMaxCapacity() < choseCountDTO.getNum()) {
throw new MsgException("当前台桌最大人数为: " + shopTable.getMaxCapacity());
}
Integer userId = TokenUtil.getUserId();
TbCashierCart tbCashierCart = getSeatCartInfo(choseCountDTO.getShopId(), choseCountDTO.getTableId(), shopEatTypeInfoDTO);
if (tbCashierCart == null) {
tbCashierCart = new TbCashierCart();
tbCashierCart.setStatus("create");
tbCashierCart.setCreatedAt(System.currentTimeMillis());
tbCashierCart.setTableId(choseCountDTO.getTableId());
tbCashierCart.setName("客座费");
tbCashierCart.setSalePrice(shopInfo.getTableFee());
tbCashierCart.setShopId(String.valueOf(choseCountDTO.getShopId()));
tbCashierCart.setTradeDay(DateUtils.getDay());
tbCashierCart.setStatus("create");
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
tbCashierCart.setPlaceNum(1);
tbCashierCart.setProductId(TableConstant.CART_SEAT_ID);
tbCashierCart.setSkuId(TableConstant.CART_SEAT_ID);
tbCashierCart.setPackFee(BigDecimal.ZERO);
tbCashierCart.setNumber(choseCountDTO.getNum());
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
tbCashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
tbCashierCart.setUserId(userId);
mpCashierCartMapper.insert(tbCashierCart);
} else {
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
tbCashierCart.setNumber(choseCountDTO.getNum());
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
tbCashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
tbCashierCart.setUserId(userId);
mpCashierCartMapper.updateById(tbCashierCart);
}
// 将数据加入缓存
String tableCartKey = RedisCst.getTableCartKey(String.valueOf(choseCountDTO.getShopId()), choseCountDTO.getTableId(), userId);
String message = redisUtil.getMessage(tableCartKey);
JSONArray jsonArray;
if (StrUtil.isNotBlank(message)) {
jsonArray = JSONObject.parseArray(message);
}else {
jsonArray = new JSONArray();
}
long count = jsonArray.stream().filter(item -> TableConstant.CART_SEAT_ID.equals(((JSONObject) item).getString("productId"))).count();
if (count < 1) {
jsonArray.add(tbCashierCart);
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString());
}
// 保存就餐人数信息
redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(choseCountDTO.getShopId(), choseCountDTO.getTableId()),
JSONObject.toJSONString(tbCashierCart), 60L * 60 * 12);
return tbCashierCart;
}, stringRedisTemplate, RedisCst.getLockKey(RedisCst.CHOSE_TABLE_COUNT, choseCountDTO.getShopId(), choseCountDTO.getTableId()));
}
private TbCashierCart getSeatCartInfo(Object shopId, String tableId, ShopEatTypeInfoDTO shopEatTypeInfoDTO) {
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.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())
// .and(r -> r.eq(TbCashierCart::getUserId, userId).or().isNull(TbCashierCart::getUserId))
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
.eq(TbCashierCart::getTableId, tableId)
.orderByDesc(TbCashierCart::getId);
List<TbCashierCart> cashierCartList = mpCashierCartMapper.selectList(query);
return cashierCartList.isEmpty() ? null : cashierCartList.get(0);
}
public Object choseEatModel(ChoseEatModelDTO choseTableDTO) {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseTableDTO.getTableId(), choseTableDTO.getShopId());
if (!shopEatTypeInfoDTO.isTakeout()) {
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.notIn(TbShopTable::getStatus, "closed", "cleaning")
.eq(TbShopTable::getQrcode, choseTableDTO.getTableId()));
if (shopTable == null) {
throw new MsgException("台桌未开台或不存在");
}
}
return mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, choseTableDTO.getShopId())
.isNull(TbCashierCart::getUseType)
.eq(TbCashierCart::getStatus, "create")
.set(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())) ;
}
}

View File

@@ -0,0 +1,13 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author Administrator
* @description 针对表【tb_call_queue】的数据库操作Service
* @createDate 2024-09-13 13:44:26
*/
public interface TbCallQueueService extends IService<TbCallQueue> {
}

View File

@@ -0,0 +1,19 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.dto.CallSubMsgDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.CancelCallQueueDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.TakeNumberDTO;
public interface TbCallService {
Object takeNumber(TakeNumberDTO takeNumberDTO);
Object getList(Integer shopId, String openId, Integer queueId);
Object getAllInfo(Integer shopId);
Object cancel(CancelCallQueueDTO cancelCallQueueDTO);
Object getState(String openId, Integer shopId, Integer queueId);
Object subMsg(CallSubMsgDTO subMsgDTO);
}

View File

@@ -0,0 +1,16 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.TbCallTable;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description 针对表【tb_call_table】的数据库操作Service
* @createDate 2024-09-13 13:44:34
*/
@Service
public interface TbCallTableService extends IService<TbCallTable> {
}

View File

@@ -34,6 +34,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -280,6 +281,7 @@ public class UserService {
tbShopUser.setTelephone(memberVo.getTelephone());
tbShopUser.setBirthDay(StringUtils.isNotBlank(memberVo.getBirthDay()) ? memberVo.getBirthDay() : null);
tbShopUser.setIsVip(Byte.parseByte("1"));
tbShopUser.setJoinTime(new Timestamp(System.currentTimeMillis()));
shopUserMapper.updateByPrimaryKeySelective(tbShopUser);
} else {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(memberVo.getId());
@@ -304,6 +306,7 @@ public class UserService {
tbShopUser.setTelephone(memberVo.getTelephone());
tbShopUser.setAmount(BigDecimal.ZERO);
tbShopUser.setIsVip(Byte.parseByte("1"));
tbShopUser.setJoinTime(new Timestamp(System.currentTimeMillis()));
tbShopUser.setCreditAmount(BigDecimal.ZERO);
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
tbShopUser.setConsumeNumber(0);

View File

@@ -0,0 +1,24 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
import com.chaozhanggui.system.cashierservice.service.TbCallQueueService;
import com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description 针对表【tb_call_queue】的数据库操作Service实现
* @createDate 2024-09-13 13:44:26
*/
@Service
@Primary
public class TbCallQueueServiceImpl extends ServiceImpl<TbCallQueueMapper, TbCallQueue>
implements TbCallQueueService{
}

View File

@@ -0,0 +1,211 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
import com.chaozhanggui.system.cashierservice.entity.TbCallTable;
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
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.entity.vo.CallQueueInfoVO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.service.TbCallQueueService;
import com.chaozhanggui.system.cashierservice.service.TbCallService;
import com.chaozhanggui.system.cashierservice.service.TbCallTableService;
import com.chaozhanggui.system.cashierservice.util.MQUtils;
import com.chaozhanggui.system.cashierservice.util.Utils;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
@Service
@AllArgsConstructor
@Primary
public class TbCallServiceImpl implements TbCallService {
private final TbCallQueueService callQueueService;
private final TbCallTableService callTableService;
private final TbShopInfoMapper shopInfoMapper;
private final TbCallQueueMapper callQueueMapper;
private final StringRedisTemplate redisTemplate;
private final MQUtils mQUtils;
private String getCallNumber(Integer shopId, TbCallTable callTable) {
return Utils.runFunAndCheckKey(() -> {
String callNumKey = RedisCst.getTableCallNumKey(shopId, callTable.getId());
String value = redisTemplate.opsForValue().get(callNumKey);
AtomicReference<String> newVal = new AtomicReference<>("");
// 初始化
if (StrUtil.isBlank(value)) {
Boolean setFlag = Utils.runFunAndRetry(() -> redisTemplate.opsForValue().setIfAbsent(callNumKey, callTable.getStart().toString()), flag -> !flag,
r -> newVal.set(redisTemplate.opsForValue().get(callNumKey)));
if (setFlag) {
return callTable.getPrefix() + callTable.getStart();
} else if (StrUtil.isNotBlank(newVal.get())) {
value = String.valueOf((Integer.parseInt(newVal.get()) + 1));
redisTemplate.opsForValue().set(callNumKey, value);
return callTable.getPrefix() + value;
} else {
throw new MsgException("生成排队号码失败");
}
} else {
value = String.valueOf((Integer.parseInt(value) + 1));
redisTemplate.opsForValue().set(callNumKey, value);
return callTable.getPrefix() + value;
}
}, redisTemplate, RedisCst.getLockKey("UPDATE_TABLE", shopId, callTable.getId()));
}
@Override
public Object takeNumber(TakeNumberDTO takeNumberDTO) {
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(takeNumberDTO.getShopId());
if (shopInfo == null) {
throw new MsgException("店铺信息不存在");
}
TbCallTable callTable = callTableService.lambdaQuery()
.eq(TbCallTable::getShopId, takeNumberDTO.getShopId())
.eq(TbCallTable::getId, takeNumberDTO.getCallTableId()).one();
if (callTable == null) {
throw new MsgException("桌型不存在");
}
TbCallQueue callQueue = callQueueService.lambdaQuery()
// .eq(TbCallQueue::getPhone, takeNumberDTO.getPhone())
.eq(TbCallQueue::getOpenId, takeNumberDTO.getOpenId())
.eq(TbCallQueue::getShopId, takeNumberDTO.getShopId())
.eq(TbCallQueue::getCreateDay, DateUtil.date().toString("yyyy-MM-dd"))
.in(TbCallQueue::getState, 0, 1)
// .ne(TbCallQueue::getIsPostpone, 2)
.eq(TbCallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one();
if (callQueue != null) {
throw new MsgException("您已取号,请勿重复取号");
}
Integer count = callQueueService.lambdaQuery()
.eq(TbCallQueue::getPhone, takeNumberDTO.getPhone())
.eq(TbCallQueue::getShopId, takeNumberDTO.getShopId())
.eq(TbCallQueue::getCreateDay, DateUtil.date().toString("yyyy-MM-dd"))
.in(TbCallQueue::getState, 0, 1)
.eq(TbCallQueue::getCallTableId, takeNumberDTO.getCallTableId()).count();
if (count > 0) {
throw new MsgException("此号码已取号,请更换号码");
}
callQueue = BeanUtil.copyProperties(takeNumberDTO, TbCallQueue.class);
callQueue.setSubState(0);
callQueue.setCreateTime(DateUtil.date());
callQueue.setShopId(shopInfo.getId());
callQueue.setShopName(shopInfo.getShopName());
callQueue.setCallNum(getCallNumber(takeNumberDTO.getShopId(), callTable));
callQueue.setCreateDay(DateUtil.date().toString("yyyy-MM-dd"));
callQueue.setNote(callTable.getNote());
callQueue.setName(callTable.getName());
boolean save = callQueueService.save(callQueue);
// 打印排号票信息
mQUtils.printCallNumTicket(callQueue.getId(), callQueue.getShopId());
return callQueue;
}
@Override
public Object getList(Integer shopId, String openId, Integer queueId) {
return callQueueMapper.selectInfoByOpenId(shopId, openId, DateUtil.date().toString("yyyy-MM-dd"), queueId);
}
@Override
public Object getAllInfo(Integer shopId) {
ArrayList<Map<String, Object>> infoList = new ArrayList<>();
List<TbCallTable> list = callTableService.lambdaQuery()
.eq(TbCallTable::getShopId, shopId).list();
list.forEach(item -> {
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
Integer count = callQueueService.lambdaQuery()
.eq(TbCallQueue::getCallTableId, item.getId())
.eq(TbCallQueue::getShopId, shopId)
.in(TbCallQueue::getState, 0, 1).count();
map.put("waitingCount", count);
map.put("waitTime", count * item.getWaitTime());
infoList.add(map);
});
return infoList;
}
@Override
public Object cancel(CancelCallQueueDTO cancelCallQueueDTO) {
return callQueueService.lambdaUpdate()
.eq(TbCallQueue::getShopId, cancelCallQueueDTO.getShopId())
.eq(TbCallQueue::getId, cancelCallQueueDTO.getQueueId())
.set(TbCallQueue::getCreateDay, DateUtil.date())
.set(TbCallQueue::getState, -1).update();
}
@Override
public Object getState(String openId, Integer shopId, Integer queueId) {
List<CallQueueInfoVO> callQueueInfoVOS = callQueueMapper.selectInfoByOpenId(shopId, openId, DateUtil.date().toString("yyyy-MM-dd"), null);
if (callQueueInfoVOS.isEmpty()) {
callQueueInfoVOS = callQueueMapper.selectInfoByOpenId(shopId, openId, DateUtil.date().toString("yyyy-MM-dd"), queueId);
}
if (!callQueueInfoVOS.isEmpty()) {
CallQueueInfoVO callQueueInfoVO = callQueueInfoVOS.get(0);
callQueueMapper.update(null, new LambdaUpdateWrapper<TbCallQueue>()
.eq(TbCallQueue::getId, callQueueInfoVO.getId())
.set(TbCallQueue::getOpenId, openId));
}
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(shopId);
HashMap<String, Object> data = new HashMap<>();
data.put("shopInfo", shopInfo);
data.put("queueInfo", callQueueInfoVOS.isEmpty() ? null : callQueueInfoVOS.get(0));
return data;
}
@Override
public Object subMsg(CallSubMsgDTO subMsgDTO) {
TbCallQueue queue = callQueueMapper.selectOne(new LambdaQueryWrapper<TbCallQueue>()
.eq(TbCallQueue::getShopId, subMsgDTO.getShopId())
.eq(TbCallQueue::getId, subMsgDTO.getQueueId()));
if (queue == null) {
throw new MsgException("您未排号请先排号");
}
if (queue.getOpenId() != null && queue.getOpenId().equals(subMsgDTO.getOpenId()) && queue.getSubState() == 1) {
return true;
}
if (StrUtil.isNotBlank(queue.getOpenId()) && queue.getSubState() == 1) {
throw new MsgException("此号码已被其他用户订阅");
}
if (!subMsgDTO.getOpenId().equals(queue.getOpenId()) && queue.getSubState() == 0) {
Integer count = callQueueService.lambdaQuery()
// .eq(TbCallQueue::getPhone, takeNumberDTO.getPhone())
.eq(TbCallQueue::getOpenId, subMsgDTO.getOpenId())
.eq(TbCallQueue::getShopId, subMsgDTO.getShopId())
.eq(TbCallQueue::getCreateDay, DateUtil.date().toString("yyyy-MM-dd"))
.in(TbCallQueue::getState, 0, 1)
.ne(TbCallQueue::getIsPostpone, 2)
.eq(TbCallQueue::getCallTableId, queue.getCallTableId()).count();
if (count > 0) {
throw new MsgException("您已订阅其他号码,请勿重复订阅");
}
}
queue.setSubState(1);
queue.setOpenId(subMsgDTO.getOpenId());
return callQueueMapper.updateById(queue);
}
}

View File

@@ -0,0 +1,24 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.entity.TbCallTable;
import com.chaozhanggui.system.cashierservice.service.TbCallTableService;
import com.chaozhanggui.system.cashierservice.mapper.TbCallTableMapper;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description 针对表【tb_call_table】的数据库操作Service实现
* @createDate 2024-09-13 13:44:34
*/
@Service
@Primary
public class TbCallTableServiceImpl extends ServiceImpl<TbCallTableMapper, TbCallTable>
implements TbCallTableService{
}

View File

@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.util;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.HttpEntity;
@@ -19,7 +20,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
public class FeieyunPrintUtil {
@@ -123,12 +123,12 @@ public class FeieyunPrintUtil {
builder.append("<CB>"+pickupNumber+"</CB><BR><BR>");
builder.append("<L>时间: "+date+" </L><BR><BR><BR>");
remark = StrUtil.emptyToDefault(remark, "");
if(productName.length()>4||remark.length()>4){
builder.append("<B><BOLD>"+productName+" "+number+"</BOLD></B><BR><BR>");
builder.append("<B><BOLD>"+productName+" x "+number+"</BOLD></B><BR><BR>");
builder.append("<B><BOLD>"+remark+" </BOLD></B><BR><BR><BR>");
}else {
builder.append("<B><BOLD>"+productName+" "+number+"</BOLD></B><BR><BR>");
builder.append("<B><BOLD>"+productName+" x "+number+"</BOLD></B><BR><BR>");
builder.append("<B><BOLD>"+remark+" </BOLD></B><BR><BR><BR>");
}

View File

@@ -1,11 +1,16 @@
package com.chaozhanggui.system.cashierservice.util;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Slf4j
@Component
public class MQUtils {
@@ -19,8 +24,37 @@ public class MQUtils {
log.info("开始发送{}mq消息, exchange: {}, routingKey: {}, data: {}", note, exchange, routingKey, data);
rabbitTemplate.convertAndSend(exchange, routingKey, JSONObject.toJSONString(data));
}
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
log.info("开始发送{}mq消息, msgId: {}, exchange: {}, routingKey: {}, data: {}", note, correlationId.getId(), exchange, routingKey, data);
rabbitTemplate.convertAndSend(exchange, routingKey, isJson ? JSONObject.toJSONString(data) : data, correlationId);
}
public <T> void sendStockSaleMsg(T data) {
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, data, "商品售出增加库存记录");
}
public void printCallNumTicket(Integer id, Integer shopId) {
CallNumPrintDTO printDTO = new CallNumPrintDTO();
printDTO.setCallQueueId(id);
printDTO.setShopId(shopId);
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_CALL_TABLE, printDTO, "排号小票打印");
}
public void printDishesTicket(Integer orderId, boolean isReturn, TbOrderDetail... detailOrderIds) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderId", orderId);
jsonObject.put("orderDetailIds", detailOrderIds);
jsonObject.put("isReturn", isReturn);
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_DISHES, jsonObject, "菜品打印", true);
}
public void printPlaceTicket(Integer id, boolean isReturn) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderId", id);
jsonObject.put("isReturn", isReturn);
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_PLACE, jsonObject, "订单打印", true);
}
}

View File

@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.util;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
@@ -71,12 +72,12 @@ public class PrinterUtils {
StringBuilder builder = new StringBuilder();
builder.append("<C><B>"+pickupNumber+"</B></C><BR><BR>");
builder.append("<S><L>时间: "+date+" </L></S><BR><BR><BR>");
remark = StrUtil.emptyToDefault(remark, "");
if(productName.length()>4||remark.length()>4){
builder.append("<CS:32>"+productName+" "+number+"</CS><BR>");
builder.append("<CS:32>"+productName+" x "+number+"</CS><BR>");
builder.append("<CS:32>"+remark+" </CS><BR>");
}else {
builder.append("<B>"+productName+" "+number+"</B><BR>");
builder.append("<B>"+productName+" x "+number+"</B><BR>");
builder.append("<B>"+remark+" </B><BR>");
}
builder.append("<OUT:150>");
@@ -105,12 +106,12 @@ public class PrinterUtils {
builder.append("<S><L>时间: " + date + " </L></S><BR><BR><BR>");
remark = StrUtil.emptyToDefault(remark, "");
if (productName.length() > 4 || remark.length() > 4) {
builder.append("<CS:32>" + productName + " " + number + "</CS><BR>");
builder.append("<CS:32>" + productName + " x " + number + "</CS><BR>");
builder.append("<CS:32>" + remark + " </CS><BR>");
} else {
builder.append("<B>" + productName + " " + number + "</B><BR>");
builder.append("<B>" + productName + " x " + number + "</B><BR>");
builder.append("<B>" + remark + " </B><BR>");
}
builder.append("<OUT:150>");

View File

@@ -0,0 +1,88 @@
package com.chaozhanggui.system.cashierservice.util;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopInfoEatModelEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopInfoRegisterlEnum;
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.MpShopInfoMapper;
import org.springframework.stereotype.Component;
@Component
public class ShopUtils {
private final MpShopInfoMapper mpShopInfoMapper;
public ShopUtils(MpShopInfoMapper mpShopInfoMapper) {
this.mpShopInfoMapper = mpShopInfoMapper;
}
/**
* 校验就餐模式是否存在并返回就餐类型信息
* @param tableId 台桌id
* @param shopId 店铺id
* @return 就餐类型信息
*/
public ShopEatTypeInfoDTO checkEatModel(String tableId, Object shopId) {
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
.eq(TbShopInfo::getId, shopId)
.eq(TbShopInfo::getStatus, 1));
if (shopInfo == null) {
throw new MsgException("店铺信息不存在");
}
boolean isOpenTakeout = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.TAKE_OUT.getValue());
boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue());
if (!isOpenDineIn && !isOpenTakeout) {
throw new MsgException("此店铺未开通任何就餐模式");
}
tableId = isOpenDineIn ? tableId : null;
String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
if (!shopInfo.getEatModel().contains(eatModel)) {
throw new MsgException("当前店铺未开启此就餐模式");
}
// 是否是快餐版/先付费
boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) &&
ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType());
boolean isTakeout = isOpenTakeout && ShopInfoEatModelEnum.TAKE_OUT.getValue().equals(eatModel);
boolean isDineInAfter = isOpenDineIn && !isMunchies && !isTakeout;
boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout;
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn);
}
public ShopEatTypeInfoDTO getEatModel(String tableId, Object shopId) {
String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
.eq(TbShopInfo::getId, shopId)
.eq(TbShopInfo::getStatus, 1));
if (shopInfo == null) {
throw new MsgException("店铺信息不存在");
}
boolean isTakeout = ShopInfoEatModelEnum.TAKE_OUT.getValue().equals(eatModel);
// 是否是快餐版/先付费
boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) &&
ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType());
boolean isDineInAfter = !isMunchies && !isTakeout;
boolean isDineInBefore = isMunchies && !isTakeout;
boolean isOpenTakeout = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.TAKE_OUT.getValue());
boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue());
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue(), isOpenTakeout, isOpenDineIn);
}
}

View File

@@ -0,0 +1,93 @@
package com.chaozhanggui.system.cashierservice.util;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
public class Utils {
public static int retryCount = 5;
private static final Logger log = LoggerFactory.getLogger(Utils.class);
public static <T> void catchErrNoReturn(Supplier<T> supplier) {
try {
supplier.get();
}catch (Exception e) {
log.error("执行方法出现异常", e);
}
}
public static <T, R> void runFunAndRetryNoReturn(
Supplier<R> function,
Function<R, Boolean> check, Consumer<R> errFun) {
log.info("工具类开始执行函数");
R result = function.get();
boolean flag = check.apply(result);
log.info("执行结果: {}", result);
while (flag && retryCount-- > 0) {
log.info("执行函数失败, 剩余尝试次数{}", retryCount);
result = function.get();
log.info("执行结果: {}", result);
flag = check.apply(result);
}
if (flag) {
errFun.accept(result);
}
}
public static<T> T runFunAndCheckKey(Supplier<T> supplier, StringRedisTemplate redisTemplate, String lockKey) {
try{
// 创建线程id, 用作判断
String clientId = UUID.randomUUID().toString();
// 设置分布式锁
boolean lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.SECONDS));
int count = 0;
while (!lock) {
if (count++ > 100) {
throw new MsgException("系统繁忙, 稍后再试");
}
Thread.sleep(20);
lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.SECONDS));
}
return supplier.get();
} catch (RuntimeException e){
log.info("执行出错:{}", e.getMessage());
throw e;
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally{
redisTemplate.delete(lockKey);
}
}
public static <T, R> R runFunAndRetry(
Supplier<R> function,
Function<R, Boolean> check, Consumer<R> errFun) {
log.info("工具类开始执行函数");
R result = function.get();
boolean flag = check.apply(result);
log.info("执行结果: {}", result);
while (flag && retryCount-- > 0) {
log.info("执行函数失败, 剩余尝试次数{}", retryCount);
result = function.get();
log.info("执行结果: {}", result);
flag = check.apply(result);
}
if (flag) {
errFun.accept(result);
}
return result;
}
}

View File

@@ -1,16 +1,25 @@
spring:
datasource:
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
username: cashier
password: Cashier@1@
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://rm-bp1b572nblln4jho2.mysql.rds.aliyuncs.com/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false
# username: root
# password: Czg666888
# driver-class-name: com.mysql.cj.jdbc.Driver
# driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
logging:
level:
com.chaozhanggui.system.openness: info
hikari:
minimum-idle: 5
maximum-pool-size: 15
idle-timeout: 30000
max-lifetime: 1800000
connection-timeout: 30000
redis:
# redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突
database: 0
@@ -38,11 +47,10 @@ spring:
username: admin
password: Czg666888
mybatis:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:mapper/*.xml
#mybatis:
# configuration:
# map-underscore-to-camel-case: true
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
ysk:
url: https://gatewaytestapi.sxczgkj.cn/gate-service/
callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack

View File

@@ -40,11 +40,11 @@ spring:
username: admin
password: Czg666888
mybatis:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:mapper/*.xml
#mybatis:
# configuration:
# map-underscore-to-camel-case: true
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# mapper-locations: classpath:mapper/*.xml
ysk:
url: https://gateway.api.sxczgkj.cn/gate-service/
callBackurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBack

View File

@@ -24,7 +24,20 @@ wx:
appId: wx212769170d2c6b2a
secrete: 8492a7e8d55bbb1b57f5c8276ea1add0
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
alipay:
sdk:
config:
serverUrl: https://openapi.alipay.com/gateway.do
appId: 2021004145625815
privateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCAjDBuS8K/IJb9ui+KuNm/sTUdEiaji4BNpZ92avO1N5JpNlGmac6ec4p3tNFT950sBLcQkClcUpQxUHQzAT6DYNNXOKyvfI/EmcqwCw6PaMNLs/8cV//J2WWZBUhLaOsjKurpm9/3W5MnTh4BGxIfBoeBMA8f8K3BgKdmyKtvIEV2h2cyjsMskdn+g6oNZcmWcms0pvpPHyH46mRaGFhpp0v19wX3WsamGldh1L2VntmaDN3C2XbSrXv90XYp5bEUqwTbLwXpMAlzTibF56d/iqv9oYi8cpAKougUFLOymnbutLNs2tLrEDSFwHcmG2/wbZHybZyYcIgFgv4arf+tAgMBAAECggEAf7hKKlw1y6Z6vvAtalxNZUuRZSfyog3p1bwYWxTavZPQcZ7Zs0lvVDmiO1u5m/7q96BbryY9IhCeUv0H5uF2lhwu/3s9AEL3qTPQkeb6eXxyhhX6A9RfPdM1Qbtg4CQHdHKg4qjP9znSVHwmDZ0y/QaEvdPdQzPjv92u9c2tn4N4x6XyBYcU5gzxiJNnIugCmBgcJo/3H2fgV+XXEhORPvy5of9b4oATHEaLS/8dAS2wuOjhzaGS4MXp3VkXn3XaYjwSzaL03qYWA+xm+aO5sJv8bmqZW7sNVck5o3sPo7cQ4VkBFVzyrRdmJcxcSRJ9MsB9JsrhoKI8pgaXrVie4QKBgQDU2vai0lpBIK/0jzRpPNoqdT8lnafnnWni8nU4kfAh+gCLi+HBPhQRT0kv4unQc2q2/gALE7sgZVO00JGY5a3R0orsojPoUSZlpypGW7GGqKy576NHn0nw4o/PdfysT92VWgt1hlfTf6qfCDhfE9APU+RGvlSWXcT8nxVel3iUaQKBgQCamoJN6+4v+chJvL2nqV8NVVRLp0vDIHxs1QOtKwUodx8Qp1D6CJYtavCXn8aNUFVNQJPJ7TQPpJjXP2rI4SN01weDwx+I+wh8PBGHV6/234R+6TvFgY1PrYgCdfNP4i/E7B4uyEhAxdU73PB8qkqRAeJGok05p7oG71KCOBiYpQKBgEZfGflcuDAeAW5GRhqg3rP4zWa/R7qgZVh9tll8jjp9b96y4XFE99d9MgId8BVVgyt6sEL5Q/2C4ni+F9TH4n6jMADp42VkJuCmsqhOOlP9whU67+2G8Sgtj0QUivPg964f9ffl8XVgGOW5DwIIB9p5btggptCLscufQK5kP545AoGADBvf6tR4wl8w9b2HqTMV08iEIqzGvVC1Dh0c/Zop/EJgN4CzUfIMOSBwGaAVAApzs+pD6QPgGP2OTwWTioo/qa4R05sbxDHNN1XJFa2jhZV6HiqMWOrNs5jm1zJ/zRjtHuJTdtyO9CvKiLbESy9XScY4/8lEfSiK5HIoJzTXkFUCgYAkYkvkW6psJpWj05XWq44UN0n6QOU/Igl35Um/iuOMVhsTmIt09STQVTuzJzfH82+sCqoRsD1blE5unKNUC1DK77aNKTv3Z0dxN9R7FAyfZRiYQXTrbBPBqWjay6FCNxn8e8UsJN4Z6FIV2LGlQI114krSap1MALKLVvnld0NaUQ==
alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB
encryptKey: Hp1TbhOqevbHCA5ji/VlqQ==
decorator:
datasource:
p6spy:
logging: file
log-file: spy.log
log-format: executionTime:%(executionTime) ms | sql:%(sqlSingleLine)
#
spring:
profiles:
@@ -52,10 +65,11 @@ pagehelper:
params: count=countSql
logging:
level:
org.springframework.web.filter.CommonsRequestLoggingFilter: debug
com.chaozhanggui.system.cashierservice.mapper: debug
com.chaozhanggui.system.cashierservice.dao: debug
# web日志
org.springframework.web: debug
# mybatis日志
org.apache.ibatis: debug
# org.springframework.web: debug
charset:
# 输出控制台编码
console: UTF-8
@@ -89,3 +103,10 @@ aliyun:
thirdPay:
payType: fushangtong
url: https://paymentapi.sxczgkj.cn
mybatis-plus:
global-config:
db-config:
id-type: auto
mapper-locations: classpath:mapper/*.xml

View File

@@ -28,6 +28,15 @@
where id = #{id}
</select>
<!--查询剩余商品优惠卷数量-->
<select id="countCouponNum" resultType="INTEGER">
SELECT
ifnull(sum(over_num), 0)
FROM
tb_activate_in_record record
INNER JOIN tb_shop_user vip ON record.vip_user_id = vip.id AND vip.user_id = #{userId}
</select>
<select id="queryByVipIdAndShopId" resultType="com.chaozhanggui.system.cashierservice.entity.TbProduct">
SELECT
tb_product.*, sum(tb_activate_in_record.over_num) as limitNumber
@@ -43,6 +52,7 @@
SELECT tb_product.name as detail,
0 as status,
sum(tb_activate_in_record.over_num) as num,
tb_activate_in_record.shop_id as shopId,
<choose>
<when test="shopName != null and shopName != ''">#{shopName}</when>
<otherwise>''</otherwise>
@@ -52,7 +62,7 @@
LEFT JOIN tb_product ON tb_activate_in_record.pro_id = tb_product.id
WHERE vip_user_id = #{vipUserId}
and tb_activate_in_record.shop_id = #{shopId}
and num!=0
and tb_activate_in_record.over_num!=0
group by tb_activate_in_record.pro_id
</select>

View File

@@ -30,6 +30,7 @@
<select id="queryVipPro" resultType="com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo">
SELECT tb_product.NAME AS detail,
tb_activate_out_record.order_id as orderId,
1 AS status,
tb_activate_out_record.use_num AS num,
<choose>

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbCallQueue">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="callTableId" column="call_table_id" jdbcType="INTEGER"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="shopName" column="shop_name" jdbcType="VARCHAR"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="state" column="state" jdbcType="TINYINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="callTime" column="call_time" jdbcType="TIMESTAMP"/>
<result property="callCount" column="call_count" jdbcType="INTEGER"/>
<result property="passTime" column="pass_time" jdbcType="TIMESTAMP"/>
<result property="cancelTime" column="cancel_time" jdbcType="TIMESTAMP"/>
<result property="note" column="note" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="openId" column="open_id" jdbcType="VARCHAR"/>
<result property="subState" column="sub_state" jdbcType="TINYINT"/>
<result property="confirmTime" column="confirm_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,call_table_id,phone,
name,shop_name,shop_id,
state,create_time,call_time,
call_count,pass_time,cancel_time,
note,user_id,open_id,
sub_state,confirm_time
</sql>
<select id="selectInfoByOpenId"
resultType="com.chaozhanggui.system.cashierservice.entity.vo.CallQueueInfoVO">
SELECT
d.shop_name,
d.logo,
d.status AS shop_state,
a.call_num,
a.id, -- 用户的排队记录ID
a.state,
a.user_id, -- 用户ID
b.name AS table_name, -- 桌子名称
b.note AS table_note, -- 桌子备注
(
SELECT COUNT(1)
FROM tb_call_queue c
WHERE
c.call_table_id = a.call_table_id
and c.shop_id=a.shop_id -- 同一张桌子
AND c.create_time &lt; a.create_time -- 在当前用户之前排队
AND c.state IN (0, 1) -- 排队中或等待中的人
AND c.create_day=#{today}
) AS waiting_count, -- 前面有几个人
(
SELECT COUNT(1) * b.wait_time
FROM tb_call_queue c
WHERE
c.call_table_id = a.call_table_id
AND c.shop_id=a.shop_id -- 同一张桌子
AND c.create_time &lt; a.create_time -- 在当前用户之前排队
AND c.state IN (0, 1) -- 排队中或等待中的人
AND c.create_day=#{today}
) AS wait_time -- 预计等待时间
FROM
tb_call_queue a
LEFT JOIN
tb_shop_info d ON a.shop_id = d.id
LEFT JOIN
tb_call_table b ON a.call_table_id = b.id
WHERE
a.shop_id = #{shopId}
AND a.create_day = #{today} -- 替换为目标日期
<if test="queueId != null">
and a.id = #{queueId} and (a.open_id = #{openId} or a.open_id is null)
</if>
<if test="queueId == null">
and a.open_id = #{openId} -- 替换为目标用户的 open_id
</if>
and a.state in (0, 1)
GROUP BY
a.id, a.user_id, b.name, b.note, b.wait_time
ORDER BY
a.create_time ASC;
</select>
</mapper>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.mapper.TbCallTableMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbCallTable">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="note" column="note" jdbcType="VARCHAR"/>
<result property="waitTime" column="wait_time" jdbcType="INTEGER"/>
<result property="prefix" column="prefix" jdbcType="VARCHAR"/>
<result property="start" column="start" jdbcType="INTEGER"/>
<result property="nearNum" column="near_num" jdbcType="INTEGER"/>
<result property="state" column="state" jdbcType="TINYINT"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="qrcode" column="qrcode" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,name,note,
wait_time,prefix,start,
near_num,state,shop_id,
qrcode,create_time,update_time
</sql>
</mapper>

View File

@@ -369,6 +369,10 @@
update tb_cashier_cart set status = #{status} where table_id = #{tableId} and status = 'create'
</update>
<update id="updateStatusByOrderIdForMini">
update tb_cashier_cart set status = #{status} where table_id = #{tableId} and status = 'create' and master_id is null
</update>
<update id="updateStatusById">
update tb_cashier_cart set status = #{status} where id = #{id}
</update>
@@ -382,4 +386,4 @@
</select>
</mapper>
</mapper>

View File

@@ -11,13 +11,14 @@
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="small_appid" jdbcType="VARCHAR" property="smallAppid" />
<result column="alipay_small_appid" jdbcType="VARCHAR" property="alipaySmallAppid" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbMerchantThirdApply">
<result column="app_token" jdbcType="LONGVARCHAR" property="appToken" />
</resultMap>
<sql id="Base_Column_List">
id, type, app_id, status, pay_password, applyment_state, created_at, updated_at,small_appid,store_id
id, type, app_id, status, pay_password, applyment_state, created_at, updated_at,small_appid,alipay_small_appid,store_id
</sql>
<sql id="Blob_Column_List">
app_token

View File

@@ -18,6 +18,14 @@
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="vendor_id" jdbcType="VARCHAR" property="vendorId" />
<result column="product_id" jdbcType="VARCHAR" property="productId" />
<result column="receipt_size" jdbcType="VARCHAR" property="receiptSize" />
<result column="classify_print" jdbcType="VARCHAR" property="classifyPrint" />
<result column="table_print" jdbcType="VARCHAR" property="tablePrint" />
<result column="print_qty" jdbcType="VARCHAR" property="printQty" />
<result column="print_method" jdbcType="VARCHAR" property="printMethod" />
<result column="print_type" jdbcType="VARCHAR" property="printType" />
<result column="print_receipt" jdbcType="VARCHAR" property="printReceipt" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbPrintMachineWithBLOBs">
<result column="config" jdbcType="LONGVARCHAR" property="config" />
@@ -25,7 +33,7 @@
</resultMap>
<sql id="Base_Column_List">
id, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids,
content_type, created_at, updated_at, sort, vendor_id, product_id
content_type, created_at, updated_at, sort, vendor_id, product_id, receipt_size, classify_print, table_print, print_qty, print_method, print_type, print_receipt
</sql>
<sql id="Blob_Column_List">
config, category_list

View File

@@ -27,7 +27,7 @@
product_ids
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
select
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
@@ -39,14 +39,14 @@
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductGroup">
insert into tb_product_group (id, name, merchant_id,
shop_id, pic, is_show,
detail, style, sort,
insert into tb_product_group (id, name, merchant_id,
shop_id, pic, is_show,
detail, style, sort,
created_at, updated_at, product_ids
)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR},
#{shopId,jdbcType=INTEGER}, #{pic,jdbcType=VARCHAR}, #{isShow,jdbcType=TINYINT},
#{detail,jdbcType=VARCHAR}, #{style,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER},
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR},
#{shopId,jdbcType=INTEGER}, #{pic,jdbcType=VARCHAR}, #{isShow,jdbcType=TINYINT},
#{detail,jdbcType=VARCHAR}, #{style,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER},
#{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{productIds,jdbcType=LONGVARCHAR}
)
</insert>
@@ -242,4 +242,4 @@
SELECT * FROM tb_product_group WHERE `shop_id` = #{shopId,jdbcType=VARCHAR} AND is_show = 1
AND `product_ids` LIKE concat('%',#{productId,jdbcType=VARCHAR},'%')
</select>
</mapper>
</mapper>

View File

@@ -31,7 +31,6 @@
<result column="is_on_sale" jdbcType="TINYINT" property="isOnSale" />
<result column="is_show" jdbcType="TINYINT" property="isShow" />
<result column="type_enum" jdbcType="VARCHAR" property="typeEnum" />
<result column="is_distribute" jdbcType="TINYINT" property="isDistribute" />
<result column="is_del" jdbcType="TINYINT" property="isDel" />
<result column="is_stock" jdbcType="TINYINT" property="isStock" />
<result column="is_pause_sale" jdbcType="TINYINT" property="isPauseSale" />
@@ -64,6 +63,7 @@
<result column="spec_table_headers" jdbcType="VARCHAR" property="specTableHeaders" />
<result column="group_category_id" jdbcType="VARCHAR" property="groupCategoryId" />
<result column="stock_number" jdbcType="INTEGER" property="stockNumber" />
<result column="warn_line" jdbcType="INTEGER" property="warnLine" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
<result column="images" jdbcType="LONGVARCHAR" property="images" />
@@ -82,7 +82,7 @@
created_at, updated_at, base_sales_number, real_sales_number, sales_number, thumb_count,
store_count, furnish_meal, furnish_express, furnish_draw, furnish_vir, is_combo,
is_show_cash, is_show_mall, is_need_examine, show_on_mall_status, show_on_mall_time,
show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers,group_category_id,stock_number
show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers,group_category_id,stock_number,warn_line
</sql>
<sql id="Blob_Column_List">
images, video, notice, group_snap, spec_info, select_spec
@@ -109,7 +109,7 @@
sort, limit_number, product_score,
status, fail_msg, is_recommend,
is_hot, is_new, is_on_sale,
is_show, type_enum, is_distribute,
is_show, type_enum,
is_del, is_stock, is_pause_sale,
is_free_freight, freight_id, strategy_type,
strategy_id, is_vip, is_delete,
@@ -121,7 +121,7 @@
show_on_mall_status, show_on_mall_time, show_on_mall_error_msg,
enable_label, tax_config_id, spec_table_headers,
images, video, notice,
group_snap, spec_info, select_spec,group_category_id,stock_number
group_snap, spec_info, select_spec,group_category_id,stock_number,warn_line
)
values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{specId,jdbcType=INTEGER},
#{sourcePath,jdbcType=VARCHAR}, #{brandId,jdbcType=INTEGER}, #{merchantId,jdbcType=VARCHAR},
@@ -132,7 +132,7 @@
#{sort,jdbcType=INTEGER}, #{limitNumber,jdbcType=INTEGER}, #{productScore,jdbcType=INTEGER},
#{status,jdbcType=TINYINT}, #{failMsg,jdbcType=VARCHAR}, #{isRecommend,jdbcType=TINYINT},
#{isHot,jdbcType=TINYINT}, #{isNew,jdbcType=TINYINT}, #{isOnSale,jdbcType=TINYINT},
#{isShow,jdbcType=TINYINT}, #{typeEnum,jdbcType=VARCHAR}, #{isDistribute,jdbcType=TINYINT},
#{isShow,jdbcType=TINYINT}, #{typeEnum,jdbcType=VARCHAR},
#{isDel,jdbcType=TINYINT}, #{isStock,jdbcType=TINYINT}, #{isPauseSale,jdbcType=TINYINT},
#{isFreeFreight,jdbcType=TINYINT}, #{freightId,jdbcType=BIGINT}, #{strategyType,jdbcType=VARCHAR},
#{strategyId,jdbcType=INTEGER}, #{isVip,jdbcType=TINYINT}, #{isDelete,jdbcType=TINYINT},
@@ -145,8 +145,7 @@
#{enableLabel,jdbcType=TINYINT}, #{taxConfigId,jdbcType=VARCHAR}, #{specTableHeaders,jdbcType=VARCHAR},
#{images,jdbcType=LONGVARCHAR}, #{video,jdbcType=LONGVARCHAR}, #{notice,jdbcType=LONGVARCHAR},
#{groupSnap,jdbcType=LONGVARCHAR}, #{specInfo,jdbcType=LONGVARCHAR}, #{selectSpec,jdbcType=LONGVARCHAR},
#{groupCategoryId,jdbcType=VARCHAR},#{stockNumber,jdbcType=INTEGER},
#{groupCategoryId,jdbcType=VARCHAR},#{stockNumber,jdbcType=INTEGER}
#{groupCategoryId,jdbcType=VARCHAR},#{stockNumber,jdbcType=INTEGER},#{warnLine,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
@@ -239,9 +238,6 @@
<if test="typeEnum != null">
type_enum,
</if>
<if test="isDistribute != null">
is_distribute,
</if>
<if test="isDel != null">
is_del,
</if>
@@ -356,6 +352,9 @@
<if test="stockNumber != null">
stock_number,
</if>
<if test="warnLine != null">
warn_line,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@@ -445,9 +444,6 @@
<if test="typeEnum != null">
#{typeEnum,jdbcType=VARCHAR},
</if>
<if test="isDistribute != null">
#{isDistribute,jdbcType=TINYINT},
</if>
<if test="isDel != null">
#{isDel,jdbcType=TINYINT},
</if>
@@ -556,12 +552,15 @@
<if test="selectSpec != null">
#{selectSpec,jdbcType=LONGVARCHAR},
</if>
<if test="groupCategoryId != null">
#{groupCategoryId,jdbcType=VARCHAR},
</if>
<if test="stockNumber != null">
#{stockNumber,jdbcType=INTEGER},
</if>
<if test="groupCategoryId != null">
#{groupCategoryId,jdbcType=VARCHAR},
</if>
<if test="stockNumber != null">
#{stockNumber,jdbcType=INTEGER},
</if>
<if test="warnLine != null">
#{warnLine,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
@@ -651,9 +650,6 @@
<if test="typeEnum != null">
type_enum = #{typeEnum,jdbcType=VARCHAR},
</if>
<if test="isDistribute != null">
is_distribute = #{isDistribute,jdbcType=TINYINT},
</if>
<if test="isDel != null">
is_del = #{isDel,jdbcType=TINYINT},
</if>
@@ -768,143 +764,146 @@
<if test="stockNumber != null">
stock_number = #{stockNumber,jdbcType=INTEGER},
</if>
<if test="warnLine != null">
warn_line = #{warnLine,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
update tb_product
set category_id = #{categoryId,jdbcType=VARCHAR},
spec_id = #{specId,jdbcType=INTEGER},
source_path = #{sourcePath,jdbcType=VARCHAR},
brand_id = #{brandId,jdbcType=INTEGER},
merchant_id = #{merchantId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
short_title = #{shortTitle,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
pack_fee = #{packFee,jdbcType=DECIMAL},
low_price = #{lowPrice,jdbcType=DECIMAL},
low_member_price = #{lowMemberPrice,jdbcType=DECIMAL},
unit_id = #{unitId,jdbcType=VARCHAR},
unit_snap = #{unitSnap,jdbcType=VARCHAR},
cover_img = #{coverImg,jdbcType=VARCHAR},
share_img = #{shareImg,jdbcType=VARCHAR},
video_cover_img = #{videoCoverImg,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
limit_number = #{limitNumber,jdbcType=INTEGER},
product_score = #{productScore,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
fail_msg = #{failMsg,jdbcType=VARCHAR},
is_recommend = #{isRecommend,jdbcType=TINYINT},
is_hot = #{isHot,jdbcType=TINYINT},
is_new = #{isNew,jdbcType=TINYINT},
is_on_sale = #{isOnSale,jdbcType=TINYINT},
is_show = #{isShow,jdbcType=TINYINT},
type_enum = #{typeEnum,jdbcType=VARCHAR},
is_distribute = #{isDistribute,jdbcType=TINYINT},
is_del = #{isDel,jdbcType=TINYINT},
is_stock = #{isStock,jdbcType=TINYINT},
is_pause_sale = #{isPauseSale,jdbcType=TINYINT},
is_free_freight = #{isFreeFreight,jdbcType=TINYINT},
freight_id = #{freightId,jdbcType=BIGINT},
strategy_type = #{strategyType,jdbcType=VARCHAR},
strategy_id = #{strategyId,jdbcType=INTEGER},
is_vip = #{isVip,jdbcType=TINYINT},
is_delete = #{isDelete,jdbcType=TINYINT},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
base_sales_number = #{baseSalesNumber,jdbcType=DOUBLE},
real_sales_number = #{realSalesNumber,jdbcType=INTEGER},
sales_number = #{salesNumber,jdbcType=INTEGER},
thumb_count = #{thumbCount,jdbcType=INTEGER},
store_count = #{storeCount,jdbcType=INTEGER},
furnish_meal = #{furnishMeal,jdbcType=INTEGER},
furnish_express = #{furnishExpress,jdbcType=INTEGER},
furnish_draw = #{furnishDraw,jdbcType=INTEGER},
furnish_vir = #{furnishVir,jdbcType=INTEGER},
is_combo = #{isCombo,jdbcType=TINYINT},
is_show_cash = #{isShowCash,jdbcType=TINYINT},
is_show_mall = #{isShowMall,jdbcType=TINYINT},
is_need_examine = #{isNeedExamine,jdbcType=TINYINT},
show_on_mall_status = #{showOnMallStatus,jdbcType=TINYINT},
show_on_mall_time = #{showOnMallTime,jdbcType=BIGINT},
show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR},
enable_label = #{enableLabel,jdbcType=TINYINT},
tax_config_id = #{taxConfigId,jdbcType=VARCHAR},
spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR},
images = #{images,jdbcType=LONGVARCHAR},
video = #{video,jdbcType=LONGVARCHAR},
notice = #{notice,jdbcType=LONGVARCHAR},
group_snap = #{groupSnap,jdbcType=LONGVARCHAR},
spec_info = #{specInfo,jdbcType=LONGVARCHAR},
select_spec = #{selectSpec,jdbcType=LONGVARCHAR},
group_category_id = #{groupCategoryId,jdbcType=VARCHAR},
stock_number = #{stockNumber,jdbcType=INTEGER}
set category_id = #{categoryId,jdbcType=VARCHAR},
spec_id = #{specId,jdbcType=INTEGER},
source_path = #{sourcePath,jdbcType=VARCHAR},
brand_id = #{brandId,jdbcType=INTEGER},
merchant_id = #{merchantId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
short_title = #{shortTitle,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
pack_fee = #{packFee,jdbcType=DECIMAL},
low_price = #{lowPrice,jdbcType=DECIMAL},
low_member_price = #{lowMemberPrice,jdbcType=DECIMAL},
unit_id = #{unitId,jdbcType=VARCHAR},
unit_snap = #{unitSnap,jdbcType=VARCHAR},
cover_img = #{coverImg,jdbcType=VARCHAR},
share_img = #{shareImg,jdbcType=VARCHAR},
video_cover_img = #{videoCoverImg,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
limit_number = #{limitNumber,jdbcType=INTEGER},
product_score = #{productScore,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
fail_msg = #{failMsg,jdbcType=VARCHAR},
is_recommend = #{isRecommend,jdbcType=TINYINT},
is_hot = #{isHot,jdbcType=TINYINT},
is_new = #{isNew,jdbcType=TINYINT},
is_on_sale = #{isOnSale,jdbcType=TINYINT},
is_show = #{isShow,jdbcType=TINYINT},
type_enum = #{typeEnum,jdbcType=VARCHAR},
is_del = #{isDel,jdbcType=TINYINT},
is_stock = #{isStock,jdbcType=TINYINT},
is_pause_sale = #{isPauseSale,jdbcType=TINYINT},
is_free_freight = #{isFreeFreight,jdbcType=TINYINT},
freight_id = #{freightId,jdbcType=BIGINT},
strategy_type = #{strategyType,jdbcType=VARCHAR},
strategy_id = #{strategyId,jdbcType=INTEGER},
is_vip = #{isVip,jdbcType=TINYINT},
is_delete = #{isDelete,jdbcType=TINYINT},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
base_sales_number = #{baseSalesNumber,jdbcType=DOUBLE},
real_sales_number = #{realSalesNumber,jdbcType=INTEGER},
sales_number = #{salesNumber,jdbcType=INTEGER},
thumb_count = #{thumbCount,jdbcType=INTEGER},
store_count = #{storeCount,jdbcType=INTEGER},
furnish_meal = #{furnishMeal,jdbcType=INTEGER},
furnish_express = #{furnishExpress,jdbcType=INTEGER},
furnish_draw = #{furnishDraw,jdbcType=INTEGER},
furnish_vir = #{furnishVir,jdbcType=INTEGER},
is_combo = #{isCombo,jdbcType=TINYINT},
is_show_cash = #{isShowCash,jdbcType=TINYINT},
is_show_mall = #{isShowMall,jdbcType=TINYINT},
is_need_examine = #{isNeedExamine,jdbcType=TINYINT},
show_on_mall_status = #{showOnMallStatus,jdbcType=TINYINT},
show_on_mall_time = #{showOnMallTime,jdbcType=BIGINT},
show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR},
enable_label = #{enableLabel,jdbcType=TINYINT},
tax_config_id = #{taxConfigId,jdbcType=VARCHAR},
spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR},
images = #{images,jdbcType=LONGVARCHAR},
video = #{video,jdbcType=LONGVARCHAR},
notice = #{notice,jdbcType=LONGVARCHAR},
group_snap = #{groupSnap,jdbcType=LONGVARCHAR},
spec_info = #{specInfo,jdbcType=LONGVARCHAR},
select_spec = #{selectSpec,jdbcType=LONGVARCHAR},
group_category_id = #{groupCategoryId,jdbcType=VARCHAR},
stock_number = #{stockNumber,jdbcType=INTEGER},
warn_line = #{warnLine,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProduct">
update tb_product
set category_id = #{categoryId,jdbcType=VARCHAR},
spec_id = #{specId,jdbcType=INTEGER},
source_path = #{sourcePath,jdbcType=VARCHAR},
brand_id = #{brandId,jdbcType=INTEGER},
merchant_id = #{merchantId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
short_title = #{shortTitle,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
pack_fee = #{packFee,jdbcType=DECIMAL},
low_price = #{lowPrice,jdbcType=DECIMAL},
low_member_price = #{lowMemberPrice,jdbcType=DECIMAL},
unit_id = #{unitId,jdbcType=VARCHAR},
unit_snap = #{unitSnap,jdbcType=VARCHAR},
cover_img = #{coverImg,jdbcType=VARCHAR},
share_img = #{shareImg,jdbcType=VARCHAR},
video_cover_img = #{videoCoverImg,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
limit_number = #{limitNumber,jdbcType=INTEGER},
product_score = #{productScore,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
fail_msg = #{failMsg,jdbcType=VARCHAR},
is_recommend = #{isRecommend,jdbcType=TINYINT},
is_hot = #{isHot,jdbcType=TINYINT},
is_new = #{isNew,jdbcType=TINYINT},
is_on_sale = #{isOnSale,jdbcType=TINYINT},
is_show = #{isShow,jdbcType=TINYINT},
type_enum = #{typeEnum,jdbcType=VARCHAR},
is_distribute = #{isDistribute,jdbcType=TINYINT},
is_del = #{isDel,jdbcType=TINYINT},
is_stock = #{isStock,jdbcType=TINYINT},
is_pause_sale = #{isPauseSale,jdbcType=TINYINT},
is_free_freight = #{isFreeFreight,jdbcType=TINYINT},
freight_id = #{freightId,jdbcType=BIGINT},
strategy_type = #{strategyType,jdbcType=VARCHAR},
strategy_id = #{strategyId,jdbcType=INTEGER},
is_vip = #{isVip,jdbcType=TINYINT},
is_delete = #{isDelete,jdbcType=TINYINT},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
base_sales_number = #{baseSalesNumber,jdbcType=DOUBLE},
real_sales_number = #{realSalesNumber,jdbcType=INTEGER},
sales_number = #{salesNumber,jdbcType=INTEGER},
thumb_count = #{thumbCount,jdbcType=INTEGER},
store_count = #{storeCount,jdbcType=INTEGER},
furnish_meal = #{furnishMeal,jdbcType=INTEGER},
furnish_express = #{furnishExpress,jdbcType=INTEGER},
furnish_draw = #{furnishDraw,jdbcType=INTEGER},
furnish_vir = #{furnishVir,jdbcType=INTEGER},
is_combo = #{isCombo,jdbcType=TINYINT},
is_show_cash = #{isShowCash,jdbcType=TINYINT},
is_show_mall = #{isShowMall,jdbcType=TINYINT},
is_need_examine = #{isNeedExamine,jdbcType=TINYINT},
show_on_mall_status = #{showOnMallStatus,jdbcType=TINYINT},
show_on_mall_time = #{showOnMallTime,jdbcType=BIGINT},
show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR},
enable_label = #{enableLabel,jdbcType=TINYINT},
tax_config_id = #{taxConfigId,jdbcType=VARCHAR},
spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR},
group_category_id = #{groupCategoryId,jdbcType=VARCHAR},
stock_number = #{stockNumber,jdbcType=INTEGER}
set category_id = #{categoryId,jdbcType=VARCHAR},
spec_id = #{specId,jdbcType=INTEGER},
source_path = #{sourcePath,jdbcType=VARCHAR},
brand_id = #{brandId,jdbcType=INTEGER},
merchant_id = #{merchantId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
short_title = #{shortTitle,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
pack_fee = #{packFee,jdbcType=DECIMAL},
low_price = #{lowPrice,jdbcType=DECIMAL},
low_member_price = #{lowMemberPrice,jdbcType=DECIMAL},
unit_id = #{unitId,jdbcType=VARCHAR},
unit_snap = #{unitSnap,jdbcType=VARCHAR},
cover_img = #{coverImg,jdbcType=VARCHAR},
share_img = #{shareImg,jdbcType=VARCHAR},
video_cover_img = #{videoCoverImg,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
limit_number = #{limitNumber,jdbcType=INTEGER},
product_score = #{productScore,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
fail_msg = #{failMsg,jdbcType=VARCHAR},
is_recommend = #{isRecommend,jdbcType=TINYINT},
is_hot = #{isHot,jdbcType=TINYINT},
is_new = #{isNew,jdbcType=TINYINT},
is_on_sale = #{isOnSale,jdbcType=TINYINT},
is_show = #{isShow,jdbcType=TINYINT},
type_enum = #{typeEnum,jdbcType=VARCHAR},
is_del = #{isDel,jdbcType=TINYINT},
is_stock = #{isStock,jdbcType=TINYINT},
is_pause_sale = #{isPauseSale,jdbcType=TINYINT},
is_free_freight = #{isFreeFreight,jdbcType=TINYINT},
freight_id = #{freightId,jdbcType=BIGINT},
strategy_type = #{strategyType,jdbcType=VARCHAR},
strategy_id = #{strategyId,jdbcType=INTEGER},
is_vip = #{isVip,jdbcType=TINYINT},
is_delete = #{isDelete,jdbcType=TINYINT},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
base_sales_number = #{baseSalesNumber,jdbcType=DOUBLE},
real_sales_number = #{realSalesNumber,jdbcType=INTEGER},
sales_number = #{salesNumber,jdbcType=INTEGER},
thumb_count = #{thumbCount,jdbcType=INTEGER},
store_count = #{storeCount,jdbcType=INTEGER},
furnish_meal = #{furnishMeal,jdbcType=INTEGER},
furnish_express = #{furnishExpress,jdbcType=INTEGER},
furnish_draw = #{furnishDraw,jdbcType=INTEGER},
furnish_vir = #{furnishVir,jdbcType=INTEGER},
is_combo = #{isCombo,jdbcType=TINYINT},
is_show_cash = #{isShowCash,jdbcType=TINYINT},
is_show_mall = #{isShowMall,jdbcType=TINYINT},
is_need_examine = #{isNeedExamine,jdbcType=TINYINT},
show_on_mall_status = #{showOnMallStatus,jdbcType=TINYINT},
show_on_mall_time = #{showOnMallTime,jdbcType=BIGINT},
show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR},
enable_label = #{enableLabel,jdbcType=TINYINT},
tax_config_id = #{taxConfigId,jdbcType=VARCHAR},
spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR},
group_category_id = #{groupCategoryId,jdbcType=VARCHAR},
stock_number = #{stockNumber,jdbcType=INTEGER},
warn_line = #{warnLine,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="upGroupRealSalesNumber">
@@ -1001,7 +1000,7 @@
</select>
<select id="selectByCodeAndSkuId" resultType="java.lang.Integer">
SELECT
IFNULL(t.number, 0 )
SUM(IFNULL(t.number, 0 ))
FROM
tb_cashier_cart t
WHERE

View File

@@ -16,7 +16,6 @@
<result column="strategy_price" jdbcType="DECIMAL" property="strategyPrice" />
<result column="stock_number" jdbcType="DOUBLE" property="stockNumber" />
<result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
<result column="warn_line" jdbcType="INTEGER" property="warnLine" />
<result column="weight" jdbcType="DOUBLE" property="weight" />
<result column="volume" jdbcType="REAL" property="volume" />
<result column="real_sales_number" jdbcType="DOUBLE" property="realSalesNumber" />
@@ -34,7 +33,7 @@
</resultMap>
<sql id="Base_Column_List">
id, shop_id, bar_code, product_id, origin_price, cost_price, member_price, meal_price,
sale_price, guide_price,suit, strategy_price, stock_number, cover_img, warn_line, weight,
sale_price, guide_price,suit, strategy_price, stock_number, cover_img, weight,
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale ,is_del,is_grounding
</sql>
<sql id="Blob_Column_List">
@@ -70,7 +69,7 @@
#{productId,jdbcType=VARCHAR}, #{originPrice,jdbcType=DECIMAL}, #{costPrice,jdbcType=DECIMAL},
#{memberPrice,jdbcType=DECIMAL}, #{mealPrice,jdbcType=DECIMAL}, #{salePrice,jdbcType=DECIMAL},
#{guidePrice,jdbcType=DECIMAL}, #{strategyPrice,jdbcType=DECIMAL}, #{stockNumber,jdbcType=DOUBLE},
#{coverImg,jdbcType=VARCHAR}, #{warnLine,jdbcType=INTEGER}, #{weight,jdbcType=DOUBLE},
#{coverImg,jdbcType=VARCHAR}, #{weight,jdbcType=DOUBLE},
#{volume,jdbcType=REAL}, #{realSalesNumber,jdbcType=DOUBLE}, #{firstShared,jdbcType=DECIMAL},
#{secondShared,jdbcType=DECIMAL}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
#{specInfo,jdbcType=LONGVARCHAR}, #{specSnap,jdbcType=LONGVARCHAR}),
@@ -118,9 +117,6 @@
<if test="coverImg != null">
cover_img,
</if>
<if test="warnLine != null">
warn_line,
</if>
<if test="weight != null">
weight,
</if>
@@ -192,9 +188,6 @@
<if test="coverImg != null">
#{coverImg,jdbcType=VARCHAR},
</if>
<if test="warnLine != null">
#{warnLine,jdbcType=INTEGER},
</if>
<if test="weight != null">
#{weight,jdbcType=DOUBLE},
</if>
@@ -266,9 +259,6 @@
<if test="coverImg != null">
cover_img = #{coverImg,jdbcType=VARCHAR},
</if>
<if test="warnLine != null">
warn_line = #{warnLine,jdbcType=INTEGER},
</if>
<if test="weight != null">
weight = #{weight,jdbcType=DOUBLE},
</if>
@@ -316,7 +306,6 @@
strategy_price = #{strategyPrice,jdbcType=DECIMAL},
stock_number = #{stockNumber,jdbcType=DOUBLE},
cover_img = #{coverImg,jdbcType=VARCHAR},
warn_line = #{warnLine,jdbcType=INTEGER},
weight = #{weight,jdbcType=DOUBLE},
volume = #{volume,jdbcType=REAL},
real_sales_number = #{realSalesNumber,jdbcType=DOUBLE},
@@ -343,7 +332,6 @@
strategy_price = #{strategyPrice,jdbcType=DECIMAL},
stock_number = #{stockNumber,jdbcType=DOUBLE},
cover_img = #{coverImg,jdbcType=VARCHAR},
warn_line = #{warnLine,jdbcType=INTEGER},
weight = #{weight,jdbcType=DOUBLE},
volume = #{volume,jdbcType=REAL},
real_sales_number = #{realSalesNumber,jdbcType=DOUBLE},

View File

@@ -54,6 +54,11 @@
<result column="districts" jdbcType="VARCHAR" property="districts"/>
<result column="is_custom" jdbcType="VARCHAR" property="isCustom" />
<result column="is_table_fee" jdbcType="TINYINT" property="isTableFee" />
<result column="table_fee" jdbcType="DECIMAL" property="tableFee" />
<result column="eat_model" jdbcType="VARCHAR" property="eatModel" />
<result column="small_qrcode" jdbcType="VARCHAR" property="smallQrcode" />
<result column="payment_qrcode" jdbcType="VARCHAR" property="paymentQrcode" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
type="com.chaozhanggui.system.cashierservice.entity.TbShopInfo">
@@ -66,7 +71,8 @@
detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type,
industry, industry_name, business_start_day,business_end_day,business_time, post_time, post_amount_line, on_sale, settle_type,
settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number,
distribute_level, created_at, updated_at, proxy_id, shop_qrcode, tag,is_open_yhq,is_use_vip,provinces,cities,districts,is_custom
distribute_level, created_at, updated_at, proxy_id, shop_qrcode, tag,is_open_yhq,is_use_vip,provinces,cities,districts,is_custom,
is_table_fee,table_fee,eat_model,small_qrcode,payment_qrcode
</sql>
<sql id="Blob_Column_List">
view

View File

@@ -31,12 +31,13 @@
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="mini_open_id" jdbcType="VARCHAR" property="miniOpenId" />
<result column="join_time" jdbcType="VARCHAR" property="joinTime" />
</resultMap>
<sql id="Base_Column_List">
id, amount, credit_amount, consume_amount, consume_number, level_consume, status,
merchant_id, shop_id, user_id, parent_id, parent_level, name, head_img, sex, birth_day,
telephone, is_vip, code, is_attention, attention_at, is_shareholder, level, distribute_type,
sort, created_at, updated_at, mini_open_id,dynamic_code
sort, created_at, updated_at, mini_open_id,dynamic_code,join_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
@@ -74,7 +75,7 @@
code, is_attention, attention_at,
is_shareholder, level, distribute_type,
sort, created_at, updated_at,
mini_open_id)
mini_open_id,join_time)
values (#{id,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{creditAmount,jdbcType=DECIMAL},
#{consumeAmount,jdbcType=DECIMAL}, #{consumeNumber,jdbcType=INTEGER}, #{levelConsume,jdbcType=DECIMAL},
#{status,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR},
@@ -84,7 +85,7 @@
#{code,jdbcType=VARCHAR}, #{isAttention,jdbcType=TINYINT}, #{attentionAt,jdbcType=INTEGER},
#{isShareholder,jdbcType=TINYINT}, #{level,jdbcType=TINYINT}, #{distributeType,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
#{miniOpenId,jdbcType=VARCHAR})
#{miniOpenId,jdbcType=VARCHAR},#{joinTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
insert into tb_shop_user
@@ -173,6 +174,9 @@
<if test="miniOpenId != null">
mini_open_id,
</if>
<if test="joinTime != null">
join_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@@ -259,6 +263,9 @@
<if test="miniOpenId != null">
#{miniOpenId,jdbcType=VARCHAR},
</if>
<if test="joinTime != null">
#{joinTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
@@ -354,6 +361,9 @@
<if test="miniOpenId != null">
mini_open_id = #{miniOpenId,jdbcType=VARCHAR},
</if>
<if test="joinTime != null">
join_time = #{joinTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@@ -385,6 +395,7 @@
sort = #{sort,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
join_time = #{joinTime,jdbcType=TIMESTAMP},
mini_open_id = #{miniOpenId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
@@ -418,6 +429,10 @@
select * from tb_shop_user where user_id=#{userId} and is_vip = 1
</select>
<select id="countAmount" resultType="BigDecimal">
select sum(amount) from tb_shop_user where user_id=#{userId} and is_vip = 1
</select>
<select id="selectByOpenId" resultType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
select * from tb_shop_user where mini_open_id = #{openId}
</select>

View File

@@ -0,0 +1,32 @@
#指定要加载的模块列表
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
#日志消息格式的实现类
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#指定日志输出 到控制台
#appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
#指定日志输出到 SLF4J 日志框架
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
#指定日志输出到 file文件
appender=com.p6spy.engine.spy.appender.FileLogger
#定义日志文件的名称。
logfile=sql.log
#是否注销 JDBC 驱动程序(默认不注销)
#deregisterdrivers=true
#设置是否在日志消息前添加前缀
useprefix=true
#指定要排除的日志类别,不记录这些类别的日志
excludecategories=info,debug,result,commit,resultset
#设置日志条目的日期时间格式
dateformat=yyyy-MM-dd HH:mm:ss
#定义数据库方言的时间戳格式。
databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss
#指定 JDBC 驱动程序列表
#driverlist=org.h2.Driver
#启用故障检测
outagedetection=true
#设置故障检测的时间间隔(单位:分钟)
outagedetectioninterval=2
#启用 SQL 过滤功能
filter=true
#排除记录包含 "SELECT 1" 的 SQL 查询
exclude=SELECT 1