diff --git a/pom.xml b/pom.xml index 2ea4374..ca2656e 100644 --- a/pom.xml +++ b/pom.xml @@ -20,11 +20,23 @@ + + + org.springframework.boot + spring-boot-starter-test + test + + com.belerweb pinyin4j 2.5.1 + + p6spy + p6spy + 3.8.2 + org.apache.commons commons-lang3 @@ -102,6 +114,22 @@ 1.3.5 + + com.baomidou + mybatis-plus-boot-starter + 3.3.1 + + + org.mybatis + mybatis-spring + + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.springframework.boot spring-boot-starter-validation @@ -203,6 +231,12 @@ io.netty netty-all + + + com.alipay.sdk + alipay-sdk-java + 4.39.165.ALL + org.springframework.boot spring-boot-starter-amqp @@ -214,6 +248,11 @@ weixin-java-miniapp 3.8.0 + + junit + junit + test + @@ -273,4 +312,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/alipayUtil/AlipayUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/alipayUtil/AlipayUtil.java new file mode 100644 index 0000000..7617b8f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/alipayUtil/AlipayUtil.java @@ -0,0 +1,134 @@ +package com.chaozhanggui.system.cashierservice.alipayUtil; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.AlipayConfig; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.internal.util.AlipayEncrypt; +import com.alipay.api.request.AlipaySystemOauthTokenRequest; +import com.alipay.api.response.AlipaySystemOauthTokenResponse; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * 支付宝通用SDK工具类 + * + * @author tankaikai + * @since 2024-09-23 16:15 + */ + +@Slf4j +@Component +public class AlipayUtil { + + /** + * 网关地址 线上:https://openapi.alipay.com/gateway.do 沙箱:https://openapi.alipaydev.com/gateway.do + */ + @Value("${alipay.sdk.config.serverUrl}") + private String serverUrl; + /** + * 应用ID + */ + @Value("${alipay.sdk.config.appId}") + private String appId; + /** + * 应用私钥 + */ + @Value("${alipay.sdk.config.privateKey}") + private String privateKey; + /** + * 支付宝公钥 + */ + @Value("${alipay.sdk.config.alipayPublicKey}") + private String alipayPublicKey; + /** + * 支付宝公钥 + */ + @Value("${alipay.sdk.config.encryptKey}") + private String encryptKey; + + /** + * 创建支付宝客户端 + * @return AlipayClient + */ + @SneakyThrows + public AlipayClient createClient() { + AlipayConfig alipayConfig = new AlipayConfig(); + //设置网关地址 + alipayConfig.setServerUrl(serverUrl); + //设置应用ID + alipayConfig.setAppId(appId); + //设置应用私钥 + alipayConfig.setPrivateKey(privateKey); + //设置支付宝公钥 + alipayConfig.setAlipayPublicKey(alipayPublicKey); + return new DefaultAlipayClient(alipayConfig); + } + + /** + * 获取支付宝用户的openId + * @param code 用户信息授权码 + * @return openId + */ + public String getOpenId(String code) throws Exception{ + AlipaySystemOauthTokenRequest req = new AlipaySystemOauthTokenRequest(); + //SDK已经封装掉了公共参数,这里只需要传入业务参数 + req.setCode(code); + req.setGrantType("authorization_code"); + //此次只是参数展示,未进行字符串转义,实际情况下请转义 + //req.setBizContent(" {" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }"); + AlipaySystemOauthTokenResponse response; + try { + response = createClient().execute(req); + }catch (AlipayApiException e){ + log.error("获取支付宝用户信息失败,错误码:{},错误信息:{}", e.getErrCode(), e.getErrMsg()); + throw e; + } + log.info("获取支付宝用户信息成功,返回结果:{}", response.getBody()); + //调用失败 + if (!response.isSuccess()) { + log.error("获取支付宝用户信息失败,错误码:{},错误信息:{}", response.getSubCode(), response.getSubMsg()); + throw new AlipayApiException(response.getSubCode(), response.getSubMsg()); + } + //调用成功,则处理业务逻辑,为配合支付系统确定沿用支付宝的老标准使用userId + return response.getUserId(); + } + + /** + * 获取支付宝用户的手机号码 + * @param encryptedData 密文 + * @return mobile + */ + public String getMobile(String encryptedData) throws Exception{ + if(StrUtil.isEmpty(encryptedData)){ + throw new AlipayApiException("加密数据不能为空"); + } + try { + log.info("解密前的数据,返回结果:{}", encryptedData); + String resp = AlipayEncrypt.decryptContent(encryptedData, "AES", encryptKey, "UTF-8"); + log.info("解密后的数据,返回结果:{}", resp); + boolean isJson = JSONUtil.isJson(resp); + if(!isJson){ + throw new AlipayApiException("解密后的数据不是json格式"); + } + JSONObject jsonObject = JSONUtil.parseObj(resp); + String code = jsonObject.getStr("code"); + String msg = jsonObject.getStr("msg"); + String mobile = jsonObject.getStr("mobile"); + if("10000".equals(code)){ + return mobile; + }else{ + throw new AlipayApiException(code,msg); + } + }catch (AlipayApiException e){ + log.error("获取支付宝用户的手机号码失败,错误码:{},错误信息:{}", e.getErrCode(), e.getErrMsg()); + throw e; + } + } + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/AuthSource.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/AuthSource.java new file mode 100644 index 0000000..11b952e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/AuthSource.java @@ -0,0 +1,35 @@ +package com.chaozhanggui.system.cashierservice.auth; + +/** + * 三方登录认证来源 + * @author tankaikai + * @since 2024-09-23 17:51 + */ +public enum AuthSource { + WECHAT("微信", "wechat"), + ALIPAY("支付宝", "alipay"); + + private String name; + private String value; + + AuthSource(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java index d2d0f9c..cb6cfc2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java @@ -49,6 +49,7 @@ public class LoginFilter implements Filter { // "cashierService/login/**",//登录部分接口不校验 "cashierService/login/wx/**",//登录部分接口不校验 + "cashierService/login/auth/**",//登录部分接口不校验 "cashierService/login/app/login",//登录部分接口不校验 "cashierService/product/queryProduct", "cashierService/product/queryProductSku", @@ -94,7 +95,7 @@ public class LoginFilter implements Filter { return; } - //environment 环境标识 wx app 后续environment不可为空 + //environment 环境标识 wx alipay app 后续environment不可为空 String environment = request.getHeader("environment"); // 判断用户TOKEN是否存在 @@ -130,7 +131,7 @@ public class LoginFilter implements Filter { String userId = jsonObject1.getString("userId"); tokenKey=RedisCst.ONLINE_APP_USER.concat(userId); //获取redis中的token - }else if(environment.equals("wx")){ + }else if(environment.equals("wx") || environment.equals("alipay")){ //获取当前登录人的用户id String openId = jsonObject1.getString("openId"); if(StringUtils.isBlank(openId)){ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/config/MyBatisPlusConfig.java b/src/main/java/com/chaozhanggui/system/cashierservice/config/MyBatisPlusConfig.java new file mode 100644 index 0000000..253f70e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/config/MyBatisPlusConfig.java @@ -0,0 +1,12 @@ +package com.chaozhanggui.system.cashierservice.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +@Configuration +public class MyBatisPlusConfig { + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/config/RequestLoggingConfig.java b/src/main/java/com/chaozhanggui/system/cashierservice/config/RequestLoggingConfig.java new file mode 100644 index 0000000..e5207cf --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/config/RequestLoggingConfig.java @@ -0,0 +1,30 @@ +package com.chaozhanggui.system.cashierservice.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.web.filter.CommonsRequestLoggingFilter; + +@Configuration +public class RequestLoggingConfig { + @Bean + @Order(-9999) + public CommonsRequestLoggingFilter logFilter() { + CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter(); + // 是否记录请求的查询参数信息 + filter.setIncludeQueryString(true); + // 是否记录请求body内容 + filter.setIncludePayload(true); + filter.setMaxPayloadLength(10000); + //是否记录请求header信息 + filter.setIncludeHeaders(false); + // 是否记录请求客户端信息 + filter.setIncludeClientInfo(true); + // 设置日期记录的前缀 + filter.setBeforeMessagePrefix("\033[32;4m请求开始:"); + filter.setBeforeMessageSuffix("\033[0m"); + filter.setAfterMessagePrefix("\033[34m请求结束:"); + filter.setAfterMessageSuffix("\033[0m"); + return filter; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/constant/TableConstant.java b/src/main/java/com/chaozhanggui/system/cashierservice/constant/TableConstant.java new file mode 100644 index 0000000..34717e0 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/constant/TableConstant.java @@ -0,0 +1,153 @@ +package com.chaozhanggui.system.cashierservice.constant; + +import io.netty.handler.codec.http2.Http2FrameStreamEvent; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +import java.util.Objects; + +public interface TableConstant { + String CART_SEAT_ID = "-999"; + + class ShopTable { + @Getter + public enum State { + IDLE("idle"), CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using"), CLEANING("cleaning"); + private final String value; + + State(String value) { + this.value = value; + } + } + } + + class OrderInfo { + @Getter + public enum Status { + REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"), + UNPAID("unpaid"), PAYING("paying"), RETURN("return"); + private final String value; + + Status(String value) { + this.value = value; + } + } + + @Getter + public enum UseType { + TAKEOUT("takeout"), + DINE_IN_AFTER("dine-in-after"), + DINE_IN_BEFORE("dine-in-before"); + private final String value; + + UseType(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } + + class FreeDineRecord { + @Getter + public enum State { + WAIT_PAY(0), + SUCCESS_PAY(1), + FAIL_PAY(2); + private final Integer value; + + State(Integer value) { + this.value = value; + } + } + + @Getter + public enum UseType { + TAKEOUT("takeout"), + DINE_IN_AFTER("dine-in-after"), + DINE_IN_BEFORE("dine-in-before"); + private final String value; + + UseType(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } + + class ShopInfo { + @Getter + public enum EatModel { + TAKEOUT("takeout"), + DINE_IN("dine-in"); + private final String value; + + EatModel(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } + + class MemberIn { + @Getter + public enum Type { + NORMAL(0), + FREE_DINE(1); + private final Integer value; + + Type(Integer value) { + this.value = value; + } + + public boolean equalsVals(Integer value) { + return Objects.equals(this.value, value); + } + } + } + + class ActivateOutRecord { + @Getter + public enum Type { + // 满减 + FULL_REDUCTION(1), + // 商品 + PRODUCT(2); + private final Integer value; + + Type(Integer value) { + this.value = value; + } + + public boolean equalsVals(Integer value) { + return Objects.equals(this.value, value); + } + } + @Getter + public enum Status { + CREATE("create"), + CANCEL("cancel"), + // 商品 + CLOSED("closed"); + private final String value; + + Status(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } + + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java index 83211ee..c826119 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java @@ -1,11 +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; @@ -24,12 +26,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.Collections; import java.util.List; +import java.util.Map; /** * 通用接口 @@ -50,6 +54,8 @@ public class CommonController { private TbPlatformDictMapper platformDictMapper; @Resource private FileService fileService; + @Resource + private TbShopExtendMapper extendMapper; private final LoginService loginService;; @@ -163,6 +169,21 @@ public class CommonController { return new Result(CodeEnum.SUCCESS, fileService.uploadFile(file)); } + @RequestMapping("common/shopExtend") + public Result getShopExtend(@RequestBody Map map) { + if (CollectionUtils.isEmpty(map) || !map.containsKey("shopId") || !map.containsKey("autokey")) return new Result(CodeEnum.SUCCESS); + return new Result(CodeEnum.SUCCESS, extendMapper.queryByShopIdAndAutoKey(Integer.valueOf(map.get("shopId").toString()),map.get("autokey"))); + } + + /** + * 交班 + */ + @PostMapping("common/handoverData") + public Result handoverData(@RequestBody Map map) throws Exception{ + PushToClientChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(map),map.get("shopId")); + return Result.success(CodeEnum.SUCCESS); + } + // 检查手机号格式是否正确的方法 private boolean isValidPhoneNumber(String phone) { return phone.matches("^1[3-9]\\d{9}$"); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index 8fd3de8..55dc30d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import cn.hutool.core.util.ObjectUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alipay.api.AlipayApiException; +import com.chaozhanggui.system.cashierservice.alipayUtil.AlipayUtil; +import com.chaozhanggui.system.cashierservice.auth.AuthSource; import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper; import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount; import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; @@ -16,10 +18,12 @@ import com.chaozhanggui.system.cashierservice.service.LoginService; import com.chaozhanggui.system.cashierservice.service.OnlineUserService; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; -import com.chaozhanggui.system.cashierservice.util.*; +import com.chaozhanggui.system.cashierservice.util.IpUtil; +import com.chaozhanggui.system.cashierservice.util.MD5Utils; +import com.chaozhanggui.system.cashierservice.util.StringUtil; +import com.chaozhanggui.system.cashierservice.util.TokenUtil; import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -60,28 +64,27 @@ public class LoginContoller { @Autowired RedisUtil redisUtil; + @Resource + AlipayUtil alipayUtil; + @RequestMapping("/wx/business/login") - public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code, - @RequestParam(value = "shopId", required = false) String shopId - ) { + public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code, @RequestParam(value = "shopId", required = false) String shopId) { JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, businessAppId, businessSecrete); String openid = SessionKeyOpenId.getString("openid"); - if(Objects.isNull(openid)){ + if (Objects.isNull(openid)) { return Result.fail("获取微信id失败"); } - return loginService.wxBusinessLogin(openid,shopId); + return loginService.wxBusinessLogin(openid, shopId); } @GetMapping("/wx/business/openId") - public Result getOpenId( - @RequestParam String code - ) { + public Result getOpenId(@RequestParam String code) { JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete); String openid = SessionKeyOpenId.getString("openid"); - if(Objects.isNull(openid)){ + if (Objects.isNull(openid)) { return Result.fail("获取微信id失败"); } @@ -95,50 +98,46 @@ public class LoginContoller { * @param map * @return */ - @RequestMapping("/wx/custom/login") - public Result wxCustomLogin(HttpServletRequest request, @RequestBody Map map) { + @RequestMapping("/auth/custom/login") + public Result authCustomLogin(HttpServletRequest request, @RequestBody Map map) { if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) { Result.fail("code不能为空"); } - String code = map.get("code").toString(); - String rawData = map.get("rawData"); -// String signature = map.get("signature"); -// String encryptedData = map.get("encryptedData"); -// String ivStr = map.get("iv"); -// String phone = map.get("phone"); - // 用户非敏感信息:rawData - // 签名:signature - JSONObject rawDataJson = JSON.parseObject(rawData); - // 1.接收小程序发送的code - // 2.开发者服务器 登录凭证校验接口 appi + appsecret + code - JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete); - // 3.接收微信接口服务 获取返回的参数 - String openid = SessionKeyOpenId.getString("openid"); -// String sessionKey = SessionKeyOpenId.getString("session_key"); - - // 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey) -// String signature2 = DigestUtils.sha1Hex(rawData + sessionKey); -// if (!signature.equals(signature2)) { -// return Result.fail("签名校验失败"); -// } -// String phone = ""; -// try{ -// String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr); -// if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) { -// }// phone =JSONObject.parseObject(data).get("phoneNumber").toString(); -// }catch (Exception e){ -// log.info("登录传参:获取手机号失败{}",e.getMessage()); -// } - String nickName = rawDataJson.getString("nickName"); - String avatarUrl = rawDataJson.getString("avatarUrl"); - try { - return loginService.wxCustomLogin(openid, avatarUrl, nickName, "", IpUtil.getIpAddr(request)); - } catch (Exception e) { - e.printStackTrace(); + // 三方登录来源 wechat、alipay + String source = map.getOrDefault("source",AuthSource.WECHAT.getValue()); + String code = map.get("code"); + if(AuthSource.WECHAT.getValue().equals(source)){ + try { + // 1.接收小程序发送的code + // 2.开发者服务器 登录凭证校验接口 appi + appsecret + code + JSONObject wxResp = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete); + //Integer errCode = wxResp.getInteger("errcode"); + log.info("微信获取openid响应报文:{}", wxResp.toJSONString()); + boolean hasOpenId = wxResp.containsKey("openid"); + if (!hasOpenId) { + return Result.fail("登录失败:" + wxResp.getString("errmsg")); + } + String a = "{\"width\":\"58\",\"printerNum\":\"1\",\"categoryList\":[{\"id\":30,\"name\":\"奶茶\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":35,\"name\":\"酒水饮料\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":65,\"name\":\"火锅\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":95,\"name\":\"串串\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null},{\"id\":96,\"name\":\"烧烤\",\"shortName\":null,\"tree\":null,\"pid\":null,\"pic\":null,\"merchantId\":null,\"shopId\":null,\"style\":null,\"isShow\":null,\"detail\":null,\"sort\":null,\"keyWord\":null,\"createdAt\":null,\"updatedAt\":null}],\"model\":\"normal\",\"feet\":\"0\",\"autoCut\":\"1\"}"; + // 3.接收微信接口服务 获取返回的参数 + String openid = wxResp.getString("openid"); + return loginService.wxCustomLogin(openid, "", "", "", IpUtil.getIpAddr(request)); + } catch (Exception e) { + e.printStackTrace(); + log.error("登录失败:",e); + } + }else if(AuthSource.ALIPAY.getValue().equals(source)){ + try { + String openId = alipayUtil.getOpenId(code); + return loginService.alipayCustomLogin(openId); + }catch (AlipayApiException e){ + log.error("登录失败:",e); + return Result.fail("登录失败:"+e.getErrMsg()); + }catch (Exception e){ + e.printStackTrace(); + log.error("登录失败:",e); + } } - return Result.fail("登录失败"); - } @@ -179,14 +178,28 @@ public class LoginContoller { // return Result.fail("获取手机号失败,请重试!"); // } @RequestMapping("getPhoneNumber") - public Result getPhoneNumber(@RequestHeader String openId,@RequestBody Map map) { - + public Result getPhoneNumber(@RequestHeader String openId, @RequestBody Map map) { + String encryptedData = map.get("encryptedData"); + // 三方登录来源 wechat、alipay + String source = map.getOrDefault("source",AuthSource.WECHAT.getValue()); + if (AuthSource.ALIPAY.getValue().equals(source)) { + try { + String mobile = alipayUtil.getMobile(encryptedData); + return Result.success(CodeEnum.SUCCESS, mobile); + }catch (AlipayApiException e){ + log.error("获取手机号失败:",e); + return Result.fail("获取手机号失败:"+e.getErrMsg()); + }catch (Exception e){ + e.printStackTrace(); + log.error("登录手机号失败:",e); + return Result.fail("获取手机号失败:未知错误"); + } + } if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) { Result.fail("code不能为空"); } - String code = map.get("code").toString(); + String code = map.get("code"); - String encryptedData = map.get("encryptedData"); String ivStr = map.get("iv"); if (StringUtils.isBlank(encryptedData) || StringUtils.isBlank(ivStr)) { @@ -201,14 +214,14 @@ public class LoginContoller { try { if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) { // if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) { - return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber")); + return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber")); // } // log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber")); // return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString()); } - } catch (Exception e){ + } catch (Exception e) { // e.printStackTrace(); - log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,data); + log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},", sessionKey, encryptedData, ivStr, data); } return Result.fail("获取手机号失败,请重试!"); } @@ -254,10 +267,8 @@ public class LoginContoller { * @return */ @GetMapping("createCardNo") - public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id, - @RequestParam("shopId") String shopId - ) { - return loginService.createCardNo(id, openId,shopId); + public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id, @RequestParam("shopId") String shopId) { + return loginService.createCardNo(id, openId, shopId); } @GetMapping("/userInfo") @@ -267,6 +278,7 @@ public class LoginContoller { /** * 更新用户信息 + * * @param token * @param userInfo * @return @@ -281,16 +293,16 @@ public class LoginContoller { } @PostMapping(value = "/upPass") - public Result upPass(@RequestHeader String token,@RequestBody UserPassDto passVo){ + public Result upPass(@RequestHeader String token, @RequestBody UserPassDto passVo) { String userId = TokenUtil.parseParamFromToken(token).getString("userId"); String newPass = MD5Utils.MD5Encode(passVo.getNewPass(), "utf-8"); if (ObjectUtil.isNull(passVo.getCode())) { String oldPass = MD5Utils.MD5Encode(passVo.getOldPass(), "utf-8"); - return loginService.upPass(userId,oldPass, newPass); + return loginService.upPass(userId, oldPass, newPass); } else { boolean tf = loginService.validate(passVo.getCode(), passVo.getPhone()); if (tf) { - TbUserInfo userInfo=new TbUserInfo(); + TbUserInfo userInfo = new TbUserInfo(); userInfo.setId(Integer.valueOf(userId)); userInfo.setPassword(newPass); return loginService.upUserInfo(userInfo); @@ -301,16 +313,16 @@ public class LoginContoller { } @PostMapping(value = "modityPass") - public Result modityPass(@RequestHeader String token,@RequestBody UserPassDto passVo){ + public Result modityPass(@RequestHeader String token, @RequestBody UserPassDto passVo) { String userId = TokenUtil.parseParamFromToken(token).getString("userId"); String newPass = MD5Utils.MD5Encode(passVo.getNewPass(), "utf-8"); if (ObjectUtil.isNull(passVo.getCode())) { String oldPass = MD5Utils.MD5Encode(passVo.getOldPass(), "utf-8"); - return loginService.upPass(userId,oldPass, newPass); + return loginService.upPass(userId, oldPass, newPass); } else { boolean tf = loginService.validate(passVo.getCode(), passVo.getPhone()); if (tf) { - TbUserInfo userInfo=new TbUserInfo(); + TbUserInfo userInfo = new TbUserInfo(); userInfo.setId(Integer.valueOf(userId)); userInfo.setPassword(newPass); return loginService.upUserInfo(userInfo); @@ -359,12 +371,12 @@ public class LoginContoller { } //验证密码 String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8"); - return loginService.appLogin(authUserDto.getUsername(),openid, mdPasswordString); + return loginService.appLogin(authUserDto.getUsername(), openid, mdPasswordString); } else { // tf = true; tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername()); if (tf) { - return loginService.appLogin(authUserDto.getUsername(),openid, null); + return loginService.appLogin(authUserDto.getUsername(), openid, null); } else { return Result.fail("验证码输入有误"); } @@ -393,29 +405,31 @@ public class LoginContoller { /** * 重置资金密码 + * * @param token * @param map * @return */ @RequestMapping("resetPwd") - public Result resetPwd(@RequestHeader String token,@RequestBody Map map){ + public Result resetPwd(@RequestHeader String token, @RequestBody Map map) { String userId = TokenUtil.parseParamFromToken(token).getString("userId"); - return loginService.resetPwd(userId,map); + return loginService.resetPwd(userId, map); } /** * 修改密码 + * * @param token * @param map * @return */ @RequestMapping("mpdifyPwd") - public Result mpdifyPwd(@RequestHeader String token,@RequestBody Map map){ + public Result mpdifyPwd(@RequestHeader String token, @RequestBody Map map) { String userId = TokenUtil.parseParamFromToken(token).getString("userId"); - return loginService.modifyPwd(userId,map); + return loginService.modifyPwd(userId, map); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java index adc35e7..151bcbd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java @@ -4,9 +4,9 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; -import com.chaozhanggui.system.cashierservice.entity.Enum.PayTypeConstant; import com.chaozhanggui.system.cashierservice.interceptor.RequestWrapper; import com.chaozhanggui.system.cashierservice.service.PayService; +import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.DateUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -14,8 +14,8 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.Date; +import java.util.HashMap; import java.util.Map; -import java.util.Random; @CrossOrigin(origins = "*") @RestController @@ -57,7 +57,8 @@ 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.fstMemberInSuccess(orderNo,tradeNo); + String payType=object.getStr("payType"); + return payService.fstMemberInSuccess(orderNo,tradeNo, payType); } } } @@ -66,11 +67,6 @@ public class NotifyController { } - @RequestMapping("test") - public void test(@RequestParam String payOrderNO){ - payService.test(payOrderNO); - } - @RequestMapping("notifyCallBack") public String notifyCallBack(HttpServletRequest request){ @@ -84,6 +80,7 @@ public class NotifyController { && !"0100".equals(object.getStr("payType")) ){ String orderNo=object.getStr("orderNumber"); + return payService.callBackPay(orderNo); } } @@ -91,6 +88,15 @@ public class NotifyController { return null; } + /** + * 支付取消 + * @return 影响数量 + */ + @PostMapping("cancel") + public Result notifyCancel(@RequestBody HashMap data) { + return Result.successWithData(payService.cancelOrder(data.get("orderId"))); + } + @RequestMapping("notifyfstCallBack") public String notifyfstCallBack(HttpServletRequest request){ @@ -104,7 +110,11 @@ public class NotifyController { if("TRADE_SUCCESS".equals(object.get("state").toString())){ String orderNo=object.get("mchOrderNo").toString(); String tradeNo=object.get("payOrderId").toString(); - return payService.callBackPayFST(tradeNo); + String payType=object.getStr("payType"); + return payService.callBackPayFST(tradeNo,payType); + }else { + String tradeNo=object.get("payOrderId").toString(); + return String.valueOf(payService.activateOrder(tradeNo)); } } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java index b43ec8a..be25987 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java @@ -1,15 +1,17 @@ package com.chaozhanggui.system.cashierservice.controller; -import com.chaozhanggui.system.cashierservice.entity.TbShopTable; -import com.chaozhanggui.system.cashierservice.entity.dto.OrderDto; +import cn.hutool.core.util.ObjectUtil; +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; @CrossOrigin(origins = "*") @RestController @@ -17,32 +19,38 @@ import java.text.ParseException; @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()); } + /** - * 订单回显 - * @param orderId - * @return + * 订单详情 + * @param orderId 订单id + * @return 订单信息 */ @GetMapping ("/orderInfo") - private Result orderInfo(@RequestParam(required = false) Integer orderId){ - if (orderId==null) { - return Result.fail("请返回首页订单列表查看"); - } - return orderService.orderInfo(orderId); + public Result getCartByOrderId( + @RequestParam Integer orderId + ){ + return Result.successWithData(orderService.orderDetail(orderId)); } @GetMapping("/orderList") @@ -51,55 +59,11 @@ public class OrderController { return orderService.orderList(userId,page,size,status); } - @GetMapping("/tradeIntegral") - private Result tradeIntegral(@RequestParam("userId") String userId, @RequestParam("id") String id) throws IOException, ParseException { - return orderService.tradeIntegral(userId,id); - } -// @GetMapping("/我的积分") -// private Result mineYhq(@RequestParam("userId") String userId) throws IOException { -// return orderService.mineYhq(userId); -// } - @GetMapping("/mineCoupons") - private Result mineCoupons(@RequestHeader String token, - @RequestParam("userId") String userId, - @RequestParam("status") String status, - @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, - @RequestParam(value = "size", required = false, defaultValue = "1") Integer size, - @RequestParam("orderId") String orderId - ) throws IOException { - return orderService.mineCoupons(userId,orderId,status,page,size); - } - @GetMapping("/findCoupons") - private Result findCoupons(@RequestHeader String token,String type, - @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, - @RequestParam(value = "size", required = false, defaultValue = "1") Integer size) throws IOException { - return orderService.findCoupons(type,page,size); - } - - @GetMapping("/findWiningUser") - private Result findWiningUser(){ - return orderService.findWiningUser(); - } - @GetMapping("/mineWinner") - private Result mineWinner(@RequestHeader String token,@RequestParam Integer userId, - @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, - @RequestParam(value = "size", required = false, defaultValue = "1") Integer size){ - return orderService.mineWinner(userId,page,size); - } - @GetMapping("/getYhqPara") - private Result getYhqPara(){ - return orderService.getYhqPara(); - } - @GetMapping("/getYhqDouble") - private Result getYhqDouble(@RequestParam Integer orderId){ - return orderService.getYhqDouble(orderId); - } - @PostMapping("/yhqDouble") - private Result yhqDouble(@RequestParam Integer conponsId){ - return orderService.yhqDouble(conponsId); - } - @GetMapping("/kc") - private Result kc(){ - return orderService.kc(); + @PostMapping("/rmOrder") + private Result rmOrder(@RequestBody Map map){ + if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("orderId") || ObjectUtil.isEmpty(map.get("orderId"))) { + return Result.fail("订单号不允许为空"); + } + return orderService.rmOrder(Integer.valueOf(map.get("orderId").toString())); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java index 79db6f6..c5c8348 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java @@ -1,7 +1,10 @@ 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.entity.dto.MemberInDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.OrderPayDTO; import com.chaozhanggui.system.cashierservice.service.PayService; import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.IpUtil; @@ -9,11 +12,14 @@ import com.chaozhanggui.system.cashierservice.util.TokenUtil; import com.fasterxml.jackson.core.JsonProcessingException; 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 javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.math.BigDecimal; import java.util.Map; +import java.util.Objects; @CrossOrigin(origins = "*") @RestController @@ -30,20 +36,17 @@ public class PayController { * 支付 * * @param request payType wechatPay:微信支付;aliPay:支付宝支付; - * @param map - * @return */ @RequestMapping("orderPay") @LimitSubmit(key = "orderPay:%s") - public Result pay(HttpServletRequest request, @RequestHeader("openId") String openId, @RequestBody Map map) { - if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("orderId") || ObjectUtil.isEmpty(map.get("orderId"))) { - return Result.fail("订单号不允许为空"); - } - + public Result pay(HttpServletRequest request, @RequestHeader("openId") String openId, @RequestBody OrderPayDTO payDTO) { try { - return payService.payOrder(openId, map.get("orderId"), IpUtil.getIpAddr(request)); + if (ObjectUtil.isEmpty(openId) || Objects.isNull(openId)) { + return Result.fail("付款用户[userId]参数不能为空"); + } + return payService.payOrder(openId, payDTO, IpUtil.getIpAddr(request)); } catch (Exception e) { - e.printStackTrace(); + log.error("支付失败", e); } return Result.fail("支付失败"); } @@ -63,7 +66,7 @@ public class PayController { @RequestParam("memberId") String memberId, @RequestParam("pwd") String pwd ) { - return payService.accountPay(orderId, memberId, token,pwd); + return payService.accountPay(orderId, memberId, token, pwd); } @RequestMapping("groupOrderPay") @@ -77,6 +80,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"); } @@ -124,7 +129,6 @@ public class PayController { @RequestMapping("getActive") public Result getActive( - @RequestHeader("token") String token, @RequestParam("shopId") String shopId, @RequestParam("page") int page, @RequestParam("pageSize") int pageSize) { @@ -137,16 +141,23 @@ public class PayController { * * @param request * @param openId - * @param map - * @return */ @RequestMapping("memeberIn") @LimitSubmit(key = "memeberIn:%s") - public Result memeberIn(HttpServletRequest request, @RequestHeader("openId") String openId, @RequestHeader("id") String id, - @RequestBody Map map - ) { + public Result memeberIn(HttpServletRequest request, + @RequestHeader("openId") String openId, @RequestHeader("id") String id, + @RequestBody @Validated MemberInDTO memberInDTO) { try { - return payService.memberIn(openId, id, map.get("amount").toString(), map.get("shopId").toString(), IpUtil.getIpAddr(request)); + if (memberInDTO.getOrderId() == null && memberInDTO.getAmount() == null) { + return Result.fail("金额和订单id不能同时为空"); + } + + if(memberInDTO.getAmount() != null && memberInDTO.getAmount().compareTo(BigDecimal.ZERO) <= 0) { + return Result.fail("充值金额不能小于等于0"); + } + memberInDTO.setUserId(TokenUtil.getUserId()); + memberInDTO.setOpenId(openId); + return payService.memberIn(memberInDTO, IpUtil.getIpAddr(request)); } catch (JsonProcessingException e) { throw new RuntimeException(e); } @@ -160,7 +171,7 @@ public class PayController { @RequestParam("userId") String userId, @RequestParam("shopId") String shopId ) { - return payService.getShopByMember(userId,shopId,page,pageSize); + return payService.getShopByMember(userId, shopId, page, pageSize); } @RequestMapping("queryMemberAccount") diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java index b36d7d9..77fcd9a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -2,7 +2,12 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.system.cashierservice.constant.TableConstant; +import com.chaozhanggui.system.cashierservice.entity.TbCashierCart; +import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO; import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO; import com.chaozhanggui.system.cashierservice.service.CartService; import com.chaozhanggui.system.cashierservice.service.ProductService; @@ -10,8 +15,13 @@ import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; @CrossOrigin(origins = "*") @@ -36,11 +46,15 @@ public class ProductController { public Result queryShopIdByTableCode( @RequestHeader("openId") String openId, @RequestHeader("id") String userId, - @RequestParam String lat, - @RequestParam String lng, - @RequestParam("code") String code + @RequestParam(required = false) String lat, + @RequestParam(required = false) String lng, + @RequestParam(required = false) String code, + @RequestParam(required = false) Integer shopId ) { - return productService.queryShopIdByTableCode(userId, openId, code,lat,lng); + if (shopId == null && StrUtil.isBlank(code)) { + return Result.fail("参数缺失"); + } + return productService.queryShopIdByTableCode(userId, openId, code,lat,lng, shopId); } /** @@ -50,12 +64,13 @@ public class ProductController { * @return */ @RequestMapping("queryProduct") - public Result queryProduct(@RequestBody Map map) { + public Result queryProduct(@RequestHeader("id") String userId,@RequestBody Map map) { if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("shopId")) { return Result.fail("参数错误"); } return productService.queryProduct( + userId, map.get("shopId").toString(), (map.containsKey("productGroupId") && ObjectUtil.isNotEmpty(map.get("productGroupId"))) ? map.get("productGroupId").toString() : ""); } @@ -81,9 +96,10 @@ public class ProductController { @RequestParam(value = "code", required = false) String code, @RequestParam("shopId") String shopId, @RequestParam("productId") String productId, - @RequestParam("spec_tag") String spec_tag + @RequestParam("spec_tag") String spec_tag, + @RequestParam("isVip") String isVip ) { - return productService.queryProductSku(code,shopId, productId, spec_tag); + return productService.queryProductSku(code,shopId, productId, spec_tag,isVip); } @PostMapping("addCart") @@ -92,6 +108,32 @@ public class ProductController { return cartService.createCart(jsonObject); } + /** + * 餐位费选择 + * @return 餐位费信息 + */ + @PostMapping("/choseCount") + public Result choseCount(@Validated @RequestBody ChoseCountDTO choseCountDTO) { + return Result.success(CodeEnum.SUCCESS, productService.choseCount(choseCountDTO)); + } + + @PostMapping("/choseEatModel") + public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) { + List cashierCartList = cartService.choseEatModel(choseEatModelDTO); + BigDecimal amount = BigDecimal.ZERO; + ArrayList cashierCarts = new ArrayList<>(); + for (TbCashierCart item : cashierCartList) { + if (!TableConstant.CART_SEAT_ID.equals(item.getProductId())) { + cashierCarts.add(item); + } + amount = amount.add(item.getTotalAmount()); + } + HashMap data = new HashMap<>(); + data.put("amount", amount); + data.put("info", cashierCarts); + return Result.success(CodeEnum.SUCCESS, data); + } + @PostMapping("cleanCart") public Result cleanCart(@RequestBody JSONObject jsonObject) { log.info("清空购物车数据:{}", jsonObject); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java new file mode 100644 index 0000000..77ae919 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbCallTableController.java @@ -0,0 +1,77 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import cn.hutool.core.util.StrUtil; +import com.chaozhanggui.system.cashierservice.entity.dto.BaseCallTableDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.CallSubMsgDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.CancelCallQueueDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.TakeNumberDTO; +import com.chaozhanggui.system.cashierservice.service.TbCallService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import lombok.AllArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * 叫号 + */ +@RestController +@RequestMapping("/callTable") +@AllArgsConstructor +public class TbCallTableController { + + private final TbCallService tbCallService; + + @PostMapping("takeNumber") + public Result takeNumber( + @Validated @RequestBody TakeNumberDTO takeNumberDTO + ) { + return Result.successWithData(tbCallService.takeNumber(takeNumberDTO)); + } + + /** + * 排号列表 + * @param openId openId + * @param shopId 店铺id + * @return data + */ + @GetMapping("queue") + public Result get( + @RequestParam String openId, + @RequestParam Integer shopId, + @RequestParam(required = false) Integer queueId + ) { + return Result.successWithData(tbCallService.getList(shopId, openId, queueId)); + } + + @GetMapping + public Result getList( + @RequestParam Integer shopId + ) { + return Result.successWithData(tbCallService.getAllInfo(shopId)); + } + + @PostMapping("/cancel") + public Result cancel( + @Validated @RequestBody CancelCallQueueDTO cancelCallQueueDTO + ) { + return Result.successWithData(tbCallService.cancel(cancelCallQueueDTO)); + } + + @GetMapping("state") + public Result getState( + @RequestParam String openId, + @RequestParam Integer shopId, + @RequestParam(required = false) Integer queueId + ) { + return Result.successWithData(tbCallService.getState(openId, shopId, queueId)); + } + + @PostMapping("subMsg") + public Result subMsg( + @Validated @RequestBody CallSubMsgDTO subMsgDTO + ) { + return Result.successWithData(tbCallService.subMsg(subMsgDTO)); + } + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbMemberPointsController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbMemberPointsController.java new file mode 100644 index 0000000..99fde14 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbMemberPointsController.java @@ -0,0 +1,127 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import cn.hutool.core.map.MapProxy; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPoints; +import com.chaozhanggui.system.cashierservice.entity.dto.OrderDeductionPointsDTO; +import com.chaozhanggui.system.cashierservice.service.TbMemberPointsService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.Map; + + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/member-points") +public class TbMemberPointsController { + + @Autowired + private TbMemberPointsService tbMemberPointsService; + + /** + * 分页 + * + * @param params + * @return + */ + @GetMapping("page") + public Result page(@RequestParam Map params) { + PageInfo page = tbMemberPointsService.page(params); + return Result.successWithData(page); + } + + /** + * 获取会员积分等信息 + * + * @param memberId + * @return + */ + @GetMapping("{memberId}") + public Result getMemberPoints(@PathVariable("memberId") Long memberId) { + TbMemberPoints memberPoints = tbMemberPointsService.getMemberPoints(memberId); + return Result.successWithData(memberPoints); + } + + /** + * 获取订单可用积分及抵扣金额 + * + * @param memberId + * @param orderAmount + * @return + */ + @GetMapping("calc-usable-points") + public Result getMemberUsablePoints(@RequestParam Long memberId, @RequestParam BigDecimal orderAmount) { + OrderDeductionPointsDTO usablePoints = tbMemberPointsService.getMemberUsablePoints(memberId, orderAmount); + return Result.successWithData(usablePoints); + } + + /** + * 根据抵扣金额计算所需积分 + * + * @param memberId + * @param orderAmount + * @param deductionAmount + * @return + */ + @GetMapping("calc-used-points") + public Result calcUsedPoints(@RequestParam Long memberId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) { + int points = tbMemberPointsService.calcUsedPoints(memberId, orderAmount, deductionAmount); + return Result.successWithData(points); + } + + /** + * 根据积分计算可抵扣金额 + * + * @param memberId + * @param orderAmount + * @param points + * @return + */ + @GetMapping("calc-deduction-amount") + public Result calcDeductionAmount(@RequestParam Long memberId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) { + BigDecimal deductionAmount = tbMemberPointsService.calcDeductionAmount(memberId, orderAmount, points); + return Result.successWithData(deductionAmount); + } + + /** + * 支付完成扣减积分(支付成功回调中使用) + * + * @param params + * @return + */ + @PostMapping("payed-deduct-points") + public Result deductPoints(@RequestBody Map params) { + MapProxy proxy = MapProxy.create(params); + Long memberId = proxy.getLong("memberId"); + Integer points = proxy.getInt("points"); + String content = proxy.getStr("content"); + Long orderId = proxy.getLong("orderId"); + boolean ret = tbMemberPointsService.deductPoints(memberId, points, content, orderId); + return Result.successWithData(ret); + } + + /** + * 消费赠送积分(支付成功回调中使用) + * + * @param params + * @return + */ + @PostMapping("consume-award-points") + public Result consumeAwardPoints(@RequestBody Map params) { + MapProxy proxy = MapProxy.create(params); + Long memberId = proxy.getLong("memberId"); + Long orderId = proxy.getLong("orderId"); + tbMemberPointsService.consumeAwardPoints(memberId, orderId); + return Result.success(CodeEnum.SUCCESS); + } + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbMemberPointsLogController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbMemberPointsLogController.java new file mode 100644 index 0000000..9fd9e15 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbMemberPointsLogController.java @@ -0,0 +1,39 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.TbMemberPointsLog; +import com.chaozhanggui.system.cashierservice.service.TbMemberPointsLogService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/member-points-log") +public class TbMemberPointsLogController { + + @Autowired + private TbMemberPointsLogService tbMemberPointsLogService; + + /** + * 分页 + * @param params + * @return + */ + @GetMapping("page") + public Result page(@RequestParam Map params) { + PageInfo page = tbMemberPointsLogService.page(params); + return Result.successWithData(page); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsBasicSettingController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsBasicSettingController.java new file mode 100644 index 0000000..2c4291e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsBasicSettingController.java @@ -0,0 +1,47 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.TbPointsBasicSetting; +import com.chaozhanggui.system.cashierservice.service.TbPointsBasicSettingService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/basic-setting") +public class TbPointsBasicSettingController { + + @Autowired + private TbPointsBasicSettingService tbPointsBasicSettingService; + + /** + * 信息 + * @param shopId + * @return + */ + @GetMapping("{shopId}") + public Result get(@PathVariable("shopId") Long shopId) { + TbPointsBasicSetting data = tbPointsBasicSettingService.getByShopId(shopId); + return Result.successWithData(data); + } + + /** + * 保存 + * @param entity + * @return + */ + @PostMapping + public Result save(@RequestBody TbPointsBasicSetting entity) { + tbPointsBasicSettingService.save(entity); + return Result.success(CodeEnum.SUCCESS); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsExchangeRecordController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsExchangeRecordController.java new file mode 100644 index 0000000..1f5e332 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsExchangeRecordController.java @@ -0,0 +1,86 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.TbPointsExchangeRecord; +import com.chaozhanggui.system.cashierservice.service.TbPointsExchangeRecordService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/exchange-record") +public class TbPointsExchangeRecordController { + + @Autowired + private TbPointsExchangeRecordService tbPointsExchangeRecordService; + + /** + * 分页 + * + * @param params + * @return + */ + @GetMapping("page") + public Result page(@RequestParam Map params) { + PageInfo page = tbPointsExchangeRecordService.page(params); + return Result.successWithData(page); + } + + /** + * 信息 + * + * @param id + * @return + */ + @GetMapping("{id}") + public Result get(@PathVariable("id") Long id) { + TbPointsExchangeRecord data = tbPointsExchangeRecordService.get(id); + return Result.successWithData(data); + } + + /** + * 核销 + * + * @param record + * @return + */ + @PostMapping("checkout") + public Result checkout(@RequestBody TbPointsExchangeRecord record) { + tbPointsExchangeRecordService.checkout(record.getCouponCode()); + return Result.success(CodeEnum.SUCCESS); + } + + /** + * 兑换 + * + * @param record + * @return + */ + @PostMapping("exchange") + public Result exchange(@RequestBody TbPointsExchangeRecord record) { + TbPointsExchangeRecord data = tbPointsExchangeRecordService.exchange(record); + return Result.successWithData(data); + } + + /** + * 统计 + * + * @param params + * @return + */ + @GetMapping("total") + public Result total(@RequestParam Map params) { + Map data = tbPointsExchangeRecordService.total(params); + return Result.successWithData(data); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsGoodsSettingController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsGoodsSettingController.java new file mode 100644 index 0000000..e5ab1a5 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbPointsGoodsSettingController.java @@ -0,0 +1,81 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.TbPointsGoodsSetting; +import com.chaozhanggui.system.cashierservice.service.TbPointsGoodsSettingService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/goods-setting") +public class TbPointsGoodsSettingController { + + @Autowired + private TbPointsGoodsSettingService tbPointsGoodsSettingService; + + /** + * 分页 + * @param params + * @return + */ + @GetMapping("page") + public Result page(@RequestParam Map params) { + PageInfo page = tbPointsGoodsSettingService.page(params); + return Result.successWithData(page); + } + + /** + * 信息 + * @param id + * @return + */ + @GetMapping("{id}") + public Result get(@PathVariable("id") Long id) { + TbPointsGoodsSetting data = tbPointsGoodsSettingService.getById(id); + return Result.successWithData(data); + } + + /** + * 保存 + * @param entity + * @return + */ + @PostMapping + public Result save(@RequestBody TbPointsGoodsSetting entity) { + boolean ret = tbPointsGoodsSettingService.save(entity); + return Result.successWithData(ret); + } + + /** + * 修改 + * @param dto + * @return + */ + @PutMapping + public Result update(@RequestBody TbPointsGoodsSetting dto) { + boolean ret = tbPointsGoodsSettingService.update(dto); + return Result.successWithData(ret); + } + + /** + * 删除 + * @param id + * @return + */ + @DeleteMapping("{id}") + public Result delete(@PathVariable("id") Long id) { + tbPointsGoodsSettingService.delete(id); + return Result.success(CodeEnum.SUCCESS); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopCouponController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopCouponController.java new file mode 100644 index 0000000..641d310 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopCouponController.java @@ -0,0 +1,38 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto; +import com.chaozhanggui.system.cashierservice.service.TbShopCouponService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 优惠券(TbShopCoupon)表控制层 + * + * @author ww + * @since 2024-10-23 15:37:26 + */ +@RestController +@RequestMapping("coupon") +public class TbShopCouponController { + /** + * 服务对象 + */ + @Autowired + private TbShopCouponService tbShopCouponService; + + /** + * 根据优惠券DTO查询优惠券 + * @param param 优惠券DTO + * @return 查询结果 + */ + @RequestMapping("find") + public Result find(@Validated @RequestBody CouponDto param) { + return tbShopCouponService.find(param); + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index c13a247..57ec9e5 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -3,26 +3,21 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; -import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper; import com.chaozhanggui.system.cashierservice.dao.TbUserInfoMapper; import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; import com.chaozhanggui.system.cashierservice.entity.TbShopUser; import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; -import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo; -import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo; import com.chaozhanggui.system.cashierservice.entity.vo.OpenMemberVo; import com.chaozhanggui.system.cashierservice.service.UserService; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; -import com.chaozhanggui.system.cashierservice.util.TokenUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.io.IOException; import java.math.BigDecimal; @CrossOrigin(origins = "*") @@ -42,32 +37,22 @@ public class UserContoller { @Autowired private TbUserInfoMapper userInfoMapper; -// @GetMapping("/userInfo") -// public JSONObject userInfo(@RequestParam("openId") String openId ) throws Exception { -// TbUserInfo shopUser = userInfoMapper.selectByOpenId(openId); -// JSONObject jsonObject = new JSONObject(); -// if (Objects.isNull(shopUser)){ -// jsonObject.put("status","fail"); -// jsonObject.put("msg","用户不存在"); -// return jsonObject; -// } -// String userSign = UUID.randomUUID().toString().replaceAll("-",""); -// String token = TokenUtil.generateJfToken(openId,userSign); -// JSONObject object = new JSONObject(); -// object.put("token",token); -// object.put("userSign",userSign); -// object.put("num",shopUser.getTotalScore()); -// jsonObject.put("status","success"); -// jsonObject.put("msg","成功"); -// jsonObject.put("data",object); -// return jsonObject; -// } - @PostMapping("/openMember") public Result openMember(@RequestBody OpenMemberVo memberVo){ + if(StringUtils.isBlank(memberVo.getTelephone())){ + return Result.fail("手机号不可为空"); + } return userService.openMember(memberVo); } + @PostMapping("/upVipPhont") + public Result upVipPhont(@RequestBody OpenMemberVo memberVo){ + if(StringUtils.isBlank(memberVo.getTelephone())){ + return Result.fail("手机号不可为空"); + } + return userService.upVipPhont(memberVo); + } + @GetMapping("/shopUserInfo") public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception { if(shopId.equals("undefined")){ @@ -127,51 +112,11 @@ public class UserContoller { return Result.success(CodeEnum.SUCCESS, shopUser); } - @GetMapping("/userCoupon") - public Result userCoupon(@RequestParam("userId") String userId, @RequestParam("orderNum") BigDecimal orderNum) throws Exception { - int num = userService.userCoupon(userId, orderNum); - return Result.success(CodeEnum.SUCCESS, num); - } - - @PostMapping("/modityIntegral") - public JSONObject modityIntegral(@RequestHeader String token, @RequestBody IntegralVo integralVo) throws Exception { - JSONObject jsonObject = TokenUtil.parseParamFromToken(token); - String userSign = jsonObject.getString("userSign"); - return userService.modityIntegral(integralVo, userSign); - } - - @PostMapping("/userIntegral") - public JSONObject userIntegral(@RequestHeader String token, @RequestBody IntegralFlowVo integralFlowVo) throws Exception { - JSONObject jsonObject = TokenUtil.parseParamFromToken(token); - String userSign = jsonObject.getString("userSign"); - return userService.userIntegral(integralFlowVo, userSign); - } - - @PostMapping("/userAllIntegral") - public JSONObject userAllIntegral(@RequestBody IntegralFlowVo integralFlowVo) throws Exception { -// JSONObject jsonObject = TokenUtil.parseParamFromToken(token); -// String userSign = jsonObject.getString("userSign"); - return userService.userAllIntegral(integralFlowVo, "userSign"); - } - - @PostMapping("/userAll") - public JSONObject userAll(@RequestBody IntegralFlowVo integralFlowVo) throws Exception { -// JSONObject jsonObject = TokenUtil.parseParamFromToken(token); -// String userSign = jsonObject.getString("userSign"); - return userService.userAll(integralFlowVo, "userSign"); - } - - /** * 获取订阅当前用户店库存预警消息的二维码 - * - * @param shopId - * @return */ @GetMapping("/subQrCode") - public Result getSubQrCode( - @RequestParam String shopId - ) throws Exception { + public Result getSubQrCode(@RequestParam String shopId) throws Exception { String url = userService.getSubQrCode(shopId); return Result.successWithData(url); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java new file mode 100644 index 0000000..a69145f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java @@ -0,0 +1,76 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord; +import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 活动商品赠送表(TbActivateInRecord)表数据库访问层 + * + * @author ww + * @since 2024-08-22 11:13:40 + */ +public interface TbActivateInRecordMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateInRecord queryById(Integer id); + + /** + * 查询数据 + * + * @param tbActivateInRecord 查询条件 + * @return 对象列表 + */ + List queryAll(TbActivateInRecord tbActivateInRecord); + + //未使用券 + List queryByVipIdAndShopId(@Param("vipUserIds") List vipUserIds, @Param("shopId") Integer shopId); + //过期券 + List queryByVipIdAndShopIdExpire(@Param("vipUserIds") List vipUserIds, @Param("shopId") Integer shopId); + + int countCouponNum(@Param("userId") Integer userId); + + + /** + * 新增数据 + * + * @param tbActivateInRecord 实例对象 + * @return 影响行数 + */ + int insert(TbActivateInRecord tbActivateInRecord); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbActivateInRecord 实例对象 + * @return 影响行数 + */ + int update(TbActivateInRecord tbActivateInRecord); + + int updateOverNum(@Param("id") Integer id, @Param("overNum") Integer overNum); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java index 2a458b2..bd125a3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java @@ -1,29 +1,72 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbActivate; -import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Component; +import org.springframework.data.domain.Pageable; import java.math.BigDecimal; import java.util.List; -@Component -@Mapper +/** + * (TbActivate)表数据库访问层 + * + * @author ww + * @since 2024-10-23 14:19:53 + */ public interface TbActivateMapper { - int deleteByPrimaryKey(Integer id); - int insert(TbActivate record); + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivate queryById(Integer id); - int insertSelective(TbActivate record); + /** + * 查询数据 + * + * @param tbActivate 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAll(TbActivate tbActivate, @Param("pageable") Pageable pageable); - TbActivate selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbActivate record); - - int updateByPrimaryKey(TbActivate record); + List selectByShopId(String shopId); TbActivate selectByAmount(@Param("shopId") String shopId,@Param("amount") BigDecimal amount); - List selectByShpopId(String shopId); + + /** + * 新增数据 + * + * @param tbActivate 实例对象 + * @return 影响行数 + */ + int insert(TbActivate tbActivate); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbActivate 实例对象 + * @return 影响行数 + */ + int update(TbActivate tbActivate); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java new file mode 100644 index 0000000..6c9d6f7 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java @@ -0,0 +1,72 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord; +import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层 + * + * @author ww + * @since 2024-10-23 14:55:22 + */ +public interface TbActivateOutRecordMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateOutRecord queryById(Integer id); + + /** + * 查询数据 + * + * @param tbActivateOutRecord 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAll(TbActivateOutRecord tbActivateOutRecord, @Param("pageable") Pageable pageable); + + List queryByVipIdAndShopId(@Param("vipUserIds") List vipUserIds, @Param("shopId") Integer shopId); + + /** + * 新增数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 影响行数 + */ + int insert(TbActivateOutRecord tbActivateOutRecord); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 影响行数 + */ + int update(TbActivateOutRecord tbActivateOutRecord); + + int updateRefNum(@Param("id")Integer id,@Param("refNum")Integer refNum); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java index 4f2e299..f620062 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java @@ -56,5 +56,6 @@ public interface TbCashierCartMapper { List selectByOrderId(@Param("orderId") String orderId,@Param("status") String status); void updateStatusByTableId(@Param("tableId")String tableId,@Param("status") String status); + void updateStatusByOrderIdForMini(@Param("tableId")String tableId,@Param("status") String status); void updateStatusById(@Param("id")Integer id,@Param("status") String status); -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCouponProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCouponProductMapper.java new file mode 100644 index 0000000..6ca6628 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCouponProductMapper.java @@ -0,0 +1,72 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbCouponProduct; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * 活动赠送商品表(TbCouponProduct)表数据库访问层 + * + * @author ww + * @since 2024-10-23 14:35:49 + */ +public interface TbCouponProductMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbCouponProduct queryById(Integer id); + + /** + * 查询数据 + * + * @param tbCouponProduct 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAll(TbCouponProduct tbCouponProduct, @Param("pageable") Pageable pageable); + + + List queryAllByCouponId(Integer couponId); + List queryProsByActivateId(@Param("couponId")Integer couponId,@Param("num")Integer num); + + + /** + * 新增数据 + * + * @param tbCouponProduct 实例对象 + * @return 影响行数 + */ + int insert(TbCouponProduct tbCouponProduct); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbCouponProduct 实例对象 + * @return 影响行数 + */ + int update(TbCouponProduct tbCouponProduct); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbDeviceOperateInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbDeviceOperateInfoMapper.java deleted file mode 100644 index 38b0c4d..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbDeviceOperateInfoMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbDeviceOperateInfo; - -public interface TbDeviceOperateInfoMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbDeviceOperateInfo record); - - int insertSelective(TbDeviceOperateInfo record); - - TbDeviceOperateInfo selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbDeviceOperateInfo record); - - int updateByPrimaryKey(TbDeviceOperateInfo record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbDeviceStockMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbDeviceStockMapper.java deleted file mode 100644 index 88b0e55..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbDeviceStockMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbDeviceStock; - -public interface TbDeviceStockMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbDeviceStock record); - - int insertSelective(TbDeviceStock record); - - TbDeviceStock selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbDeviceStock record); - - int updateByPrimaryKey(TbDeviceStock record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbIntegralFlowMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbIntegralFlowMapper.java deleted file mode 100644 index cb6f56f..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbIntegralFlowMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbIntegralFlow; - -public interface TbIntegralFlowMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbIntegralFlow record); - - int insertSelective(TbIntegralFlow record); - - TbIntegralFlow selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbIntegralFlow record); - - int updateByPrimaryKey(TbIntegralFlow record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbIntegralMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbIntegralMapper.java deleted file mode 100644 index 322cfcd..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbIntegralMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbIntegral; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Component -public interface TbIntegralMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbIntegral record); - - int insertSelective(TbIntegral record); - - TbIntegral selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbIntegral record); - - int updateByPrimaryKey(TbIntegral record); - - List selectAllByUserId(String userId); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java deleted file mode 100644 index 08bf7d4..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbMerchantCouponMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbMerchantCoupon; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Component; - -/** - * 优惠券(TbMerchantCoupon)表数据库访问层 - * - * @author lyf - * @since 2024-04-02 09:24:16 - */ -@Component -@Mapper -public interface TbMerchantCouponMapper { - - /** - * 通过ID查询单条数据 - * - * @param id 主键 - * @return 实例对象 - */ - TbMerchantCoupon queryById(Integer id); - - - -} - diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java index 20d3776..0affb60 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbOrderInfoMapper.java @@ -11,6 +11,10 @@ import java.util.List; @Component @Mapper public interface TbOrderInfoMapper { + + /** + * 逻辑删除 + */ int deleteByPrimaryKey(Integer id); int insert(TbOrderInfo record); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbParamsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbParamsMapper.java deleted file mode 100644 index f234c90..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbParamsMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbParams; - -public interface TbParamsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbParams record); - - int insertSelective(TbParams record); - - TbParams selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbParams record); - - int updateByPrimaryKey(TbParams record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlussDeviceGoodsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlussDeviceGoodsMapper.java deleted file mode 100644 index c97cc2d..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlussDeviceGoodsMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbPlussDeviceGoods; - -public interface TbPlussDeviceGoodsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbPlussDeviceGoods record); - - int insertSelective(TbPlussDeviceGoods record); - - TbPlussDeviceGoods selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbPlussDeviceGoods record); - - int updateByPrimaryKeyWithBLOBs(TbPlussDeviceGoods record); - - int updateByPrimaryKey(TbPlussDeviceGoods record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java index 3968f0d..9e33d9a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java @@ -26,7 +26,7 @@ public interface TbProductMapper { List selectByIds(@Param("list") List ids); Integer selectByQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId); - Integer selectByCodeAndSkuId(@Param("code") String code,@Param("skuId") Integer skuId,@Param("shopId") String shopId); + Integer selectByCodeAndSkuId(@Param("code") String code,@Param("skuId") Integer skuId,@Param("shopId") String shopId,@Param("isVip") String isVip); Integer selectByNewQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId,@Param("list") List list); List selGroups(@Param("proName") String proName,@Param("type") String type, diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbReceiptSalesMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbReceiptSalesMapper.java deleted file mode 100644 index 51af334..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbReceiptSalesMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbReceiptSales; - -public interface TbReceiptSalesMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbReceiptSales record); - - int insertSelective(TbReceiptSales record); - - TbReceiptSales selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbReceiptSales record); - - int updateByPrimaryKey(TbReceiptSales record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbReleaseFlowMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbReleaseFlowMapper.java deleted file mode 100644 index 0cce4bd..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbReleaseFlowMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TbReleaseFlowMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbReleaseFlow record); - - int insertSelective(TbReleaseFlow record); - - TbReleaseFlow selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbReleaseFlow record); - - int updateByPrimaryKey(TbReleaseFlow record); - - List selectByUserId(@Param("userId") String userId); - - List selectAll(); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbRenewalsPayLogMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbRenewalsPayLogMapper.java deleted file mode 100644 index 0f317e8..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbRenewalsPayLogMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbRenewalsPayLog; - -public interface TbRenewalsPayLogMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbRenewalsPayLog record); - - int insertSelective(TbRenewalsPayLog record); - - TbRenewalsPayLog selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbRenewalsPayLog record); - - int updateByPrimaryKey(TbRenewalsPayLog record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java index 3030d0f..5cbe34a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java @@ -17,7 +17,7 @@ public interface TbShopAdDao { * * @return 对象列表 */ - @Select("select * from fycashier.tb_shop_ad where (shop_id = #{songId} or shop_id = 1) and status=1") + @Select("select * from tb_shop_ad where (shop_id = #{songId} or shop_id = 1) and status=1") List shopAdList(Integer shopId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCashSpreadMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCashSpreadMapper.java deleted file mode 100644 index ddcc1bd..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCashSpreadMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbShopCashSpread; -import com.chaozhanggui.system.cashierservice.entity.TbShopCashSpreadWithBLOBs; - -public interface TbShopCashSpreadMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbShopCashSpreadWithBLOBs record); - - int insertSelective(TbShopCashSpreadWithBLOBs record); - - TbShopCashSpreadWithBLOBs selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbShopCashSpreadWithBLOBs record); - - int updateByPrimaryKeyWithBLOBs(TbShopCashSpreadWithBLOBs record); - - int updateByPrimaryKey(TbShopCashSpread record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCouponMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCouponMapper.java new file mode 100644 index 0000000..0ce36a0 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCouponMapper.java @@ -0,0 +1,68 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopCoupon; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * 优惠券(TbShopCoupon)表数据库访问层 + * + * @author ww + * @since 2024-10-23 14:25:13 + */ +public interface TbShopCouponMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbShopCoupon queryById(Integer id); + + /** + * 查询数据 + * + * @param tbShopCoupon 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAll(TbShopCoupon tbShopCoupon, @Param("pageable") Pageable pageable); + + + /** + * 新增数据 + * + * @param tbShopCoupon 实例对象 + * @return 影响行数 + */ + int insert(TbShopCoupon tbShopCoupon); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbShopCoupon 实例对象 + * @return 影响行数 + */ + int update(TbShopCoupon tbShopCoupon); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCurrencyMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCurrencyMapper.java deleted file mode 100644 index 8dbcb5b..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopCurrencyMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbShopCurrency; -import com.chaozhanggui.system.cashierservice.entity.TbShopCurrencyWithBLOBs; - -public interface TbShopCurrencyMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbShopCurrencyWithBLOBs record); - - int insertSelective(TbShopCurrencyWithBLOBs record); - - TbShopCurrencyWithBLOBs selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbShopCurrencyWithBLOBs record); - - int updateByPrimaryKeyWithBLOBs(TbShopCurrencyWithBLOBs record); - - int updateByPrimaryKey(TbShopCurrency record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopExtendMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopExtendMapper.java new file mode 100644 index 0000000..0e80d49 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopExtendMapper.java @@ -0,0 +1,33 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopExtend; + +import java.util.List; + +/** + * 店铺扩展信息(TbShopExtend)表数据库访问层 + * + * @author ww + * @since 2024-08-21 09:40:25 + */ +public interface TbShopExtendMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbShopExtend queryById(Integer id); + + TbShopExtend queryByShopIdAndAutoKey(Integer shopId,String autokey); + + /** + * 查询数据 + * + * @param tbShopExtend 查询条件 + * @return 对象列表 + */ + List queryAll(TbShopExtend tbShopExtend); +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java index ad6904e..a22953d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java @@ -13,11 +13,6 @@ import java.util.List; @Component @Mapper public interface TbShopInfoMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbShopInfo record); - - int insertSelective(TbShopInfo record); List selShopInfoByGps(@Param("rightTopLng") Double rightTopLng, @Param("rightTopLat") Double rightTopLat, @Param("leftBottomLng") Double leftBottomLng, @Param("leftBottomLat") Double leftBottomLat, @@ -30,12 +25,6 @@ public interface TbShopInfoMapper { List selectByIds(@Param("list") List ids); - int updateByPrimaryKeySelective(TbShopInfo record); - - int updateByPrimaryKeyWithBLOBs(TbShopInfo record); - - int updateByPrimaryKey(TbShopInfo record); - TbShopInfo selectByQrCode(String qrcode); TbShopInfo selectByPhone(String phone); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongMapper.java index c998a25..77196f8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongMapper.java @@ -30,10 +30,10 @@ public interface TbShopSongMapper { List selectAllAndSearch(Integer shopId, String keyWord); - @Select("select * from fycashier.tb_shop_song where id=#{songId} and status=1") + @Select("select * from tb_shop_song where id=#{songId} and status=1") TbShopSong selectById(@Param("songId") Integer songId); - @Update("update fycashier.tb_shop_song set sales_number=sales_number+#{num} where id=#{id}") + @Update("update tb_shop_song set sales_number=sales_number+#{num} where id=#{id}") int incrNum(@Param("num") Integer num,@Param("id") Integer id); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongOrderMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongOrderMapper.java index 7c461ed..ed7720b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongOrderMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopSongOrderMapper.java @@ -48,7 +48,7 @@ public interface TbShopSongOrderMapper { " AND a.id=#{id}") Map selectByUserIdAndId(@Param("openId") String openId, @Param("id") Integer id); - @Select("select * from fycashier.tb_shop_song_order where order_no=#{orderNo};") + @Select("select * from tb_shop_song_order where order_no=#{orderNo};") TbShopSongOrder selectByOrderNo(@Param("orderNo") String orderNo); @Delete("DELETE FROM tb_shop_song_order\n" + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java index a87fe71..6df8e88 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopUserMapper.java @@ -1,14 +1,13 @@ package com.chaozhanggui.system.cashierservice.dao; -import com.chaozhanggui.system.cashierservice.entity.TbParams; import com.chaozhanggui.system.cashierservice.entity.TbShopUser; import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; 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; @Component @Mapper @@ -32,11 +31,11 @@ public interface TbShopUserMapper { TbShopUser selectByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId); TbShopUser selectPCByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId); List selectAllByUserId(@Param("userId") String userId); + List selectVipByUserId(@Param("userId") Integer userId); + BigDecimal countAmount(@Param("userId") Integer userId); List selectByUserId(@Param("userId") String userId, @Param("shopId") String shopId); TbShopUser selectByOpenId(@Param("openId") String openId); - - TbParams selectParams(); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbSplitAccountsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbSplitAccountsMapper.java deleted file mode 100644 index 70ee67a..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbSplitAccountsMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts; - -public interface TbSplitAccountsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbSplitAccounts record); - - int insertSelective(TbSplitAccounts record); - - TbSplitAccounts selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbSplitAccounts record); - - int updateByPrimaryKey(TbSplitAccounts record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbSystemCouponsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbSystemCouponsMapper.java deleted file mode 100644 index c66ed50..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbSystemCouponsMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons; -import org.apache.ibatis.annotations.Param; - -import java.math.BigDecimal; -import java.util.List; - -public interface TbSystemCouponsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbSystemCoupons record); - - int insertSelective(TbSystemCoupons record); - - TbSystemCoupons selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbSystemCoupons record); - - int updateByPrimaryKey(TbSystemCoupons record); - - List selectAll(@Param("type") String type); - - int selectByAmount(@Param("orderNum") BigDecimal orderNum); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserCouponsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserCouponsMapper.java deleted file mode 100644 index 192a2e3..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserCouponsMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbUserCoupons; -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; - -@Component -@Mapper -public interface TbUserCouponsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbUserCoupons record); - - int insertSelective(TbUserCoupons record); - - TbUserCoupons selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbUserCoupons record); - - int updateByPrimaryKey(TbUserCoupons record); - - List selectByUserId(@Param("userId") String userId,@Param("status") String status,@Param("amount") BigDecimal amount); - - TbUserCoupons selectByOrderId(@Param("orderId") Integer orderId); - - int selectByUserIdAndAmount(@Param("userId") String userId, @Param("orderNum") BigDecimal orderNum); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbWiningParamsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbWiningParamsMapper.java deleted file mode 100644 index 803fc9f..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbWiningParamsMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbWiningParams; - -import java.util.List; - -public interface TbWiningParamsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbWiningParams record); - - int insertSelective(TbWiningParams record); - - TbWiningParams selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbWiningParams record); - - int updateByPrimaryKey(TbWiningParams record); - - List selectAll(); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbWiningUserMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbWiningUserMapper.java deleted file mode 100644 index 8659d34..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbWiningUserMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbWiningUser; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Component -@Mapper -public interface TbWiningUserMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbWiningUser record); - - int insertSelective(TbWiningUser record); - - TbWiningUser selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbWiningUser record); - - int updateByPrimaryKey(TbWiningUser record); - - List selectAllByTrade(@Param("day") String day); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbYhqParamsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbYhqParamsMapper.java deleted file mode 100644 index 0693c83..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbYhqParamsMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbYhqParams; - -import java.util.List; - -public interface TbYhqParamsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TbYhqParams record); - - int insertSelective(TbYhqParams record); - - TbYhqParams selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TbYhqParams record); - - int updateByPrimaryKey(TbYhqParams record); - - List selectAll(); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ViewOrderMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ViewOrderMapper.java deleted file mode 100644 index 44a16c9..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ViewOrderMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.ViewOrder; - -public interface ViewOrderMapper { - int insert(ViewOrder record); - - int insertSelective(ViewOrder record); -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/OrderUseTypeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/OrderUseTypeEnum.java new file mode 100644 index 0000000..28707a3 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/OrderUseTypeEnum.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.entity.Enum; + +import lombok.Getter; + +/** + * 订餐用餐类型枚举 + */ +@Getter +public enum OrderUseTypeEnum { + TAKEOUT("takeout"), + DINE_IN_AFTER("dine-in-after"), + DINE_IN_BEFORE("dine-in-before"); + private final String value; + + OrderUseTypeEnum(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/PlatformTypeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/PlatformTypeEnum.java new file mode 100644 index 0000000..b23596d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/PlatformTypeEnum.java @@ -0,0 +1,13 @@ +package com.chaozhanggui.system.cashierservice.entity.Enum; + +import lombok.Getter; + +@Getter +public enum PlatformTypeEnum { + MINI_APP("miniapp"); + private final String value; + + PlatformTypeEnum(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoEatModelEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoEatModelEnum.java new file mode 100644 index 0000000..9f9ee03 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoEatModelEnum.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.entity.Enum; + +import lombok.Getter; + +/** + * 店铺就餐类型 + */ +@Getter +public enum ShopInfoEatModelEnum { + TAKE_OUT("take-out"), + DINE_IN("dine-in"); + + private final String value; + + ShopInfoEatModelEnum(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoRegisterlEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoRegisterlEnum.java new file mode 100644 index 0000000..5765104 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/Enum/ShopInfoRegisterlEnum.java @@ -0,0 +1,20 @@ +package com.chaozhanggui.system.cashierservice.entity.Enum; + +import lombok.Getter; + +/** + * 店铺注册类型枚举 + */ +@Getter +public enum ShopInfoRegisterlEnum { + // 快餐版 + MUNCHIES("munchies"), + // 餐饮版 + RESTAURANT("restaurant"); + + private final String value; + + ShopInfoRegisterlEnum(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java index c223bfc..35d9c79 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java @@ -1,24 +1,48 @@ package com.chaozhanggui.system.cashierservice.entity; +import java.util.Date; import java.io.Serializable; -import java.math.BigDecimal; +import java.util.List; +/** + * (TbActivate)实体类 + * + * @author ww + * @since 2024-10-23 14:16:33 + */ public class TbActivate implements Serializable { + private static final long serialVersionUID = 216340931948517603L; + private Integer id; private Integer shopId; + /** + * 充值金额 + */ + private Integer amount; + /** + * 赠送金额 + */ + private Integer giftAmount; + /** + * 是否使用优惠卷 0否 1是 + */ + private Integer isUseCoupon; + /** + * 优惠卷id + */ + private Integer couponId; + /** + * 优惠卷数量 + */ + private Integer num; - private Integer minNum; + private Date createTime = new Date(); - private Integer maxNum; + private Date updateTime = new Date(); - private BigDecimal handselNum; - - private String handselType; - - private String isDel; - - private static final long serialVersionUID = 1L; + private String couponDesc; + private List gives; public Integer getId() { return id; @@ -36,43 +60,77 @@ public class TbActivate implements Serializable { this.shopId = shopId; } - public Integer getMinNum() { - return minNum; + public Integer getAmount() { + return amount; } - public void setMinNum(Integer minNum) { - this.minNum = minNum; + public void setAmount(Integer amount) { + this.amount = amount; } - public Integer getMaxNum() { - return maxNum; + public Integer getGiftAmount() { + return giftAmount; } - public void setMaxNum(Integer maxNum) { - this.maxNum = maxNum; + public void setGiftAmount(Integer giftAmount) { + this.giftAmount = giftAmount; } - public BigDecimal getHandselNum() { - return handselNum; + public Integer getIsUseCoupon() { + return isUseCoupon; } - public void setHandselNum(BigDecimal handselNum) { - this.handselNum = handselNum; + public void setIsUseCoupon(Integer isUseCoupon) { + this.isUseCoupon = isUseCoupon; } - public String getHandselType() { - return handselType; + public Integer getCouponId() { + return couponId; } - public void setHandselType(String handselType) { - this.handselType = handselType == null ? null : handselType.trim(); + public void setCouponId(Integer couponId) { + this.couponId = couponId; } - public String getIsDel() { - return isDel; + public Integer getNum() { + return num; } - public void setIsDel(String isDel) { - this.isDel = isDel == null ? null : isDel.trim(); + public void setNum(Integer num) { + this.num = num; } -} \ No newline at end of file + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + + public String getCouponDesc() { + return couponDesc; + } + + public void setCouponDesc(String couponDesc) { + this.couponDesc = couponDesc; + } + + public List getGives() { + return gives; + } + + public void setGives(List gives) { + this.gives = gives; + } +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java new file mode 100644 index 0000000..e7385df --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java @@ -0,0 +1,223 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 活动商品赠送记录表(TbActivateInRecord)实体类 + * + * @author ww + * @since 2024-10-23 16:43:02 + */ +public class TbActivateInRecord implements Serializable { + private static final long serialVersionUID = -31673077202067433L; + + private Integer id; +/** + * 会员id + */ + private Integer vipUserId; +/** + * 卷Id (校验是否可用) + */ + private Integer couponId; +/** + * 卷描述 满10减2/商品卷 + */ + private String name; +/** + * 1-满减 2-商品 + */ + private Integer type; +/** + * 商品id + */ + private Integer proId; +/** + * 满多少金额 + */ + private Integer fullAmount; +/** + * 减多少金额 + */ + private Integer discountAmount; +/** + * 赠送数量 + */ + private Integer num; +/** + * 未使用数量 + */ + private Integer overNum; +/** + * 店铺id + */ + private Integer shopId; +/** + * 来源活动id + */ + private Integer sourceActId; + + private Integer sourceFlowId; +/** + * 可用开始时间 + */ + private Date useStartTime; +/** + * 可用结束时间 + */ + private Date useEndTime; + + private Date createTime; + + private Date updateTime; + + private String couponJson; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getVipUserId() { + return vipUserId; + } + + public void setVipUserId(Integer vipUserId) { + this.vipUserId = vipUserId; + } + + public Integer getCouponId() { + return couponId; + } + + public void setCouponId(Integer couponId) { + this.couponId = couponId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getProId() { + return proId; + } + + public void setProId(Integer proId) { + this.proId = proId; + } + + public Integer getFullAmount() { + return fullAmount; + } + + public void setFullAmount(Integer fullAmount) { + this.fullAmount = fullAmount; + } + + public Integer getDiscountAmount() { + return discountAmount; + } + + public void setDiscountAmount(Integer discountAmount) { + this.discountAmount = discountAmount; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Integer getOverNum() { + return overNum; + } + + public void setOverNum(Integer overNum) { + this.overNum = overNum; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getSourceActId() { + return sourceActId; + } + + public void setSourceActId(Integer sourceActId) { + this.sourceActId = sourceActId; + } + + public Integer getSourceFlowId() { + return sourceFlowId; + } + + public void setSourceFlowId(Integer sourceFlowId) { + this.sourceFlowId = sourceFlowId; + } + + public Date getUseStartTime() { + return useStartTime; + } + + public void setUseStartTime(Date useStartTime) { + this.useStartTime = useStartTime; + } + + public Date getUseEndTime() { + return useEndTime; + } + + public void setUseEndTime(Date useEndTime) { + this.useEndTime = useEndTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getCouponJson() { + return couponJson; + } + + public void setCouponJson(String couponJson) { + this.couponJson = couponJson; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateOutRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateOutRecord.java new file mode 100644 index 0000000..d1afc74 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateOutRecord.java @@ -0,0 +1,141 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 活动赠送商品使用记录表(TbActivateOutRecord)实体类 + * + * @author ww + * @since 2024-10-23 14:55:22 + */ +public class TbActivateOutRecord implements Serializable { + private static final long serialVersionUID = -34082928893064380L; + + private Integer id; + + private Integer shopId; + /** + * 订单id + */ + private String orderId; + /** + * 商品赠送Id tb_activate_in_record的id + */ + private Integer giveId; + /** + * 会员id + */ + private Integer vipUserId; + /** + * 1-满减 2-商品 + */ + private Integer type; + /** + * 使用数量 + */ + private Integer useNum; + /** + * 退单量 + */ + private Integer refNum; + /** + * 新建: create, 完成: closed, 取消:cancel, + */ + private String status; + + private Date createTime; + + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public Integer getGiveId() { + return giveId; + } + + public void setGiveId(Integer giveId) { + this.giveId = giveId; + } + + public Integer getVipUserId() { + return vipUserId; + } + + public void setVipUserId(Integer vipUserId) { + this.vipUserId = vipUserId; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getUseNum() { + return useNum; + } + + public void setUseNum(Integer useNum) { + this.useNum = useNum; + } + + public Integer getRefNum() { + return refNum; + } + + public void setRefNum(Integer refNum) { + this.refNum = refNum; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallQueue.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallQueue.java new file mode 100644 index 0000000..943ac55 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallQueue.java @@ -0,0 +1,213 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 叫号排号表 + * @TableName tb_call_queue + */ +@TableName(value ="tb_call_queue") +@Data +public class TbCallQueue implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * 叫号台桌类型id + */ + private Integer callTableId; + + /** + * 手机号 + */ + private String phone; + + /** + * 姓名 + */ + private String name; + + /** + * 店铺名称 + */ + private String shopName; + + /** + * 店铺id + */ + private Integer shopId; + + /** + * -1已取消 0排队中 1叫号中 2已入座 3 已过号 + */ + private Integer state; + + /** + * 排号时间 + */ + private Date createTime; + + /** + * 叫号时间 + */ + private Date callTime; + + /** + * 叫号次数 + */ + private Integer callCount; + + /** + * 过号时间 + */ + private Date passTime; + + /** + * 取消时间 + */ + private Date cancelTime; + + /** + * 备注 + */ + private String note; + + /** + * + */ + private Integer userId; + + /** + * + */ + private String openId; + + /** + * 订阅提醒 0未订阅 1已订阅 + */ + private Integer subState; + + /** + * 确认时间 + */ + private Date confirmTime; + + /** + * 叫号号码 + */ + private String callNum; + + /** + * 创建年月日 + */ + private String createDay; + + /** + * 是否已经顺延 + */ + private Integer isPostpone; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + TbCallQueue other = (TbCallQueue) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getCallTableId() == null ? other.getCallTableId() == null : this.getCallTableId().equals(other.getCallTableId())) + && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone())) + && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) + && (this.getShopName() == null ? other.getShopName() == null : this.getShopName().equals(other.getShopName())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getCallTime() == null ? other.getCallTime() == null : this.getCallTime().equals(other.getCallTime())) + && (this.getCallCount() == null ? other.getCallCount() == null : this.getCallCount().equals(other.getCallCount())) + && (this.getPassTime() == null ? other.getPassTime() == null : this.getPassTime().equals(other.getPassTime())) + && (this.getCancelTime() == null ? other.getCancelTime() == null : this.getCancelTime().equals(other.getCancelTime())) + && (this.getNote() == null ? other.getNote() == null : this.getNote().equals(other.getNote())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getOpenId() == null ? other.getOpenId() == null : this.getOpenId().equals(other.getOpenId())) + && (this.getSubState() == null ? other.getSubState() == null : this.getSubState().equals(other.getSubState())) + && (this.getConfirmTime() == null ? other.getConfirmTime() == null : this.getConfirmTime().equals(other.getConfirmTime())) + && (this.getCallNum() == null ? other.getCallNum() == null : this.getCallNum().equals(other.getCallNum())) + && (this.getCreateDay() == null ? other.getCreateDay() == null : this.getCreateDay().equals(other.getCreateDay())) + && (this.getIsPostpone() == null ? other.getIsPostpone() == null : this.getIsPostpone().equals(other.getIsPostpone())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getCallTableId() == null) ? 0 : getCallTableId().hashCode()); + result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode()); + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + result = prime * result + ((getShopName() == null) ? 0 : getShopName().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getState() == null) ? 0 : getState().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getCallTime() == null) ? 0 : getCallTime().hashCode()); + result = prime * result + ((getCallCount() == null) ? 0 : getCallCount().hashCode()); + result = prime * result + ((getPassTime() == null) ? 0 : getPassTime().hashCode()); + result = prime * result + ((getCancelTime() == null) ? 0 : getCancelTime().hashCode()); + result = prime * result + ((getNote() == null) ? 0 : getNote().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getOpenId() == null) ? 0 : getOpenId().hashCode()); + result = prime * result + ((getSubState() == null) ? 0 : getSubState().hashCode()); + result = prime * result + ((getConfirmTime() == null) ? 0 : getConfirmTime().hashCode()); + result = prime * result + ((getCallNum() == null) ? 0 : getCallNum().hashCode()); + result = prime * result + ((getCreateDay() == null) ? 0 : getCreateDay().hashCode()); + result = prime * result + ((getIsPostpone() == null) ? 0 : getIsPostpone().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", callTableId=").append(callTableId); + sb.append(", phone=").append(phone); + sb.append(", name=").append(name); + sb.append(", shopName=").append(shopName); + sb.append(", shopId=").append(shopId); + sb.append(", state=").append(state); + sb.append(", createTime=").append(createTime); + sb.append(", callTime=").append(callTime); + sb.append(", callCount=").append(callCount); + sb.append(", passTime=").append(passTime); + sb.append(", cancelTime=").append(cancelTime); + sb.append(", note=").append(note); + sb.append(", userId=").append(userId); + sb.append(", openId=").append(openId); + sb.append(", subState=").append(subState); + sb.append(", confirmTime=").append(confirmTime); + sb.append(", callNum=").append(callNum); + sb.append(", createDay=").append(createDay); + sb.append(", isPostpone=").append(isPostpone); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallTable.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallTable.java new file mode 100644 index 0000000..a917dd6 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCallTable.java @@ -0,0 +1,149 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * + * @TableName tb_call_table + */ +@TableName(value ="tb_call_table") +@Data +public class TbCallTable implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * 名称 + */ + private String name; + + /** + * 描述 + */ + private String note; + + /** + * 等待时间分钟 + */ + private Integer waitTime; + + /** + * 前缀 + */ + private String prefix; + + /** + * 起始号码 + */ + private Integer start; + + /** + * 临近几桌提醒 + */ + private Integer nearNum; + + /** + * 0禁用 1使用 + */ + private Integer state; + + /** + * 店铺id + */ + private Integer shopId; + + /** + * 二维码地址 + */ + private String qrcode; + + /** + * + */ + private Date createTime; + + /** + * + */ + private Date updateTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + TbCallTable other = (TbCallTable) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) + && (this.getNote() == null ? other.getNote() == null : this.getNote().equals(other.getNote())) + && (this.getWaitTime() == null ? other.getWaitTime() == null : this.getWaitTime().equals(other.getWaitTime())) + && (this.getPrefix() == null ? other.getPrefix() == null : this.getPrefix().equals(other.getPrefix())) + && (this.getStart() == null ? other.getStart() == null : this.getStart().equals(other.getStart())) + && (this.getNearNum() == null ? other.getNearNum() == null : this.getNearNum().equals(other.getNearNum())) + && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getQrcode() == null ? other.getQrcode() == null : this.getQrcode().equals(other.getQrcode())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + result = prime * result + ((getNote() == null) ? 0 : getNote().hashCode()); + result = prime * result + ((getWaitTime() == null) ? 0 : getWaitTime().hashCode()); + result = prime * result + ((getPrefix() == null) ? 0 : getPrefix().hashCode()); + result = prime * result + ((getStart() == null) ? 0 : getStart().hashCode()); + result = prime * result + ((getNearNum() == null) ? 0 : getNearNum().hashCode()); + result = prime * result + ((getState() == null) ? 0 : getState().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getQrcode() == null) ? 0 : getQrcode().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", name=").append(name); + sb.append(", note=").append(note); + sb.append(", waitTime=").append(waitTime); + sb.append(", prefix=").append(prefix); + sb.append(", start=").append(start); + sb.append(", nearNum=").append(nearNum); + sb.append(", state=").append(state); + sb.append(", shopId=").append(shopId); + sb.append(", qrcode=").append(qrcode); + sb.append(", createTime=").append(createTime); + sb.append(", updateTime=").append(updateTime); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java index 0c99e3a..d978055 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java @@ -1,5 +1,8 @@ package com.chaozhanggui.system.cashierservice.entity; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import lombok.Data; import org.apache.commons.lang3.StringUtils; @@ -8,6 +11,7 @@ import java.math.BigDecimal; @Data public class TbCashierCart implements Serializable { + @TableId(type = IdType.AUTO) private Integer id; private String masterId; @@ -58,7 +62,14 @@ public class TbCashierCart implements Serializable { private Long updatedAt; 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; @@ -69,4 +80,4 @@ public class TbCashierCart implements Serializable { return ""; } } -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCouponProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCouponProduct.java new file mode 100644 index 0000000..2572106 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCouponProduct.java @@ -0,0 +1,83 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 活动赠送商品表(TbCouponProduct)实体类 + * + * @author ww + * @since 2024-10-23 14:35:49 + */ +public class TbCouponProduct implements Serializable { + private static final long serialVersionUID = 619724621133545616L; + + private Integer id; + /** + * 活动Id + */ + private Integer couponId; + /** + * 商品id + */ + private Integer productId; + /** + * 数量 + */ + private Integer num; + + private Date createTime; + + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCouponId() { + return couponId; + } + + public void setCouponId(Integer couponId) { + this.couponId = couponId; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbDeviceOperateInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbDeviceOperateInfo.java deleted file mode 100644 index e6c8e56..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbDeviceOperateInfo.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.util.Date; - -public class TbDeviceOperateInfo implements Serializable { - private Integer id; - - private String deviceno; - - private String type; - - private String shopId; - - private Date createtime; - - private String remark; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getDeviceno() { - return deviceno; - } - - public void setDeviceno(String deviceno) { - this.deviceno = deviceno == null ? null : deviceno.trim(); - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type == null ? null : type.trim(); - } - - public String getShopId() { - return shopId; - } - - public void setShopId(String shopId) { - this.shopId = shopId == null ? null : shopId.trim(); - } - - public Date getCreatetime() { - return createtime; - } - - public void setCreatetime(Date createtime) { - this.createtime = createtime; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark == null ? null : remark.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbDeviceStock.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbDeviceStock.java deleted file mode 100644 index 0c6fc38..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbDeviceStock.java +++ /dev/null @@ -1,249 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -public class TbDeviceStock implements Serializable { - private Integer id; - - private String code; - - private String snno; - - private String orderno; - - private BigDecimal price; - - private String type; - - private String groupno; - - private String buymercname; - - private String buymercid; - - private String actmercname; - - private String actmercid; - - private String status; - - private Date createtime; - - private String createby; - - private String delflag; - - private String remarks; - - private Date updatetime; - - private String deviceno; - - private Integer belonguserid; - - private Integer extractuserid; - - private String rolecode; - - private Date instocktime; - - private String transferstatus; - - private Date bindtime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code == null ? null : code.trim(); - } - - public String getSnno() { - return snno; - } - - public void setSnno(String snno) { - this.snno = snno == null ? null : snno.trim(); - } - - public String getOrderno() { - return orderno; - } - - public void setOrderno(String orderno) { - this.orderno = orderno == null ? null : orderno.trim(); - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type == null ? null : type.trim(); - } - - public String getGroupno() { - return groupno; - } - - public void setGroupno(String groupno) { - this.groupno = groupno == null ? null : groupno.trim(); - } - - public String getBuymercname() { - return buymercname; - } - - public void setBuymercname(String buymercname) { - this.buymercname = buymercname == null ? null : buymercname.trim(); - } - - public String getBuymercid() { - return buymercid; - } - - public void setBuymercid(String buymercid) { - this.buymercid = buymercid == null ? null : buymercid.trim(); - } - - public String getActmercname() { - return actmercname; - } - - public void setActmercname(String actmercname) { - this.actmercname = actmercname == null ? null : actmercname.trim(); - } - - public String getActmercid() { - return actmercid; - } - - public void setActmercid(String actmercid) { - this.actmercid = actmercid == null ? null : actmercid.trim(); - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status == null ? null : status.trim(); - } - - public Date getCreatetime() { - return createtime; - } - - public void setCreatetime(Date createtime) { - this.createtime = createtime; - } - - public String getCreateby() { - return createby; - } - - public void setCreateby(String createby) { - this.createby = createby == null ? null : createby.trim(); - } - - public String getDelflag() { - return delflag; - } - - public void setDelflag(String delflag) { - this.delflag = delflag == null ? null : delflag.trim(); - } - - public String getRemarks() { - return remarks; - } - - public void setRemarks(String remarks) { - this.remarks = remarks == null ? null : remarks.trim(); - } - - public Date getUpdatetime() { - return updatetime; - } - - public void setUpdatetime(Date updatetime) { - this.updatetime = updatetime; - } - - public String getDeviceno() { - return deviceno; - } - - public void setDeviceno(String deviceno) { - this.deviceno = deviceno == null ? null : deviceno.trim(); - } - - public Integer getBelonguserid() { - return belonguserid; - } - - public void setBelonguserid(Integer belonguserid) { - this.belonguserid = belonguserid; - } - - public Integer getExtractuserid() { - return extractuserid; - } - - public void setExtractuserid(Integer extractuserid) { - this.extractuserid = extractuserid; - } - - public String getRolecode() { - return rolecode; - } - - public void setRolecode(String rolecode) { - this.rolecode = rolecode == null ? null : rolecode.trim(); - } - - public Date getInstocktime() { - return instocktime; - } - - public void setInstocktime(Date instocktime) { - this.instocktime = instocktime; - } - - public String getTransferstatus() { - return transferstatus; - } - - public void setTransferstatus(String transferstatus) { - this.transferstatus = transferstatus == null ? null : transferstatus.trim(); - } - - public Date getBindtime() { - return bindtime; - } - - public void setBindtime(Date bindtime) { - this.bindtime = bindtime; - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineConfig.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineConfig.java new file mode 100644 index 0000000..38d8bc3 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineConfig.java @@ -0,0 +1,150 @@ +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.math.BigDecimal; +import java.util.Date; +import lombok.Data; + +/** + * 霸王餐配置信息表 + * @TableName tb_free_dine_config + */ +@TableName(value ="tb_free_dine_config") +@Data +public class TbFreeDineConfig implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * 是否启用 + */ + private Integer enable; + + /** + * 充值多少倍免单 + */ + private Integer rechargeTimes; + + /** + * 订单满多少元可以使用 + */ + private BigDecimal rechargeThreshold; + + /** + * 是否与优惠券共享 + */ + private Integer withCoupon; + + /** + * 是否与积分同享 + */ + private Integer withPoints; + + /** + * 充值说明 + */ + private String rechargeDesc; + + /** + * 使用类型 dine-in店内 takeout 自取 post快递,takeaway外卖 + */ + private String useType; + + /** + * 门店id + */ + private Integer shopId; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date updateTime; + + /** + * 可用的子门店id + */ + private String childShopIdList; + + @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; + } + TbFreeDineConfig other = (TbFreeDineConfig) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getEnable() == null ? other.getEnable() == null : this.getEnable().equals(other.getEnable())) + && (this.getRechargeTimes() == null ? other.getRechargeTimes() == null : this.getRechargeTimes().equals(other.getRechargeTimes())) + && (this.getRechargeThreshold() == null ? other.getRechargeThreshold() == null : this.getRechargeThreshold().equals(other.getRechargeThreshold())) + && (this.getWithCoupon() == null ? other.getWithCoupon() == null : this.getWithCoupon().equals(other.getWithCoupon())) + && (this.getWithPoints() == null ? other.getWithPoints() == null : this.getWithPoints().equals(other.getWithPoints())) + && (this.getRechargeDesc() == null ? other.getRechargeDesc() == null : this.getRechargeDesc().equals(other.getRechargeDesc())) + && (this.getUseType() == null ? other.getUseType() == null : this.getUseType().equals(other.getUseType())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) + && (this.getChildShopIdList() == null ? other.getChildShopIdList() == null : this.getChildShopIdList().equals(other.getChildShopIdList())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getEnable() == null) ? 0 : getEnable().hashCode()); + result = prime * result + ((getRechargeTimes() == null) ? 0 : getRechargeTimes().hashCode()); + result = prime * result + ((getRechargeThreshold() == null) ? 0 : getRechargeThreshold().hashCode()); + result = prime * result + ((getWithCoupon() == null) ? 0 : getWithCoupon().hashCode()); + result = prime * result + ((getWithPoints() == null) ? 0 : getWithPoints().hashCode()); + result = prime * result + ((getRechargeDesc() == null) ? 0 : getRechargeDesc().hashCode()); + result = prime * result + ((getUseType() == null) ? 0 : getUseType().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + result = prime * result + ((getChildShopIdList() == null) ? 0 : getChildShopIdList().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(", enable=").append(enable); + sb.append(", rechargeTimes=").append(rechargeTimes); + sb.append(", rechargeThreshold=").append(rechargeThreshold); + sb.append(", withCoupon=").append(withCoupon); + sb.append(", withPoints=").append(withPoints); + sb.append(", rechargeDesc=").append(rechargeDesc); + sb.append(", useType=").append(useType); + sb.append(", shopId=").append(shopId); + sb.append(", createTime=").append(createTime); + sb.append(", updateTime=").append(updateTime); + sb.append(", childShopIdList=").append(childShopIdList); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineRecord.java new file mode 100644 index 0000000..bd64fc0 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbFreeDineRecord.java @@ -0,0 +1,166 @@ +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.math.BigDecimal; +import java.util.Date; +import lombok.Data; + +/** + * 霸王餐充值记录 + * @TableName tb_free_dine_record + */ +@TableName(value ="tb_free_dine_record") +@Data +public class TbFreeDineRecord implements Serializable { + /** + * + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * 0 已选择待消耗 1 已消耗 2 取消支付 + */ + private Integer state; + + /** + * 订单id + */ + private Integer orderId; + + /** + * 订单金额 + */ + private BigDecimal orderAmount; + + /** + * 充值金额 + */ + private BigDecimal rechargeAmount; + + /** + * 最终支付金额 + */ + private BigDecimal payAmount; + + /** + * 用户id + */ + private Integer userId; + + /** + * 会员id + */ + private Integer vipUserId; + + /** + * 店铺id + */ + private Integer shopId; + + /** + * 使用的优惠券信息 + */ + private String couponInfo; + + /** + * 使用的积分信息 + */ + private Integer pointsNum; + + /** + * 充值倍率 + */ + private Integer rechargeTimes; + + /** + * + */ + private BigDecimal rechargeThreshold; + + /** + * 创建时间 + */ + private Date createTime; + + @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; + } + TbFreeDineRecord other = (TbFreeDineRecord) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState())) + && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) + && (this.getOrderAmount() == null ? other.getOrderAmount() == null : this.getOrderAmount().equals(other.getOrderAmount())) + && (this.getRechargeAmount() == null ? other.getRechargeAmount() == null : this.getRechargeAmount().equals(other.getRechargeAmount())) + && (this.getPayAmount() == null ? other.getPayAmount() == null : this.getPayAmount().equals(other.getPayAmount())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getVipUserId() == null ? other.getVipUserId() == null : this.getVipUserId().equals(other.getVipUserId())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getCouponInfo() == null ? other.getCouponInfo() == null : this.getCouponInfo().equals(other.getCouponInfo())) + && (this.getPointsNum() == null ? other.getPointsNum() == null : this.getPointsNum().equals(other.getPointsNum())) + && (this.getRechargeTimes() == null ? other.getRechargeTimes() == null : this.getRechargeTimes().equals(other.getRechargeTimes())) + && (this.getRechargeThreshold() == null ? other.getRechargeThreshold() == null : this.getRechargeThreshold().equals(other.getRechargeThreshold())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getState() == null) ? 0 : getState().hashCode()); + result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); + result = prime * result + ((getOrderAmount() == null) ? 0 : getOrderAmount().hashCode()); + result = prime * result + ((getRechargeAmount() == null) ? 0 : getRechargeAmount().hashCode()); + result = prime * result + ((getPayAmount() == null) ? 0 : getPayAmount().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getVipUserId() == null) ? 0 : getVipUserId().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getCouponInfo() == null) ? 0 : getCouponInfo().hashCode()); + result = prime * result + ((getPointsNum() == null) ? 0 : getPointsNum().hashCode()); + result = prime * result + ((getRechargeTimes() == null) ? 0 : getRechargeTimes().hashCode()); + result = prime * result + ((getRechargeThreshold() == null) ? 0 : getRechargeThreshold().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().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(", state=").append(state); + sb.append(", orderId=").append(orderId); + sb.append(", orderAmount=").append(orderAmount); + sb.append(", rechargeAmount=").append(rechargeAmount); + sb.append(", payAmount=").append(payAmount); + sb.append(", userId=").append(userId); + sb.append(", vipUserId=").append(vipUserId); + sb.append(", shopId=").append(shopId); + sb.append(", couponInfo=").append(couponInfo); + sb.append(", pointsNum=").append(pointsNum); + sb.append(", rechargeTimes=").append(rechargeTimes); + sb.append(", rechargeThreshold=").append(rechargeThreshold); + sb.append(", createTime=").append(createTime); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbIntegral.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbIntegral.java deleted file mode 100644 index ed52c85..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbIntegral.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -public class TbIntegral implements Serializable { - private Integer id; - - private String userId; - - private BigDecimal num; - - private String status; - - private Date createTime; - - private Date updateTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId == null ? null : userId.trim(); - } - - public BigDecimal getNum() { - return num; - } - - public void setNum(BigDecimal num) { - this.num = num; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status == null ? null : status.trim(); - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbIntegralFlow.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbIntegralFlow.java deleted file mode 100644 index 888295e..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbIntegralFlow.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -public class TbIntegralFlow implements Serializable { - private Integer id; - - private String userId; - - private BigDecimal num; - - private Date createTime; - - private Date updateTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId == null ? null : userId.trim(); - } - - public BigDecimal getNum() { - return num; - } - - public void setNum(BigDecimal num) { - this.num = num; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberIn.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberIn.java index aa6b8d4..9ca7508 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberIn.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberIn.java @@ -1,9 +1,12 @@ package com.chaozhanggui.system.cashierservice.entity; +import lombok.Data; + import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; +@Data public class TbMemberIn implements Serializable { private Integer id; @@ -27,93 +30,11 @@ public class TbMemberIn implements Serializable { private Integer shopId; + private Integer orderId; + + private Integer type; + private static final long serialVersionUID = 1L; - public Integer getId() { - return id; - } - public void setId(Integer id) { - this.id = id; - } - - public Integer getUserId() { - return userId; - } - - public void setUserId(Integer userId) { - this.userId = userId; - } - - public Integer getMerchantId() { - return merchantId; - } - - public void setMerchantId(Integer merchantId) { - this.merchantId = merchantId; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code == null ? null : code.trim(); - } - - public BigDecimal getAmount() { - return amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status == null ? null : status.trim(); - } - - public String getOrderNo() { - return orderNo; - } - - public void setOrderNo(String orderNo) { - this.orderNo = orderNo == null ? null : orderNo.trim(); - } - - public String getTradeNo() { - return tradeNo; - } - - public void setTradeNo(String tradeNo) { - this.tradeNo = tradeNo == null ? null : tradeNo.trim(); - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - public Integer getShopId() { - return shopId; - } - - public void setShopId(Integer shopId) { - this.shopId = shopId; - } -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPoints.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPoints.java new file mode 100644 index 0000000..3e3429e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPoints.java @@ -0,0 +1,67 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_shop_user") +public class TbMemberPoints { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 会员id + */ + @TableField(value = "id", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private Long memberId; + /** + * 会员名称 + */ + @TableField("name") + private String memberName; + /** + * 会员头像 + */ + @TableField("head_img") + private String avatarUrl; + /** + * 手机号码 + */ + @TableField("telephone") + private String mobile; + /** + * 账户积分 + */ + @TableField("account_points") + private Integer accountPoints; + /** + * 最近一次积分变动时间 + */ + @TableField("last_points_change_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date lastPointsChangeTime; + /** + * 最近一次浮动积分 + */ + @TableField("last_float_points") + private Integer lastFloatPoints; +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPointsLog.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPointsLog.java new file mode 100644 index 0000000..1d5a609 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPointsLog.java @@ -0,0 +1,70 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_member_points_log") +public class TbMemberPointsLog { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 会员id + */ + private Long memberId; + /** + * 会员名称 + */ + private String memberName; + /** + * 会员头像 + */ + private String avatarUrl; + /** + * 摘要信息(如:兑换某个商品/消费多少钱/充值多少钱/新会员赠送积分等) + */ + private String content; + /** + * 订单编号 + */ + private String orderNo; + /** + * 手机号码 + */ + private String mobile; + /** + * 浮动类型 add-累加 subtract-扣减 + */ + private String floatType; + /** + * 浮动积分(非0正负数) + */ + private Integer floatPoints; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java deleted file mode 100644 index 4f5bee0..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantCoupon.java +++ /dev/null @@ -1,420 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.util.Date; -import java.io.Serializable; - -/** - * 优惠券(TbMerchantCoupon)实体类 - * - * @author lyf - * @since 2024-04-02 09:22:41 - */ -public class TbMerchantCoupon implements Serializable { - private static final long serialVersionUID = 391103766508753856L; - /** - * 自增 - */ - private Integer id; - /** - * 状态0-关闭 1 正常 - */ - private Integer status; - /** - * 优惠券名称 - */ - private String title; - - private String templateId; - - private String shopId; - - private String shopSnap; - /** - * 开始时间 - */ - private Date fromTime; - /** - * 到期时间 - */ - private Date toTime; - /** - * 限领数量 - */ - private String limitNumber; - private String useNumber; - /** - * 发放数量 - */ - private Integer number; - /** - * 剩余数量 - */ - private String leftNumber; - /** - * 优惠金额 - */ - private Double amount; - /** - * 订单满赠金额 - */ - private Double limitAmount; - /** - * 是否显示0-不显示 1显示 - */ - private Integer isShow; - /** - * 图标 - */ - private String pic; - /** - * 0-满减 1-折扣 - */ - private Integer type; - /** - * 折扣 ,一位小数 - */ - private Float ratio; - /** - * 最大折扣金额 - */ - private Double maxRatioAmount; - /** - * 优惠券途径,首充|分销 - */ - private String track; - /** - * 品类product 商品券 ---cateogry 品类券common -通 用券 - */ - private String classType; - /** - * 有效期类型:0-toTime有效 1-effectDays有效 - */ - private Integer effectType; - /** - * 领取之日有效天数 - */ - private Integer effectDays; - /** - * 关联商品Id - */ - private String relationIds; - - private String relationList; - /** - * 发放人 - */ - private String editor; - /** - * 说明 - */ - private String note; - - private Long createdAt; - - private Long updatedAt; - /** - * 支持堂食 - */ - private Integer furnishMeal; - /** - * 支持配送 - */ - private Integer furnishExpress; - /** - * 支持自提 - */ - private Integer furnishDraw; - /** - * 支持虚拟 - */ - private Integer furnishVir; - - private Integer disableDistribute; - /** - * 商户Id - */ - private String merchantId; - - - public String getUseNumber() { - return useNumber; - } - - public void setUseNumber(String useNumber) { - this.useNumber = useNumber; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTemplateId() { - return templateId; - } - - public void setTemplateId(String templateId) { - this.templateId = templateId; - } - - public String getShopId() { - return shopId; - } - - public void setShopId(String shopId) { - this.shopId = shopId; - } - - public String getShopSnap() { - return shopSnap; - } - - public void setShopSnap(String shopSnap) { - this.shopSnap = shopSnap; - } - - public Date getFromTime() { - return fromTime; - } - - public void setFromTime(Date fromTime) { - this.fromTime = fromTime; - } - - public Date getToTime() { - return toTime; - } - - public void setToTime(Date toTime) { - this.toTime = toTime; - } - - public String getLimitNumber() { - return limitNumber; - } - - public void setLimitNumber(String limitNumber) { - this.limitNumber = limitNumber; - } - - public Integer getNumber() { - return number; - } - - public void setNumber(Integer number) { - this.number = number; - } - - public String getLeftNumber() { - return leftNumber; - } - - public void setLeftNumber(String leftNumber) { - this.leftNumber = leftNumber; - } - - public Double getAmount() { - return amount; - } - - public void setAmount(Double amount) { - this.amount = amount; - } - - public Double getLimitAmount() { - return limitAmount; - } - - public void setLimitAmount(Double limitAmount) { - this.limitAmount = limitAmount; - } - - public Integer getIsShow() { - return isShow; - } - - public void setIsShow(Integer isShow) { - this.isShow = isShow; - } - - public String getPic() { - return pic; - } - - public void setPic(String pic) { - this.pic = pic; - } - - public Integer getType() { - return type; - } - - public void setType(Integer type) { - this.type = type; - } - - public Float getRatio() { - return ratio; - } - - public void setRatio(Float ratio) { - this.ratio = ratio; - } - - public Double getMaxRatioAmount() { - return maxRatioAmount; - } - - public void setMaxRatioAmount(Double maxRatioAmount) { - this.maxRatioAmount = maxRatioAmount; - } - - public String getTrack() { - return track; - } - - public void setTrack(String track) { - this.track = track; - } - - public String getClassType() { - return classType; - } - - public void setClassType(String classType) { - this.classType = classType; - } - - public Integer getEffectType() { - return effectType; - } - - public void setEffectType(Integer effectType) { - this.effectType = effectType; - } - - public Integer getEffectDays() { - return effectDays; - } - - public void setEffectDays(Integer effectDays) { - this.effectDays = effectDays; - } - - public String getRelationIds() { - return relationIds; - } - - public void setRelationIds(String relationIds) { - this.relationIds = relationIds; - } - - public String getRelationList() { - return relationList; - } - - public void setRelationList(String relationList) { - this.relationList = relationList; - } - - public String getEditor() { - return editor; - } - - public void setEditor(String editor) { - this.editor = editor; - } - - public String getNote() { - return note; - } - - public void setNote(String note) { - this.note = note; - } - - 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; - } - - public Integer getFurnishMeal() { - return furnishMeal; - } - - public void setFurnishMeal(Integer furnishMeal) { - this.furnishMeal = furnishMeal; - } - - public Integer getFurnishExpress() { - return furnishExpress; - } - - public void setFurnishExpress(Integer furnishExpress) { - this.furnishExpress = furnishExpress; - } - - public Integer getFurnishDraw() { - return furnishDraw; - } - - public void setFurnishDraw(Integer furnishDraw) { - this.furnishDraw = furnishDraw; - } - - public Integer getFurnishVir() { - return furnishVir; - } - - public void setFurnishVir(Integer furnishVir) { - this.furnishVir = furnishVir; - } - - public Integer getDisableDistribute() { - return disableDistribute; - } - - public void setDisableDistribute(Integer disableDistribute) { - this.disableDistribute = disableDistribute; - } - - public String getMerchantId() { - return merchantId; - } - - public void setMerchantId(String merchantId) { - this.merchantId = merchantId; - } - -} - diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java index 8e9901e..4e1fd88 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMerchantThirdApply.java @@ -23,6 +23,8 @@ public class TbMerchantThirdApply implements Serializable { private String smallAppid; + private String alipaySmallAppid; + private String storeId; @@ -117,4 +119,12 @@ public class TbMerchantThirdApply implements Serializable { public void setStoreId(String storeId) { this.storeId = storeId; } + + public String getAlipaySmallAppid() { + return alipaySmallAppid; + } + + public void setAlipaySmallAppid(String alipaySmallAppid) { + this.alipaySmallAppid = alipaySmallAppid; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java index 3d97089..d91d8db 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java @@ -1,5 +1,6 @@ package com.chaozhanggui.system.cashierservice.entity; +import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import java.io.Serializable; @@ -20,6 +21,8 @@ public class TbOrderDetail implements Serializable { private Integer num; + private Byte isVip; + private String productName; private String status; @@ -35,6 +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; -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java index 60a3dcf..f87e7f4 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java @@ -1,5 +1,9 @@ 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.chaozhanggui.system.cashierservice.constant.TableConstant; import lombok.Data; import java.io.Serializable; @@ -8,6 +12,7 @@ import java.util.List; @Data public class TbOrderInfo implements Serializable { + @TableId(type = IdType.AUTO) private Integer id; //订单号 @@ -58,11 +63,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 +106,37 @@ public class TbOrderInfo implements Serializable { private String masterId; private String isBuyCoupon; private String isUseCoupon; + @TableField(exist = false) private Integer totalNumber; + @TableField(exist = false) private List detailList; + @TableField(exist = false) private String winnnerNo; + @TableField(exist = false) private String isWinner; + @TableField(exist = false) + private String shopName; + + private String useType; + + // 下单次数 + private Integer placeNum; + + private Integer seatCount; + private BigDecimal seatAmount; + private BigDecimal pointsDiscountAmount; + private Integer pointsNum; + // 用户优惠券id + private String activateInInfoList; + private BigDecimal activateInDiscountAmount; //根据状态返回 需付款 已付款 未付款 已退 + @TableField(exist = false) private String description; - public void setDescription() { + public void setDescription(String shopName) { + this.shopName = shopName; switch (status) { case "closed": this.description = "已付款"; @@ -186,4 +216,8 @@ public class TbOrderInfo implements Serializable { this.createdAt = System.currentTimeMillis(); this.isAccepted = 1; } -} \ No newline at end of file + + public String getEatModel() { + return TableConstant.OrderInfo.UseType.TAKEOUT.equalsVals(this.getUseType()) ? TableConstant.ShopInfo.EatModel.TAKEOUT.getValue() : TableConstant.ShopInfo.EatModel.DINE_IN.getValue(); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbParams.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbParams.java deleted file mode 100644 index 5aa9414..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbParams.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - - -@Data -public class TbParams implements Serializable { - private Integer id; - - private BigDecimal integralRatio; - private BigDecimal twoRatio; - - private BigDecimal tradeRatio; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlussDeviceGoods.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlussDeviceGoods.java deleted file mode 100644 index d3132cc..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlussDeviceGoods.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.util.Date; - -public class TbPlussDeviceGoods implements Serializable { - private Integer id; - - private String code; - - private String name; - - private String devicelogo; - - private String introdesc; - - private Integer sort; - - private Integer status; - - private Integer tagid; - - private String depositflag; - - private Date createtime; - - private Date updatetime; - - private String detail; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code == null ? null : code.trim(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - public String getDevicelogo() { - return devicelogo; - } - - public void setDevicelogo(String devicelogo) { - this.devicelogo = devicelogo == null ? null : devicelogo.trim(); - } - - public String getIntrodesc() { - return introdesc; - } - - public void setIntrodesc(String introdesc) { - this.introdesc = introdesc == null ? null : introdesc.trim(); - } - - public Integer getSort() { - return sort; - } - - public void setSort(Integer sort) { - this.sort = sort; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public Integer getTagid() { - return tagid; - } - - public void setTagid(Integer tagid) { - this.tagid = tagid; - } - - public String getDepositflag() { - return depositflag; - } - - public void setDepositflag(String depositflag) { - this.depositflag = depositflag == null ? null : depositflag.trim(); - } - - public Date getCreatetime() { - return createtime; - } - - public void setCreatetime(Date createtime) { - this.createtime = createtime; - } - - public Date getUpdatetime() { - return updatetime; - } - - public void setUpdatetime(Date updatetime) { - this.updatetime = updatetime; - } - - public String getDetail() { - return detail; - } - - public void setDetail(String detail) { - this.detail = detail == null ? null : detail.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsBasicSetting.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsBasicSetting.java new file mode 100644 index 0000000..0c10760 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsBasicSetting.java @@ -0,0 +1,71 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_points_basic_setting") +public class TbPointsBasicSetting { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 开启消费赠送积分 1-开启 0-关闭 + */ + private Integer enableRewards; + /** + * 每消费xx元赠送1积分 + */ + private BigDecimal consumeAmount; + /** + * 开启下单积分抵扣 1-开启 0-关闭 + */ + private Integer enableDeduction; + /** + * 下单积分抵扣门槛 + */ + private Integer minDeductionPoint; + /** + * 下单最高抵扣比例 + */ + private BigDecimal maxDeductionRatio; + /** + * 下单抵扣积分比例 1元=?积分 + */ + private Integer equivalentPoints; + /** + * 开启积分商城 1-开启 0-关闭 + */ + private Integer enablePointsMall; + /** + * 浏览模式 list-列表 grid-宫格 + */ + private String browseMode; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsExchangeRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsExchangeRecord.java new file mode 100644 index 0000000..5013fc3 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsExchangeRecord.java @@ -0,0 +1,100 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_points_exchange_record") +public class TbPointsExchangeRecord { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单编号 + */ + private String orderNo; + /** + * 店铺id + */ + private Long shopId; + /** + * 积分商品id + */ + private Long pointsGoodsId; + /** + * 积分商品名称 + */ + private String pointsGoodsName; + /** + * 商品图片URL + */ + private String goodsImageUrl; + /** + * 领取方式 self-自取 post-邮寄 + */ + private String pickupMethod; + /** + * 会员id + */ + private Long memberId; + /** + * 会员名称 + */ + private String memberName; + /** + * 手机号码 + */ + private String mobile; + /** + * 会员头像 + */ + private String avatarUrl; + /** + * 消耗积分 + */ + private Integer spendPoints; + /** + * 额外支付 + */ + private BigDecimal extraPaymentAmount; + /** + * 兑换券券码 + */ + private String couponCode; + /** + * 状态 waiting-待自取 done-已完成 + */ + private String status; + /** + * 创建时间(下单时间) + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + /** + * 更新时间(核销时间) + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + @TableField(value = "count(*)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private Long count; + + @TableField(value = "sum(extra_payment_amount)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private BigDecimal totalAmount; +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsGoodsSetting.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsGoodsSetting.java new file mode 100644 index 0000000..3cf3932 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPointsGoodsSetting.java @@ -0,0 +1,89 @@ +package com.chaozhanggui.system.cashierservice.entity; + + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_points_goods_setting") +public class TbPointsGoodsSetting { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 商品类型 physical-实物 coupon-优惠劵 + */ + private String goodsCategory; + /** + * 商品名称 + */ + private String goodsName; + /** + * 商品图片URL + */ + @TableField(value = "goods_image_url", updateStrategy = FieldStrategy.IGNORED) + private String goodsImageUrl; + /** + * 所需积分 + */ + private Integer requiredPoints; + /** + * 额外价格 + */ + private BigDecimal extraPrice; + /** + * 排序(权重),数字越高,显示约靠前 + */ + private Integer sort; + /** + * 数量 + */ + private Integer quantity; + /** + * 商品详情 + */ + @TableField(value = "goods_description", updateStrategy = FieldStrategy.IGNORED) + private String goodsDescription; + /** + * 累计兑换数量 + */ + private Integer totalExchangeCount; + /** + * 是否上架 1-是 0-否 + */ + private Integer status; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + /** + * 逻辑删除标志 1-是 0-否 + */ + private Integer delFlag; +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java index 3bdee44..2518cdf 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPrintMachine.java @@ -35,6 +35,14 @@ public class TbPrintMachine implements Serializable { private String productId; + private String receiptSize; + private String classifyPrint; + private String tablePrint; + private String printQty; + private String printMethod; + private String printType; + private String printReceipt; + private static final long serialVersionUID = 1L; public Integer getId() { @@ -164,4 +172,60 @@ public class TbPrintMachine implements Serializable { public void setProductId(String productId) { this.productId = productId == null ? null : productId.trim(); } + + public String getReceiptSize() { + return receiptSize; + } + + public void setReceiptSize(String receiptSize) { + this.receiptSize = receiptSize; + } + + public String getClassifyPrint() { + return classifyPrint; + } + + public void setClassifyPrint(String classifyPrint) { + this.classifyPrint = classifyPrint; + } + + public String getTablePrint() { + return tablePrint; + } + + public void setTablePrint(String tablePrint) { + this.tablePrint = tablePrint; + } + + public String getPrintQty() { + return printQty; + } + + public void setPrintQty(String printQty) { + this.printQty = printQty; + } + + public String getPrintMethod() { + return printMethod; + } + + public void setPrintMethod(String printMethod) { + this.printMethod = printMethod; + } + + public String getPrintType() { + return printType; + } + + public void setPrintType(String printType) { + this.printType = printType; + } + + public String getPrintReceipt() { + return printReceipt; + } + + public void setPrintReceipt(String printReceipt) { + this.printReceipt = printReceipt; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java index ba7404d..e455026 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java @@ -66,11 +66,6 @@ public class TbProduct implements Serializable { private String typeEnum; - /** - * 是否共享库存 - */ - private Byte isDistribute; - private Byte isDel; private Byte isStock; @@ -140,6 +135,9 @@ public class TbProduct implements Serializable { //是否可售 1 可售 0非可售 private Integer isSale = 1; + private Integer warnLine = 0; + + public String getImages() { return images; @@ -403,13 +401,6 @@ public class TbProduct implements Serializable { this.typeEnum = typeEnum == null ? null : typeEnum.trim(); } - public Byte getIsDistribute() { - return isDistribute; - } - - public void setIsDistribute(Byte isDistribute) { - this.isDistribute = isDistribute; - } public Byte getIsDel() { return isDel; @@ -683,4 +674,12 @@ public class TbProduct implements Serializable { public void setIsSale(Integer isSale) { this.isSale = isSale; } + + public Integer getWarnLine() { + return warnLine; + } + + public void setWarnLine(Integer warnLine) { + this.warnLine = warnLine; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java index 325eda4..5005cce 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java @@ -32,7 +32,6 @@ public class TbProductSku implements Serializable { private String coverImg; - private Integer warnLine; private Double weight; @@ -175,14 +174,6 @@ public class TbProductSku implements Serializable { this.coverImg = coverImg == null ? null : coverImg.trim(); } - public Integer getWarnLine() { - return warnLine; - } - - public void setWarnLine(Integer warnLine) { - this.warnLine = warnLine; - } - public Double getWeight() { return weight; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbReceiptSales.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbReceiptSales.java deleted file mode 100644 index 1a38a26..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbReceiptSales.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; - -public class TbReceiptSales implements Serializable { - private Integer id; - - private String title; - - private String logo; - - private Boolean showContactInfo; - - private Boolean showMember; - - private Boolean showMemberCode; - - private Boolean showMemberScore; - - private Boolean showMemberWallet; - - private String footerRemark; - - private Boolean showCashCharge; - - private Boolean showSerialNo; - - private Boolean bigSerialNo; - - private String headerText; - - private String headerTextAlign; - - private String footerText; - - private String footerTextAlign; - - private String footerImage; - - private String prePrint; - - private Long createdAt; - - private Long updatedAt; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title == null ? null : title.trim(); - } - - public String getLogo() { - return logo; - } - - public void setLogo(String logo) { - this.logo = logo == null ? null : logo.trim(); - } - - public Boolean getShowContactInfo() { - return showContactInfo; - } - - public void setShowContactInfo(Boolean showContactInfo) { - this.showContactInfo = showContactInfo; - } - - public Boolean getShowMember() { - return showMember; - } - - public void setShowMember(Boolean showMember) { - this.showMember = showMember; - } - - public Boolean getShowMemberCode() { - return showMemberCode; - } - - public void setShowMemberCode(Boolean showMemberCode) { - this.showMemberCode = showMemberCode; - } - - public Boolean getShowMemberScore() { - return showMemberScore; - } - - public void setShowMemberScore(Boolean showMemberScore) { - this.showMemberScore = showMemberScore; - } - - public Boolean getShowMemberWallet() { - return showMemberWallet; - } - - public void setShowMemberWallet(Boolean showMemberWallet) { - this.showMemberWallet = showMemberWallet; - } - - public String getFooterRemark() { - return footerRemark; - } - - public void setFooterRemark(String footerRemark) { - this.footerRemark = footerRemark == null ? null : footerRemark.trim(); - } - - public Boolean getShowCashCharge() { - return showCashCharge; - } - - public void setShowCashCharge(Boolean showCashCharge) { - this.showCashCharge = showCashCharge; - } - - public Boolean getShowSerialNo() { - return showSerialNo; - } - - public void setShowSerialNo(Boolean showSerialNo) { - this.showSerialNo = showSerialNo; - } - - public Boolean getBigSerialNo() { - return bigSerialNo; - } - - public void setBigSerialNo(Boolean bigSerialNo) { - this.bigSerialNo = bigSerialNo; - } - - public String getHeaderText() { - return headerText; - } - - public void setHeaderText(String headerText) { - this.headerText = headerText == null ? null : headerText.trim(); - } - - public String getHeaderTextAlign() { - return headerTextAlign; - } - - public void setHeaderTextAlign(String headerTextAlign) { - this.headerTextAlign = headerTextAlign == null ? null : headerTextAlign.trim(); - } - - public String getFooterText() { - return footerText; - } - - public void setFooterText(String footerText) { - this.footerText = footerText == null ? null : footerText.trim(); - } - - public String getFooterTextAlign() { - return footerTextAlign; - } - - public void setFooterTextAlign(String footerTextAlign) { - this.footerTextAlign = footerTextAlign == null ? null : footerTextAlign.trim(); - } - - public String getFooterImage() { - return footerImage; - } - - public void setFooterImage(String footerImage) { - this.footerImage = footerImage == null ? null : footerImage.trim(); - } - - public String getPrePrint() { - return prePrint; - } - - public void setPrePrint(String prePrint) { - this.prePrint = prePrint == null ? null : prePrint.trim(); - } - - public Long getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Long updatedAt) { - this.updatedAt = updatedAt; - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbReleaseFlow.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbReleaseFlow.java deleted file mode 100644 index 34414ed..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbReleaseFlow.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -@Data -public class TbReleaseFlow implements Serializable { - private Integer id; - - private String userId; - - private BigDecimal num; - - private String type; - private String operationType; - - private String remark; - private String nickName; - - private String fromSource; - - private Date createTime; - private String createTr; - private String openId; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbRenewalsPayLog.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbRenewalsPayLog.java deleted file mode 100644 index 9a4bcbd..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbRenewalsPayLog.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.math.BigDecimal; - -public class TbRenewalsPayLog implements Serializable { - private Integer id; - - private String payType; - - private String shopId; - - private String orderId; - - private String openId; - - private String userId; - - private String transactionId; - - private BigDecimal amount; - - private Byte status; - - private String remark; - - private String attach; - - private Long expiredAt; - - private Long createdAt; - - private Long updatedAt; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getPayType() { - return payType; - } - - public void setPayType(String payType) { - this.payType = payType == null ? null : payType.trim(); - } - - public String getShopId() { - return shopId; - } - - public void setShopId(String shopId) { - this.shopId = shopId == null ? null : shopId.trim(); - } - - public String getOrderId() { - return orderId; - } - - public void setOrderId(String orderId) { - this.orderId = orderId == null ? null : orderId.trim(); - } - - public String getOpenId() { - return openId; - } - - public void setOpenId(String openId) { - this.openId = openId == null ? null : openId.trim(); - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId == null ? null : userId.trim(); - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId == null ? null : transactionId.trim(); - } - - public BigDecimal getAmount() { - return amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public Byte getStatus() { - return status; - } - - public void setStatus(Byte status) { - this.status = status; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark == null ? null : remark.trim(); - } - - public String getAttach() { - return attach; - } - - public void setAttach(String attach) { - this.attach = attach == null ? null : attach.trim(); - } - - public Long getExpiredAt() { - return expiredAt; - } - - public void setExpiredAt(Long expiredAt) { - this.expiredAt = expiredAt; - } - - public Long getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Long updatedAt) { - this.updatedAt = updatedAt; - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCashSpread.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCashSpread.java deleted file mode 100644 index 1a6d486..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCashSpread.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; - -public class TbShopCashSpread implements Serializable { - private Integer id; - - private Long createdAt; - - private Long updatedAt; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Long getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Long updatedAt) { - this.updatedAt = updatedAt; - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCashSpreadWithBLOBs.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCashSpreadWithBLOBs.java deleted file mode 100644 index ac6cc8a..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCashSpreadWithBLOBs.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; - -public class TbShopCashSpreadWithBLOBs extends TbShopCashSpread implements Serializable { - private String saleReceipt; - - private String triplicateReceipt; - - private String screenConfig; - - private String tagConfig; - - private String scaleConfig; - - private static final long serialVersionUID = 1L; - - public String getSaleReceipt() { - return saleReceipt; - } - - public void setSaleReceipt(String saleReceipt) { - this.saleReceipt = saleReceipt == null ? null : saleReceipt.trim(); - } - - public String getTriplicateReceipt() { - return triplicateReceipt; - } - - public void setTriplicateReceipt(String triplicateReceipt) { - this.triplicateReceipt = triplicateReceipt == null ? null : triplicateReceipt.trim(); - } - - public String getScreenConfig() { - return screenConfig; - } - - public void setScreenConfig(String screenConfig) { - this.screenConfig = screenConfig == null ? null : screenConfig.trim(); - } - - public String getTagConfig() { - return tagConfig; - } - - public void setTagConfig(String tagConfig) { - this.tagConfig = tagConfig == null ? null : tagConfig.trim(); - } - - public String getScaleConfig() { - return scaleConfig; - } - - public void setScaleConfig(String scaleConfig) { - this.scaleConfig = scaleConfig == null ? null : scaleConfig.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCoupon.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCoupon.java new file mode 100644 index 0000000..fc54428 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCoupon.java @@ -0,0 +1,288 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.time.LocalTime; +import java.util.Date; +import java.io.Serializable; + +/** + * 优惠券(TbShopCoupon)实体类 + * + * @author ww + * @since 2024-10-24 10:40:00 + */ +public class TbShopCoupon implements Serializable { + private static final long serialVersionUID = 382961088281627909L; + /** + * 自增 + */ + private Integer id; + + private String shopId; + /** + * 名称(无意义) + */ + private String title; + /** + * 1-满减 2-商品 + */ + private Integer type; + /** + * 满多少金额 + */ + private Integer fullAmount; + /** + * 减多少金额 + */ + private Integer discountAmount; + /** + * 描述 + */ + private String description; + /** + * 发放数量 + */ + private Integer number; + /** + * 剩余数量 + */ + private Integer leftNumber; + /** + * 有效期类型,可选值为 fixed(固定时间)/custom(自定义时间) + */ + private String validityType; + /** + * 有效天数 + */ + private Integer validDays; + /** + * 隔多少天生效 + */ + private Integer daysToTakeEffect; + /** + * 有效开始时间 + */ + private Date validStartTime; + /** + * 有效结束时间 + */ + private Date validEndTime; + /** + * 周 数组["周一","周二"] + */ + private String userDays; + /** + * all-全时段 custom-指定时段 + */ + private String useTimeType; + /** + * 可用开始时间 + */ + private LocalTime useStartTime; + /** + * 可用结束时间 + */ + private LocalTime useEndTime; + /** + * 已使用数量 + */ + private Integer useNumber; + /** + * 发放人 + */ + private String editor; + /** + * 状态0-关闭 1 正常 + */ + private Integer status; + + private Date createTime; + + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getShopId() { + return shopId; + } + + public void setShopId(String shopId) { + this.shopId = shopId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getFullAmount() { + return fullAmount; + } + + public void setFullAmount(Integer fullAmount) { + this.fullAmount = fullAmount; + } + + public Integer getDiscountAmount() { + return discountAmount; + } + + public void setDiscountAmount(Integer discountAmount) { + this.discountAmount = discountAmount; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + + public Integer getLeftNumber() { + return leftNumber; + } + + public void setLeftNumber(Integer leftNumber) { + this.leftNumber = leftNumber; + } + + public String getValidityType() { + return validityType; + } + + public void setValidityType(String validityType) { + this.validityType = validityType; + } + + public Integer getValidDays() { + return validDays; + } + + public void setValidDays(Integer validDays) { + this.validDays = validDays; + } + + public Integer getDaysToTakeEffect() { + return daysToTakeEffect; + } + + public void setDaysToTakeEffect(Integer daysToTakeEffect) { + this.daysToTakeEffect = daysToTakeEffect; + } + + public Date getValidStartTime() { + return validStartTime; + } + + public void setValidStartTime(Date validStartTime) { + this.validStartTime = validStartTime; + } + + public Date getValidEndTime() { + return validEndTime; + } + + public void setValidEndTime(Date validEndTime) { + this.validEndTime = validEndTime; + } + + public String getUserDays() { + return userDays; + } + + public void setUserDays(String userDays) { + this.userDays = userDays; + } + + public String getUseTimeType() { + return useTimeType; + } + + public void setUseTimeType(String useTimeType) { + this.useTimeType = useTimeType; + } + + public LocalTime getUseStartTime() { + return useStartTime; + } + + public void setUseStartTime(LocalTime useStartTime) { + this.useStartTime = useStartTime; + } + + public LocalTime getUseEndTime() { + return useEndTime; + } + + public void setUseEndTime(LocalTime useEndTime) { + this.useEndTime = useEndTime; + } + + public Integer getUseNumber() { + return useNumber; + } + + public void setUseNumber(Integer useNumber) { + this.useNumber = useNumber; + } + + public String getEditor() { + return editor; + } + + public void setEditor(String editor) { + this.editor = editor; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCurrency.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCurrency.java deleted file mode 100644 index 4b71c95..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCurrency.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.math.BigDecimal; - -public class TbShopCurrency implements Serializable { - private Integer id; - - private String shopId; - - private BigDecimal prepareAmount; - - private String currency; - - private Byte decimalsDigits; - - private String discountRound; - - private String merchantId; - - private Byte smallChange; - - private Byte enableCustomDiscount; - - private BigDecimal maxDiscount; - - private Double maxPercent; - - private String bizDuration; - - private Byte allowWebPay; - - private Byte isAutoToZero; - - private Byte isIncludeTaxPrice; - - private String taxNumber; - - private Long createdAt; - - private Long updatedAt; - - private Byte autoLockScreen; - - private Byte voiceNotification; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getShopId() { - return shopId; - } - - public void setShopId(String shopId) { - this.shopId = shopId == null ? null : shopId.trim(); - } - - public BigDecimal getPrepareAmount() { - return prepareAmount; - } - - public void setPrepareAmount(BigDecimal prepareAmount) { - this.prepareAmount = prepareAmount; - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency == null ? null : currency.trim(); - } - - public Byte getDecimalsDigits() { - return decimalsDigits; - } - - public void setDecimalsDigits(Byte decimalsDigits) { - this.decimalsDigits = decimalsDigits; - } - - public String getDiscountRound() { - return discountRound; - } - - public void setDiscountRound(String discountRound) { - this.discountRound = discountRound == null ? null : discountRound.trim(); - } - - public String getMerchantId() { - return merchantId; - } - - public void setMerchantId(String merchantId) { - this.merchantId = merchantId == null ? null : merchantId.trim(); - } - - public Byte getSmallChange() { - return smallChange; - } - - public void setSmallChange(Byte smallChange) { - this.smallChange = smallChange; - } - - public Byte getEnableCustomDiscount() { - return enableCustomDiscount; - } - - public void setEnableCustomDiscount(Byte enableCustomDiscount) { - this.enableCustomDiscount = enableCustomDiscount; - } - - public BigDecimal getMaxDiscount() { - return maxDiscount; - } - - public void setMaxDiscount(BigDecimal maxDiscount) { - this.maxDiscount = maxDiscount; - } - - public Double getMaxPercent() { - return maxPercent; - } - - public void setMaxPercent(Double maxPercent) { - this.maxPercent = maxPercent; - } - - public String getBizDuration() { - return bizDuration; - } - - public void setBizDuration(String bizDuration) { - this.bizDuration = bizDuration == null ? null : bizDuration.trim(); - } - - public Byte getAllowWebPay() { - return allowWebPay; - } - - public void setAllowWebPay(Byte allowWebPay) { - this.allowWebPay = allowWebPay; - } - - public Byte getIsAutoToZero() { - return isAutoToZero; - } - - public void setIsAutoToZero(Byte isAutoToZero) { - this.isAutoToZero = isAutoToZero; - } - - public Byte getIsIncludeTaxPrice() { - return isIncludeTaxPrice; - } - - public void setIsIncludeTaxPrice(Byte isIncludeTaxPrice) { - this.isIncludeTaxPrice = isIncludeTaxPrice; - } - - public String getTaxNumber() { - return taxNumber; - } - - public void setTaxNumber(String taxNumber) { - this.taxNumber = taxNumber == null ? null : taxNumber.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; - } - - public Byte getAutoLockScreen() { - return autoLockScreen; - } - - public void setAutoLockScreen(Byte autoLockScreen) { - this.autoLockScreen = autoLockScreen; - } - - public Byte getVoiceNotification() { - return voiceNotification; - } - - public void setVoiceNotification(Byte voiceNotification) { - this.voiceNotification = voiceNotification; - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCurrencyWithBLOBs.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCurrencyWithBLOBs.java deleted file mode 100644 index 5fc056b..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopCurrencyWithBLOBs.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; - -public class TbShopCurrencyWithBLOBs extends TbShopCurrency implements Serializable { - private String discountConfigs; - - private String serviceCharge; - - private static final long serialVersionUID = 1L; - - public String getDiscountConfigs() { - return discountConfigs; - } - - public void setDiscountConfigs(String discountConfigs) { - this.discountConfigs = discountConfigs == null ? null : discountConfigs.trim(); - } - - public String getServiceCharge() { - return serviceCharge; - } - - public void setServiceCharge(String serviceCharge) { - this.serviceCharge = serviceCharge == null ? null : serviceCharge.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopExtend.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopExtend.java new file mode 100644 index 0000000..82867d6 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopExtend.java @@ -0,0 +1,113 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 店铺扩展信息(TbShopExtend)实体类 + * + * @author ww + * @since 2024-08-21 09:40:26 + */ +public class TbShopExtend implements Serializable { + private static final long serialVersionUID = -25782280496188600L; + /** + * 自增id + */ + private Integer id; + /** + * 商户Id + */ + private Integer shopId; + /** + * img:图片;text:文本; + */ + private String type; + /** + * 描述 + */ + private String name; + /** + * 自定义key + */ + private String autokey; + /** + * 值 + */ + private String value; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 创建时间 + */ + private Date createTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAutokey() { + return autokey; + } + + public void setAutokey(String autokey) { + this.autokey = autokey; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java index 4e94053..a7665ac 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java @@ -5,114 +5,263 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; - +/** + * (TbShopInfo)实体类 + * + * @author ww + * @since 2024-10-23 15:03:55 + */ @Data public class TbShopInfo implements Serializable { + private static final long serialVersionUID = -75915575260078554L; + + /** + * 自增id + */ private Integer id; - + /** + * 店铺帐号 + */ private String account; - + /** + * 店铺代号,策略方式为city +店铺号(8位) + */ private String shopCode; - + /** + * 店铺口号 + */ private String subTitle; - + /** + * 商户Id + */ private String merchantId; - + /** + * 店铺名称 + */ private String shopName; - + /** + * 连锁店扩展店名 + */ private String chainName; - + /** + * 背景图 + */ private String backImg; - + /** + * 门头照 + */ private String frontImg; - + /** + * 联系人姓名 + */ private String contactName; - + /** + * 联系电话 + */ private String phone; - + /** + * 店铺log0 + */ private String logo; - - private Byte isDeposit; - - private Byte isSupply; - + /** + * 是否参与代收 0--不参与 1参与 + */ + private Integer isDeposit; + /** + * 是否为供应商 + */ + private Integer isSupply; + /** + * 封面图 + */ private String coverImg; - + /** + * 店铺分享图 + */ private String shareImg; - + /** + * 轮播图 + */ + private String view; + /** + * 店铺简介 + */ private String detail; - + /** + * 经纬度 + */ private String lat; - + /** + * 经纬度 + */ private String lng; - + /** + * 未用 + */ private String mchId; private String registerType; - - private Byte isWxMaIndependent; - + /** + * 是否独立的微信小程序 + */ + private Integer isWxMaIndependent; + /** + * 详细地址 + */ private String address; - + /** + * 类似于这种规则51.51.570 + */ private String city; - + /** + * 店铺类型 超市--MARKET---其它店SHOP + */ private String type; - + /** + * 行业 + */ private String industry; - + /** + * 行业名称 + */ private String industryName; - + /** + * 营业时间(周开始) + */ private String businessStartDay; + /** + * 营业时间(周结束) + */ private String businessEndDay; + /** + * 营业时间 + */ private String businessTime; - + /** + * 配送时间 + */ private String postTime; private BigDecimal postAmountLine; - - private Byte onSale; - - private Byte settleType; - + /** + * 0停业1,正常营业,网上售卖 + */ + private Integer onSale; + /** + * 0今日,1次日 + */ + private Integer settleType; + /** + * 时间 + */ private String settleTime; - + /** + * 入驻时间 + */ private Integer enterAt; - + /** + * 到期时间 + */ private Long expireAt; - - private Byte status; - - private Float average; - + /** + * -1 平台禁用 0-过期,1正式营业, + */ + private Integer status; + /** + * 人均消费 + */ + private BigDecimal average; + /** + * 订单等待时间 + */ private Integer orderWaitPayMinute; - + /** + * 支持登陆设备个数 + */ private Integer supportDeviceNumber; - - private Byte distributeLevel; + /** + * 分销层级(1-下级分销 2-两下级分销) + */ + private Integer distributeLevel; private Long createdAt; private Long updatedAt; private String proxyId; - - private String view; + /** + * trial试用版,release正式 + */ + private String profiles; /** * 商家二维码 */ private String shopQrcode; - private String isOpenYhq; - private Byte isUseVip; /** - * 商户标签 + * 商家标签 */ private String tag; + + private String isOpenYhq; + /** + * 0否1是 + */ + private Integer isUseVip; + /** + * 省 + */ private String provinces; + /** + * 市 + */ private String cities; + /** + * 区/县 + */ private String districts; - + /** + * 是否允许会员自定义金额 1 允许 0 不允许 + */ private String isCustom; + /** + * 是否开启退款密码 1 启用 0 禁用 + */ + private String isReturn; + /** + * 是否开启会员充值密码 1 启用 0 禁用 + */ + private String isMemberIn; + /** + * 是否开启会员退款密码 1 启用 0 禁用 + */ + private String isMemberReturn; + /** + * 是否免除桌位费 0否1是 + */ + private Integer isTableFee; + /** + * 是否启用会员价 0否1是 + */ + private Integer isMemberPrice; + /** + * 积分群体 all-所有 vip-仅针对会员 + */ + private String consumeColony; + /** + * 桌位费 + */ + private BigDecimal tableFee; + /** + * 就餐模式 堂食 dine-in 外带 take-out + */ + private String eatModel; + /** + * 小程序码(零点八零首页) + */ + private String smallQrcode; + /** + * 店铺收款码 + */ + private String paymentQrcode; - private static final long serialVersionUID = 1L; - -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java index 9fd5e39..a4f2bcd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopTable.java @@ -1,8 +1,13 @@ package com.chaozhanggui.system.cashierservice.entity; +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + import java.io.Serializable; import java.math.BigDecimal; +import java.util.Date; +@Data public class TbShopTable implements Serializable { private Integer id; @@ -36,144 +41,26 @@ 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; - } + private Integer autoClear; + private Date useTime; + private Date endTime; + private Integer productNum; + private BigDecimal totalAmount; + private BigDecimal realAmount; + private Integer useNum; - public void setQrcode(String qrcode) { - this.qrcode = qrcode; - } - private static final long serialVersionUID = 1L; - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - public Integer getShopId() { - return shopId; - } - - public void setShopId(Integer shopId) { - this.shopId = shopId; - } - - public Integer getMaxCapacity() { - return maxCapacity; - } - - public void setMaxCapacity(Integer maxCapacity) { - this.maxCapacity = maxCapacity; - } - - public Integer getSort() { - return sort; - } - - public void setSort(Integer sort) { - this.sort = sort; - } - - public Integer getAreaId() { - return areaId; - } - - public void setAreaId(Integer areaId) { - this.areaId = areaId; - } - - public Byte getIsPredate() { - return isPredate; - } - - public void setIsPredate(Byte isPredate) { - this.isPredate = isPredate; - } - - public BigDecimal getPredateAmount() { - return predateAmount; - } - - public void setPredateAmount(BigDecimal predateAmount) { - this.predateAmount = predateAmount; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status == null ? null : status.trim(); - } - - public Byte getType() { - return type; - } - - public void setType(Byte type) { - this.type = type; - } - - public BigDecimal getAmount() { - return amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public BigDecimal getPerhour() { - return perhour; - } - - public void setPerhour(BigDecimal perhour) { - this.perhour = perhour; - } - - public String getView() { - return view; - } - - public void setView(String view) { - this.view = view == null ? null : view.trim(); - } - - public Long getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Long updatedAt) { - this.updatedAt = updatedAt; - } -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java index 0c9ad7d..0d47251 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java @@ -4,6 +4,7 @@ import org.springframework.data.annotation.Transient; import java.io.Serializable; import java.math.BigDecimal; +import java.sql.Timestamp; public class TbShopUser implements Serializable { private String id; @@ -70,10 +71,14 @@ public class TbShopUser implements Serializable { private String lng=""; private String address=""; - @Transient private String isUser; + private Timestamp joinTime; + + + + private static final long serialVersionUID = 1L; public String getId() { @@ -348,4 +353,13 @@ 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; + } } + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUserFlow.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUserFlow.java index 730cd8f..fb8f548 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUserFlow.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUserFlow.java @@ -21,6 +21,11 @@ public class TbShopUserFlow implements Serializable { private String type; + + private String isReturn; + + private String remark; + private static final long serialVersionUID = 1L; public Integer getId() { @@ -86,4 +91,20 @@ public class TbShopUserFlow implements Serializable { public void setType(String type) { this.type = type == null ? null : type.trim(); } + + public String getIsReturn() { + return isReturn; + } + + public void setIsReturn(String isReturn) { + this.isReturn = isReturn; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSplitAccounts.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSplitAccounts.java deleted file mode 100644 index 89408a0..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSplitAccounts.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -@Data -//分配金额 -public class TbSplitAccounts implements Serializable { - private Integer id; - - private Integer merchantId;//商户ID - - private Integer shopId;//店铺ID - - private BigDecimal couponsPrice;//优惠券价值 - - private BigDecimal conponsAmount;//优惠券面额 - private BigDecimal originAmount;// - - private String isSplit; - - private BigDecimal orderAmount; - - private Date createTime; - - private Date splitTime; - - private String tradeDay; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserCoupons.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserCoupons.java deleted file mode 100644 index 6f59527..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserCoupons.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -@Data -public class TbUserCoupons implements Serializable { - private Integer id; - - private String userId; - private Integer orderId; - - private BigDecimal couponsPrice; - - private BigDecimal couponsAmount; - private TbOrderInfo orderInfo; - - private String status; - private String isDouble; - - private Date createTime; - - private Date updateTime; - - private Date endTime; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java index e449864..6bb7f5a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java @@ -101,7 +101,11 @@ public class TbUserInfo implements Serializable { private String pwd; - private String custPhone="400-6666-389"; + private String custPhone = "400-6666-389"; + //优惠卷数量 + private Integer couponAll = 0; + //储值数量 + private BigDecimal balanceAll = BigDecimal.ZERO; public String getAvatar() { @@ -505,4 +509,20 @@ public class TbUserInfo implements Serializable { public void setPwd(String pwd) { this.pwd = pwd; } + + public Integer getCouponAll() { + return couponAll; + } + + public void setCouponAll(Integer couponAll) { + this.couponAll = couponAll; + } + + public BigDecimal getBalanceAll() { + return balanceAll; + } + + public void setBalanceAll(BigDecimal balanceAll) { + this.balanceAll = balanceAll; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbWiningParams.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbWiningParams.java deleted file mode 100644 index 6c513c1..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbWiningParams.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -@Data -public class TbWiningParams implements Serializable { - private Integer id; - - private BigDecimal minPrice; - - private BigDecimal maxPrice; - - private Integer winingNum; - - private Integer winingUserNum; - private String status; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbWiningUser.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbWiningUser.java deleted file mode 100644 index 3855259..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbWiningUser.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -@Data -public class TbWiningUser implements Serializable { - private Integer id; - - private String userName; - - private String orderNo; - - private BigDecimal orderAmount; - - private String isUser; - - private Date createTime; - - private String isRefund; - - private BigDecimal refundAmount; - - private String refundNo; - - private String refundPayType; - - private String tradeDay; - - private Date refundTime; - - - private static final long serialVersionUID = 1L; - public TbWiningUser(){ - super(); - } - public TbWiningUser(String userName,String orderNo,BigDecimal orderAmount, - String isUser,String tradeDay){ - this.createTime = new Date(); - this.userName = userName; - this.orderNo = orderNo; - this.orderAmount = orderAmount; - this.isUser = isUser; - this.tradeDay = tradeDay; - this.isRefund = "true"; - this.refundAmount = BigDecimal.ZERO; - this.refundPayType = "WX"; - - - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbYhqParams.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbYhqParams.java deleted file mode 100644 index 41e19af..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbYhqParams.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -@Data -public class TbYhqParams implements Serializable { - private Integer id; - - private String name; - - private BigDecimal minPrice; - - private BigDecimal maxPrice; - - private String status; - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/ViewOrder.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/ViewOrder.java deleted file mode 100644 index 1c33659..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/ViewOrder.java +++ /dev/null @@ -1,378 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity; - -import java.io.Serializable; -import java.math.BigDecimal; - -public class ViewOrder implements Serializable { - private BigDecimal aliPaidAmount; - - private Integer id; - - private BigDecimal amount; - - private BigDecimal bankPaidAmount; - - private String billingId; - - private BigDecimal cashPaidAmount; - - private Long createdAt; - - private Integer deductScore; - - private BigDecimal depositPaidAmount; - - private BigDecimal discountAmount; - - private BigDecimal freightAmount; - - private Byte isMaster; - - private Byte isVip; - - private String masterId; - - private String memberId; - - private String orderNo; - - private String orderType; - - private BigDecimal otherPaidAmount; - - private Long paidTime; - - private BigDecimal payAmount; - - private Integer productScore; - - private String productType; - - private String refOrderId; - - private Byte refundAble; - - private BigDecimal refundAmount; - - private String sendType; - - private BigDecimal settlementAmount; - - private String shopId; - - private BigDecimal smallChange; - - private String status; - - private String tableId; - - private String tableParty; - - private String terminalSnap; - - private String userId; - - private BigDecimal virtualPaidAmount; - - private BigDecimal wxPaidAmount; - - private String cartList; - - private static final long serialVersionUID = 1L; - - public BigDecimal getAliPaidAmount() { - return aliPaidAmount; - } - - public void setAliPaidAmount(BigDecimal aliPaidAmount) { - this.aliPaidAmount = aliPaidAmount; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public BigDecimal getAmount() { - return amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public BigDecimal getBankPaidAmount() { - return bankPaidAmount; - } - - public void setBankPaidAmount(BigDecimal bankPaidAmount) { - this.bankPaidAmount = bankPaidAmount; - } - - public String getBillingId() { - return billingId; - } - - public void setBillingId(String billingId) { - this.billingId = billingId == null ? null : billingId.trim(); - } - - public BigDecimal getCashPaidAmount() { - return cashPaidAmount; - } - - public void setCashPaidAmount(BigDecimal cashPaidAmount) { - this.cashPaidAmount = cashPaidAmount; - } - - public Long getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - } - - public Integer getDeductScore() { - return deductScore; - } - - public void setDeductScore(Integer deductScore) { - this.deductScore = deductScore; - } - - public BigDecimal getDepositPaidAmount() { - return depositPaidAmount; - } - - public void setDepositPaidAmount(BigDecimal depositPaidAmount) { - this.depositPaidAmount = depositPaidAmount; - } - - public BigDecimal getDiscountAmount() { - return discountAmount; - } - - public void setDiscountAmount(BigDecimal discountAmount) { - this.discountAmount = discountAmount; - } - - public BigDecimal getFreightAmount() { - return freightAmount; - } - - public void setFreightAmount(BigDecimal freightAmount) { - this.freightAmount = freightAmount; - } - - public Byte getIsMaster() { - return isMaster; - } - - public void setIsMaster(Byte isMaster) { - this.isMaster = isMaster; - } - - public Byte getIsVip() { - return isVip; - } - - public void setIsVip(Byte isVip) { - this.isVip = isVip; - } - - public String getMasterId() { - return masterId; - } - - public void setMasterId(String masterId) { - this.masterId = masterId == null ? null : masterId.trim(); - } - - public String getMemberId() { - return memberId; - } - - public void setMemberId(String memberId) { - this.memberId = memberId == null ? null : memberId.trim(); - } - - public String getOrderNo() { - return orderNo; - } - - public void setOrderNo(String orderNo) { - this.orderNo = orderNo == null ? null : orderNo.trim(); - } - - public String getOrderType() { - return orderType; - } - - public void setOrderType(String orderType) { - this.orderType = orderType == null ? null : orderType.trim(); - } - - public BigDecimal getOtherPaidAmount() { - return otherPaidAmount; - } - - public void setOtherPaidAmount(BigDecimal otherPaidAmount) { - this.otherPaidAmount = otherPaidAmount; - } - - public Long getPaidTime() { - return paidTime; - } - - public void setPaidTime(Long paidTime) { - this.paidTime = paidTime; - } - - public BigDecimal getPayAmount() { - return payAmount; - } - - public void setPayAmount(BigDecimal payAmount) { - this.payAmount = payAmount; - } - - public Integer getProductScore() { - return productScore; - } - - public void setProductScore(Integer productScore) { - this.productScore = productScore; - } - - public String getProductType() { - return productType; - } - - public void setProductType(String productType) { - this.productType = productType == null ? null : productType.trim(); - } - - public String getRefOrderId() { - return refOrderId; - } - - public void setRefOrderId(String refOrderId) { - this.refOrderId = refOrderId == null ? null : refOrderId.trim(); - } - - public Byte getRefundAble() { - return refundAble; - } - - public void setRefundAble(Byte refundAble) { - this.refundAble = refundAble; - } - - public BigDecimal getRefundAmount() { - return refundAmount; - } - - public void setRefundAmount(BigDecimal refundAmount) { - this.refundAmount = refundAmount; - } - - public String getSendType() { - return sendType; - } - - public void setSendType(String sendType) { - this.sendType = sendType == null ? null : sendType.trim(); - } - - public BigDecimal getSettlementAmount() { - return settlementAmount; - } - - public void setSettlementAmount(BigDecimal settlementAmount) { - this.settlementAmount = settlementAmount; - } - - public String getShopId() { - return shopId; - } - - public void setShopId(String shopId) { - this.shopId = shopId == null ? null : shopId.trim(); - } - - public BigDecimal getSmallChange() { - return smallChange; - } - - public void setSmallChange(BigDecimal smallChange) { - this.smallChange = smallChange; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status == null ? null : status.trim(); - } - - public String getTableId() { - return tableId; - } - - public void setTableId(String tableId) { - this.tableId = tableId == null ? null : tableId.trim(); - } - - public String getTableParty() { - return tableParty; - } - - public void setTableParty(String tableParty) { - this.tableParty = tableParty == null ? null : tableParty.trim(); - } - - public String getTerminalSnap() { - return terminalSnap; - } - - public void setTerminalSnap(String terminalSnap) { - this.terminalSnap = terminalSnap == null ? null : terminalSnap.trim(); - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId == null ? null : userId.trim(); - } - - public BigDecimal getVirtualPaidAmount() { - return virtualPaidAmount; - } - - public void setVirtualPaidAmount(BigDecimal virtualPaidAmount) { - this.virtualPaidAmount = virtualPaidAmount; - } - - public BigDecimal getWxPaidAmount() { - return wxPaidAmount; - } - - public void setWxPaidAmount(BigDecimal wxPaidAmount) { - this.wxPaidAmount = wxPaidAmount; - } - - public String getCartList() { - return cartList; - } - - public void setCartList(String cartList) { - this.cartList = cartList == null ? null : cartList.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BaseCallTableDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BaseCallTableDTO.java new file mode 100644 index 0000000..c431171 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BaseCallTableDTO.java @@ -0,0 +1,13 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class BaseCallTableDTO { + @NotNull + private Integer callTableId; + @NotNull + private Integer shopId; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallNumPrintDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallNumPrintDTO.java new file mode 100644 index 0000000..ac37d31 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallNumPrintDTO.java @@ -0,0 +1,9 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +@Data +public class CallNumPrintDTO { + private Integer callQueueId; + private Integer shopId; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallSubMsgDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallSubMsgDTO.java new file mode 100644 index 0000000..2e823aa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CallSubMsgDTO.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Data +public class CallSubMsgDTO { + @NotNull + private Integer queueId; + @NotEmpty + private String openId; + @NotNull + private Integer shopId; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java new file mode 100644 index 0000000..e0dd55a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CancelCallQueueDTO.java @@ -0,0 +1,13 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class CancelCallQueueDTO { + @NotNull + private Integer queueId; + @NotNull + private Integer shopId; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseCountDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseCountDTO.java new file mode 100644 index 0000000..3d64bd5 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseCountDTO.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Data +public class ChoseCountDTO { + @NotNull + private Integer shopId; + @NotEmpty + private String tableId; + @NotNull + @Min(1) + private Integer num; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java new file mode 100644 index 0000000..6760671 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ChoseEatModelDTO.java @@ -0,0 +1,20 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Data +public class ChoseEatModelDTO { + @NotNull + private Integer shopId; + private String tableId; + @NotNull + @Max(1) + @Min(0) + // 0切换店内 1切换外带 + private Integer type; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CouponDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CouponDto.java new file mode 100644 index 0000000..a5165da --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CouponDto.java @@ -0,0 +1,15 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class CouponDto { + private Integer shopId; + private Integer userId; + //-1已过期 1未使用 2已使用 + @NotNull(message = "状态不允许为空") + private Integer status; + private Integer orderId; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CouponUseDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CouponUseDto.java new file mode 100644 index 0000000..0859352 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CouponUseDto.java @@ -0,0 +1,15 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class CouponUseDto { + private Integer shopId; + private Integer orderId; + //满减券id + private Integer couponId; + //商品券id + private List proCouponIds; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/MemberInDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/MemberInDTO.java new file mode 100644 index 0000000..c1a03ca --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/MemberInDTO.java @@ -0,0 +1,26 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Data +public class MemberInDTO { + @NotNull + private Integer shopId; + private Integer userId; +// @NotBlank(message = "用户信息不允许为空") + private String openId; + private BigDecimal amount; + private Integer orderId; + // 使用的优惠券 + private List userCouponIds = new ArrayList<>(); + // 是否使用积分抵扣 + private boolean usePoints ; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderDeductionPointsDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderDeductionPointsDTO.java new file mode 100644 index 0000000..7f94b4d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderDeductionPointsDTO.java @@ -0,0 +1,61 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 获取会员可用积分 + * @author tankaikai + * @since 2024-10-26 11:40 + */ +@Data +public class OrderDeductionPointsDTO { + + /** + * 本单最多可抵扣多少积分 + */ + private Integer maxUsablePoints; + /** + * 根据策略计算出的最少可以抵扣的金额 + */ + private BigDecimal minDeductionAmount; + /** + * 根据策略计算出的最多可以抵扣的金额 + */ + private BigDecimal maxDeductionAmount; + /** + * 下单积分抵扣门槛(每次使用不低于这个值) + */ + private Integer minDeductionPoints; + /** + * 会员账户积分 + */ + private Integer accountPoints; + /** + * 订单金额 (扣除各类折扣) + */ + private BigDecimal orderAmount; + /** + * 使用的积分数量 + */ + private Integer usedPoints; + /** + * 实际抵扣的金额 + */ + private Integer deductionAmount; + /** + * 下单抵扣积分比例 1元=?积分 + */ + private Integer equivalentPoints; + /** + * 不可抵扣原因 + */ + private String unusableReason; + /** + * 是否可用 + */ + private Boolean usable; + + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderPayDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderPayDTO.java new file mode 100644 index 0000000..6ce9276 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderPayDTO.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class OrderPayDTO { + @NotNull(message = "订单号不允许为空") + private Integer orderId; + @NotBlank(message = "支付类型不允许为空") + private String payType; + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java new file mode 100644 index 0000000..b1117c9 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class ShopEatTypeInfoDTO { + private boolean isTakeout; + private boolean isMunchies; + private boolean isDineInAfter; + private boolean isDineInBefore; + private TbShopInfo shopInfo; + private String useType; + private boolean isOpenTakeout; + private boolean isOpenDineIn; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TakeNumberDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TakeNumberDTO.java new file mode 100644 index 0000000..a560f29 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TakeNumberDTO.java @@ -0,0 +1,21 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +@EqualsAndHashCode(callSuper = true) +@Data +public class TakeNumberDTO extends BaseCallTableDTO{ + @NotBlank + @Pattern(regexp = "^1\\d{10}$|^(0\\d{2,3}-?|\\(0\\d{2,3}\\))?[1-9]\\d{4,7}(-\\d{1,8})?$",message = "手机号码格式错误") + private String phone; + private String note; + private String name; + @NotBlank + private String openId; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UserCouponDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UserCouponDto.java new file mode 100644 index 0000000..b53d03f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UserCouponDto.java @@ -0,0 +1,11 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import lombok.Data; + +@Data +public class UserCouponDto extends BasePageDto{ + private Integer userId; + private Integer status; + private Integer shopId; + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ActivateInInfoVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ActivateInInfoVO.java new file mode 100644 index 0000000..46cd10d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ActivateInInfoVO.java @@ -0,0 +1,14 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class ActivateInInfoVO { + private Integer id; + private Integer couponId; + private Integer num; +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CallQueueInfoVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CallQueueInfoVO.java new file mode 100644 index 0000000..9174ce6 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CallQueueInfoVO.java @@ -0,0 +1,17 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +@Data +public class CallQueueInfoVO { + private Integer id; + private String tableName; + private String tableNote; + private Integer waitingCount; + private Integer waitTime; + private Integer state; + private String callNum; + private String shopState; + private String shopName; + private String logo; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/GroupOrderDetailsVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/GroupOrderDetailsVo.java index cee294b..9dfc193 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/GroupOrderDetailsVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/GroupOrderDetailsVo.java @@ -55,7 +55,7 @@ public class GroupOrderDetailsVo { * 商家名称 */ private String shopName; - private Byte isUseVip; + private Integer isUseVip; /** * 商家电话 */ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/IntegralFlowVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/IntegralFlowVo.java deleted file mode 100644 index 12cfe06..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/IntegralFlowVo.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity.vo; - -import lombok.Data; - -import java.math.BigDecimal; - -/** - * @author lyf - */ -@Data -public class IntegralFlowVo { - private String openId; - private Integer page; - private Integer pageSize; - private String sign; - -} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/IntegralVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/IntegralVo.java deleted file mode 100644 index c26ab36..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/IntegralVo.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.chaozhanggui.system.cashierservice.entity.vo; - -import lombok.Data; - -import java.math.BigDecimal; - -/** - * @author lyf - */ -@Data -public class IntegralVo { - //openId - private String openId; - //数量 - private BigDecimal num; - //类型 - private String type; - //签名 - private String sign; - -} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java index b08c50e..28c9515 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java @@ -6,10 +6,8 @@ import lombok.Data; public class OpenMemberVo { private Integer id; private Integer shopId; - private String headImg; - - private String nickName; - private String telephone; + private String nickName; private String birthDay; + private String headImg; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderConfirmVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderConfirmVo.java index 1e774e4..5ffcca6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderConfirmVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderConfirmVo.java @@ -8,7 +8,7 @@ import java.math.BigDecimal; public class OrderConfirmVo { private String proId; private String shopId; - private Byte isUseVip; + private Integer isUseVip; /** * 商品图片 */ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java index 03ee617..a5abc9e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OrderVo.java @@ -37,4 +37,9 @@ public class OrderVo { private String outNumber; + private String useType; + + private Integer shopId; + private String qrcode; + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java new file mode 100644 index 0000000..6e0f865 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java @@ -0,0 +1,34 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class TbUserCouponVo { + private Integer id; + private BigDecimal fullAmount; + private BigDecimal discountAmount; + private Integer couponId; + private Integer proId; + //优惠券名称 + private String name; + //优惠券类型 1 满减 2 商品券 + private Integer type; + //数量 + private Integer num; + //到期时间 + private Date endTime; + private Long expireTime; + private String useRestrictions; + private boolean isUse = false; + + + public void setEndTime(Date endTime) { + this.endTime = endTime; + if(endTime!=null){ + expireTime=endTime.getTime(); + } + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java index b79a877..5e8bb65 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java @@ -14,7 +14,11 @@ import java.util.List; @WebFilter(urlPatterns = {"/cashierService/*"},filterName = "customFilter") public class CustomFilter implements Filter { - private static final List unFilterUrlList= Arrays.asList("/cashierService/notify/notifyCallBack","/cashierService/notify/memberInCallBack"); + private static final List unFilterUrlList = + Arrays.asList( + "/cashierService/notify/notifyCallBack", + "/cashierService/notify/memberInCallBack" + ); private boolean isfilter(String url){ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpCashierCartMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpCashierCartMapper.java new file mode 100644 index 0000000..8a630d5 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpCashierCartMapper.java @@ -0,0 +1,19 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbCashierCart; +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; + +/** +* @author Administrator +* @description 针对表【tb_call_queue】的数据库操作Mapper +* @createDate 2024-09-13 13:44:26 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue +*/ +public interface MpCashierCartMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpMemberInMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpMemberInMapper.java new file mode 100644 index 0000000..c016e50 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpMemberInMapper.java @@ -0,0 +1,16 @@ +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.TbMemberIn; + +/** +* @author Administrator +*/ +public interface MpMemberInMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderDetailMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderDetailMapper.java new file mode 100644 index 0000000..50405a3 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderDetailMapper.java @@ -0,0 +1,19 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail; +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; + +/** +* @author Administrator +* @description 针对表【tb_call_queue】的数据库操作Mapper +* @createDate 2024-09-13 13:44:26 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue +*/ +public interface MpOrderDetailMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderInfoMapper.java new file mode 100644 index 0000000..0dc8d2f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpOrderInfoMapper.java @@ -0,0 +1,19 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; + +/** +* @author Administrator +* @description 针对表【tb_call_queue】的数据库操作Mapper +* @createDate 2024-09-13 13:44:26 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue +*/ +public interface MpOrderInfoMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopCouponMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopCouponMapper.java new file mode 100644 index 0000000..5a7425d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopCouponMapper.java @@ -0,0 +1,19 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbCashierCart; +import com.chaozhanggui.system.cashierservice.entity.TbShopCoupon; + +/** +* @author Administrator +* @description 针对表【tb_call_queue】的数据库操作Mapper +* @createDate 2024-09-13 13:44:26 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue +*/ +public interface MpShopCouponMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopInfoMapper.java new file mode 100644 index 0000000..7f72780 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopInfoMapper.java @@ -0,0 +1,22 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbCallQueue; +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; +import com.chaozhanggui.system.cashierservice.entity.vo.CallQueueInfoVO; + +import java.util.List; + +/** +* @author Administrator +* @description 针对表【tb_call_queue】的数据库操作Mapper +* @createDate 2024-09-13 13:44:26 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue +*/ +public interface MpShopInfoMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopTableMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopTableMapper.java new file mode 100644 index 0000000..1409402 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopTableMapper.java @@ -0,0 +1,19 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbCashierCart; +import com.chaozhanggui.system.cashierservice.entity.TbShopTable; + +/** +* @author Administrator +* @description 针对表【tb_call_queue】的数据库操作Mapper +* @createDate 2024-09-13 13:44:26 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue +*/ +public interface MpShopTableMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallQueueMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallQueueMapper.java new file mode 100644 index 0000000..ba394aa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallQueueMapper.java @@ -0,0 +1,22 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.chaozhanggui.system.cashierservice.entity.TbCallQueue; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.vo.CallQueueInfoVO; + +import java.util.List; + +/** +* @author Administrator +* @description 针对表【tb_call_queue】的数据库操作Mapper +* @createDate 2024-09-13 13:44:26 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue +*/ +public interface TbCallQueueMapper extends BaseMapper { + + List selectInfoByOpenId(Integer shopId, String openId, String today, Integer queueId); +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallTableMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallTableMapper.java new file mode 100644 index 0000000..adefb7b --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbCallTableMapper.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.chaozhanggui.system.cashierservice.entity.TbCallTable; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Administrator +* @description 针对表【tb_call_table】的数据库操作Mapper +* @createDate 2024-09-13 13:44:34 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallTable +*/ +public interface TbCallTableMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbFreeDineConfigMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbFreeDineConfigMapper.java new file mode 100644 index 0000000..a0abe2c --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbFreeDineConfigMapper.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineConfig; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Administrator +* @description 针对表【tb_free_dine_config(霸王餐配置信息表)】的数据库操作Mapper +* @createDate 2024-10-25 14:22:41 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbFreeDineConfig +*/ +public interface TbFreeDineConfigMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbFreeDineRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbFreeDineRecordMapper.java new file mode 100644 index 0000000..a411afa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbFreeDineRecordMapper.java @@ -0,0 +1,18 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Administrator +* @description 针对表【tb_free_dine_record(霸王餐充值记录)】的数据库操作Mapper +* @createDate 2024-10-30 09:48:31 +* @Entity com.chaozhanggui.system.cashierservice.entity.TbFreeDineRecord +*/ +public interface TbFreeDineRecordMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsLogMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsLogMapper.java new file mode 100644 index 0000000..9ddf2d8 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsLogMapper.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPointsLog; +import org.apache.ibatis.annotations.Mapper; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbMemberPointsLogMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsMapper.java new file mode 100644 index 0000000..04ab248 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsMapper.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPoints; +import org.apache.ibatis.annotations.Mapper; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbMemberPointsMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsBasicSettingMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsBasicSettingMapper.java new file mode 100644 index 0000000..71380fb --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsBasicSettingMapper.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbPointsBasicSetting; +import org.apache.ibatis.annotations.Mapper; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbPointsBasicSettingMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsExchangeRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsExchangeRecordMapper.java new file mode 100644 index 0000000..c889113 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsExchangeRecordMapper.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbPointsExchangeRecord; +import org.apache.ibatis.annotations.Mapper; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbPointsExchangeRecordMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsGoodsSettingMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsGoodsSettingMapper.java new file mode 100644 index 0000000..8ea5351 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbPointsGoodsSettingMapper.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbPointsGoodsSetting; +import org.apache.ibatis.annotations.Mapper; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbPointsGoodsSettingMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/MpShopTableService.java b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/MpShopTableService.java new file mode 100644 index 0000000..cc11b5a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/MpShopTableService.java @@ -0,0 +1,26 @@ +package com.chaozhanggui.system.cashierservice.mpservice; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.constant.TableConstant; +import com.chaozhanggui.system.cashierservice.entity.TbShopTable; + +public interface MpShopTableService extends IService { + /** + * 根据台桌id修改台桌状态 + * @param tableId qrcode + * @param state 状态 + */ + boolean updateStateByQrcode(String tableId, TableConstant.ShopTable.State state); + + /** + * 根据qrcode获取台桌 + * @param tableId qrcode + */ + TbShopTable selectByQrcode(String tableId); + + /** + * 清除台桌状态 + * @param tableId 台桌id + */ + boolean clearTableState(String tableId); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/impl/MpShopTableServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/impl/MpShopTableServiceImpl.java new file mode 100644 index 0000000..db06283 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mpservice/impl/MpShopTableServiceImpl.java @@ -0,0 +1,45 @@ +package com.chaozhanggui.system.cashierservice.mpservice.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.constant.TableConstant; +import com.chaozhanggui.system.cashierservice.entity.TbShopTable; +import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper; +import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +@Service +@Primary +public class MpShopTableServiceImpl extends ServiceImpl implements MpShopTableService { + @Override + public boolean updateStateByQrcode(String tableId, TableConstant.ShopTable.State state) { + return update(new LambdaUpdateWrapper() + .eq(TbShopTable::getQrcode, tableId) + .set(TbShopTable::getStatus, state.getValue())); + } + + @Override + public TbShopTable selectByQrcode(String tableId) { + return getOne(new LambdaQueryWrapper() + .eq(TbShopTable::getQrcode, tableId)); + } + + @Override + public boolean clearTableState(String tableId) { + TbShopTable shopTable = selectByQrcode(tableId); + if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) { + return update(new LambdaUpdateWrapper() + .eq(TbShopTable::getQrcode, tableId) + .set(TbShopTable::getUseTime, null) + .set(TbShopTable::getProductNum, 0) + .set(TbShopTable::getTotalAmount, 0) + .set(TbShopTable::getRealAmount, 0) + .set(TbShopTable::getUseNum, 0) + .set(TbShopTable::getStatus, TableConstant.ShopTable.State.CLEANING.getValue())); + }else { + return updateStateByQrcode(tableId, TableConstant.ShopTable.State.CLEANING); + } + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java index 339735f..3a065d5 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToAppChannelHandlerAdapter.java @@ -3,11 +3,13 @@ package com.chaozhanggui.system.cashierservice.netty; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO; import com.chaozhanggui.system.cashierservice.netty.config.NettyChannelHandlerAdapter; import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.util.JSONUtil; +import com.chaozhanggui.system.cashierservice.util.ShopUtils; import com.chaozhanggui.system.cashierservice.util.SpringUtils; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler.Sharable; @@ -17,6 +19,8 @@ import io.netty.handler.timeout.IdleState; import io.netty.handler.timeout.IdleStateEvent; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; @@ -35,7 +39,9 @@ import java.util.concurrent.ConcurrentHashMap; public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { /** - * [tableID-shopId, [userId, ctx]] + * 台桌下单为: TAKEOUT_TABLE_CART:shopId:tableID + * 店内自取为: DINE_IN_TABLE_CART:shopId:userId + * [shopId:tableID, [userId, ctx]] */ private static Map> webSocketMap = new HashMap<>(); @@ -51,6 +57,9 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { private RabbitProducer a; //注入为空 public static RabbitProducer rabbitProducer; + + private ShopUtils shopUtils = SpringUtils.getBean(ShopUtils.class); + @PostConstruct public void b() { rabbitProducer = this.a; @@ -88,13 +97,14 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { // 遍历webSocketMap,查找并移除对应的ChannelHandlerContext String key = ctxToUserIdMap.get(ctx); if (StringUtils.isNotBlank(key)) { - String[] split = key.split(":"); + String[] split = key.split("-"); ConcurrentHashMap tableMap = webSocketMap.get(split[0]); if (tableMap != null && !tableMap.isEmpty() && tableMap.size() > 0) { tableMap.remove(split[1]); if (tableMap.isEmpty() || tableMap.size() == 0) { webSocketMap.remove(split[0]); - redisUtils.deleteByKey(RedisCst.TABLE_CART.concat(split[0])); + // 删除购物车缓存 + redisUtils.deleteByKey(split[0]); } } } @@ -133,12 +143,14 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { channelInactive(ctx); return; } - String key = tableId + "-" + shopId; - log.info("netty连接 接收到数据 建立连接参数 param:{}",jsonObject); + + ShopEatTypeInfoDTO eatModel = shopUtils.getEatModel(tableId, shopId); + String tableCartKey = RedisCst.getTableCartKey(shopId, eatModel.isOpenDineIn() ? tableId : null, Integer.valueOf(userId)); + log.info("netty连接 接收到数据 建立连接参数 key: {} param:{}", tableCartKey, jsonObject); this.tableId=tableId; this.shopId=shopId; - if (webSocketMap.containsKey(key)) { - ConcurrentHashMap userSocketMap = webSocketMap.get(key); + if (webSocketMap.containsKey(tableCartKey)) { + ConcurrentHashMap userSocketMap = webSocketMap.get(tableCartKey); ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId); if (channelHandlerContext != null) { channelHandlerContext.close(); @@ -147,9 +159,9 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { } else { ConcurrentHashMap userSocketMap = new ConcurrentHashMap<>(); userSocketMap.put(userId, ctx); - webSocketMap.put(key,userSocketMap); + webSocketMap.put(tableCartKey,userSocketMap); } - ctxToUserIdMap.put(ctx, key + ":" + userId); + ctxToUserIdMap.put(ctx, tableCartKey + "-" + userId); JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("status", "success"); jsonObject1.put("msg", "连接成功"); @@ -163,11 +175,13 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { log.info("netty连接 接收到接口数据:meg:{}",msg); jsonObject.put("tableId", this.tableId); jsonObject.put("shopId", this.shopId); + Integer userId = jsonObject.getInteger("userId"); if("sku".equals(type)){ - boolean exist = redisUtils.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))); + String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId); + boolean exist = redisUtils.exists(tableCartKey); Integer num = 0; if (exist){ - String message = redisUtils.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))); + String message = redisUtils.getMessage(tableCartKey); JSONArray array = JSON.parseArray(message); for (int i = 0; i < array.size(); i++) { JSONObject object = array.getJSONObject(i); @@ -226,11 +240,12 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { } @Async - public void AppSendInfo(String message, String tableId,String userId, boolean userFlag) { - log.info("netty连接 发送消息 tableId:{} userId:{} userFlag:{} message:{}",tableId,userId,userFlag, JSONUtil.toJSONString(message)); + public void AppSendInfo(String message, String redisKey,String userId, boolean userFlag) { + log.info("netty连接 发送消息 key:{} userId:{} userFlag:{} message:{}",redisKey,userId,userFlag, JSONUtil.toJSONString(message)); + log.info("当前已连接队列信息: {}", webSocketMap); if (userFlag) { - if (webSocketMap.containsKey(tableId)) { - ConcurrentHashMap webSockets = webSocketMap.get(tableId); + if (webSocketMap.containsKey(redisKey)) { + ConcurrentHashMap webSockets = webSocketMap.get(redisKey); if(!webSockets.isEmpty()){ if (StringUtils.isNotBlank(userId)) { ChannelHandlerContext ctx = webSockets.get(userId); @@ -241,15 +256,15 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { } } } else { - if (StringUtils.isEmpty(tableId)) { + if (StringUtils.isEmpty(redisKey)) { // 向所有用户发送信息 for (ConcurrentHashMap value : webSocketMap.values()) { for (ChannelHandlerContext ctx : value.values()) { sendMesToApp(message,ctx); } } - } else if (webSocketMap.containsKey(tableId)) { - ConcurrentHashMap webSockets = webSocketMap.get(tableId); + } else if (webSocketMap.containsKey(redisKey)) { + ConcurrentHashMap webSockets = webSocketMap.get(redisKey); if(!webSockets.isEmpty()) { for (String user : webSockets.keySet()) { ChannelHandlerContext ctx = webSockets.get(user); @@ -261,10 +276,10 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter { } } }else { - log.info("netty连接 发送消息 桌码群发 tableId:{} 失败",tableId); + log.info("netty连接 发送消息 桌码群发 tableId:{} 失败",redisKey); } } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java index cedc930..b994d1a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java @@ -160,6 +160,19 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte }); } + @Async + public void AppSendInfo(String message, String shopId) { + log.info("长链接发送交班数据。"); + ConcurrentHashMap webSockets = webSocketMap.get(shopId); + if (webSockets != null) { + for (ChannelHandlerContext ctx : webSockets.values()) { + sendMesToApp(message, ctx); + } + } + } + + + //发送打印消息 有重发机制 public void AppSendInfoV1(String shopId, String orderNo, JSONObject message) { log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}", shopId, message.get("orderInfo")); retryQueue.computeIfAbsent(shopId, k -> new ConcurrentLinkedQueue<>()).offer(message); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java index c3c1d16..2ad7144 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java @@ -3,10 +3,12 @@ package com.chaozhanggui.system.cashierservice.rabbit; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.service.CartService; +import com.chaozhanggui.system.cashierservice.util.ShopUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.amqp.rabbit.annotation.RabbitHandler; @@ -26,6 +28,9 @@ public class CartConsumer { private RedisUtil redisUtil; @Autowired private CartService cartService; + @Autowired + private ShopUtils shopUtils; + @RabbitHandler @RabbitListener(queues = {"${queue}"}) public void listener(String message) { @@ -34,6 +39,7 @@ public class CartConsumer { JSONObject jsonObject = JSON.parseObject(message); String tableId = jsonObject.getString("tableId"); String shopId = jsonObject.getString("shopId"); + Integer userId = jsonObject.getInteger("userId"); if (jsonObject.getString("type").equals("initCart") ) { cartService.initCart(jsonObject); } @@ -46,15 +52,7 @@ public class CartConsumer { else if (jsonObject.getString("type").equals("queryCart") ) { cartService.queryCart(jsonObject); } else if(jsonObject.getString("type").equals("createOrder")){ - String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId)); - if (StringUtils.isEmpty(cartDetail)){ - log.info("createOrder购物车为空"); - throw new MsgException("购物车为空无法下单"); - } - JSONArray array = JSON.parseArray(cartDetail); - if (array.size() > 0){ - cartService.createOrder(jsonObject); - } + cartService.createOrder(jsonObject); } // else if(jsonObject.getString("type").equals("clearCart")){ // cartService.clearCart(jsonObject); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/IntegralConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/IntegralConsumer.java deleted file mode 100644 index a4155f3..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/IntegralConsumer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.chaozhanggui.system.cashierservice.rabbit; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.chaozhanggui.system.cashierservice.redis.RedisUtil; -import com.chaozhanggui.system.cashierservice.service.IntegralService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.annotation.RabbitHandler; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -@Slf4j -@Component -@RabbitListener(queues = {RabbitConstants.INTEGRAL_QUEUE_PUT}) -@Service -public class IntegralConsumer { - - - @Autowired - private RedisUtil redisUtil; - @Autowired - private IntegralService integralService; - @RabbitHandler - public void listener(String message) { - try { - JSONObject jsonObject = JSON.parseObject(message); - integralService.integralAdd(jsonObject); - } catch (Exception e) { - e.getMessage(); - } - } - - -} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java index 1657918..c1cebdf 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java @@ -1,11 +1,13 @@ package com.chaozhanggui.system.cashierservice.rabbit; +import cn.hutool.core.util.ArrayUtil; 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; import com.chaozhanggui.system.cashierservice.model.OrderDetailPO; +import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.util.DateUtils; import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil; import com.chaozhanggui.system.cashierservice.util.JSONUtil; @@ -14,12 +16,18 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; 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; @Slf4j @Component @@ -47,6 +55,10 @@ public class PrintMechineConsumer { @Autowired private TbOrderDetailMapper tbOrderDetailMapper; + @Autowired + private RedisTemplate redisTemplate2; + @Autowired + private StringRedisTemplate stringRedisTemplate; @RabbitHandler public void listener(String message) { @@ -74,184 +86,443 @@ public class PrintMechineConsumer { return; } - list.parallelStream().forEach(tbPrintMachineWithBLOBs->{ + log.info("打印机列表,{}", ArrayUtil.toString(list)); + log.info("待打印订单信息, {}", orderInfo); + + list.forEach(tbPrintMachineWithBLOBs -> { if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) { - log.error("非网络打印机:{},{}",tbPrintMachineWithBLOBs.getAddress(),tbPrintMachineWithBLOBs.getConnectionType()); + log.error("非网络打印机:{},{}", tbPrintMachineWithBLOBs.getAddress(), tbPrintMachineWithBLOBs.getConnectionType()); return; } if (!"1".equals(tbPrintMachineWithBLOBs.getStatus().toString())) { - log.error("打印机状态异常:{},{}",tbPrintMachineWithBLOBs.getAddress(),tbPrintMachineWithBLOBs.getStatus()); + log.error("打印机状态异常:{},{}", tbPrintMachineWithBLOBs.getAddress(), tbPrintMachineWithBLOBs.getStatus()); return; } - JSONObject config = JSONObject.parseObject(tbPrintMachineWithBLOBs.getConfig()); - String model = config.getString("model"); + String model = tbPrintMachineWithBLOBs.getPrintMethod(); - String printerNum = config.getString("printerNum"); + String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1]; - String feet = config.getString("feet"); + List categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class); - String autoCut = config.getString("autoCut"); - - List categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class); - - switch (tbPrintMachineWithBLOBs.getContentType()){ + switch (tbPrintMachineWithBLOBs.getContentType()) { case "yxyPrinter": - yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); + yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); break; case "fePrinter": - fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); + fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); break; } }); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } /** - * 博时结云打印机 + * 仅打印制作单「厨房」 + */ + private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + log.info("一菜一品打印,待打印信息:{}", cashierCarts); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + + cashierCarts.parallelStream().forEach(it -> { + + // 取餐号不为空为代客下单 + if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) { + log.info("--------------------代客下单 打印一菜一品"); + printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo); + return; + } + log.info("--------------------非代客下单 打印一菜一品"); + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + }); + } + } + + /** + * 仅打印结算单「前台」 + */ + private void onlyFrontDeskForYxy(String orderId, TbOrderInfo orderInfo, String printerNum, TbShopInfo shopInfo, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + detailPO.setOutNumber(orderInfo.getOutNumber()); + String data = PrinterUtils.getCashPrintData(detailPO, "结算单"); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + + } + } + + /** + * 博时结云打印机 + * * @param tbPrintMachineWithBLOBs * @param model * @param orderInfo * @param shopInfo * @param printerNum */ - private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List categoryInfos){ - String orderId=orderInfo.getId().toString(); - - + private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + String orderId = orderInfo.getId().toString(); switch (tbPrintMachineWithBLOBs.getSubType()) { case "label": //标签打印机 break; case "cash": //小票打印机 - switch (model) { - case "normal": //普通出单 - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if(ObjectUtil.isEmpty(it.getCategoryId())){ - categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count= categoryInfos.stream().filter(c-> - c.getId().toString().equals(categoryId) - ).count(); - - if(count>0){ - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ - - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark()); - detailPO.setOutNumber(orderInfo.getOutNumber()); - String data= PrinterUtils.getCashPrintData(detailPO,"结算单"); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - - } - - break; - case "one": //一菜一品 - cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); - 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, 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; } } + private void printTicket(Integer orderId, List categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) { + String printKey = RedisCst.ORDER_PRINT_PRO + orderId; + AtomicReference> printProductSet = new AtomicReference<>(redisTemplate2.opsForSet().members(printKey)); + List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderId); + log.info("--------------------订单detail列表: {}", tbOrderDetails); + log.info("--------------------缓存打印printProductSet: {}", printProductSet); + if (!tbOrderDetails.isEmpty()) { + + // 重置打印数据 + redisTemplate2.delete(printKey); + tbOrderDetails.forEach(it -> { + log.info("开始打印一菜一品票据,:{}", it.getProductName()); + String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId(); + + long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + log.info("获取当前类别是否未打印类别:{}", count); + if (count > 0) { + + // 统计已打数量 + int printerNum = 0; + boolean isReturn = false; + String key = RedisCst.ORDER_PRINT + orderId + ":" + it.getProductId() + ":" + it.getProductSkuId(); + String info = stringRedisTemplate.opsForValue().get(key); + stringRedisTemplate.opsForValue().set(key, String.valueOf(it.getNum()), 60 * 60 * 24, TimeUnit.SECONDS); + + log.info("--------------------已打印数量: {}", info); + + // 删除已打印数据 + if (printProductSet.get() != null) { + printProductSet.set(printProductSet.get().stream().filter(r -> { + TbOrderDetail detail = (TbOrderDetail) r; + return !detail.getProductSkuId().equals(it.getProductSkuId()) || !detail.getProductId().equals(it.getProductId()); + }).collect(Collectors.toSet())); + } + if (info != null) { + isReturn = it.getNum() - Integer.parseInt(info) < 0; + printerNum = it.getNum() - Integer.parseInt(info); + } else { + printerNum = it.getNum(); + } - private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List categoryInfos){ - String orderId=orderInfo.getId().toString(); + log.info("--------------------isReturn: {}, 数量: {}", isReturn, printerNum); + + + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId()); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + + // 将已打印信息加入redis + it.setRemark(remark); + redisTemplate2.opsForSet().add(printKey, it); + redisTemplate2.expire(printKey, 24, TimeUnit.HOURS); + + // 已打印不再打印 + if (info != null && printerNum == 0) { + log.info("--------------------------订单已打印,跳过打印"); + return; + } + + String data; + String voiceJson; + if (isReturn) { + + data = PrinterUtils.getPrintData("return", + StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(), + DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), Math.abs(printerNum), remark); + voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}"; + + PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data); + + } else { + data = PrinterUtils.getPrintData("", orderInfo.getMasterId(), + DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), + printerNum, remark); + voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; + PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data); + + + } + } + }); + + } + + // 已删除的商品打印退款信息 + if (printProductSet.get() != null) { + printProductSet.get().forEach(item -> { + log.info("已删除订单,打印退款票据, {}", item); + TbOrderDetail orderDetail = (TbOrderDetail) item; + String data = PrinterUtils.getPrintData("return", + StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(), + DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark()); + String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}"; + PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data); + + String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId(); + log.info("删除商品数量记录key, {}", key); + stringRedisTemplate.delete(key); + }); + } + } + + /** + * 仅打印结算单「前台」 + */ + private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + if ("return".equals(orderInfo.getOrderType())) { + List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); + if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { + List detailList = new ArrayList<>(); + tbOrderDetails.parallelStream().forEach(it -> { + String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + log.info("获取当前类别是否未打印类别:{}", count); + + + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); + detailList.add(detail); + + }); + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + + + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { +// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + + String printType = "退款单"; + + String data = PrinterUtils.getCashPrintData(detailPO, printType); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + } + + + } else { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); + String printType = "结算单"; + + if ("return".equals(orderInfo.getOrderType())) { + printType = "退款单"; + } + + + FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); + } + + } + } + } + + /** + * 仅打印制作单「厨房」 + */ + private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + cashierCarts.parallelStream().forEach(it -> { + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); + } + }); + } + } + + + private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + String orderId = orderInfo.getId().toString(); switch (tbPrintMachineWithBLOBs.getSubType()) { case "label": //标签打印机 - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - cashierCarts.parallelStream().forEach(it->{ + cashierCarts.parallelStream().forEach(it -> { String categoryId; - if(ObjectUtil.isEmpty(it.getCategoryId())){ - categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); } else { categoryId = it.getCategoryId(); } - Long count= categoryInfos.stream().filter(c-> + Long count = categoryInfos.stream().filter(c -> c.getId().toString().equals(categoryId) ).count(); - if(count>0) { + if (count > 0) { TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); String remark = ""; if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { remark = tbProductSkuWithBLOBs.getSpecSnap(); } - for(int i=0;i tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); - if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { - List detailList = new ArrayList<>(); - tbOrderDetails.parallelStream().forEach(it -> { - String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - log.info("获取当前类别是否未打印类别:{}", count); - - - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); - detailList.add(detail); - - }); - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - - - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { -// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); - - String printType = "退款单"; - - String data = PrinterUtils.getCashPrintData(detailPO, printType); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - } - - - } else { - cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); - - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); - String printType = "结算单"; - - if ("return".equals(orderInfo.getOrderType())) { - printType = "退款单"; - } - - - FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); - } - - } - } - - break; - case "one": //一菜一品 - - cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - - cashierCarts.parallelStream().forEach(it -> { - - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); - } - }); - } + if ("normal".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("one".equals(model)) { + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("all".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); } - break; + break; case "kitchen": //出品打印机 break; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java index 01a8b62..ec4aa74 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java @@ -62,4 +62,23 @@ public interface RabbitConstants { // 库存记录交换机 String EXCHANGE_STOCK_RECORD = "exchange.stock.record"; String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale"; + + + public static final String BALANCE_PUT="balance_put"; + public static final String BALANCE_QUEUE_PUT="balance_queue_put"; + + public static final String BALANCE_ROUTINGKEY_PUT="balance_routingkey_put"; + + + // 菜品打印 + String EXCHANGE_PRINT = "exchange.print"; + String ROUTING_KEY_PRINT_DISHES = "routing.dishes.print"; + + // 订单打印 + String QUEUE_PRINT_PLACE = "queue.place.order.print"; + String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print"; + + // 排队小票打印 + String QUEUE_PRINT_CALL_TABLE = "queue.print.call.table"; + String ROUTING_KEY_CALL_TABLE = "routing.call.table"; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java index f0d67ac..2155fcd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java @@ -58,6 +58,15 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback { rabbitTemplate.convertAndSend(RabbitConstants.CONS_MSG_COLLECT_PUT, RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT, content, correlationId); } + + + public void balance(String content){ + CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString()); + rabbitTemplate.convertAndSend(RabbitConstants.BALANCE_PUT, RabbitConstants.BALANCE_ROUTINGKEY_PUT, content, correlationId); + } + + + @Override public void confirm(CorrelationData correlationData, boolean ack, String cause) { logger.info(" 回调id:" + correlationData); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisConfig.java b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisConfig.java index 35934b2..0019723 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisConfig.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisConfig.java @@ -96,4 +96,11 @@ public class RedisConfig { template.setValueSerializer(new StringRedisSerializer(Charset.forName("UTF-8"))); return template; } + + @Bean + public RedisTemplate redisTemplate2(RedisConnectionFactory factory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(factory); + return template; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java index d305be3..c5e3907 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java @@ -1,19 +1,23 @@ package com.chaozhanggui.system.cashierservice.redis; -/** 功能描述:redis前缀 -* @params: -* @return: -* @Author: wgc -* @Date: 2020-12-19 15:02 -*/ +import cn.hutool.core.util.StrUtil; + +/** + * 功能描述:redis前缀 + * + * @params: + * @return: + * @Author: wgc + * @Date: 2020-12-19 15:02 + */ public class RedisCst { - //在线用户 + //在线用户 public static final String ONLINE_USER = "ONLINE_USER:"; public static final String PHONE_LIMIT = "PHONE_LIMIT:"; public static final String ONLINE_APP_USER = "ONLINE_APP_USER:"; public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:"; - public static final String TABLE_CART = "TABLE:CART:"; +// public static final String TABLE_CART = "TABLE:CART:"; public static final String ORDER_EXPIRED = "ORDER:EXPIRED:"; public static final String TABLE_ORDER = "TABLE:ORDER:"; public static final String PRODUCT = "PRODUCT:"; @@ -21,9 +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 CHOSE_TABLE_COUNT = "CHOSE_TABLE_COUNT"; + + 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; + } + + public static String getTableCallNumKey(Integer shopId, Integer callTableId) { + return TABLE_CALL_NUMBER + shopId + ":" + callTableId; + } + + public static String getLockKey(String sign, Object... args) { + StringBuilder key = new StringBuilder(LOCK_KEY + ":" + sign + ":"); + for (Object arg : args) { + key.append(":").append(arg.toString()); + } + return key.toString(); + } + + public static String getTakeoutTableCartKey(String shopId, Object userId) { + return TAKEOUT_TABLE_CART + shopId + ":" + userId; +// return DINE_IN_TABLE_CART + shopId + ":" + userId; + } + + public static String getDineInTableCartKey(String shopId, String tableId) { + return DINE_IN_TABLE_CART + shopId + ":" + tableId; + } + + public static String getTableCartKey(String shopId, String tableId, Object userId) { + if (StrUtil.isBlank(tableId)) { + return getTakeoutTableCartKey(shopId, userId); + } + return getDineInTableCartKey(shopId, tableId); + } + + public static String getCurrentTableSeatCount(Object shopId, String tableId) { + return CURRENT_TABLE_SEAR_COUNT + (shopId + ":" + tableId); + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 1985f1a..950c1d8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -1,23 +1,33 @@ package com.chaozhanggui.system.cashierservice.service; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.chaozhanggui.system.cashierservice.constant.TableConstant; import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum; +import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum; import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum; +import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO; import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.mapper.*; +import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService; import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter; import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; -import com.chaozhanggui.system.cashierservice.util.DateUtils; -import com.chaozhanggui.system.cashierservice.util.JSONUtil; -import com.chaozhanggui.system.cashierservice.util.LockUtils; -import com.chaozhanggui.system.cashierservice.util.N; +import com.chaozhanggui.system.cashierservice.util.*; import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil; import com.chaozhanggui.system.cashierservice.wxUtil.WxAccountUtil; import lombok.extern.slf4j.Slf4j; @@ -25,16 +35,19 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.io.IOException; import java.math.BigDecimal; import java.time.Instant; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * @author lyf @@ -57,20 +70,23 @@ public class CartService { private TbMerchantAccountMapper merchantAccountMapper; @Autowired private TbUserInfoMapper userInfoMapper; + @Autowired + private TbShopUserMapper shopUserMapper; + @Autowired private TbOrderDetailMapper orderDetailMapper; @Autowired private TbShopTableMapper shopTableMapper; - @Autowired - private TbUserCouponsMapper userCouponsMapper; - @Autowired - private TbSystemCouponsMapper systemCouponsMapper; private final TbUserShopMsgMapper tbUserShopMsgMapper; private final WechatUtil wechatUtil; private final WxAccountUtil wxAccountUtil; private final TbShopOpenIdMapper shopOpenIdMapper; + @Resource + private TbActivateInRecordService activateInRecordService; + @Autowired + private TbActivateOutRecordMapper outRecordMapper; @Autowired private RabbitProducer producer; @@ -85,14 +101,32 @@ public class CartService { private final RedisTemplate redisTemplate; + private final StringRedisTemplate stringRedisTemplate; + + private final ShopUtils shopUtils; + @Autowired private TbProskuConMapper tbProskuConMapper; @Autowired TbConsInfoMapper tbConsInfoMapper; + @Autowired + private MpShopInfoMapper mpShopInfoMapper; + @Autowired + private MpOrderInfoMapper mpOrderInfoMapper; + @Autowired + private MpCashierCartMapper mpCashierCartMapper; + @Autowired + private MpOrderDetailMapper mpOrderDetailMapper; + @Autowired + private MpShopTableMapper mpShopTableMapper; - public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate) { + private final MpShopTableService mpShopTableService; + @Autowired + private MQUtils mQUtils; + + public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate, StringRedisTemplate stringRedisTemplate, ShopUtils shopUtils, MpShopTableService mpShopTableService) { this.tbUserShopMsgMapper = tbUserShopMsgMapper; this.wechatUtil = wechatUtil; this.wxAccountUtil = wxAccountUtil; @@ -100,44 +134,184 @@ public class CartService { this.productService = productService; this.tbProductMapper = tbProductMapper; this.redisTemplate = redisTemplate; + this.stringRedisTemplate = stringRedisTemplate; + this.shopUtils = shopUtils; + this.mpShopTableService = mpShopTableService; + } + + + /** + * 获取当前台桌当前下单次数 + * + * @param tableId 台桌id + * @param shopId 店铺id + * @param shopEatTypeInfoDTO 用餐类型 + * @return 对应的次数,为order最后次数+1 + */ + private int getCurrentPlaceNum(String tableId, Object shopId, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { + TbOrderInfo orderInfo = getCurrentOrder(shopEatTypeInfoDTO, tableId, shopId); + return orderInfo == null ? 1 : orderInfo.getPlaceNum() + 1; + } + + private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO, String tableId, Object shopId) { + // 获取当前台桌最新订单,先付款模式不获取 + if (eatTypeInfoDTO.isDineInBefore()) { + return null; + } + List orderInfoList = mpOrderInfoMapper.selectPage(new Page<>(1, 1), new LambdaQueryWrapper() + .eq(TbOrderInfo::getStatus, "unpaid") + .eq(TbOrderInfo::getUseType, eatTypeInfoDTO.getUseType()) + .eq(TbOrderInfo::getShopId, shopId) + .eq(TbOrderInfo::getTableId, tableId) + .eq(TbOrderInfo::getTradeDay, DateUtils.getDay()) + .orderByDesc(TbOrderInfo::getId)).getRecords(); + return orderInfoList.isEmpty() ? null : orderInfoList.get(0); } public void initCart(JSONObject jsonObject) { String tableId = jsonObject.getString("tableId"); String shopId = jsonObject.getString("shopId"); - String key = tableId + "-" + shopId; + Integer userId = jsonObject.getInteger("userId"); BigDecimal amount = BigDecimal.ZERO; JSONArray array = new JSONArray(); - if (redisUtil.exists(RedisCst.TABLE_CART.concat(key))) { - array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))); - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); - if (cashierCart.getNumber() > 0) { - amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); - } + + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.getEatModel(tableId, shopId); + if (!shopEatTypeInfoDTO.isOpenDineIn() && shopEatTypeInfoDTO.isOpenTakeout()) { + tableId = null; + } + String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId); + // 免除座位费,删除当前台桌座位费信息 + TbShopInfo shopInfo = shopEatTypeInfoDTO.getShopInfo(); + boolean ignoreTableFee = shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1; + + TbCashierCart seatCartInfo = null; +// if (redisUtil.exists(tableCartKey)) { +// JSONArray jsonArray = JSON.parseArray(redisUtil.getMessage(tableCartKey)); +// for (int i = 0; i < jsonArray.size(); i++) { +// JSONObject object = array.getJSONObject(i); +// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); +// if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) { +// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); +// } +// +// if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) { +// seatCartInfo = cashierCart; +// if (!ignoreTableFee) { +// array.add(cashierCart); +// } +// }else { +// array.add(cashierCart); +// } +// } +// } else { + + // 查询购物车所有信息 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopId) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .isNull(TbCashierCart::getOrderId) + .and(q -> q.isNull(TbCashierCart::getUseType).or().eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())) + .eq(TbCashierCart::getStatus, "create"); + + if (StrUtil.isNotBlank(tableId)) { + queryWrapper.eq(TbCashierCart::getTableId, tableId); + } else { + queryWrapper.eq(TbCashierCart::getUserId, userId); } - } else { - List tbCashierCarts = cashierCartMapper.selectByShopIdAndTableId(shopId, tableId); + + List tbCashierCarts = mpCashierCartMapper.selectList(queryWrapper); if (!CollectionUtils.isEmpty(tbCashierCarts)) { for (TbCashierCart cashierCart : tbCashierCarts) { - array.add(cashierCart); - amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) { + seatCartInfo = cashierCart; + }else { + array.add(cashierCart); + } + if (cashierCart.getIsVip().equals((byte) 1)) continue; + if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) { + amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + } } - redisUtil.saveMessage(RedisCst.TABLE_CART.concat(key), array.toString()); + redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L); } +// } + + if (ignoreTableFee && seatCartInfo != null) { + mpCashierCartMapper.deleteById(seatCartInfo.getId()); + }else { + redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(seatCartInfo), 60 * 60 * 12L); } + JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("status", "success"); jsonObject1.put("msg", "成功"); jsonObject1.put("type", "addCart"); jsonObject1.put("data", array); jsonObject1.put("amount", amount); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false); + } + + public void checkSeatInfo(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String tableId, Integer userId) { + TbShopInfo shopInfo = shopEatTypeInfoDTO.getShopInfo(); + if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1) { + return; + } + if (!shopEatTypeInfoDTO.isTakeout()) { + // 查询购物车所有信息 + LambdaQueryWrapper query = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopInfo().getId()) + .eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID) + .eq(TbCashierCart::getSkuId, TableConstant.CART_SEAT_ID) + .eq(TbCashierCart::getStatus, "create") + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) + .eq(TbCashierCart::getTableId, tableId) + .orderByDesc(TbCashierCart::getId); + List cashierCartList = mpCashierCartMapper.selectList(query); + TbCashierCart cart = cashierCartList.isEmpty() ? null : cashierCartList.get(0); + if (cart != null) { + return; + } + + + String oldSeatInfo = redisUtil.getMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId)); + TbCashierCart tbCashierCart = null; + if (StrUtil.isNotBlank(oldSeatInfo)) { + tbCashierCart = JSONObject.parseObject(oldSeatInfo, TbCashierCart.class); + } + + if (tbCashierCart == null) { + tbCashierCart = new TbCashierCart(); + tbCashierCart.setStatus("create"); + tbCashierCart.setCreatedAt(System.currentTimeMillis()); + tbCashierCart.setTableId(tableId); + tbCashierCart.setName("客座费"); + tbCashierCart.setSalePrice(shopInfo.getTableFee()); + tbCashierCart.setShopId(String.valueOf(shopEatTypeInfoDTO.getShopInfo().getId())); + tbCashierCart.setTradeDay(DateUtils.getDay()); + tbCashierCart.setStatus("create"); + tbCashierCart.setTotalAmount(shopInfo.getTableFee()); + tbCashierCart.setPlaceNum(1); + tbCashierCart.setProductId("-999"); + tbCashierCart.setSkuId("-999"); + tbCashierCart.setPackFee(BigDecimal.ZERO); + tbCashierCart.setNumber(1); + tbCashierCart.setTotalNumber(1); + tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); + tbCashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue()); + tbCashierCart.setUserId(userId); + } + tbCashierCart.setId(null); + + mpCashierCartMapper.insert(tbCashierCart); + redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(tbCashierCart), 60 * 60 * 12L); + + } } /** * 加入购物车 + * * @param jsonObject 商品信息 */ public Result createCart(JSONObject jsonObject) { @@ -148,146 +322,220 @@ public class CartService { String skuId = jsonObject.getString("skuId"); Integer type = jsonObject.getInteger("type"); Integer buyNum = jsonObject.getInteger("num"); - if (StringUtils.isBlank(tableId) || StringUtils.isBlank(shopId) || StringUtils.isBlank(productId) - || StringUtils.isBlank(skuId) || type==null || buyNum == null) { + Integer isVip = jsonObject.getInteger("isVip"); + Integer userId = jsonObject.getInteger("userId"); + // 商品备注 + String note = jsonObject.getString("note"); + if (StringUtils.isBlank(shopId) || StringUtils.isBlank(productId) + || StringUtils.isBlank(skuId) || type == null || buyNum == null) { return Result.fail("参数缺失"); } - String key = tableId + "-" + shopId; - TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId)); - if (tbProduct == null) { - log.error("该商品不存在 productId:{}", productId); - return Result.fail("该商品不存在"); - } - // 判断商品是否已下架 - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId)); - if (tbProductSkuWithBLOBs ==null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) { - rmCart(jsonObject,skuId,key); - return Result.fail("商品已下架"); - } - if (tbProduct.getIsStock() == 1) { - // 1:共享库存 0:独立库存 - if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) { + + boolean isSeatCart = "-999".equals(productId); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(tableId, shopId); + String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId); + // 检查客座费并设置 + checkSeatInfo(shopEatTypeInfoDTO, tableId, userId); + + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = null; + if (!isSeatCart) { + TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId)); + if (tbProduct == null) { + log.error("该商品不存在 productId:{}", productId); + return Result.fail("该商品不存在"); + } + // 判断商品是否已下架 + tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId)); + if (tbProductSkuWithBLOBs == null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) { + rmCart(jsonObject, skuId, tableCartKey); + return Result.fail("商品已下架"); + } + if (tbProduct.getIsStock() == 1) { if (tbProduct.getIsPauseSale() == 1) {//是否售罄 - rmCart(jsonObject,skuId,key); - return Result.fail("该商品已售罄"); - } - } else { - if (tbProductSkuWithBLOBs.getIsPauseSale() == 1) {//是否售罄 - rmCart(jsonObject,skuId,key); + rmCart(jsonObject, skuId, tableCartKey); return Result.fail("该商品已售罄"); } } - } - - - List proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId),Integer.valueOf(shopId),Integer.valueOf(productId)); - if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){ - for (TbProskuCon proskuCon : proskuConList) { - if("1".equals(proskuCon.getStatus())){ - TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); - if("1".equals(consInfo.getIsCheck())){ - if(N.gt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){ - return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足")); + // 检查耗材 + List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId), Integer.valueOf(shopId), Integer.valueOf(productId)); + if (Objects.nonNull(proskuConList) && !proskuConList.isEmpty()) { + for (TbProskuCon proskuCon : proskuConList) { + if ("1".equals(proskuCon.getStatus())) { + TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); + if ("1".equals(consInfo.getIsCheck())) { + if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) { + return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足")); + } + } } } } } - } - JSONArray jsonArray = new JSONArray(); + ArrayList cashierCartArrayList = new ArrayList<>(); BigDecimal amount = BigDecimal.ZERO; - try{ - if (redisUtil.exists(RedisCst.TABLE_CART.concat(key))) { - JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(key))); + try { + if (redisUtil.exists(tableCartKey)) { + JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey)); if (Objects.isNull(array) || array.isEmpty()) { if (type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId); + jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); jsonArray.add(cashierCart); + cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum()); + cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + } } else { boolean flag = true; + + boolean hasSeat = false; for (int i = 0; i < array.size(); i++) { JSONObject object = array.getJSONObject(i); TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); - if (cashierCart.getSkuId().equals(skuId)) { + cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum()); + + if (cashierCart.getSkuId().equals(skuId) && (isVip == null || cashierCart.getIsVip().intValue() == isVip)) { cashierCart.setTotalNumber(buyNum); cashierCart.setNumber(buyNum); - if (type == 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) { + cashierCart.setNote(note); + if (tbProductSkuWithBLOBs != null && type == 0 && isVip != null && isVip == 0 && tbProductSkuWithBLOBs.getSuit() != null + && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) { cashierCartMapper.deleteByPrimaryKey(cashierCart.getId()); continue; } + + if (isSeatCart) { + TbShopTable shopTable = shopTableMapper.selectQRcode(tableId); + if (cashierCart.getTotalNumber() > shopTable.getMaxCapacity()) { + return Result.fail("当前台桌最大人数未: " + shopTable.getMaxCapacity()); + } + } + if (cashierCart.getNumber() > 0) { - cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + // 设置备注 + cashierCart.setNote(note); + // 设置打包费 + if (shopEatTypeInfoDTO.isTakeout() && !isSeatCart) { + // 打包费 + TbProduct product = productMapper.selectById(Integer.valueOf(productId)); + cashierCart.setPackFee(product.getPackFee() != null ? + product.getPackFee().multiply(BigDecimal.valueOf(buyNum)) : BigDecimal.ZERO); + + } + if (isVip != null && isVip == 1) { + cashierCart.setTotalAmount(BigDecimal.ZERO); + } else { + cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()) + .multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + } cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); - cashierCartMapper.updateByPrimaryKeySelective(cashierCart); + mpCashierCartMapper.updateById(cashierCart); } else { - cashierCartMapper.deleteByPrimaryKey(cashierCart.getId()); + mpCashierCartMapper.deleteById(cashierCart.getId()); continue; } flag = false; } jsonArray.add(cashierCart); + cashierCartArrayList.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + + if ("-999".equals(cashierCart.getProductId())) { + hasSeat = true; + } } + if (flag && type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId); + jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); jsonArray.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); } + } } else { if (type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId); - jsonArray.add(cashierCart); - amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); + if (!TableConstant.CART_SEAT_ID.equals(productId)) { + jsonArray.add(cashierCart); + } + cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum()); + cashierCartArrayList.add(cashierCart); + if (isVip != 1) { + amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + } } } - }catch (MsgException e){ - if(e.getMessage().equals("商品起售库存不足")){ + } catch (MsgException e) { + if (e.getMessage().equals("商品起售库存不足")) { return Result.fail("商品起售库存不足"); } } - redisUtil.saveMessage(RedisCst.TABLE_CART.concat(key), jsonArray.toJSONString()); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "success"); - jsonObject1.put("msg", "成功"); - jsonObject1.put("type", "addcart"); - jsonObject1.put("data", jsonArray); - jsonObject1.put("amount", amount); - jsonObject1.put("reqData", jsonObject); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, "", false); + + redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString(), 60 * 60 * 12L); + // 餐位费 +// Object seatCost = jsonArray.stream().findFirst().filter(info -> "-999".equals(((TbCashierCart) info).getProductId())).orElse(null); + TbCashierCart seatCost = cashierCartArrayList.stream().findFirst().filter(info -> "-999".equals(info.getProductId())).orElse(null); + HashMap data = new HashMap<>(); + data.put("status", "success"); + data.put("msg", "成功"); + data.put("type", "addcart"); + data.put("data", jsonArray); + data.put("seatFee", BeanUtil.copyProperties(seatCost, TbCashierCart.class)); + data.put("amount", amount); + data.put("reqData", jsonObject); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(data), tableCartKey, "", false); } catch (Exception e) { - log.error("长链接错误 createCart{}", e.getMessage()); + log.error("长链接错误 createCar", e); } return Result.success(CodeEnum.SUCCESS); } - private void rmCart(JSONObject jsonObject,String skuId, String key) { + private List> formatCartStruct(List cashierCartList) { + // 根据placeNum进行分组 + Map> groupedByPlaceNum = cashierCartList.stream() + .collect(Collectors.groupingBy(TbCashierCart::getPlaceNum)); + + ArrayList> list = new ArrayList<>(); + groupedByPlaceNum.forEach((k, v) -> { + HashMap item = new HashMap<>(); + item.put("placeNum", k); + item.put("placeTime", !v.isEmpty() ? v.get(0).getUpdatedAt() : null); + item.put("info", v); + list.add(item); + }); + return list; + } + + private void rmCart(JSONObject jsonObject, String skuId, String redisKey) { JSONArray jsonArray = new JSONArray(); BigDecimal amount = BigDecimal.ZERO; - if (redisUtil.exists(RedisCst.TABLE_CART.concat(key))) { - JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(key))); + if (redisUtil.exists(redisKey)) { + JSONArray array = JSON.parseArray(redisUtil.getMessage(redisKey)); if (!Objects.isNull(array) && !array.isEmpty()) { boolean flag = false; for (int i = 0; i < array.size(); i++) { JSONObject object = array.getJSONObject(i); TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); if (cashierCart.getSkuId().equals(skuId)) { - cashierCartMapper.deleteByPrimaryKey(cashierCart.getId()); - flag = true; - continue; + if (StrUtil.isNotBlank(cashierCart.getMasterId())) { + throw new MsgException("代客下单商品不支持操作"); + } else { + cashierCartMapper.deleteByPrimaryKey(cashierCart.getId()); + flag = true; + continue; + } } jsonArray.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); } - redisUtil.saveMessage(RedisCst.TABLE_CART.concat(key), jsonArray.toJSONString()); + redisUtil.saveMessage(redisKey, jsonArray.toJSONString()); JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("status", "success"); jsonObject1.put("msg", "成功"); @@ -295,8 +543,8 @@ public class CartService { jsonObject1.put("data", jsonArray); jsonObject1.put("amount", amount); jsonObject1.put("reqData", jsonObject); - if(flag){ - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, "", false); + if (flag) { + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), redisKey, "", false); } } } @@ -311,22 +559,9 @@ public class CartService { * @param num 库存数 */ private void updateProductStock(TbProduct product, TbProductSkuWithBLOBs productSku, Integer num) { - String key = RedisCst.PRODUCT + product.getShopId() + ":product" + product.getId(); - double stock = num; - if (product.getIsDistribute() == 1) { - productMapper.updateStockById(product.getId().toString(), num); - stock = (double) (product.getStockNumber() - num); - } else { - key = RedisCst.PRODUCT + product.getShopId() + ":" + productSku.getId(); - productSkuMapper.updateStockById(productSku.getId().toString(), num); - stock = productSku.getStockNumber() - num; - } - if (num > 0) { - redisUtil.getIncrNum(key, "1"); - } else { - redisUtil.getIncrNum(key, "2"); - } + productMapper.updateStockById(product.getId().toString(), num); + CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(productSku, product, num)); @@ -338,7 +573,7 @@ public class CartService { * @param productSku sku */ private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer num) { - if (productSku.getWarnLine() == null) { + if (product.getWarnLine() == null) { return; } @@ -352,26 +587,20 @@ public class CartService { return; } - if (productSku.getStockNumber() == null) { - productSku.setStockNumber((double) 0); - } if (product.getStockNumber() == null) { product.setStockNumber(0); } - if ( - (product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine()) - || (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine() - ) { + if (product.getStockNumber() - num <= product.getWarnLine()) { List shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType()); shopOpenIds.forEach(item -> { String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId()); if (message == null) { wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), - product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num) + product.getStockNumber() - num , item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopInfo.getId()); redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L); - }else { + } else { log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId()); } @@ -379,37 +608,29 @@ public class CartService { } } - private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception{ + private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, + String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception { try { TbProduct product = productMapper.selectById(Integer.valueOf(productId)); String key = tableId + "-" + shopId; TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId)); TbCashierCart cashierCart = new TbCashierCart(); - if (productSku.getSuit() != null && productSku.getSuit() > 1) { + if (productSku.getSuit() != null && productSku.getSuit() > 1 && isVip != 1) { if (product.getIsStock() == 1) { boolean isSale = false; - // 1:共享库存 0:独立库存 - if (Integer.valueOf(product.getIsDistribute()).equals(1)) { - if (num > productSku.getSuit()) { - if (num > product.getStockNumber()) isSale = true; - }else { - if (productSku.getSuit() > product.getStockNumber()) isSale = true; - } + if (num > productSku.getSuit()) { + if (num > product.getStockNumber()) isSale = true; } else { - if (num > productSku.getSuit()) { - if (num > productSku.getStockNumber()) isSale = true; - }else { - if (productSku.getSuit() > productSku.getStockNumber()) isSale = true; - } + if (productSku.getSuit() > product.getStockNumber()) isSale = true; } if (isSale) { throw new MsgException("商品起售库存不足"); } } - if(num > productSku.getSuit()){ + if (num > productSku.getSuit()) { cashierCart.setNumber(num); cashierCart.setTotalNumber(num); - }else { + } else { cashierCart.setNumber(productSku.getSuit()); cashierCart.setTotalNumber(productSku.getSuit()); } @@ -417,6 +638,7 @@ public class CartService { cashierCart.setNumber(num); cashierCart.setTotalNumber(num); } + cashierCart.setNote(note); cashierCart.setProductId(productId); cashierCart.setSkuId(skuId); cashierCart.setCoverImg(product.getCoverImg()); @@ -424,7 +646,7 @@ public class CartService { cashierCart.setCategoryId(product.getCategoryId()); cashierCart.setShopId(shopId); cashierCart.setUserId(userId); - cashierCart.setTableId(tableId); + cashierCart.setTableId(StrUtil.isBlank(tableId) ? null : tableId); cashierCart.setSkuName(productSku.getSpecSnap()); cashierCart.setIsPack("false"); cashierCart.setIsGift("false"); @@ -435,9 +657,21 @@ public class CartService { cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCart.setPackFee(BigDecimal.ZERO); cashierCart.setRefundNumber(0); - cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee()))); - cashierCartMapper.insert(cashierCart); - + cashierCart.setTradeDay(DateUtils.getDay()); + // 打包费 + if (isTakeout && product.getPackFee() != null) { + cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num))); + } + if (isVip == 1) { + cashierCart.setIsVip(Byte.parseByte("1")); + cashierCart.setTotalAmount(BigDecimal.ZERO); + cashierCart.setSalePrice(BigDecimal.ZERO); + } else { + cashierCart.setIsVip((byte) 0); + cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee()))); + } + cashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue()); + mpCashierCartMapper.insert(cashierCart); //修改耗材数据 // JSONObject jsonObject=new JSONObject(); @@ -448,19 +682,22 @@ public class CartService { return cashierCart; } catch (Exception e) { - log.error("长链接错误 addCart{}", e.getMessage()); + log.error("长链接错误 addCart {}", e.getMessage()); throw e; } } @Transactional(rollbackFor = Exception.class) - public void createOrder(JSONObject jsonObject) { + public Result createOrder(JSONObject jsonObject) { try { + JSONObject responseData = new JSONObject(); + String shopId = jsonObject.getString("shopId"); String tableId = jsonObject.getString("tableId"); - String remark = StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark"); - String key = tableId + "-" + shopId; - JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(key))); + String userId = jsonObject.getString("userId"); + String sendType = jsonObject.getString("sendType"); + String remark = StringUtils.isBlank(jsonObject.getString("remark")) ? "" : jsonObject.getString("remark"); + BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal packAMount = BigDecimal.ZERO; BigDecimal originAmount = BigDecimal.ZERO; @@ -474,178 +711,252 @@ public class CartService { MsgException.throwException("生成订单错误"); } - String userId = jsonObject.getString("userId"); TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); if (tbUserInfo == null) { MsgException.throwException("生成订单失败"); } - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); - TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId())); - TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId())); - // 判断商品是否已下架 - if (tbProduct.getIsGrounding().equals(0)) { - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "商品已下架:" + tbProduct1.getName()); - jsonObject1.put("data", new ArrayList<>()); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - return; - } - - log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId()); - CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cashierCart.getNumber())); - - - log.info("开始修改库存,商品id:{},商品名:{}", tbProduct1.getId(), tbProduct1.getName()); - // 修改库存 - try { - if (tbProduct1.getIsStock() == 1) { - productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1); - } else { - productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1); - } - } catch (Exception e) { - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", tbProduct1.getName() + "库存不足"); - jsonObject1.put("data", new ArrayList<>()); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - return; - } - - - totalAmount = totalAmount.add(cashierCart.getTotalAmount()); - packAMount = packAMount.add(cashierCart.getPackFee()); - originAmount = originAmount.add(cashierCart.getTotalAmount()); - if (Objects.nonNull(tbProduct)) { - saleAmount = saleAmount.add(tbProduct.getSalePrice()); - } - TbOrderDetail orderDetail = new TbOrderDetail(); - orderDetail.setCreateTime(new Date()); - orderDetail.setNum(cashierCart.getNumber()); - orderDetail.setPrice(cashierCart.getSalePrice()); - if (cashierCart.getIsPack().equals("true")) { - orderDetail.setPriceAmount(cashierCart.getTotalAmount().add(cashierCart.getPackFee())); - } else { - orderDetail.setPriceAmount(cashierCart.getTotalAmount()); - } - orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); - orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId())); - orderDetail.setProductSkuName(tbProduct.getSpecSnap()); - orderDetail.setProductName(cashierCart.getName()); - orderDetail.setShopId(jsonObject.getInteger("shopId")); - orderDetail.setPackAmount(cashierCart.getPackFee()); - orderDetail.setProductImg(cashierCart.getCoverImg()); - orderDetail.setStatus("unpaid"); - if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { - orderId = Integer.valueOf(cashierCart.getOrderId()); - } - orderDetails.add(orderDetail); - if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { - orderId = Integer.valueOf(cashierCart.getOrderId()); - } - cashierCartMapper.updateStatusById(cashierCart.getId(), "final"); + if (StrUtil.isBlank(sendType)) { + MsgException.throwException("用餐类型不为空"); } - //总金额 - TbShopTable shopTable = shopTableMapper.selectQRcode(jsonObject.getString("tableId")); + + // 获取当前下单次数和用餐类型 + if ("takeself".equals(sendType)) { + tableId = null; + } + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(tableId, shopId); + Integer currentPlaceNum = getCurrentPlaceNum(tableId, shopId, shopEatTypeInfoDTO); + String tableCartKey = RedisCst.getTableCartKey(shopId, shopEatTypeInfoDTO.isOpenDineIn() ? tableId : null, Integer.valueOf(userId)); + JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey)); + // 查询购物车所有信息 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopId) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .eq(TbCashierCart::getStatus, "create"); + + TbShopTable shopTable = null; + // 外带模式 + if (shopEatTypeInfoDTO.isTakeout()) { + queryWrapper.eq(TbCashierCart::getUserId, userId); + // 台桌点单 + } else { + String finalTableId = tableId; + queryWrapper.and(q -> { + q.eq(TbCashierCart::getTableId, finalTableId).or().eq(TbCashierCart::getUserId, userId); + }).and(q -> q.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()).or().isNull(TbCashierCart::getUseType)); + + shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper() + .eq(TbShopTable::getQrcode, tableId)); + if (shopTable == null) { + throw new MsgException("台桌不存在"); + } + } + + // 所有订单信息 + List cashierCartList = mpCashierCartMapper.selectList(queryWrapper); + + if (cashierCartList.isEmpty()) { + responseData.put("status", "fail"); + responseData.put("msg", "购物车为空"); + responseData.put("data", new ArrayList<>()); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true); + return Result.fail("购物车为空"); + } + + // 就餐人数 + ArrayList cashierIds = new ArrayList<>(); + + Integer seatNum = 0; + BigDecimal seatCost = BigDecimal.ZERO; + for (TbCashierCart tbCashierCart : cashierCartList) { + cashierIds.add(tbCashierCart.getId()); + if ("-999".equals(tbCashierCart.getProductId())) { + seatNum = tbCashierCart.getNumber(); + seatCost = tbCashierCart.getTotalAmount(); + } + + if (StringUtils.isNotEmpty(tbCashierCart.getOrderId())) { + orderId = Integer.valueOf(tbCashierCart.getOrderId()); + } + } + + // 校验是否选择人数 + // 设置餐位费 + TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); + if (!shopEatTypeInfoDTO.isTakeout() && shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0 + && (seatNum < 1 || cashierCartList.size() < 2)) { + log.info("消息推送"); + responseData.put("msg", "购物车为空"); + if (shopTable.getMaxCapacity() < seatNum) { + responseData.put("msg", "当前台桌最大人数为: " + shopTable.getMaxCapacity()); + } + responseData.put("status", "fail"); + responseData.put("type", jsonObject.getString("type")); + responseData.put("data", ""); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true); + return Result.fail(responseData.getString("msg")); + } + + + TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId); + boolean isVip = tbShopUser != null && tbShopUser.getIsVip().equals((byte) 1); + + // 查询历史orderDetail + Integer finalOrderId = orderId; + List oldOrderDetailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper() + .eq(TbOrderDetail::getStatus, "unpaid") + .and(q -> q.in(TbOrderDetail::getCartId, cashierIds).or().eq(TbOrderDetail::getOrderId, finalOrderId)) + .eq(TbOrderDetail::getShopId, shopId)); + HashMap oldOrderDetailMap = new HashMap<>(); + ArrayList removeOrderDetailList = new ArrayList<>(); + ArrayList addOrderDetail = new ArrayList<>(); + + oldOrderDetailList.forEach(item -> { + oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item); + if (cashierIds.contains(item.getCartId())) { + oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item); + } else { + removeOrderDetailList.add(item); + } + }); + boolean hasNewInfo = false; + + // 外带模式去除餐位费 + TbCashierCart seatCartInfo = null; + //校验 库存 耗材 + for (TbCashierCart cart : cashierCartList) { + if (shopEatTypeInfoDTO.isTakeout() && "-999".equals(cart.getProductId())) { + seatCartInfo = cart; + continue; + } + + // 设置打包费 + if (shopEatTypeInfoDTO.isTakeout()) { + cart.setTableId(""); + // 打包费 + TbProduct product = productMapper.selectById(Integer.valueOf(cart.getProductId())); + cart.setPackFee(product.getPackFee() != null ? + product.getPackFee().multiply(BigDecimal.valueOf(cart.getNumber())) : BigDecimal.ZERO); + cart.setIsPack("true"); + } else { + cart.setTableId(tableId); + cart.setPackFee(BigDecimal.ZERO); + } + + TbProductSkuWithBLOBs tbProduct; + if (!"-999".equals(cart.getProductId())) { + tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cart.getSkuId())); + TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId())); + // 判断商品是否已下架 + if (tbProduct.getIsGrounding().equals(0)) { + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("status", "fail"); + jsonObject1.put("msg", "商品已下架:" + tbProduct1.getName()); + jsonObject1.put("data", new ArrayList<>()); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true); + continue; + } + + log.info("下单,开始校验库存预警,购物车id:{}", cart.getId()); + CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cart.getNumber())); + + log.info("开始修改库存,商品id:{},商品名:{}", tbProduct1.getId(), tbProduct1.getName()); + // 修改库存 + try { + // 首次下单扣除库存 + if (StrUtil.isBlank(cart.getOrderId())) { + if (tbProduct1.getIsStock() == 1) { + productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber()); + } else { + productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber()); + } + } + + } catch (Exception e) { + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("status", "fail"); + jsonObject1.put("msg", tbProduct1.getName() + "库存不足"); + jsonObject1.put("data", new ArrayList<>()); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true); + throw new MsgException((String) jsonObject1.get("msg")); + } + saleAmount = saleAmount.add(tbProduct.getSalePrice()); + } else { + tbProduct = null; + saleAmount = saleAmount.add(shopEatTypeInfoDTO.getShopInfo().getTableFee()); + } + + totalAmount = totalAmount.add(cart.getTotalAmount()); + packAMount = packAMount.add(cart.getPackFee()); + originAmount = originAmount.add(cart.getTotalAmount()); + + TbOrderDetail orderDetail = oldOrderDetailMap.get(cart.getOrderId() + cart.getId()); + if (orderDetail == null) { + orderDetail = new TbOrderDetail(); + hasNewInfo = true; + addOrderDetail.add(orderDetail); + } + orderDetail.setCreateTime(new Date()); + orderDetail.setNum(cart.getNumber()); + orderDetail.setPrice(cart.getSalePrice()); + if (cart.getIsPack().equals("true")) { + orderDetail.setPriceAmount(cart.getTotalAmount().add(cart.getPackFee())); + } else { + orderDetail.setPriceAmount(cart.getTotalAmount()); + } + orderDetail.setProductId(Integer.valueOf(cart.getProductId())); + orderDetail.setProductSkuId(Integer.valueOf(cart.getSkuId())); + orderDetail.setProductSkuName(tbProduct == null ? null : tbProduct.getSpecSnap()); + orderDetail.setProductName(cart.getName()); + orderDetail.setShopId(jsonObject.getInteger("shopId")); + orderDetail.setPackAmount(cart.getPackFee()); + orderDetail.setProductImg(cart.getCoverImg()); + orderDetail.setStatus("unpaid"); + orderDetail.setIsVip(cart.getIsVip()); + orderDetail.setCartId(cart.getId()); + if (StringUtils.isNotEmpty(cart.getOrderId())) { + orderId = Integer.valueOf(cart.getOrderId()); + } + orderDetail.setUseType(shopEatTypeInfoDTO.getUseType()); + if (orderDetail.getPlaceNum() == null) { + orderDetail.setPlaceNum(currentPlaceNum); + } + + // 设置下单次数 + if (cart.getPlaceNum() == null) { + cart.setPlaceNum(currentPlaceNum); + } + + orderDetails.add(orderDetail); + cart.setStatus(shopEatTypeInfoDTO.isDineInAfter() ? "create" : "final"); + cart.setUpdatedAt(DateUtil.current()); + + if (!TableConstant.CART_SEAT_ID.equals(cart.getProductId()) || !shopEatTypeInfoDTO.getUseType().equals(OrderUseTypeEnum.TAKEOUT.getValue())) { + cart.setUseType(shopEatTypeInfoDTO.getUseType()); + } + + if (cart.getId() != null) { + mpCashierCartMapper.updateById(cart); + } else { + mpCashierCartMapper.insert(cart); + } + } + //生成订单 TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); - String isBuyYhq = "false"; - String isuseYhq = "false"; - if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) { - couponId = jsonObject.getString("couponsId"); - //1:购买优惠券,0:自己持有优惠券 - Integer couponsId = jsonObject.getInteger("couponsId"); - if (jsonObject.getString("isBuyYhq").equals("1")) { - TbSystemCoupons systemCoupons = systemCouponsMapper.selectByPrimaryKey(couponsId); - if (Objects.isNull(systemCoupons) || !systemCoupons.getStatus().equals("0")) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "优惠券已售空"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - if (N.gt(systemCoupons.getCouponsAmount(), totalAmount)) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "订单金额小于优惠价金额"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - totalAmount = totalAmount.add(systemCoupons.getCouponsPrice()).subtract(systemCoupons.getCouponsAmount()); - originAmount = originAmount.add(systemCoupons.getCouponsPrice()); - couponAmount = systemCoupons.getCouponsAmount(); - systemCoupons.setStatus("1"); - systemCouponsMapper.updateByPrimaryKeySelective(systemCoupons); - TbUserCoupons userCoupons = new TbUserCoupons(); - userCoupons.setEndTime(DateUtils.getNewDate(new Date(), 3, systemCoupons.getDayNum())); - userCoupons.setCouponsAmount(systemCoupons.getCouponsAmount()); - userCoupons.setCouponsPrice(systemCoupons.getCouponsPrice()); - userCoupons.setStatus("1"); - userCoupons.setUserId(userId); - userCoupons.setCreateTime(new Date()); - userCouponsMapper.insert(userCoupons); - couponId = userCoupons.getId() + ""; - couponAmount = userCoupons.getCouponsAmount(); - } else { - TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(couponsId); - if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "优惠券已使用"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - if (N.gt(userCoupons.getCouponsAmount(), totalAmount)) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "订单金额小于优惠价金额"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - totalAmount = totalAmount.subtract(userCoupons.getCouponsAmount()); - userCoupons.setStatus("1"); - userCoupons.setEndTime(DateUtils.getNewDate(new Date(), 5, 30)); - userCouponsMapper.updateByPrimaryKeySelective(userCoupons); - couponAmount = userCoupons.getCouponsAmount(); - } - isuseYhq = "true"; - } - if (Objects.nonNull(orderInfo)) { + if (orderInfo != null) { log.info("订单状态:" + orderInfo.getStatus()); if (!"unpaid".equals(orderInfo.getStatus())) { log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "订单正在支付中,请稍后再试"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); + responseData.put("status", "fail"); + responseData.put("msg", "订单正在支付中,请稍后再试"); + responseData.put("type", jsonObject.getString("type")); + responseData.put("data", ""); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true); log.info("消息推送"); - return; + return Result.fail("订单正在支付中,请稍后再试"); } - - orderDetailMapper.deleteByOUrderId(orderId); orderInfo.setUpdatedAt(System.currentTimeMillis()); orderInfo.setSettlementAmount(totalAmount); orderInfo.setUserCouponId(couponId); @@ -655,20 +966,33 @@ public class CartService { orderInfo.setOrderAmount(totalAmount.add(packAMount)); orderInfo.setFreightAmount(BigDecimal.ZERO); orderInfo.setProductAmount(saleAmount); - orderInfo.setIsBuyCoupon(isBuyYhq); - orderInfo.setIsUseCoupon(isuseYhq); orderInfo.setRemark(remark); - orderInfoMapper.updateByPrimaryKeySelective(orderInfo); - + if (StrUtil.isNotBlank(remark)) { + orderInfo.setRemark(remark); + } + orderInfo.setUserId(userId); + if (hasNewInfo) { + orderInfo.setPlaceNum(currentPlaceNum); + } + orderInfo.setUseType(shopEatTypeInfoDTO.getUseType()); + orderInfo.setSeatCount(seatNum); + orderInfo.setSeatAmount(seatCost); + orderInfo.setSendType(sendType); + mpOrderInfoMapper.updateById(orderInfo); } else { orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount); orderInfo.setMerchantId(String.valueOf(tbMerchantAccount.getId())); orderInfo.setUserCouponId(couponId); orderInfo.setOriginAmount(originAmount); - orderInfo.setIsBuyCoupon(isBuyYhq); - orderInfo.setIsUseCoupon(isuseYhq); orderInfo.setUserCouponAmount(couponAmount); - orderInfo.setRemark(remark); + if (StrUtil.isNotBlank(remark)) { + orderInfo.setRemark(remark); + } + orderInfo.setUserId(userId); + orderInfo.setPlaceNum(currentPlaceNum); + orderInfo.setUseType(shopEatTypeInfoDTO.getUseType()); + orderInfo.setSeatCount(seatNum); + orderInfo.setSeatAmount(seatCost); JSONObject object = new JSONObject(); String outNumber = redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId"))); @@ -687,27 +1011,59 @@ public class CartService { } } orderInfo.setOutNumber(number + ""); + orderInfo.setSendType(sendType); redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")), object.toString()); - orderInfoMapper.insert(orderInfo); + mpOrderInfoMapper.insert(orderInfo); orderId = orderInfo.getId(); - - } + for (TbOrderDetail orderDetail : orderDetails) { - orderDetail.setOrderId(orderId); - orderDetailMapper.insert(orderDetail); + orderDetail.setOrderId(orderInfo.getId()); + if (orderDetail.getId() != null) { + mpOrderDetailMapper.updateById(orderDetail); + } else { + mpOrderDetailMapper.insert(orderDetail); + } } - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); + + // 去除餐位费信息 + for (TbCashierCart cashierCart : cashierCartList) { cashierCart.setUpdatedAt(System.currentTimeMillis()); cashierCart.setOrderId(orderId + ""); - cashierCart.setStatus("closed"); - cashierCartMapper.updateByPrimaryKeySelective(cashierCart); - object.put("updatedAt", System.currentTimeMillis()); - object.put("orderId", orderId + ""); + if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) && !shopEatTypeInfoDTO.isDineInAfter()) + || shopEatTypeInfoDTO.isDineInBefore()) { + cashierCart.setStatus("closed"); + } + cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? currentPlaceNum : cashierCart.getPlaceNum()); + mpCashierCartMapper.updateById(cashierCart); + } + + cashierCartList = cashierCartList.stream().filter(item -> !"-999".equals(item.getProductId())).collect(Collectors.toList()); + // 删除旧的餐位费信息 +// if (shopEatTypeInfoDTO.isTakeout() && seatCartInfo != null) { +// cashierCartMapper.deleteByPrimaryKey(seatCartInfo.getId()); +// } + + // 打印票据 + if (!addOrderDetail.isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) { + log.info("待打印菜品信息: {}", addOrderDetail); + mQUtils.printDishesTicket(orderInfo.getId(), false, addOrderDetail.toArray(new TbOrderDetail[0])); + } + + if (!removeOrderDetailList.isEmpty()) { + log.info("待打印退菜菜品信息: {}", removeOrderDetailList); + // 退单票 + mpOrderDetailMapper.deleteBatchIds(removeOrderDetailList.stream().map(TbOrderDetail::getId).collect(Collectors.toList())); + if (shopEatTypeInfoDTO.isDineInAfter()) { + mQUtils.printDishesTicket(orderInfo.getId(), true, removeOrderDetailList.toArray(new TbOrderDetail[0])); + } + } + + // 修改台桌状态 + if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(tableId)) { + mpShopTableService.updateStateByQrcode(tableId, TableConstant.ShopTable.State.USING); } // 发送mq消息 @@ -717,30 +1073,28 @@ public class CartService { log.info("开始发送mq消息,消耗耗材,消息内容:{}", jsonObject2); producer.cons(jsonObject2.toString()); - redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString()); + redisUtil.saveMessage(tableCartKey, new JSONArray().toJSONString()); orderInfo.setDetailList(orderDetails); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "success"); - jsonObject1.put("msg", "成功"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", orderInfo); - redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId)); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - JSONObject jsonObject12 = new JSONObject(); - jsonObject12.put("status", "success"); - jsonObject12.put("msg", "成功"); - jsonObject12.put("type", "order"); - jsonObject12.put("amount", BigDecimal.ZERO); + responseData.put("status", "success"); + responseData.put("msg", "成功"); + responseData.put("type", jsonObject.getString("type")); + responseData.put("data", orderInfo); + redisUtil.deleteByKey(tableCartKey); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true); - jsonObject12.put("data", new JSONArray()); + responseData.put("status", "success"); + responseData.put("msg", "成功"); + responseData.put("type", "order"); + responseData.put("amount", BigDecimal.ZERO); + responseData.put("data", new JSONArray()); // PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), jsonObject.getString("userId")); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId")); + redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L); + List finalCashierCartList = cashierCartList; ThreadUtil.execAsync(() -> { ThreadUtil.sleep(5, TimeUnit.SECONDS); - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); + for (TbCashierCart cashierCart : finalCashierCartList) { // 发送判断耗材是否耗尽消息 JSONObject objectMsg = new JSONObject(); objectMsg.put("skuId", Integer.valueOf(cashierCart.getSkuId())); @@ -749,17 +1103,19 @@ public class CartService { } }); - + return Result.successWithData(orderInfo); } catch (Exception e) { - log.info("长链接错误 addCart{}", e.getMessage()); + log.info("长链接错误 createOrder{}", e.getMessage()); e.printStackTrace(); } + + return Result.fail("失败"); } private TbOrderInfo getOrder(BigDecimal totalAmount, BigDecimal packAMount, TbShopTable shopTable, String merchantId, JSONObject jsonObject, BigDecimal originAmount) { TbOrderInfo orderInfo = new TbOrderInfo(); - String orderNo = generateOrderNumber(); + String orderNo = generateOrderNumber(jsonObject.getString("environment")); orderInfo.setOrderNo(orderNo); orderInfo.setSettlementAmount(totalAmount); orderInfo.setPackFee(packAMount); @@ -787,45 +1143,47 @@ public class CartService { return orderInfo; } - public String generateOrderNumber() { + public String generateOrderNumber(String environment) { String date = DateUtils.getSdfTimes(); Random random = new Random(); int randomNum = random.nextInt(900) + 100; + if ("alipay".equalsIgnoreCase(environment)) { + return "ALI" + date + randomNum; + } return "WX" + date + randomNum; } public void clearCart(JSONObject jsonObject) { try { String shopId = jsonObject.getString("shopId"); - -// List skuIds=new ArrayList<>(); -// if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) { -// JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))); -// if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) { -// for (int i = 0; i < array.size(); i++) { -// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(array.get(i).toString(), TbCashierCart.class); -// redisUtil.secAdd(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), cashierCart.getNumber().toString()); -// productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber()); -// skuIds.add(cashierCart.getSkuId()); - -// } -// } + String tableId = jsonObject.getString("tableId"); + Integer userId = TokenUtil.getUserId(); + if (StrUtil.isNotBlank(tableId)) { + cashierCartMapper.updateStatusByOrderIdForMini(jsonObject.getString("tableId"), "closed"); + } else { + mpCashierCartMapper.update(null, new LambdaUpdateWrapper() + .eq(TbCashierCart::getShopId, shopId) + .and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) + .eq(TbCashierCart::getUserId, userId) +// .ne(TbCashierCart::getProductId, "-999") + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .set(TbCashierCart::getStatus, "closed")); + } + String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId); +// String message = redisUtil.getMessage(tableCartKey); +// if (StrUtil.isNotBlank(message)) { +// JSONArray jsonArray = JSONObject.parseArray(message); +// List collect = jsonArray.stream().filter(info -> "-999".equals(((JSONObject) info).getString("productId"))).collect(Collectors.toList()); +// redisUtil.saveMessage(tableCartKey, new JSONArray().toJSONString()); // } - cashierCartMapper.updateStatusByTableId(jsonObject.getString("tableId"), "closed"); - redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)), new JSONArray().toJSONString()); + redisUtil.saveMessage(tableCartKey, new JSONArray().toJSONString()); JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("status", "success"); jsonObject1.put("msg", "成功"); jsonObject1.put("type", "addcart"); jsonObject1.put("amount", BigDecimal.ZERO); jsonObject1.put("data", new ArrayList<>()); -// //修改耗材数据 -// JSONObject jsonObject2=new JSONObject(); -// jsonObject2.put("type","delete"); -// jsonObject2.put("skuIds",skuIds); -// jsonObject2.put("shopId",shopId); -// producer.cons(jsonObject2.toString()); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false); } catch (Exception e) { log.info("长链接错误 clearCart{}", e.getMessage()); e.printStackTrace(); @@ -837,8 +1195,9 @@ public class CartService { try { String shopId = jsonObject.getString("shopId"); String tableId = jsonObject.getString("tableId"); - String key = tableId + "-" + shopId; - JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))); + String userId = jsonObject.getString("userId"); + String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, Integer.valueOf(userId)); + JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey)); List ids = new ArrayList<>(); BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal packAMount = BigDecimal.ZERO; @@ -854,7 +1213,6 @@ public class CartService { throw new MsgException("生成订单错误"); } - String userId = jsonObject.getString("userId"); TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); if (tbUserInfo == null) { throw new MsgException("生成订单失败"); @@ -900,84 +1258,6 @@ public class CartService { TbShopTable shopTable = shopTableMapper.selectQRcode(jsonObject.getString("tableId")); //生成订单 TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); - String isBuyYhq = "false"; - String isuseYhq = "false"; - if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) { - couponId = jsonObject.getString("couponsId"); - //1:购买优惠券,0:自己持有优惠券 - Integer couponsId = jsonObject.getInteger("couponsId"); - if (jsonObject.getString("isBuyYhq").equals("1")) { - TbSystemCoupons systemCoupons = systemCouponsMapper.selectByPrimaryKey(couponsId); - if (Objects.isNull(systemCoupons) || !systemCoupons.getStatus().equals("0")) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "优惠券已售空"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - if (N.gt(systemCoupons.getCouponsAmount(), totalAmount)) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "订单金额小于优惠价金额"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - totalAmount = totalAmount.add(systemCoupons.getCouponsPrice()).subtract(systemCoupons.getCouponsAmount()); - originAmount = originAmount.add(systemCoupons.getCouponsPrice()); - couponAmount = systemCoupons.getCouponsAmount(); - systemCoupons.setStatus("1"); - systemCouponsMapper.updateByPrimaryKeySelective(systemCoupons); - TbUserCoupons userCoupons = new TbUserCoupons(); - userCoupons.setEndTime(DateUtils.getNewDate(new Date(), 3, systemCoupons.getDayNum())); - userCoupons.setCouponsAmount(systemCoupons.getCouponsAmount()); - userCoupons.setCouponsPrice(systemCoupons.getCouponsPrice()); - userCoupons.setStatus("1"); - userCoupons.setUserId(userId); - userCoupons.setCreateTime(new Date()); - userCouponsMapper.insert(userCoupons); - couponId = userCoupons.getId() + ""; - couponAmount = userCoupons.getCouponsAmount(); - } else { - TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(couponsId); - if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "优惠券已使用"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - if (N.gt(userCoupons.getCouponsAmount(), totalAmount)) { - log.info("开始处理订单"); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "fail"); - jsonObject1.put("msg", "订单金额小于优惠价金额"); - jsonObject1.put("type", jsonObject.getString("type")); - jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); - log.info("消息推送"); - return; - } - totalAmount = totalAmount.subtract(userCoupons.getCouponsAmount()); - userCoupons.setStatus("1"); - userCoupons.setEndTime(DateUtils.getNewDate(new Date(), 5, 30)); - userCouponsMapper.updateByPrimaryKeySelective(userCoupons); - couponAmount = userCoupons.getCouponsAmount(); - } - isuseYhq = "true"; - - } if (Objects.nonNull(orderInfo)) { log.info("订单状态:" + orderInfo.getStatus()); if (!"unpaid".equals(orderInfo.getStatus())) { @@ -987,7 +1267,7 @@ public class CartService { jsonObject1.put("msg", "订单正在支付中,请稍后再试"); jsonObject1.put("type", jsonObject.getString("type")); jsonObject1.put("data", ""); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true); log.info("消息推送"); return; } @@ -1002,16 +1282,12 @@ public class CartService { orderInfo.setOrderAmount(totalAmount.add(packAMount)); orderInfo.setFreightAmount(BigDecimal.ZERO); orderInfo.setProductAmount(saleAmount); - orderInfo.setIsBuyCoupon(isBuyYhq); - orderInfo.setIsUseCoupon(isuseYhq); orderInfoMapper.updateByPrimaryKeySelective(orderInfo); } else { orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount); orderInfo.setMerchantId(String.valueOf(tbMerchantAccount.getId())); orderInfo.setUserCouponId(couponId); orderInfo.setOriginAmount(originAmount); - orderInfo.setIsBuyCoupon(isBuyYhq); - orderInfo.setIsUseCoupon(isuseYhq); orderInfo.setUserCouponAmount(couponAmount); JSONObject object = new JSONObject(); @@ -1051,16 +1327,16 @@ public class CartService { object.put("updatedAt", System.currentTimeMillis()); object.put("orderId", orderId + ""); } - redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString()); + redisUtil.saveMessage(tableCartKey, array.toJSONString()); orderInfo.setDetailList(orderDetails); JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("status", "success"); jsonObject1.put("msg", "成功"); jsonObject1.put("type", jsonObject.getString("type")); jsonObject1.put("data", orderInfo); - redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId)); + redisUtil.deleteByKey(tableCartKey); redisUtil.saveMessage(RedisCst.TABLE_ORDER.concat(orderInfo.getOrderNo()), JSONObject.toJSONString(orderInfo), 24 * 60 * 60L); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true); JSONObject jsonObject12 = new JSONObject(); jsonObject12.put("status", "success"); jsonObject12.put("msg", "成功"); @@ -1068,7 +1344,7 @@ public class CartService { jsonObject12.put("amount", BigDecimal.ZERO); jsonObject12.put("data", new JSONArray()); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), tableCartKey, "", false); } catch (Exception e) { log.info("长链接错误 pendingOrder{}", e.getMessage()); e.printStackTrace(); @@ -1078,7 +1354,10 @@ public class CartService { public void queryCart(JSONObject jsonObject) { try { String shopId = jsonObject.getString("shopId"); - JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))); + Integer userId = jsonObject.getInteger("userId"); + String tableId = jsonObject.getString("tableId"); + String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId); + JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey)); BigDecimal amount = BigDecimal.ZERO; for (int i = 0; i < array.size(); i++) { JSONObject object = array.getJSONObject(i); @@ -1091,11 +1370,63 @@ public class CartService { jsonObject1.put("type", jsonObject.getString("type")); jsonObject1.put("data", array); jsonObject1.put("amount", amount); - PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false); } catch (Exception e) { log.info("长链接错误 queryCart{}", e.getMessage()); e.printStackTrace(); } } + public List choseEatModel(ChoseEatModelDTO choseEatModelDTO) { + Integer userId = TokenUtil.getUserId(); + List cashierCartList; + // 外带模式 + if (choseEatModelDTO.getType() == 1) { + // 查询购物车所有信息 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId()) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .isNull(TbCashierCart::getOrderId) + .ne(TbCashierCart::getProductId, "-999") + .eq(TbCashierCart::getStatus, "create"); + queryWrapper.eq(TbCashierCart::getUserId, userId); + cashierCartList = mpCashierCartMapper.selectList(queryWrapper); + + // 计算打包费 + if (cashierCartList.isEmpty()) { + return new ArrayList<>(); + } + + List productIds = cashierCartList.stream().map(TbCashierCart::getProductId).collect(Collectors.toList()); + Map productMap = productMapper.selectByIds(productIds).stream() + .collect(Collectors.toMap( + TbProduct::getId, // keyMapper,使用 Product 的 getId() 方法作为 key + product -> product // valueMapper,直接使用 Product 对象作为 value + )); + cashierCartList.forEach(item -> { + TbProduct tbProduct = productMap.get(Integer.parseInt(item.getProductId())); + item.setIsPack("true"); + if (tbProduct != null && tbProduct.getPackFee() != null) { + BigDecimal packFee = tbProduct.getPackFee().multiply(BigDecimal.valueOf(item.getNumber())); + item.setPackFee(packFee); + item.setTotalAmount(item.getTotalAmount().add(packFee)); + } + }); + + }else { + // 查询购物车所有信息 + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseEatModelDTO.getTableId(), choseEatModelDTO.getShopId()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, choseEatModelDTO.getShopId()) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .isNull(TbCashierCart::getOrderId) + .eq(TbCashierCart::getTableId, choseEatModelDTO.getTableId()) + .and(q -> q.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()).or().isNull(TbCashierCart::getUseType).or().eq(TbCashierCart::getUseType, "")) + .eq(TbCashierCart::getStatus, "create"); + cashierCartList = mpCashierCartMapper.selectList(queryWrapper); + } + + // 所有订单信息 + return cashierCartList; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CashierCartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CashierCartService.java deleted file mode 100644 index 760fdfa..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CashierCartService.java +++ /dev/null @@ -1,156 +0,0 @@ -//package com.chaozhanggui.system.cashierservice.service; -// -//import com.chaozhanggui.system.cashierservice.dao.TbCashierCartMapper; -//import com.chaozhanggui.system.cashierservice.dao.TbProductMapper; -//import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper; -//import com.chaozhanggui.system.cashierservice.entity.TbCashierCart; -//import com.chaozhanggui.system.cashierservice.entity.TbProduct; -//import com.chaozhanggui.system.cashierservice.entity.TbProductSku; -//import com.chaozhanggui.system.cashierservice.entity.dto.ProductCartDto; -//import com.chaozhanggui.system.cashierservice.entity.vo.CashierCarVo; -//import com.chaozhanggui.system.cashierservice.exception.MsgException; -//import com.chaozhanggui.system.cashierservice.sign.CodeEnum; -//import com.chaozhanggui.system.cashierservice.sign.Result; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.beans.BeanUtils; -//import org.springframework.stereotype.Service; -//import org.springframework.transaction.annotation.Transactional; -// -//import javax.annotation.Resource; -//import java.math.BigDecimal; -//import java.time.Instant; -//import java.util.ArrayList; -//import java.util.HashMap; -//import java.util.List; -// -///** -// * @author lyf -// */ -//@Service -//@Slf4j -//public class CashierCartService { -// @Resource -// private TbCashierCartMapper cashierCartMapper; -// @Resource -// private TbProductMapper productMapper; -// @Resource -// private TbProductSkuMapper productSkuMapper; -// -// /** -// * 增加购物车 -// * @param productCartDto -// * @return -// */ -// @Transactional(rollbackFor = Exception.class) -// public Result batchAdd(ProductCartDto productCartDto){ -// //首先确认金额 -// TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productCartDto.getProductId())); -// if (tbProduct == null){ -// return Result.fail("商品信息不存在"); -// } -// -// TbCashierCart cashierCart = cashierCartMapper.selectByProduct(productCartDto.getProductId(), productCartDto.getTableId()); -// if (cashierCart != null){ -// if ("add".equals(productCartDto.getType())){ -// TbCashierCart cashierCartNow = new TbCashierCart(); -// cashierCartNow.setNumber(cashierCart.getNumber()+1F); -// cashierCartNow.setId(cashierCart.getId()); -// cashierCartMapper.updateByPrimaryKeySelective(cashierCartNow); -// return Result.success(CodeEnum.ENCRYPT); -// }else if ("minus".equals(productCartDto.getType())){ -// TbCashierCart cashierCartNow = new TbCashierCart(); -// cashierCartNow.setNumber(cashierCart.getNumber()-1F); -// cashierCartNow.setId(cashierCart.getId()); -// if (cashierCartNow.getNumber() == 0F){ -// cashierCartNow.setStatus("clear"); -// cashierCartMapper.updateByPrimaryKeySelective(cashierCartNow); -// return Result.success(CodeEnum.ENCRYPT); -// } -// cashierCartMapper.updateByPrimaryKeySelective(cashierCartNow); -// return Result.success(CodeEnum.ENCRYPT); -// }else { -// throw new MsgException("添加购物车失败"); -// } -// } -// //增加新的购物车 -// TbCashierCart tbCashierCart = new TbCashierCart(); -// BeanUtils.copyProperties(productCartDto,tbCashierCart); -// tbCashierCart.setSalePrice(tbProduct.getLowPrice()); -// tbCashierCart.setCreatedAt(Instant.now().toEpochMilli()); -// tbCashierCart.setUpdatedAt(Instant.now().toEpochMilli()); -// tbCashierCart.setTotalNumber(0.00F); -// tbCashierCart.setRefundNumber(0.00F); -// tbCashierCart.setType((byte) 0); -// tbCashierCart.setSkuId(productCartDto.getSkuInfo()); -// //购物车状态打开 -// tbCashierCart.setStatus("open"); -// -// int insert = cashierCartMapper.insertSelective(tbCashierCart); -// if (insert>0){ -// return Result.success(CodeEnum.SUCCESS); -// } -// throw new MsgException("添加购物车失败"); -// } -// -// -// public Result cartList(Integer tableId){ -// HashMap map = new HashMap<>(); -// List tbCashierCarts = cashierCartMapper.selectByTableId(tableId); -// BigDecimal total = new BigDecimal("0.00"); -// for (TbCashierCart date :tbCashierCarts) { -// Float number = date.getNumber(); -// BigDecimal bigDecimalValue = new BigDecimal(number.toString()); -// total=total.add(bigDecimalValue.multiply(date.getSalePrice())); -// } -// -// map.put("cartList",tbCashierCarts); -// map.put("total",total); -// -// return Result.success(CodeEnum.ENCRYPT,map); -// -// } -// @Transactional(rollbackFor = Exception.class) -// public Result updateNumber(Integer tableId,String type){ -// TbCashierCart cashierCart = cashierCartMapper.selectByPrimaryKey(tableId); -// if (cashierCart == null){ -// return Result.fail("商品不存在"); -// } -// if ("add".equals(type)){ -// TbCashierCart cashierCartNow = new TbCashierCart(); -// cashierCartNow.setNumber(cashierCart.getNumber()+1F); -// cashierCartNow.setId(cashierCart.getId()); -// cashierCartMapper.updateByPrimaryKeySelective(cashierCartNow); -// return Result.success(CodeEnum.ENCRYPT); -// }else if ("minus".equals(type)){ -// TbCashierCart cashierCartNow = new TbCashierCart(); -// cashierCartNow.setNumber(cashierCart.getNumber()-1F); -// cashierCartNow.setId(cashierCart.getId()); -// if (cashierCartNow.getNumber() == 0F){ -// cashierCartNow.setStatus("clear"); -// cashierCartMapper.updateByPrimaryKeySelective(cashierCartNow); -// return Result.success(CodeEnum.ENCRYPT); -// } -// cashierCartMapper.updateByPrimaryKeySelective(cashierCartNow); -// return Result.success(CodeEnum.ENCRYPT); -// }else { -// throw new MsgException("更改商品失败"); -// } -// -// } -// @Transactional(rollbackFor = Exception.class) -// public Result clearCart(Integer tableId){ -// List cashierCarVos = cashierCartMapper.selectByTableIdOpen(tableId); -// if (cashierCarVos.isEmpty()){ -// return Result.fail("购物车内无商品"); -// } -// List ids = new ArrayList<>(); -// for (CashierCarVo date :cashierCarVos) { -// ids.add(date.getId()); -// } -// int i = cashierCartMapper.updateByIdsStatus(ids, Instant.now().toEpochMilli()); -// if (i != ids.size()){ -// throw new MsgException("清空购物车失败"); -// } -// return Result.success(CodeEnum.ENCRYPT); -// } -//} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java index 0c560ce..e6f2f83 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java @@ -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 categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class); - List categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class); - - switch (tbPrintMachineWithBLOBs.getContentType()){ + switch (tbPrintMachineWithBLOBs.getContentType()) { case "yxyPrinter": - yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); + yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); break; case "fePrinter": - fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); + fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); break; } }); 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 categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + 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 categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + cashierCarts.parallelStream().forEach(it -> { + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + 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 categoryInfos){ - String orderId=orderInfo.getId().toString(); - - + private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + String orderId = orderInfo.getId().toString(); switch (tbPrintMachineWithBLOBs.getSubType()) { case "label": //标签打印机 break; case "cash": //小票打印机 - switch (model) { - case "normal": //普通出单 - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if(ObjectUtil.isEmpty(it.getCategoryId())){ - categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count= categoryInfos.stream().filter(c-> - c.getId().toString().equals(categoryId) - ).count(); - - if(count>0){ - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ - - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark()); - 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 categoryInfos) { + if ("return".equals(orderInfo.getOrderType())) { + List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); + if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { + List detailList = new ArrayList<>(); + tbOrderDetails.parallelStream().forEach(it -> { + String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + log.info("获取当前类别是否未打印类别:{}", count); + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); + detailList.add(detail); - private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List categoryInfos){ - String orderId=orderInfo.getId().toString(); + }); + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + + + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { +// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + + String printType = "退款单"; + + String data = PrinterUtils.getCashPrintData(detailPO, printType); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + } + + + } else { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); + String printType = "结算单"; + + if ("return".equals(orderInfo.getOrderType())) { + printType = "退款单"; + } + + + FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); + } + + } + } + } + + /** + * 仅打印制作单「厨房」 + */ + private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + cashierCarts.parallelStream().forEach(it -> { + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); + } + }); + } + } + + + private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + String orderId = orderInfo.getId().toString(); switch (tbPrintMachineWithBLOBs.getSubType()) { case "label": //标签打印机 - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - cashierCarts.parallelStream().forEach(it->{ + cashierCarts.parallelStream().forEach(it -> { String categoryId; - if(ObjectUtil.isEmpty(it.getCategoryId())){ - categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); } else { categoryId = it.getCategoryId(); } - Long count= categoryInfos.stream().filter(c-> + Long count = categoryInfos.stream().filter(c -> c.getId().toString().equals(categoryId) ).count(); - if(count>0) { + if (count > 0) { TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); String remark = ""; if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { remark = tbProductSkuWithBLOBs.getSpecSnap(); } - for(int i=0;i tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); - if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { - List detailList = new ArrayList<>(); - tbOrderDetails.parallelStream().forEach(it -> { - String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - log.info("获取当前类别是否未打印类别:{}", count); - - - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); - detailList.add(detail); - - }); - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - - - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { -// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); - - String printType = "退款单"; - - String data = PrinterUtils.getCashPrintData(detailPO, printType); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - } - - - } else { - cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); - - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); - String printType = "结算单"; - - if ("return".equals(orderInfo.getOrderType())) { - printType = "退款单"; - } - - - FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); - } - - } - } - - break; - case "one": //一菜一品 - - cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - - cashierCarts.parallelStream().forEach(it -> { - - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); - } - }); - } + if ("normal".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("one".equals(model)) { + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("all".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); } break; case "kitchen": //出品打印机 @@ -398,6 +409,4 @@ public class CloudPrinterService { } - - } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/IntegralService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/IntegralService.java deleted file mode 100644 index 3d948da..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/IntegralService.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.chaozhanggui.system.cashierservice.service; - -import com.alibaba.fastjson.JSONObject; -import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.*; -import com.chaozhanggui.system.cashierservice.exception.MsgException; -import com.chaozhanggui.system.cashierservice.redis.RedisUtil; -import com.chaozhanggui.system.cashierservice.util.DateUtils; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.text.ParseException; -import java.util.*; - -/** - * @author lyf - */ -@Service -@Slf4j -public class IntegralService { - @Autowired - private RedisUtil redisUtil; - @Autowired - private TbOrderInfoMapper orderInfoMapper; - @Autowired - private TbUserInfoMapper userInfoMapper; - @Autowired - private TbProductMapper productMapper; - @Autowired - private TbProductSkuMapper productSkuMapper; - @Autowired - private TbShopInfoMapper shopInfoMapper; - @Autowired - private TbShopUserMapper tbShopUserMapper; - @Resource - private TbReleaseFlowMapper integralFlowMapper; - @Autowired - private TbUserCouponsMapper userCouponsMapper; - @Autowired - private TbSplitAccountsMapper splitAccountsMapper; - - @Transactional(rollbackFor = Exception.class) - public void integralAdd(JSONObject jsonObject) throws ParseException { - String type = jsonObject.getString("type"); - if (type.equals("trade")){ - //优惠券兑换积分 - Integer integralId = jsonObject.getInteger("integralId"); - TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(integralId); - if (Objects.isNull(userCoupons) || !"0".equals(userCoupons.getStatus())){ - throw new MsgException("优惠券已被使用"); - } - userCoupons.setStatus("trade"); - userCoupons.setUpdateTime(new Date()); - userCouponsMapper.updateByPrimaryKeySelective(userCoupons); - TbParams params = tbShopUserMapper.selectParams(); - TbReleaseFlow integralFlow = new TbReleaseFlow(); - integralFlow.setNum(userCoupons.getCouponsAmount().multiply(params.getTradeRatio())); - integralFlow.setCreateTime(new Date()); - integralFlow.setFromSource(userCoupons.getId()+""); - integralFlow.setType("TRADEADD"); - integralFlow.setUserId(userCoupons.getUserId()); - integralFlowMapper.insert(integralFlow); - TbUserInfo userInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userCoupons.getUserId())); - if (Objects.nonNull(userInfo)){ - userInfo.setTotalScore(userInfo.getTotalScore() + integralFlow.getNum().intValue()); - userInfoMapper.updateByPrimaryKeySelective(userInfo); - } - }else { - Integer orderId = jsonObject.getInteger("orderId"); - TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); - if (StringUtils.isNotBlank(orderInfo.getUserCouponId())){ - TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserCouponId())); - if (Objects.nonNull(userCoupons)){ - TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId())); - TbSplitAccounts splitAccounts = new TbSplitAccounts(); - splitAccounts.setConponsAmount(userCoupons.getCouponsAmount()); - splitAccounts.setCreateTime(new Date()); - splitAccounts.setIsSplit("false"); - splitAccounts.setMerchantId(Integer.valueOf(shopInfo.getMerchantId())); - splitAccounts.setShopId(shopInfo.getId()); - splitAccounts.setOrderAmount(orderInfo.getPayAmount()); - splitAccounts.setTradeDay(DateUtils.getDay()); - splitAccounts.setOriginAmount(orderInfo.getOriginAmount()); - splitAccountsMapper.insert(splitAccounts); - } - } - if (Objects.isNull(orderInfo)) { - log.error("该订单不存在"); - return; - } - TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId())); - if (Objects.isNull(shopInfo) || !"true".equals(shopInfo.getIsOpenYhq())){ - log.error("该店铺未开启优惠券功能"); - return; - } - - TbParams params = tbShopUserMapper.selectParams(); - TbUserCoupons userCoupons = new TbUserCoupons(); - userCoupons.setUserId(orderInfo.getUserId()); - userCoupons.setCouponsAmount(orderInfo.getOrderAmount().subtract(orderInfo.getUserCouponAmount()).multiply(params.getIntegralRatio())); - userCoupons.setStatus("0"); - userCoupons.setOrderId(orderId); - userCoupons.setCouponsPrice(userCoupons.getCouponsAmount().multiply(new BigDecimal("0.5"))); - userCoupons.setCreateTime(new Date()); - userCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,30)); - //执行插入方法 - userCouponsMapper.insert(userCoupons); - } - - } - -} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index c9194ed..183fd0e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -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 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); @@ -537,21 +584,23 @@ public class LoginService { ) { return Result.fail("参数错误"); } - TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); - boolean flag = validate(map.get("code").toString(), userInfo.getTelephone()); - if (!flag) { - return Result.fail("验证码错误"); + String phone = userInfo.getTelephone(); + if (map.containsKey("vipId")) { + TbShopUser tbShopUser = tbShopUserMapper.selectByPrimaryKey(map.get("vipId").toString()); + phone = tbShopUser.getTelephone(); } + if (StringUtils.isBlank(phone)) return Result.fail("设置密码失败,手机号获取为空"); + boolean flag = validate(map.get("code").toString(), phone); + + if (!flag) return Result.fail("验证码错误"); userInfo.setIsPwd("1"); userInfo.setPwd(MD5Utils.md5(map.get("pwd").toString())); userInfo.setUpdatedAt(System.currentTimeMillis()); tbUserInfoMapper.updateByPrimaryKey(userInfo); - return Result.success(CodeEnum.SUCCESS); - } @@ -581,11 +630,4 @@ public class LoginService { return Result.success(CodeEnum.SUCCESS); } - - - public static void main(String[] args) { - for (int i = 0; i < 10; i++) { - System.out.println(RandomUtil.randomNumbers(10)); - } - } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java index 3455262..466667f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java @@ -1,35 +1,39 @@ 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 com.alibaba.fastjson.JSONObject; -import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.*; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.chaozhanggui.system.cashierservice.constant.TableConstant; +import com.chaozhanggui.system.cashierservice.dao.TbOrderDetailMapper; +import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopTableMapper; +import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail; +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; +import com.chaozhanggui.system.cashierservice.entity.TbShopTable; import com.chaozhanggui.system.cashierservice.entity.vo.OrderVo; -import com.chaozhanggui.system.cashierservice.exception.MsgException; -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.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.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; -import com.chaozhanggui.system.cashierservice.util.DateUtils; -import com.chaozhanggui.system.cashierservice.util.N; -import com.chaozhanggui.system.cashierservice.util.RedisUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; 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.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.Objects; -import java.util.concurrent.TimeUnit; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; /** * @author 12847 @@ -37,8 +41,6 @@ import java.util.concurrent.TimeUnit; @Service public class OrderService { - @Resource - private RabbitProducer producer; @Resource private TbOrderInfoMapper orderInfoMapper; @@ -48,36 +50,19 @@ public class OrderService { @Resource private TbShopTableMapper shopTableMapper; - @Resource - private TbProductSkuMapper productSkuMapper; - - @Resource - private TbUserInfoMapper userInfoMapper; - @Autowired - private TbWiningUserMapper tbWiningUserMapper; @Resource private TbOrderDetailMapper tbOrderDetailMapper; - @Autowired - private TbReleaseFlowMapper releaseFlowMapper; - @Resource - private TbParamsMapper paramsMapper; - @Resource - private RedisUtil redisUtil; - @Resource - private RedisUtils redisUtils; - @Resource - private TbUserCouponsMapper userCouponsMapper; - @Resource - private TbSystemCouponsMapper systemCouponsMapper; - @Autowired - private TbYhqParamsMapper yhqParamsMapper; - @Autowired - private TbShopUserMapper shopUserMapper; - @Autowired - private TbOrderInfoMapper tbOrderInfoMapper; + private MpCashierCartMapper mpCashierCartMapper; + @Autowired + private MpOrderDetailMapper mpOrderDetailMapper; + @Autowired + private MpOrderInfoMapper mpOrderInfoMapper; + @Autowired + private MpShopInfoMapper mpShopInfoMapper; + /** * 创建订单 * @@ -208,10 +193,20 @@ 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); } + public Result rmOrder(Integer orderId) { + int i = orderInfoMapper.deleteByPrimaryKey(orderId); + if (i > 0) { + return Result.success(CodeEnum.SUCCESS); + } + return Result.fail("删除失败"); + } + public Result orderList(Integer userId, Integer page, Integer size, String status) { // TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(userId); @@ -220,10 +215,14 @@ public class OrderService { // } PageHelper.startPage(page, size); List tbOrderInfos = orderInfoMapper.selectByUserId(userId, status); - + String shopName = ""; for (TbOrderInfo orderInfo : tbOrderInfos) { - orderInfo.setDescription(); - List list = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId()); + TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId())); + shopName = tbShopInfo.getShopName(); + orderInfo.setDescription(shopName); + List list = mpOrderDetailMapper.selectList(new LambdaQueryWrapper() + .eq(TbOrderDetail::getOrderId, orderInfo.getId()) + .ne(TbOrderDetail::getProductId, TableConstant.CART_SEAT_ID)); int num = 0; for (TbOrderDetail orderDetail : list) { num = num + orderDetail.getNum(); @@ -248,178 +247,87 @@ public class OrderService { } - @Transactional(rollbackFor = Exception.class) - public Result tradeIntegral(String userId, String id) throws ParseException { - updateIntegral(userId, id); - return Result.success(CodeEnum.ENCRYPT); - } + public Object orderDetail(Integer orderId) { - private void updateIntegral(String userId, String id) throws ParseException { + TbOrderInfo orderInfo = mpOrderInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(TbOrderInfo::getId, orderId)); - boolean lock_coin = redisUtils.lock(RedisCst.INTEGRAL_COIN_KEY + userId, 5000, TimeUnit.MILLISECONDS); - if (lock_coin) { - TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(Integer.valueOf(id)); - if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")) { - throw new MsgException("该优惠券已被使用"); - } - TbParams params = paramsMapper.selectByPrimaryKey(1); - BigDecimal jfAmount = params.getTradeRatio().multiply(userCoupons.getCouponsAmount()); - TbUserInfo tbShopUser = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); - tbShopUser.setTotalScore(tbShopUser.getTotalScore()+jfAmount.intValue()); - userInfoMapper.updateByPrimaryKeySelective(tbShopUser); - userCoupons.setStatus("2"); - userCoupons.setUpdateTime(new Date()); - userCouponsMapper.updateByPrimaryKeySelective(userCoupons); - TbSystemCoupons systemCoupons = new TbSystemCoupons(); - systemCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,30)); - systemCoupons.setCouponsAmount(userCoupons.getCouponsAmount()); - systemCoupons.setCouponsPrice(userCoupons.getCouponsPrice()); - systemCoupons.setStatus("0"); - systemCoupons.setName(userCoupons.getCouponsAmount()+"无门槛优惠券"); - systemCoupons.setCreateTime(new Date()); - String typeName = findName(userCoupons.getCouponsAmount()); - systemCoupons.setTypeName(typeName); - systemCouponsMapper.insert(systemCoupons); - TbReleaseFlow releaseFlow = new TbReleaseFlow(); - releaseFlow.setNum(jfAmount); - releaseFlow.setCreateTime(new Date()); - releaseFlow.setFromSource("OWER"); - releaseFlow.setUserId(userId); - releaseFlow.setOperationType("ADD"); - releaseFlow.setType("EXCHANGEADD"); - releaseFlow.setRemark("兑换增加"); - releaseFlowMapper.insert(releaseFlow); - redisUtils.releaseLock(RedisCst.INTEGRAL_COIN_KEY + userId); - } else { - updateIntegral(userId, id); + if (orderInfo == null) { + return Result.fail("订单不存在"); } - } - private String findName(BigDecimal amount) { - List list = yhqParamsMapper.selectAll(); - String typeName = ""; - for (TbYhqParams yhqParams:list){ - if (N.egt(amount,yhqParams.getMinPrice()) && N.gt(yhqParams.getMaxPrice(),amount)){ - typeName = yhqParams.getName(); - break; + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId())); + if (shopInfo == null) { + return Result.fail("店铺不存在"); + } + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbOrderDetail::getShopId, orderInfo.getShopId()) + .ne(TbOrderDetail::getProductId, TableConstant.CART_SEAT_ID) + .eq(TbOrderDetail::getOrderId, orderId); + + List list = mpOrderDetailMapper.selectList(queryWrapper); + AtomicReference mealCashierCart = new AtomicReference<>(); + list.forEach(item -> { + item.setPlaceNum(item.getPlaceNum() == null ? 0 : item.getPlaceNum()); + if (item.getProductId() == -999) { + mealCashierCart.set(item); + } + }); + + // 根据placeNum进行分组 + Map> groupedByPlaceNum = list.stream() + .collect(Collectors.groupingBy(TbOrderDetail::getPlaceNum)); + + ArrayList> dataList = new ArrayList<>(); + groupedByPlaceNum.forEach((k, v) -> { + HashMap 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(shopInfo.getShopName()); + orderVo.setStatus(orderInfo.getStatus()); + //TODO 增加商家二维码 + orderVo.setShopQrcode(shopInfo.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); } } - return typeName; - } - - - public Result mineCoupons(String userId, String orderId,String status, Integer page, Integer size) { - BigDecimal amount=null; - if(ObjectUtil.isNotNull(orderId)&&ObjectUtil.isNotEmpty(orderId)){ - TbOrderInfo orderInfo= tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId)); - amount=orderInfo.getOriginAmount(); - } - - - PageHelper.startPage(page, size); - List list = userCouponsMapper.selectByUserId(userId,status,amount); - PageInfo pageInfo = new PageInfo(list); - return Result.success(CodeEnum.SUCCESS, pageInfo); - } - - public Result findCoupons(String type, Integer page, Integer size) { - PageHelper.startPage(page, size); - List list = systemCouponsMapper.selectAll(type); - PageInfo pageInfo = new PageInfo(list); - return Result.success(CodeEnum.SUCCESS, pageInfo); - } - - public Result findWiningUser() { - String day = DateUtils.getDay(); - List list = tbWiningUserMapper.selectAllByTrade(day); - return Result.success(CodeEnum.SUCCESS, list); - } - - public Result getYhqPara() { - List list = yhqParamsMapper.selectAll(); - return Result.success(CodeEnum.SUCCESS, list); - } - - public Result testPay(Integer orderId) { - TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); - orderInfo.setStatus("closed"); - orderInfo.setPayType("wx_lite"); - orderInfo.setPayOrderNo("test"); - orderInfo.setPayAmount(orderInfo.getOrderAmount()); - orderInfoMapper.updateByPrimaryKeySelective(orderInfo); - JSONObject jsonObject=new JSONObject(); - jsonObject.put("token",0); - jsonObject.put("type","wxcreate"); - jsonObject.put("orderId",orderId.toString()); - producer.putOrderCollect(jsonObject.toJSONString()); - JSONObject coupons = new JSONObject(); - coupons.put("type","buy"); - coupons.put("orderId",orderId); - producer.printCoupons(coupons.toJSONString()); - return Result.success(CodeEnum.SUCCESS); - } - - public Result getYhqDouble(Integer orderId) { - TbUserCoupons userCoupons = userCouponsMapper.selectByOrderId(orderId); - if (Objects.nonNull(userCoupons)){ - TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); - userCoupons.setOrderInfo(orderInfo); - } - return Result.success(CodeEnum.SUCCESS,userCoupons); - } - @Transactional(rollbackFor = Exception.class) - public Result yhqDouble(Integer conponsId) { - TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(conponsId); - if (Objects.isNull(userCoupons) || userCoupons.getIsDouble().equals("true")){ - throw new MsgException("该优惠券翻倍已领取"); - } - modityDouble(conponsId); - return Result.success(CodeEnum.SUCCESS); - } - - - private void modityDouble(Integer conponsId) { - - boolean lock_coin = redisUtils.lock(RedisCst.COUPONS_COIN_KEY + conponsId, 5000, TimeUnit.MILLISECONDS); - if (lock_coin) { - TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(conponsId); - if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0") || userCoupons.getIsDouble().equals("true")) { - throw new MsgException("该优惠券已翻倍"); - } - TbParams params = shopUserMapper.selectParams(); - userCoupons.setIsDouble("true"); - userCoupons.setCouponsAmount(userCoupons.getCouponsAmount().multiply(params.getTwoRatio())); - userCoupons.setCouponsPrice(userCoupons.getCouponsPrice().multiply(params.getTwoRatio())); - userCoupons.setUpdateTime(new Date()); - userCouponsMapper.updateByPrimaryKeySelective(userCoupons); - redisUtils.releaseLock(RedisCst.COUPONS_COIN_KEY + conponsId); - } else { - modityDouble(conponsId); - } - } - - public Result mineWinner(Integer userId, Integer page, Integer size) { - PageHelper.startPage(page, size); - List list = orderInfoMapper.selectWinnerByUserId(userId); - for (TbOrderInfo tbOrderInfo:list){ - if (StringUtils.isNotEmpty(tbOrderInfo.getWinnnerNo())){ - tbOrderInfo.setIsWinner("true"); - }else { - tbOrderInfo.setIsWinner("false"); - } - } - PageInfo pageInfo = new PageInfo(list); - if (page > pageInfo.getPages()) { - pageInfo.setList(Collections.emptyList()); - } - return Result.success(CodeEnum.SUCCESS, pageInfo); - } - - public Result kc() { - List list = productSkuMapper.selectAll(); - for (TbProductSku productSku:list){ - redisUtil.saveMessage(RedisCst.PRODUCT + productSku.getShopId() + ":" +productSku.getId(),"10000"); - } - return Result.success(CodeEnum.SUCCESS); + 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())); + orderVo.setQrcode(shopInfo.getShopQrcode()); + Map 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()))); + map.put("registerType", shopInfo.getRegisterType()); + return map; } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index cf77531..9ce9312 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1,16 +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.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.constant.TableConstant; 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.MemberInDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.OrderPayDTO; import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto; +import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO; +import com.chaozhanggui.system.cashierservice.entity.vo.ActivateInInfoVO; import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; +import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.mapper.*; import com.chaozhanggui.system.cashierservice.model.PayReq; import com.chaozhanggui.system.cashierservice.model.TradeQueryReq; +import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService; import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter; import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.redis.RedisCst; @@ -23,6 +36,7 @@ import com.chaozhanggui.system.cashierservice.thirdpay.resp.WxScanPayResp; import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService; import com.chaozhanggui.system.cashierservice.util.*; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -31,6 +45,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,8 +54,11 @@ import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; import java.io.IOException; import java.math.BigDecimal; +import java.math.RoundingMode; +import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; @Service @Slf4j @@ -71,6 +89,12 @@ public class PayService { @Autowired TbShopPayTypeMapper tbShopPayTypeMapper; + @Autowired + private TbCouponProductMapper couProductMapper; + @Autowired + private TbShopCouponMapper couponMapper; + @Resource + private TbActivateInRecordMapper activateInRecordMapper; @Autowired private TbShopSongOrderMapper tbShopSongOrderMapper; @@ -111,6 +135,10 @@ public class PayService { @Autowired TbShopUserFlowMapper tbShopUserFlowMapper; + @Resource + private TbActivateInRecordService activateInRecordService; + @Autowired + private TbActivateOutRecordMapper outRecordMapper; @Value("${thirdPay.payType}") private String thirdPayType; @@ -149,59 +177,98 @@ public class PayService { private final TbShopSongOrderService shopSongOrderService; @Autowired 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) { + private final MpShopTableService mpShopTableService; + private final TbFreeDineConfigService freeDineConfigService; + private final TbShopCouponService shopCouponService; + private final MpMemberInMapper mpMemberInMapper; + @Qualifier("tbShopCouponService") + @Autowired + private TbShopCouponService tbShopCouponService; + @Autowired + private TbShopCouponMapper tbShopCouponMapper; + @Autowired + private MpShopCouponMapper mpShopCouponMapper; + @Autowired + private TbFreeDineRecordMapper tbFreeDineRecordMapper; + private final TbFreeDineRecordService freeDineRecordService; + + public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, MpShopTableService mpShopTableService, TbFreeDineConfigService freeDineConfigService, TbShopCouponService shopCouponService, MpMemberInMapper mpMemberInMapper, TbFreeDineRecordService freeDineRecordService) { this.shopSongOrderService = shopSongOrderService; + this.mpShopTableService = mpShopTableService; + this.freeDineConfigService = freeDineConfigService; + this.shopCouponService = shopCouponService; + this.mpMemberInMapper = mpMemberInMapper; + this.freeDineRecordService = freeDineRecordService; } - @Transactional(rollbackFor = Exception.class) - public Result payOrder(String openId, String orderId, String ip) throws Exception { - - if (ObjectUtil.isEmpty(openId) || Objects.isNull(openId)) { - return Result.fail("付款用户[userId]参数不能为空"); - } - - TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId)); + 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 = 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())); + } + /** + * 校验订单支付状态是否正常 + * @param orderInfo 订单信息 + */ + private void checkOrderPayState(TbOrderInfo orderInfo) { if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus())) { - return Result.fail("订单状态异常,不允许支付"); + throw new MsgException("订单状态异常,不允许支付"); } - if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) { - return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。"); + + if (!OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(orderInfo.getUseType()) && System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) { + throw new MsgException("订单十五分钟内有效,当前已超时,请重新下单。"); } if (ObjectUtil.isNull(orderInfo.getMerchantId()) || ObjectUtil.isEmpty(orderInfo.getMerchantId())) { - return Result.fail("没有对应的商户"); + throw new MsgException("没有对应的商户"); } + } - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null); - if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) { - return Result.fail("购物车信息不存在"); - } - - StringBuffer body = new StringBuffer(); - for (TbCashierCart cashierCart : cashierCarts) { - body.append(cashierCart.getName()); - } - - - TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId())); - - if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) { - return Result.fail("支付通道不存在"); - } - - TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId); + /** + * 保存订单支付详情 + * @param orderInfo 订单信息 + * @param payType 支付类型 + * @return 订单支付 + */ + private TbOrderPayment createOrderPayment(TbOrderInfo orderInfo, String payType) { + TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(String.valueOf(orderInfo.getId())); + String payName = "wechatPay".equals(payType) ? "微信支付" : "aliPay".equals(payType) ? "支付宝支付" : "未知支付"; if (ObjectUtil.isEmpty(payment) || payment == null) { payment = new TbOrderPayment(); payment.setPayTypeId("ysk"); payment.setAmount(orderInfo.getOrderAmount()); payment.setPaidAmount(orderInfo.getPayAmount()); payment.setHasRefundAmount(BigDecimal.ZERO); - payment.setPayName("微信支付"); - payment.setPayType("wechatPay"); + payment.setPayName(payName); + payment.setPayType(payType); payment.setReceived(payment.getAmount()); payment.setChangeFee(BigDecimal.ZERO); payment.setMemberId(orderInfo.getMemberId()); @@ -210,104 +277,234 @@ public class PayService { payment.setCreatedAt(System.currentTimeMillis()); tbOrderPaymentMapper.insert(payment); } else { + payment.setPayName(payName); + payment.setPayType(payType); payment.setUpdatedAt(System.currentTimeMillis()); tbOrderPaymentMapper.updateByPrimaryKey(payment); } - if ("ysk".equals(thirdPayType)) { - PayReq req = new PayReq(); + return payment; - req.setAppId(thirdApply.getAppId()); - req.setTimestamp(System.currentTimeMillis()); - req.setIp(ip); - req.setMercOrderNo(orderInfo.getOrderNo()); - req.setNotifyUrl(callBackurl); - req.setPayAmt(payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); - req.setPayType("03"); - req.setPayWay("WXZF"); - req.setSubject("扫码点餐"); - req.setUserId(openId); + } + private JSONObject yskPay(TbMerchantThirdApply thirdApply, TbOrderInfo orderInfo, TbOrderPayment payment, String openId, String userId, String ip) { + PayReq req = new PayReq(); + req.setAppId(thirdApply.getAppId()); + req.setTimestamp(System.currentTimeMillis()); + req.setIp(ip); + req.setMercOrderNo(orderInfo.getOrderNo()); + req.setNotifyUrl(callBackurl); + req.setPayAmt(payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); + req.setPayType("03"); + req.setPayWay("WXZF"); + req.setSubject("扫码点餐"); + req.setUserId(openId); + Map map = BeanUtil.transBeanMap(req); + req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true)); + log.info("开始发送银收客支付请求,请求: {}", req); + ResponseEntity response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class); + log.info("银收客支付请求结束,响应: {}", response); + if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) { + JSONObject object = JSONObject.parseObject(response.getBody()); + if (object.get("code").equals("0")) { + payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString()); + payment.setUpdatedAt(System.currentTimeMillis()); + tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); + orderInfo.setStatus("paying"); + orderInfo.setPayOrderNo(payment.getTradeNumber()); + orderInfo.setUserId(userId); + tbOrderInfoMapper.updateByPrimaryKey(orderInfo); - Map map = BeanUtil.transBeanMap(req); - req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true)); + //清除缓存购物车数据 + redisUtil.deleteByKey(RedisCst.getTableCartKey(orderInfo.getTableId(), orderInfo.getTableId(), orderInfo.getUserId())); + tbCashierCartMapper.updateStatusByOrderId(orderInfo.getId().toString(), "final"); + return object.getJSONObject("data"); + } else { + throw new MsgException(object.getString("msg")); + } + } + throw new MsgException("支付失败"); + } - ResponseEntity response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class); - if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) { - JSONObject object = JSONObject.parseObject(response.getBody()); - if (object.get("code").equals("0")) { - payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString()); + private JsonNode fstPay(String body, TbMerchantThirdApply thirdApply, TbOrderInfo orderInfo, TbOrderPayment payment, String openId, String userId, String ip) throws JsonProcessingException { + String reqbody; + if (body.length() > 15) { + reqbody = body.substring(0, 6).concat("....").concat(body.substring(body.length() - 6, body.length())); + } else { + reqbody = body; + } + + String smallAppid = thirdApply.getSmallAppid(); + String appId = thirdApply.getAppId(); + String appToken = thirdApply.getAppToken(); + if ("aliPay".equals(orderInfo.getPayType())){ + smallAppid = thirdApply.getAlipaySmallAppid(); + } + String convertPayType = "aliPay".equals(orderInfo.getPayType()) ? "ALIPAY" : "WECHAT"; + PublicResp publicResp = thirdPayService.scanpay(thirdUrl, + appId, + reqbody, + reqbody, + payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), + 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(); + if ("TRADE_AWAIT".equals(wxScanPayResp.getState())) { + payment.setTradeNumber(wxScanPayResp.getPayOrderId()); payment.setUpdatedAt(System.currentTimeMillis()); 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); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "success"); - jsonObject1.put("msg", "成功"); - jsonObject1.put("type", ""); - jsonObject1.put("data", new JSONArray()); - jsonObject1.put("amount", 0); -// AppWebSocketServer.AppSendInfo(jsonObject1,key, "",false); - tbCashierCartMapper.updateStatusByOrderId(orderId.toString(), "final"); - return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data")); + redisUtil.deleteByKey(RedisCst.getTableCartKey(orderInfo.getShopId(), orderInfo.getTableId(), orderInfo.getUserId())); + tbCashierCartMapper.updateStatusByOrderId(orderInfo.getId().toString(), "final"); + ObjectMapper mapper = new ObjectMapper(); + return mapper.readTree(wxScanPayResp.getPayInfo()); } else { - return Result.fail(object.getString("msg")); - } - } - } else { - String reqbody = ""; - - if (body.length() > 15) { - reqbody = body.substring(0, 6).concat("....").concat(body.substring(body.length() - 6, body.length())).toString(); - } else { - reqbody = body.toString(); - } - - PublicResp publicResp = thirdPayService.scanpay(thirdUrl, thirdApply.getAppId(), - 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()); - if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { - if ("000000".equals(publicResp.getCode())) { - WxScanPayResp wxScanPayResp = publicResp.getObjData(); - if ("TRADE_AWAIT".equals(wxScanPayResp.getState())) { - payment.setTradeNumber(wxScanPayResp.getPayOrderId()); - payment.setUpdatedAt(System.currentTimeMillis()); - tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); - orderInfo.setStatus("paying"); - orderInfo.setPayOrderNo(payment.getTradeNumber()); - - - tbOrderInfoMapper.updateByPrimaryKey(orderInfo); - String key = RedisCst.TABLE_CART.concat(orderInfo.getTableId()).concat("-").concat(orderInfo.getShopId()); - //清除缓存购物车数据 - redisUtil.deleteByKey(key); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("status", "success"); - jsonObject1.put("msg", "成功"); - jsonObject1.put("type", ""); - jsonObject1.put("data", new JSONArray()); - jsonObject1.put("amount", 0); - -// AppWebSocketServer.AppSendInfo(jsonObject1,key, "",false); - tbCashierCartMapper.updateStatusByOrderId(orderId.toString(), "final"); - ObjectMapper mapper = new ObjectMapper(); - return Result.success(CodeEnum.SUCCESS, mapper.readTree(wxScanPayResp.getPayInfo())); - } else { - return Result.fail(publicResp.getMsg()); - } + throw new MsgException(publicResp.getMsg()); } } } + log.error("福商通支付失败,响应: {}", publicResp); + throw new MsgException("支付失败"); + } + private BigDecimal getFreeDineOrderInfo(MemberInDTO payDTO) { + TbOrderInfo orderInfo = mpOrderInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(TbOrderInfo::getId, payDTO.getOrderId()) + .in(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.UNPAID.getValue(), TableConstant.OrderInfo.Status.PAYING.getValue())); + if (orderInfo == null) { + throw new MsgException("订单不存在或不处于待支付状态"); + } - return Result.fail("失败"); + // 获取店铺霸王餐配置 + TbFreeDineConfig freeDineConfig = freeDineConfigService.getByShopId(orderInfo.getShopId()); + if (freeDineConfig == null || freeDineConfig.getEnable() == null || freeDineConfig.getEnable() == 0) { + throw new MsgException("店铺未开启霸王餐配置"); + } + + // 校验订单金额是否满足 + if (orderInfo.getOriginAmount().compareTo(freeDineConfig.getRechargeThreshold()) < 0) { + throw new MsgException("当前订单金额未满足霸王餐最低标准"); + } + + // 校验优惠券积分同享 + if (!payDTO.getUserCouponIds().isEmpty() && freeDineConfig.getWithCoupon() == 0) { + throw new MsgException("当前店铺未开启与优惠券同享"); + } + + if (payDTO.isUsePoints() && freeDineConfig.getWithPoints() == 0) { + throw new MsgException("当前店铺未开启与积分同享"); + } + + // 校验就餐模式是否满足 + if (!freeDineConfig.getUseType().contains(orderInfo.getEatModel())) { + throw new MsgException("当前店铺未开启此就餐模式霸王餐"); + } + BigDecimal shouldPayAmount = orderInfo.getOriginAmount().multiply(BigDecimal.valueOf(freeDineConfig.getRechargeTimes())); + + TbFreeDineRecord record = tbFreeDineRecordMapper.selectOne(new LambdaQueryWrapper().eq(TbFreeDineRecord::getOrderId, orderInfo.getId())); + if (record == null) { + record = new TbFreeDineRecord(); + } + record.setState(TableConstant.FreeDineRecord.State.WAIT_PAY.getValue()); + record.setOrderId(orderInfo.getId()); + record.setOrderAmount(orderInfo.getOrderAmount()); + if (!payDTO.getUserCouponIds().isEmpty()) { + List userCouponList = shopCouponService.getActivateCouponByAmount(Integer.valueOf(orderInfo.getShopId()), String.valueOf(payDTO.getUserId()), shouldPayAmount); + if (userCouponList.isEmpty()) { + throw new MsgException("存在不可用优惠券"); + } + + ArrayList activateInInfoVOS = new ArrayList<>(); + for (Integer userCouponId : payDTO.getUserCouponIds()) { + TbUserCouponVo userCouponVo = userCouponList.stream().filter(item -> item.getId().equals(userCouponId)).findFirst().orElse(null); + if (userCouponVo == null) { + throw new MsgException("存在不可用优惠券"); + } + + shouldPayAmount = shouldPayAmount.subtract(userCouponVo.getDiscountAmount()); + ActivateInInfoVO activateInInfoVO = new ActivateInInfoVO() + .setId(userCouponVo.getId()) + .setCouponId(userCouponVo.getCouponId()) + .setNum(1); + activateInInfoVOS.add(activateInInfoVO); + } + + List tbShopCoupons = mpShopCouponMapper.selectBatchIds(activateInInfoVOS.stream().map(ActivateInInfoVO::getCouponId).collect(Collectors.toList())); + if (tbShopCoupons.size() != payDTO.getUserCouponIds().size()) { + throw new MsgException("存在不可用优惠券"); + } + + // 设置优惠券信息 + orderInfo.setActivateInInfoList(JSONObject.toJSONString(activateInInfoVOS)); + orderInfo.setUserCouponAmount(BigDecimal.valueOf(tbShopCoupons.stream().map(TbShopCoupon::getDiscountAmount).reduce(0, Integer::sum))); + record.setCouponInfo(JSONObject.toJSONString(userCouponList)); + } + + // TODO 霸王餐积分 + if (payDTO.isUsePoints()) { + + } + record.setRechargeAmount(shouldPayAmount); + record.setVipUserId(payDTO.getUserId()); + record.setShopId(Integer.valueOf(orderInfo.getShopId())); + record.setRechargeTimes(freeDineConfig.getRechargeTimes()); + record.setRechargeThreshold(freeDineConfig.getRechargeThreshold()); + record.setCreateTime(DateUtil.date()); + + mpOrderInfoMapper.updateById(orderInfo); + return shouldPayAmount; + } + + private void createFreeDineOrder(TbOrderInfo orderInfo) { + } + + @Transactional(rollbackFor = Exception.class) + public Result payOrder(String openId, OrderPayDTO payDTO, String ip) throws Exception { + TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(payDTO.getOrderId()); + checkOrderPayState(orderInfo); + + List cashierCarts = tbCashierCartMapper.selectByOrderId(String.valueOf(payDTO.getOrderId()), null); + if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) { + return Result.fail("购物车信息不存在"); + } + + StringBuilder body = new StringBuilder(); + for (TbCashierCart cashierCart : cashierCarts) { + 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(payDTO.getPayType()) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) { + return Result.fail("店铺未配置支付宝小程序appId"); + } + + String userId = String.valueOf(TokenUtil.getUserId()); + TbOrderPayment payment = createOrderPayment(orderInfo, payDTO.getPayType()); + + orderInfo.setPayType(payDTO.getPayType()); + if ("ysk".equals(thirdPayType)) { + return Result.successWithData(yskPay(thirdApply, orderInfo, payment, openId, userId, ip)); + } else { + return Result.successWithData(fstPay(body.toString(), thirdApply, orderInfo, payment, openId, userId, ip)); + } } @@ -321,11 +518,11 @@ public class PayService { if (ObjectUtil.isEmpty(orderInfo)) { 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("未获取到用户信息"); @@ -372,11 +569,12 @@ public class PayService { TbShopUserFlow flow = new TbShopUserFlow(); flow.setShopUserId(Integer.valueOf(user.getId())); flow.setBizCode("accountPay"); - flow.setBizName("会员储值卡支付"); + flow.setBizName("余额支付"); flow.setType("-"); flow.setAmount(orderInfo.getOrderAmount()); flow.setBalance(user.getAmount()); flow.setCreateTime(new Date()); + flow.setIsReturn("0"); tbShopUserFlowMapper.insert(flow); @@ -384,15 +582,20 @@ 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() + .eq(TbCashierCart::getOrderId, orderId) + .eq(TbCashierCart::getUseType, orderInfo.getUseType()) + .in(TbCashierCart::getStatus, "create", "closed") + .set(TbCashierCart::getStatus, "final")); - - tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed"); - - tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed"); + mpOrderDetailMapper.update(null, new LambdaUpdateWrapper().eq(TbOrderDetail::getId, orderId) + .eq(TbOrderDetail::getUseType, orderInfo.getUseType()) + .eq(TbOrderDetail::getStatus, "unpaid") + .set(TbOrderDetail::getStatus, "closed")); log.info("更新购物车:{}", cartCount); @@ -403,7 +606,16 @@ public class PayService { producer.putOrderCollect(jsonObject.toJSONString()); - producer.printMechine(orderId); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId()); + List detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper() + .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消息并保存库存记录 @@ -411,6 +623,33 @@ public class PayService { data.put("orderId", orderInfo.getId()); data.put("plat", "miniApp"); 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()); + producer.balance(baObj.toString()); + + // 为代客下单清楚当前台桌最新订单 + String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(), orderInfo.getShopId()); + String currentOrderId = stringRedisTemplate.opsForValue().get(currentOrderKey); + if (currentOrderId != null && currentOrderId.equals(orderId)) { + stringRedisTemplate.delete(currentOrderKey); + } + + // 重置台桌状态 + if (StrUtil.isNotBlank(orderInfo.getTableId())) { + TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId()); + if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) { + mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE); + }else { + mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING); + } + } return Result.success(CodeEnum.SUCCESS, "1"); } @@ -457,6 +696,7 @@ public class PayService { flow.setAmount(orderInfo.getOrderAmount()); flow.setBalance(user.getAmount()); flow.setCreateTime(new Date()); + flow.setIsReturn("0"); tbShopUserFlowMapper.insert(flow); for (int i = 0; i < orderInfo.getNumber(); i++) { @@ -495,6 +735,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()); @@ -572,14 +817,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 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(), @@ -587,7 +839,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(); @@ -672,6 +924,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); @@ -684,7 +938,16 @@ public class PayService { log.info("发送打印数据"); - producer.printMechine(orderInfo.getId() + ""); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId()); + List detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper() + .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": //退款成功 @@ -705,7 +968,8 @@ public class PayService { } } } else { - PublicResp publicResp = thirdPayService.queryOrder(thirdUrl, thirdApply.getAppId(), payment.getTradeNumber(), null, thirdApply.getAppToken()); + PublicResp 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 = ""; @@ -724,6 +988,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); @@ -736,7 +1002,16 @@ public class PayService { log.info("发送打印数据"); - producer.printMechine(orderInfo.getId() + ""); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId()); + List detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper() + .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); @@ -756,36 +1031,41 @@ public class PayService { @Transactional(rollbackFor = Exception.class) - public Result memberIn(String openId, String userId, String amount, String shopId, String ip) throws JsonProcessingException { - if (ObjectUtil.isEmpty(openId) || ObjectUtil.isEmpty(userId)) { - return Result.fail("用户信息允许为空"); - } + public Result memberIn(MemberInDTO memberInDTO, String ip) throws JsonProcessingException { - TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); + TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(memberInDTO.getUserId()); if (ObjectUtil.isEmpty(userInfo)) { return Result.fail("用户基本信息不存在"); } - TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId); + TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(String.valueOf(memberInDTO.getUserId()), String.valueOf(memberInDTO.getShopId())); if (ObjectUtil.isEmpty(tbShopUser)) { return Result.fail("对应的用户信息不存在"); } - - TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId)); + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(memberInDTO.getShopId()); if (ObjectUtil.isEmpty(shopInfo)) { return Result.fail("对应的店铺信息不存在"); } - TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId())); if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) { return Result.fail("支付通道不存在"); } - BigDecimal payAmount = new BigDecimal(amount).setScale(2, BigDecimal.ROUND_DOWN); - + // 霸王餐活动充值 + BigDecimal payAmount; TbMemberIn memberIn = new TbMemberIn(); + if (memberInDTO.getOrderId() != null) { + payAmount = getFreeDineOrderInfo(memberInDTO); + memberIn.setType(TableConstant.MemberIn.Type.FREE_DINE.getValue()); + // 会员充值 + }else { + payAmount = memberInDTO.getAmount().setScale(2, RoundingMode.DOWN); + memberIn.setType(TableConstant.MemberIn.Type.NORMAL.getValue()); + + } + memberIn.setAmount(payAmount); memberIn.setUserId(Integer.valueOf(tbShopUser.getUserId())); memberIn.setCode(tbShopUser.getCode()); @@ -793,7 +1073,8 @@ public class PayService { memberIn.setStatus("7"); memberIn.setMerchantId(Integer.valueOf(shopInfo.getMerchantId())); memberIn.setCreateTime(new Date()); - tbMemberInMapper.insert(memberIn); + memberIn.setOrderId(memberInDTO.getOrderId()); + mpMemberInMapper.insert(memberIn); if ("ysk".equals(thirdPayType)) { @@ -804,11 +1085,11 @@ public class PayService { req.setIp(ip); req.setMercOrderNo(SnowFlakeUtil.generateOrderNo()); req.setNotifyUrl(callBackIn); - req.setPayAmt(amount); + req.setPayAmt(payAmount.toPlainString()); req.setPayType("03"); req.setPayWay("WXZF"); req.setSubject("充值"); - req.setUserId(openId); + req.setUserId(String.valueOf(memberInDTO.getUserId())); Map map = BeanUtil.transBeanMap(req); @@ -831,7 +1112,10 @@ public class PayService { String orderNo = DateUtils.getsdfTimesSS(); PublicResp publicResp = thirdPayService .scanpay(thirdUrl, thirdApply.getAppId(), - "会员充值", "会员充值", new BigDecimal(amount).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(), "WECHAT", thirdApply.getSmallAppid(), openId, ip, orderNo, thirdApply.getStoreId(), callInBack, null, thirdApply.getAppToken()); + "会员充值", "会员充值", payAmount + .multiply(new BigDecimal(100)).longValue(), "WECHAT", + thirdApply.getSmallAppid(), memberInDTO.getOpenId(), ip, orderNo, thirdApply.getStoreId(), + callInBack, null, thirdApply.getAppToken()); if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if ("000000".equals(publicResp.getCode())) { WxScanPayResp wxScanPayResp = publicResp.getObjData(); @@ -840,6 +1124,7 @@ public class PayService { memberIn.setOrderNo(orderNo); memberIn.setTradeNo(wxScanPayResp.getPayOrderId()); memberIn.setUpdateTime(new Date()); + memberIn.setOrderId(memberIn.getOrderId()); tbMemberInMapper.updateByPrimaryKeySelective(memberIn); ObjectMapper mapper = new ObjectMapper(); return Result.success(CodeEnum.SUCCESS, mapper.readTree(wxScanPayResp.getPayInfo())); @@ -868,12 +1153,12 @@ public class PayService { //更新子单状态 tbOrderDetailMapper.updateStatusByOrderIdAndStatus(orderInfo.getId(), "closed"); - //修改主单状态 orderInfo.setStatus("closed"); orderInfo.setPayType("wx_lite"); orderInfo.setPayOrderNo(payOrderNO); orderInfo.setPayAmount(orderInfo.getOrderAmount()); + orderInfo.setPaidTime(System.currentTimeMillis()); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); @@ -885,10 +1170,26 @@ public class PayService { producer.putOrderCollect(jsonObject.toJSONString()); log.info("发送打印数据"); - producer.printMechine(orderInfo.getId() + ""); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId()); + List detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper() + .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())); + // 为代客下单清除当前台桌最新订单 + String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(), orderInfo.getShopId()); + String currentOrderId = stringRedisTemplate.opsForValue().get(currentOrderKey); + if (currentOrderId != null && currentOrderId.equals(orderInfo.getId().toString())) { + stringRedisTemplate.delete(currentOrderKey); + } + // 发送mq消息并保存库存记录 JSONObject data = new JSONObject(); data.put("orderId", orderInfo.getId()); @@ -901,50 +1202,96 @@ public class PayService { } + /** + * 订单支付成功修改订单和子单状态 + * @param orderInfo 订单信息 + * @param payType 支付平台 + * @param payOrderNO 三方支付订单号 + */ + private void orderSuccessPay(TbOrderInfo orderInfo, String payType, String payOrderNO) { + int cartCount = mpCashierCartMapper.update(null, new LambdaUpdateWrapper() + .eq(TbCashierCart::getOrderId, orderInfo.getId()) + .eq(TbCashierCart::getUseType, orderInfo.getUseType()) + .in(TbCashierCart::getStatus, "create", "closed") + .set(TbCashierCart::getStatus, "final")); + log.info("更新购物车:{}", cartCount); + + //更新子单状态 + mpOrderDetailMapper.update(null, new LambdaUpdateWrapper().eq(TbOrderDetail::getOrderId, orderInfo.getId()) + .eq(TbOrderDetail::getUseType, orderInfo.getUseType()) + .in(TbOrderDetail::getStatus, "unpaid") + .set(TbOrderDetail::getStatus, "closed")); + + //修改主单状态 + orderInfo.setStatus("closed"); + 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); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("token", 0); + jsonObject.put("type", "wxcreate"); + jsonObject.put("orderId", orderInfo.getId().toString()); + producer.putOrderCollect(jsonObject.toJSONString()); + + log.info("发送订单打印数据"); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getTableId(), orderInfo.getShopId()); + List detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper() + .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()); + producer.printCoupons(coupons.toJSONString()); + sendOrderToClient(orderInfo); + redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString())); + + // 为代客下单清楚当前台桌最新订单 + String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(), orderInfo.getShopId()); + String currentOrderId = stringRedisTemplate.opsForValue().get(currentOrderKey); + if (currentOrderId != null && currentOrderId.equals(orderInfo.getId().toString())) { + stringRedisTemplate.delete(currentOrderKey); + } + + // 发送mq消息并保存库存记录 + JSONObject data = new JSONObject(); + data.put("orderId", orderInfo.getId()); + data.put("plat", "miniApp"); + mQUtils.sendStockSaleMsg(data); + + // 重置台桌状态 + if (StrUtil.isNotBlank(orderInfo.getTableId())) { + TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId()); + if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) { + mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE); + }else { + mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING); + } + } + } + @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"); + orderSuccessPay(orderInfo, payType, payOrderNO); - log.info("更新购物车:{}", cartCount); - - //更新子单状态 - tbOrderDetailMapper.updateStatusByOrderIdAndStatus(orderInfo.getId(), "closed"); - - //修改主单状态 - orderInfo.setStatus("closed"); - orderInfo.setPayType("wx_lite"); - orderInfo.setPayOrderNo(payOrderNO); - orderInfo.setPayAmount(orderInfo.getOrderAmount()); - tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); - - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("token", 0); - jsonObject.put("type", "wxcreate"); - jsonObject.put("orderId", orderInfo.getId().toString()); - - producer.putOrderCollect(jsonObject.toJSONString()); - - log.info("发送打印数据"); - producer.printMechine(orderInfo.getId() + ""); - JSONObject coupons = new JSONObject(); - coupons.put("type", "buy"); - coupons.put("orderId", orderInfo.getId().toString()); - producer.printCoupons(coupons.toJSONString()); - sendOrderToClient(orderInfo); - redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString())); - - // 发送mq消息并保存库存记录 - JSONObject data = new JSONObject(); - data.put("orderId", orderInfo.getId()); - data.put("plat", "miniApp"); - mQUtils.sendStockSaleMsg(data); return "SUCCESS"; } @@ -982,7 +1329,22 @@ public class PayService { public Result getActivate(String shopId, int page, int pageSize) { PageHelper.startPage(page, pageSize); - List list = tbActivateMapper.selectByShpopId(shopId); + List list = tbActivateMapper.selectByShopId(shopId); + for (TbActivate tbActivate : list) { + if (tbActivate.getIsUseCoupon() == 1) { + TbShopCoupon coupon = couponMapper.queryById(tbActivate.getCouponId()); + if(coupon!=null){ + if(coupon.getType()==1){ + //满减 + tbActivate.setCouponDesc("满"+coupon.getFullAmount() + "减" + coupon.getDiscountAmount()+" * "+tbActivate.getNum()+"张"); + } else if (coupon.getType() == 2) { + //商品 + tbActivate.setCouponDesc("商品券"); + tbActivate.setGives(couProductMapper.queryProsByActivateId(coupon.getId(),tbActivate.getNum())); + } + } + } + } PageInfo pageInfo = new PageInfo(list); return Result.success(CodeEnum.SUCCESS, pageInfo); } @@ -1062,6 +1424,7 @@ public class PayService { if (!"1".equals(tbShopUser.getIsVip().toString())) { tbShopUser.setIsVip(Byte.parseByte("1")); + tbShopUser.setJoinTime(new Timestamp(System.currentTimeMillis())); } //修改客户资金 @@ -1078,47 +1441,153 @@ public class PayService { flow.setAmount(memberIn.getAmount()); flow.setBalance(tbShopUser.getAmount()); flow.setCreateTime(new Date()); + flow.setIsReturn("0"); tbShopUserFlowMapper.insert(flow); - TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memberIn.getAmount()); + //会员活动 + giveActivate(tbShopUser, memberIn.getAmount(), flow.getId()); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("shopId", memberIn.getShopId()); + jsonObject.put("type", "wxMemberIn"); + jsonObject.put("amount", memberIn.getAmount()); + producer.putOrderCollect(jsonObject.toJSONString()); + return "success"; + } + + public BigDecimal giveActivate(TbShopUser tbShopUser, BigDecimal memAmount, Integer flowId) { + TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memAmount); if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) { - BigDecimal amount = BigDecimal.ZERO; - switch (activate.getHandselType()) { - case "GD": - amount = activate.getHandselNum(); - break; - case "RATIO": - amount = memberIn.getAmount().multiply(activate.getHandselNum()); - break; + if (activate.getIsUseCoupon() == 1) { + TbShopCoupon tbShopCoupon = couponMapper.queryById(activate.getCouponId()); + Date start = new Date(); + Date end = new Date(); + if ("fixed".equals(tbShopCoupon.getValidityType())) { + //固定时间 + end = DateUtil.offsetDay(new Date(),tbShopCoupon.getValidDays()); + } else if ("custom".equals(tbShopCoupon.getValidityType())) { + //自定义时间 + start = tbShopCoupon.getValidStartTime(); + end = tbShopCoupon.getValidEndTime(); + } + if (tbShopCoupon != null) { + List actGiveRecords = new ArrayList<>(); + if(tbShopCoupon.getType() == 1) { + //满减 + TbActivateInRecord record = new TbActivateInRecord(); + record.setVipUserId(Integer.valueOf(tbShopUser.getId())); + record.setCouponId(tbShopCoupon.getId()); + record.setName("满" + tbShopCoupon.getFullAmount() + "减" + tbShopCoupon.getDiscountAmount()); + record.setFullAmount(tbShopCoupon.getFullAmount()); + record.setDiscountAmount(tbShopCoupon.getDiscountAmount()); + record.setType(1); + record.setNum(activate.getNum()); + record.setOverNum(activate.getNum()); + record.setShopId(Integer.valueOf(tbShopUser.getShopId())); + record.setSourceActId(activate.getId()); + record.setSourceFlowId(flowId); + record.setUseStartTime(start); + record.setUseEndTime(end); + record.setCouponJson(activateInRecordService.getCouponJson(activate,tbShopCoupon,null)); + actGiveRecords.add(record); + } else if (tbShopCoupon.getType() == 2) { + //商品卷 + List tbCouponProducts = couProductMapper.queryAllByCouponId(tbShopCoupon.getId()); + for (TbCouponProduct actPro : tbCouponProducts) { + TbActivateInRecord record = new TbActivateInRecord(); + record.setVipUserId(Integer.valueOf(tbShopUser.getId())); + record.setCouponId(tbShopCoupon.getId()); + record.setName("商品卷"); + record.setType(2); + record.setProId(actPro.getProductId()); + record.setNum(actPro.getNum()*tbShopCoupon.getNumber()); + record.setOverNum(actPro.getNum()*tbShopCoupon.getNumber()); + record.setShopId(Integer.valueOf(tbShopUser.getShopId())); + record.setSourceActId(activate.getId()); + record.setSourceFlowId(flowId); + record.setUseStartTime(start); + record.setUseEndTime(end); + record.setCouponJson(activateInRecordService.getCouponJson(activate,tbShopCoupon,actPro)); + actGiveRecords.add(record); + } + } + activateInRecordMapper.insertBatch(actGiveRecords); + tbShopCoupon.setLeftNumber(tbShopCoupon.getLeftNumber()-activate.getNum()); + couponMapper.update(tbShopCoupon); + } } + BigDecimal amount = activate.getGiftAmount() == null ? + BigDecimal.ZERO : new BigDecimal(activate.getGiftAmount()); tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); tbShopUser.setUpdatedAt(System.currentTimeMillis()); tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser); - flow = new TbShopUserFlow(); + TbShopUserFlow flow = new TbShopUserFlow(); flow.setShopUserId(Integer.valueOf(tbShopUser.getId())); flow.setBizCode("scanMemberAwardIn"); - flow.setBizName("会员充值奖励"); + flow.setBizName("充值活动奖励"); flow.setType("+"); flow.setAmount(amount); flow.setBalance(tbShopUser.getAmount()); flow.setCreateTime(new Date()); + flow.setIsReturn("0"); tbShopUserFlowMapper.insert(flow); - - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("shopId", memberIn.getShopId()); - jsonObject.put("type", "wxMemberIn"); - jsonObject.put("amount", memberIn.getAmount()); - producer.putOrderCollect(jsonObject.toJSONString()); - + return amount; } - return "success"; + + return null; } - public String fstMemberInSuccess(String payOrderNO, String tradeNo) { + /** + * 检查充值回调是否是霸王餐活动 + * @param memberIn 充值记录 + * @param payType 支付平台 + * @param payOrderNo 三方交易订单号 + */ + private void checkFreeDineForMemberInCallBack(TbMemberIn memberIn, String payType, String payOrderNo) { + // 判断是否是霸王餐充值活动 + if (memberIn.getOrderId() != null) { + TbOrderInfo orderInfo = mpOrderInfoMapper.selectById(memberIn.getOrderId()); + if (orderInfo == null) { + log.error("订单信息不存在: orderId: {}", memberIn.getOrderId()); + return; + } + if (TableConstant.OrderInfo.Status.CLOSED.getValue().equals(orderInfo.getStatus())) { + log.error("订单状态异常: {}", orderInfo); + } + + Integer shopId = Integer.valueOf(orderInfo.getShopId()); + // 销毁使用的优惠券 + if (StrUtil.isNotBlank(orderInfo.getActivateInInfoList())) { + ArrayList activateOutRecords = new ArrayList<>(); + JSONArray activateInfoList = JSONObject.parseArray(orderInfo.getActivateInInfoList()); + activateInfoList.forEach(item -> { + ActivateInInfoVO infoVO = ((JSONObject)item).toJavaObject(ActivateInInfoVO.class); + TbActivateOutRecord tbActivateOutRecord = new TbActivateOutRecord(); + tbActivateOutRecord.setShopId(shopId); + tbActivateOutRecord.setGiveId(infoVO.getId()); + tbActivateOutRecord.setVipUserId(Integer.valueOf(orderInfo.getUserId())); + tbActivateOutRecord.setType(TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.getValue()); + tbActivateOutRecord.setUseNum(infoVO.getNum()); + tbActivateOutRecord.setStatus(TableConstant.ActivateOutRecord.Status.CLOSED.getValue()); + tbActivateOutRecord.setCreateTime(DateUtil.date()); + activateOutRecords.add(tbActivateOutRecord); + }); + shopCouponService.use(shopId, orderInfo.getId(), Integer.valueOf(orderInfo.getUserId()), activateOutRecords); + } + // 更改订单状态 + orderSuccessPay(orderInfo, payType, payOrderNo); + + // 更改霸王餐记录 +// TbFreeDineRecord freeDineRecord = freeDineRecordService.selectByOrderId(orderInfo.getId()); + freeDineRecordService.updateStateByOrderId(TableConstant.FreeDineRecord.State.SUCCESS_PAY, orderInfo.getId()); + } + } + + + public String fstMemberInSuccess(String payOrderNO, String tradeNo, String payType) { TbMemberIn memberIn = tbMemberInMapper.selectByOrderNo(payOrderNO); if (ObjectUtil.isEmpty(memberIn)) { return "充值记录不存在"; @@ -1144,6 +1613,7 @@ public class PayService { tbShopUser.setTelephone(userInfo.getTelephone()); tbShopUser.setCode(RandomUtil.randomNumbers(8)); tbShopUser.setIsVip(Byte.parseByte("1")); + tbShopUser.setJoinTime(new Timestamp(System.currentTimeMillis())); } //修改客户资金 @@ -1160,42 +1630,31 @@ public class PayService { flow.setAmount(memberIn.getAmount()); flow.setBalance(tbShopUser.getAmount()); flow.setCreateTime(new Date()); + flow.setRemark(payOrderNO); + flow.setIsReturn("0"); tbShopUserFlowMapper.insert(flow); - TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memberIn.getAmount()); - if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) { - BigDecimal amount = BigDecimal.ZERO; - switch (activate.getHandselType()) { - case "GD": - amount = activate.getHandselNum(); - break; - case "RATIO": - amount = memberIn.getAmount().multiply(activate.getHandselNum()); - break; - } - - - tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); - tbShopUser.setUpdatedAt(System.currentTimeMillis()); - tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser); - - flow = new TbShopUserFlow(); - flow.setShopUserId(Integer.valueOf(tbShopUser.getId())); - flow.setBizCode("scanMemberAwardIn"); - flow.setType("+"); - flow.setBizName("充值活动奖励"); - flow.setAmount(amount); - flow.setBalance(tbShopUser.getAmount()); - flow.setCreateTime(new Date()); - tbShopUserFlowMapper.insert(flow); - } - + // 校验霸王餐 + checkFreeDineForMemberInCallBack(memberIn, payType, payOrderNO); + //会员活动 + BigDecimal awardAmount = giveActivate(tbShopUser, memberIn.getAmount(), flow.getId()); JSONObject jsonObject = new JSONObject(); jsonObject.put("shopId", memberIn.getShopId()); jsonObject.put("type", "wxMemberIn"); jsonObject.put("amount", memberIn.getAmount()); producer.putOrderCollect(jsonObject.toJSONString()); + + + 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()); + producer.balance(baObj.toString()); + return "SUCCESS"; } @@ -1228,7 +1687,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]参数不能为空"); @@ -1298,6 +1756,26 @@ public class PayService { } + /** + * 重新激活支付中的订单 + * + * @param tradeNo + * @return + */ + public int activateOrder(String tradeNo) { + return mpOrderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getOrderNo, tradeNo) + .eq(TbOrderInfo::getStatus, "paying") + .set(TbOrderInfo::getStatus, "unpaid")); + } + + public int cancelOrder(Integer orderId) { + return mpOrderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getId, orderId) + .eq(TbOrderInfo::getStatus, "paying") + .set(TbOrderInfo::getStatus, "unpaid")); + } + // public Result returnOrder(){ // diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 20ef592..71be3ca 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -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; @@ -75,25 +88,85 @@ public class ProductService { @Autowired private TbUserInfoMapper tbUserInfoMapper; - public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng) { - if (StringUtils.isBlank(code)) return Result.fail("桌码信息为空"); + @Autowired + private TbProskuConMapper tbProskuConMapper; + + @Autowired + private TbConsInfoMapper tbConsInfoMapper; + @Resource + private TbActivateInRecordService activateInRecordService; + + 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 orderInfoList = mpOrderInfoMapper.selectPage(new Page<>(1, 1), new LambdaQueryWrapper() + .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 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)); @@ -114,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()); @@ -136,27 +209,26 @@ public class ProductService { return Result.success(CodeEnum.SUCCESS, concurrentMap); } - public Result queryProduct(String shopId, String productGroupId) { + public Result queryProduct(String userId,String shopId, String productGroupId) { ConcurrentMap concurrentMap = new ConcurrentHashMap<>(); Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; //招牌菜 List tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); - concurrentMap.put("hots", handleDate(tbProducts,true,1)); + concurrentMap.put("hots", handleDate(tbProducts,true,1,false)); List groupList = tbProductGroupMapper.selectByShopId(shopId, id); if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { //热销 TbProductGroup hot = new TbProductGroup(); hot.setName("热销"); List hots = tbProductMapper.selectHot(shopId); - hot.setProducts(handleDate(hots,true,1)); + hot.setProducts(handleDate(hots,true,1,false)); //商品 groupList.parallelStream().forEach(g -> { if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime())); String in = g.getProductIds().substring(1, g.getProductIds().length() - 1); if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { -// List products = tbProductMapper.selectByIdIn(in); List products = tbProductMapper.selectByIdInAndCheck(in); - g.setProducts(handleDate(products,false,g.getIsSale())); + g.setProducts(handleDate(products,false,g.getIsSale(),false)); } else { g.setProducts(new ArrayList<>()); } @@ -216,7 +288,8 @@ public class ProductService { // 重组有效规格数据 String tagSnap = skuResult != null ? skuResult.getTagSnap() : null; - List tbProductSkus = tbProductSkuMapper.selectGroundingByProId(querySpecDTO.getProductId()); +// List tbProductSkus = tbProductSkuMapper.selectGroundingByProId(querySpecDTO.getProductId()); + List tbProductSkus = tbProductSkuMapper.selectSku(String.valueOf(querySpecDTO.getProductId())); JSONArray finalSnap = new JSONArray(); // if (tagSnap != null) { @@ -298,11 +371,17 @@ public class ProductService { } ArrayList> specList = new ArrayList<>(); + HashMap unGroundingMap = new HashMap<>(); tbProductSkus.forEach(item -> { - HashMap itemMap = new HashMap<>(); - itemMap.put("specSnap", item.getSpecSnap()); - itemMap.put("skuId", item.getId()); - specList.add(itemMap); + if (item.getIsGrounding() == 1) { + HashMap itemMap = new HashMap<>(); + itemMap.put("specSnap", item.getSpecSnap()); + itemMap.put("skuId", item.getId()); + itemMap.put("info", item); + specList.add(itemMap); + }else { + unGroundingMap.put(item.getSpecSnap(), item); + } }); @@ -312,6 +391,14 @@ public class ProductService { for (HashMap spec : specList) { if (res.equals(spec.get("specSnap").toString())) { spec.put("isGrounding", true); + TbProductSku sku = (TbProductSku) spec.get("info"); + if (sku != null) { + tbProduct.setIsPauseSale(sku.getIsPauseSale().byteValue()); + checkPauseSale(tbProduct, new ArrayList<>(Collections.singletonList(sku)), true); + spec.put("isPauseSale", tbProduct.getIsPauseSale()); + }else { + spec.put("isPauseSale", 1); + } found = true; break; } @@ -321,6 +408,14 @@ public class ProductService { itemMap.put("specSnap", res); itemMap.put("skuId", null); itemMap.put("isGrounding", false); + TbProductSku sku = unGroundingMap.get("specSnap"); + if (sku != null) { + tbProduct.setIsPauseSale(sku.getIsPauseSale().byteValue()); + checkPauseSale(tbProduct, Collections.singletonList(sku), true); + itemMap.put("isPauseSale", tbProduct.getIsPauseSale()); + }else { + itemMap.put("isPauseSale", 1); + } otherVal.add(itemMap); } } @@ -347,9 +442,11 @@ public class ProductService { * @param check 是否校验可售 * @return */ - public List handleDate(List products,boolean check,Integer isSale){ + public List handleDate(List 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 tbProductGroups = tbProductGroupMapper.selectByProductId(it.getShopId(), it.getId().toString()); for (TbProductGroup g : tbProductGroups) { @@ -363,15 +460,14 @@ 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 tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId()); TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId()); - // 上下架对应的sku -// HashSet specSet = new HashSet<>(); + //判断库存及耗材 + checkPauseSale(it,tbProductSkus, false); + AtomicDouble sum = new AtomicDouble(0.0); BigDecimal lowerPrice = null; BigDecimal lowMemberPrice = null; @@ -401,6 +497,10 @@ public class ProductService { } it.setLowMemberPrice(lowMemberPrice); it.setProductSkuResult(skuResult); + if (isVip) { + it.setLowPrice(BigDecimal.ZERO); + it.setIsVip(Byte.parseByte("1")); + } }); return products; }else { @@ -408,9 +508,43 @@ public class ProductService { } } + public void checkPauseSale(TbProduct tbProduct, List skus, boolean isSingle) { + if (tbProduct.getIsStock() == 1) {//库存开关 1开启 + if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) { + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + return; + } - public Result queryProductSku(String code, String shopId, String productId, String spec_tag) { - if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId)) { + if (isSingle && tbProduct.getIsPauseSale() == 1) { + return; + } + Iterator iterator = skus.iterator(); + while (iterator.hasNext()) { + TbProductSku tbProductSku = iterator.next(); + List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(tbProductSku.getId()), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId())); + if (Objects.nonNull(proskuConList) && proskuConList.size() > 0) { + for (TbProskuCon proskuCon : proskuConList) { + if ("1".equals(proskuCon.getStatus())) { + TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); + if ("1".equals(consInfo.getIsCheck())) { + if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) { + iterator.remove(); + break; + } + } + } + } + } + } + if (CollectionUtils.isEmpty(skus)) { + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + } + } + } + + + public Result queryProductSku(String code, String shopId, String productId, String spec_tag,String isVip) { + if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId) || StringUtils.isEmpty(isVip)|| isVip.equals("undefined") ) { return Result.fail("参数错误"); } TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByShopIdAndProductIdAndSpec(shopId, productId, spec_tag); @@ -423,7 +557,7 @@ public class ProductService { tbProductSkuWithBLOBs.setId(null); }else { if (StringUtils.isNotBlank(code)) { - Integer sum = tbProductMapper.selectByCodeAndSkuId(code, tbProductSkuWithBLOBs.getId(), shopId); + Integer sum = tbProductMapper.selectByCodeAndSkuId(code, tbProductSkuWithBLOBs.getId(), shopId,isVip); tbProductSkuWithBLOBs.setNumber(sum); } } @@ -703,39 +837,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() + .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 query = new LambdaQueryWrapper() + .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 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() + .notIn(TbShopTable::getStatus, "closed", "cleaning") + .eq(TbShopTable::getQrcode, choseTableDTO.getTableId())); + + if (shopTable == null) { + throw new MsgException("台桌未开台或不存在"); + } + } + + return mpCashierCartMapper.update(null, new LambdaUpdateWrapper() + .eq(TbCashierCart::getShopId, choseTableDTO.getShopId()) + .isNull(TbCashierCart::getUseType) + .eq(TbCashierCart::getStatus, "create") + .set(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())) ; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateInRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateInRecordService.java new file mode 100644 index 0000000..fb12c4a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateInRecordService.java @@ -0,0 +1,25 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.system.cashierservice.entity.TbActivate; +import com.chaozhanggui.system.cashierservice.entity.TbCouponProduct; +import com.chaozhanggui.system.cashierservice.entity.TbShopCoupon; +import org.springframework.stereotype.Service; + +/** + * 活动商品赠送表(TbActivateInRecord)表服务接口 + * + * @author ww + * @since 2024-08-22 11:13:40 + */ +@Service +public class TbActivateInRecordService { + + public String getCouponJson(TbActivate activate, TbShopCoupon tbShopCoupon, TbCouponProduct couProduct){ + JSONObject result = new JSONObject(); + result.put("activate",JSONObject.toJSON(activate)); + result.put("coupon",JSONObject.toJSON(tbShopCoupon)); + result.put("couProduct",JSONObject.toJSON(couProduct)); + return result.toJSONString(); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallQueueService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallQueueService.java new file mode 100644 index 0000000..f124508 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallQueueService.java @@ -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 { + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallService.java new file mode 100644 index 0000000..6fc2e2a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallService.java @@ -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); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallTableService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallTableService.java new file mode 100644 index 0000000..ba6dac5 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbCallTableService.java @@ -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 { + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbFreeDineConfigService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbFreeDineConfigService.java new file mode 100644 index 0000000..a56498e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbFreeDineConfigService.java @@ -0,0 +1,21 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineConfig; +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineRecord; + +/** +* @author Administrator +* @description 针对表【tb_free_dine_config(霸王餐配置信息表)】的数据库操作Service +* @createDate 2024-10-25 14:22:41 +*/ +public interface TbFreeDineConfigService extends IService { + + /** + * 根据店铺id查询 + * @param shopId 店铺id + * @return 霸王餐配置 + */ + TbFreeDineConfig getByShopId(String shopId); + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbFreeDineRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbFreeDineRecordService.java new file mode 100644 index 0000000..551ff41 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbFreeDineRecordService.java @@ -0,0 +1,27 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.constant.TableConstant; +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author Administrator +* @description 针对表【tb_free_dine_record(霸王餐充值记录)】的数据库操作Service +* @createDate 2024-10-30 09:48:31 +*/ +public interface TbFreeDineRecordService extends IService { + + + /** + * 根据订单id获取霸王餐记录 + * @param orderId 订单id + */ + TbFreeDineRecord selectByOrderId(Integer orderId); + + /** + * 根据订单id修改霸王餐记录 + * @param state 状态 + * @param orderId 订单id + */ + boolean updateStateByOrderId(TableConstant.FreeDineRecord.State state, Integer orderId); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsLogService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsLogService.java new file mode 100644 index 0000000..a8b5046 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsLogService.java @@ -0,0 +1,19 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPointsLog; +import com.github.pagehelper.PageInfo; + +import java.util.Map; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbMemberPointsLogService extends IService { + + PageInfo page(Map params); + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java new file mode 100644 index 0000000..cac766d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java @@ -0,0 +1,100 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPoints; +import com.chaozhanggui.system.cashierservice.entity.dto.OrderDeductionPointsDTO; +import com.github.pagehelper.PageInfo; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbMemberPointsService extends IService { + + /** + * 会员积分分页 + * + * @param params + * @return + */ + PageInfo page(Map params); + + /** + * 获取会员积分等信息 + * + * @param memberId 会员id + * @return + */ + TbMemberPoints getMemberPoints(Long memberId); + + /** + * 初始化会员积分 + * + * @param memberId 会员id + * @return + */ + TbMemberPoints initMemberPoints(Long memberId); + + /** + * 根据会员id及订单金额计算可抵扣积分及可抵扣金额 + * + * @param memberId 会员id + * @param orderAmount 订单金额 + * @return + */ + OrderDeductionPointsDTO getMemberUsablePoints(Long memberId, BigDecimal orderAmount); + + /** + * 根据抵扣金额计算抵扣积分 + * + * @param memberId 会员id + * @param orderAmount 订单金额 + * @param deductionAmount 抵扣金额 + */ + int calcUsedPoints(Long memberId, BigDecimal orderAmount, BigDecimal deductionAmount); + + /** + * 根据抵扣积分计算抵扣金额 + * + * @param memberId 会员id + * @param orderAmount 订单金额 + * @param points 抵扣积分 + */ + BigDecimal calcDeductionAmount(Long memberId, BigDecimal orderAmount, int points); + + /** + * 扣除积分 + * + * @param memberId 会员id + * @param points 积分 + * @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分) + * @param orderId 订单id,可以为空 + * @throws Exception + */ + boolean deductPoints(Long memberId, int points, String content, Long orderId); + + /** + * 追加积分 + * + * @param memberId 会员id + * @param points 积分 + * @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分) + * @param orderId 订单id,可以为空 + * @throws Exception + */ + boolean addPoints(Long memberId, int points, String content, Long orderId); + + /** + * 消费赠送积分 + * + * @param memberId 会员id + * @param orderId 订单id + * @throws Exception + */ + void consumeAwardPoints(Long memberId, Long orderId); +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsBasicSettingService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsBasicSettingService.java new file mode 100644 index 0000000..9bd2799 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsBasicSettingService.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbPointsBasicSetting; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbPointsBasicSettingService extends IService { + boolean save(TbPointsBasicSetting entity); + + TbPointsBasicSetting getByShopId(Long shopId); +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsExchangeRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsExchangeRecordService.java new file mode 100644 index 0000000..f15a22a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsExchangeRecordService.java @@ -0,0 +1,26 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbPointsExchangeRecord; +import com.github.pagehelper.PageInfo; + +import java.util.Map; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbPointsExchangeRecordService extends IService { + + PageInfo page(Map params); + + TbPointsExchangeRecord get(Long id); + + void checkout(String couponCode); + + TbPointsExchangeRecord exchange(TbPointsExchangeRecord record); + + Map total(Map params); +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsGoodsSettingService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsGoodsSettingService.java new file mode 100644 index 0000000..4e2753e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPointsGoodsSettingService.java @@ -0,0 +1,25 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbPointsGoodsSetting; +import com.github.pagehelper.PageInfo; + +import java.util.Map; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbPointsGoodsSettingService extends IService { + + PageInfo page(Map params); + + boolean save(TbPointsGoodsSetting entity); + + boolean update(TbPointsGoodsSetting dto); + + void delete(Long id); + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopCouponService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopCouponService.java new file mode 100644 index 0000000..51956b0 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopCouponService.java @@ -0,0 +1,32 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord; +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; +import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto; +import com.chaozhanggui.system.cashierservice.entity.dto.CouponUseDto; +import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.context.annotation.Primary; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 优惠券(TbShopCoupon)表服务接口 + * + * @author ww + * @since 2024-10-23 15:37:37 + */ +public interface TbShopCouponService { + /** + * 根据金额获取可用优惠券 + * @param amount 订单金额 + */ + List getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount); + + Result find(CouponDto param); + + boolean use(Integer shopId,Integer orderId,Integer vipUserId,List param); + + boolean refund(List param); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 6c93e90..0240ce0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -1,26 +1,23 @@ package com.chaozhanggui.system.cashierservice.service; +import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; -import com.alibaba.fastjson.JSONObject; -import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow; +import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper; +import com.chaozhanggui.system.cashierservice.dao.TbUserInfoMapper; import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; import com.chaozhanggui.system.cashierservice.entity.TbShopUser; import com.chaozhanggui.system.cashierservice.entity.TbUserInfo; -import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo; -import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo; import com.chaozhanggui.system.cashierservice.entity.vo.OpenMemberVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; -import com.chaozhanggui.system.cashierservice.redis.RedisCst; 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.RedisUtils; import com.chaozhanggui.system.cashierservice.wxUtil.WxAccountUtil; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.core.io.Resource; @@ -32,8 +29,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.math.BigDecimal; -import java.util.*; -import java.util.concurrent.TimeUnit; +import java.sql.Timestamp; @Service public class UserService { @@ -42,14 +38,8 @@ public class UserService { @Autowired private TbShopUserMapper shopUserMapper; @Autowired - private TbReleaseFlowMapper releaseFlowMapper; - @Autowired private TbUserInfoMapper userInfoMapper; @Autowired - private TbUserCouponsMapper userCouponsMapper; - @Autowired - private TbSystemCouponsMapper systemCouponsMapper; - @Autowired RedisUtils redisUtils; @Qualifier("tbShopInfoMapper") @Autowired @@ -66,192 +56,8 @@ public class UserService { this.resourceLoader = resourceLoader; } - public JSONObject modityIntegral(IntegralVo integralVo, String userSign) { - JSONObject object = (JSONObject) JSONObject.toJSON(integralVo); - if (N.gt(BigDecimal.ZERO, integralVo.getNum())) { - JSONObject result = new JSONObject(); - result.put("status", "fail"); - result.put("msg", "积分数量不允许小于0"); - result.put("data", ""); - return result; - } - object.put("userSign", userSign); - JSONObject jsonObject = JSONUtil.sortJSONObject(object, CacheMap.map); - System.out.println(jsonObject.toJSONString()); - String sign = MD5Util.encrypt(jsonObject.toJSONString()); - if (!sign.equals(integralVo.getSign())) { - JSONObject result = new JSONObject(); - result.put("status", "fail"); - result.put("msg", "签名验证失败"); - result.put("data", ""); - return result; - } - TbShopUser shopUser = shopUserMapper.selectByOpenId(integralVo.getOpenId()); - if (Objects.isNull(shopUser)) { - JSONObject result = new JSONObject(); - result.put("status", "fail"); - result.put("msg", "用户不存在"); - result.put("data", ""); - return result; - } - boolean falg = updateIntegral(shopUser.getUserId(), integralVo.getNum(), integralVo.getType()); - if (!falg) { - JSONObject result = new JSONObject(); - result.put("status", "fail"); - result.put("msg", "余额不足"); - result.put("data", ""); - return result; - } - JSONObject result = new JSONObject(); - result.put("status", "success"); - result.put("msg", "操作成功"); - return result; - } - public static void main(String[] args) { - IntegralVo integralVo = new IntegralVo(); - integralVo.setNum(new BigDecimal("5254")); - integralVo.setOpenId("or1l864NBOoJZhC5x_yeziZ26j6c"); - integralVo.setType("sub"); - JSONObject object = (JSONObject) JSONObject.toJSON(integralVo); - object.put("userSign", "02c03d79c36b4c01b217ffb1baef9009"); - JSONObject jsonObject = JSONUtil.sortJSONObject(object, CacheMap.map); - System.out.println("加密前字符串:" + jsonObject.toJSONString()); - String sign = MD5Util.encrypt(jsonObject.toJSONString()); - System.out.println("加密后签名:" + sign); - } - - private Boolean updateIntegral(String userId, BigDecimal num, String type) { - - boolean lock_coin = redisUtils.lock(RedisCst.INTEGRAL_COIN_KEY + userId, 5000, TimeUnit.MILLISECONDS); - if (lock_coin) { - TbUserInfo tbShopUser = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); - boolean flag = true; - if (type.equals("sub")) { - if (num.intValue() < tbShopUser.getTotalScore()) { - flag = false; - } else { - tbShopUser.setTotalScore(tbShopUser.getTotalScore() - num.intValue()); - } - } else if (type.equals("add")) { - tbShopUser.setTotalScore(tbShopUser.getTotalScore() + num.intValue()); - } - if (flag) { - TbReleaseFlow releaseFlow = new TbReleaseFlow(); - releaseFlow.setNum(num); - releaseFlow.setCreateTime(new Date()); - releaseFlow.setFromSource("OWER"); - releaseFlow.setUserId(userId); - if (type.equals("sub")) { - releaseFlow.setType("BUYSUB"); - releaseFlow.setOperationType("SUB"); - releaseFlow.setRemark("购买商品扣除"); - } else if (type.equals("sub")) { - releaseFlow.setType("THREEADD"); - releaseFlow.setOperationType("ADD"); - releaseFlow.setRemark("退货增加"); - } - releaseFlowMapper.insert(releaseFlow); - userInfoMapper.updateByPrimaryKeySelective(tbShopUser); - } - redisUtils.releaseLock(RedisCst.INTEGRAL_COIN_KEY + userId); - return flag; - } else { - return updateIntegral(userId, num, type); - } - } - - public JSONObject userIntegral(IntegralFlowVo integralFlowVo, String userSign) { - JSONObject object = (JSONObject) JSONObject.toJSON(integralFlowVo); - object.put("userSign", userSign); - JSONObject jsonObject = JSONUtil.sortJSONObject(object, CacheMap.map); - System.out.println(jsonObject.toJSONString()); - String sign = MD5Util.encrypt(jsonObject.toJSONString()); - if (!sign.equals(integralFlowVo.getSign())) { - JSONObject result = new JSONObject(); - result.put("status", "fail"); - result.put("msg", "签名验证失败"); - result.put("data", ""); - return result; - } - TbUserInfo shopUser = userInfoMapper.selectByOpenId(integralFlowVo.getOpenId()); - if (Objects.isNull(shopUser)) { - JSONObject result = new JSONObject(); - result.put("status", "fail"); - result.put("msg", "用户不存在"); - result.put("data", ""); - return result; - } - PageHelper.startPage(integralFlowVo.getPage(), integralFlowVo.getPageSize()); - PageHelper.orderBy("id DESC"); - List list = releaseFlowMapper.selectByUserId(shopUser.getId().toString()); - for (TbReleaseFlow tbReleaseFlow:list){ - tbReleaseFlow.setCreateTr(DateUtils.getStrTime(tbReleaseFlow.getCreateTime())); - } - JSONObject result = new JSONObject(); - result.put("status", "success"); - result.put("msg", "成功"); - result.put("data", list); - return result; - } - - public JSONObject userAllIntegral(IntegralFlowVo integralFlowVo, String userSign) { -// JSONObject object = (JSONObject) JSONObject.toJSON(integralFlowVo); -// object.put("userSign", userSign); -// JSONObject jsonObject = JSONUtil.sortJSONObject(object, CacheMap.notOpenMap); -// System.out.println(jsonObject.toJSONString()); -// String sign = MD5Util.encrypt(jsonObject.toJSONString()); -// if (!sign.equals(integralFlowVo.getSign())) { -// JSONObject result = new JSONObject(); -// result.put("status", "fail"); -// result.put("msg", "签名验证失败"); -// result.put("data", ""); -// return result; -// } - PageHelper.startPage(integralFlowVo.getPage(), integralFlowVo.getPageSize()); - PageHelper.orderBy("id DESC"); - List list = releaseFlowMapper.selectAll(); - for (TbReleaseFlow tbReleaseFlow:list){ - tbReleaseFlow.setCreateTr(DateUtils.getStrTime(tbReleaseFlow.getCreateTime())); - } - PageInfo pageInfo = new PageInfo(list); - JSONObject result = new JSONObject(); - result.put("status", "success"); - result.put("msg", "成功"); - result.put("data", pageInfo); - return result; - } - - public JSONObject userAll(IntegralFlowVo integralFlowVo, String userSign) { -// JSONObject object = (JSONObject) JSONObject.toJSON(integralFlowVo); -// object.put("userSign", userSign); -// JSONObject jsonObject = JSONUtil.sortJSONObject(object, CacheMap.notOpenMap); -// System.out.println(jsonObject.toJSONString()); -// String sign = MD5Util.encrypt(jsonObject.toJSONString()); -// if (!sign.equals(integralFlowVo.getSign())) { -// JSONObject result = new JSONObject(); -// result.put("status", "fail"); -// result.put("msg", "签名验证失败"); -// result.put("data", ""); -// return result; -// } - PageHelper.startPage(integralFlowVo.getPage(), integralFlowVo.getPageSize()); - PageHelper.orderBy("id DESC"); - List list = userInfoMapper.selectAll(); - PageInfo pageInfo = new PageInfo(list); - JSONObject result = new JSONObject(); - result.put("status", "success"); - result.put("msg", "成功"); - result.put("data", pageInfo); - return result; - } - - public int userCoupon(String userId, BigDecimal orderNum) { - int userNum = userCouponsMapper.selectByUserIdAndAmount(userId,orderNum); - int sysNum = systemCouponsMapper.selectByAmount(orderNum); - return userNum+sysNum; - } public String getSubQrCode(String shopId) throws Exception { TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId)); @@ -271,25 +77,59 @@ public class UserService { } public Result openMember(OpenMemberVo memberVo) { - TbUserInfo userInfo = new TbUserInfo(); - userInfo.setId(memberVo.getId()); - userInfo.setHeadImg(memberVo.getHeadImg()); - userInfo.setNickName(memberVo.getNickName()); - userInfo.setTelephone(memberVo.getTelephone()); - userInfo.setBirthDay(memberVo.getBirthDay()); - userInfoMapper.updateByPrimaryKeySelective(userInfo); - List tbShopUsers = shopUserMapper.selectAllByUserId(memberVo.getId().toString()); - for (TbShopUser tbShopUser : tbShopUsers) { - tbShopUser.setTelephone(memberVo.getTelephone()); - shopUserMapper.updateByPrimaryKey(tbShopUser); - } TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(memberVo.getId().toString(), memberVo.getShopId().toString()); - tbShopUser.setName(memberVo.getNickName()); - tbShopUser.setHeadImg(memberVo.getHeadImg()); - tbShopUser.setTelephone(memberVo.getTelephone()); - tbShopUser.setBirthDay(memberVo.getBirthDay()); - tbShopUser.setIsVip(Byte.parseByte("1")); - shopUserMapper.updateByPrimaryKey(tbShopUser); + if (tbShopUser != null) { + tbShopUser.setName(StringUtils.isNotBlank(memberVo.getNickName()) ? memberVo.getNickName() : null); + tbShopUser.setHeadImg(StringUtils.isNotBlank(memberVo.getHeadImg()) ? memberVo.getHeadImg() : null); + 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()); + tbShopUser = shopUserMapper.selectPCByPhoneAndShopId(memberVo.getTelephone(), memberVo.getShopId().toString()); + if (tbShopUser != null) { + tbShopUser.setName(StringUtils.isNotBlank(memberVo.getNickName()) ? memberVo.getNickName() : null); + tbShopUser.setHeadImg(StringUtils.isNotBlank(memberVo.getHeadImg()) ? memberVo.getHeadImg() : null); + tbShopUser.setTelephone(memberVo.getTelephone()); + tbShopUser.setBirthDay(StringUtils.isNotBlank(memberVo.getBirthDay()) ? memberVo.getBirthDay() : null); + tbShopUser.setUserId(tbUserInfo.getId().toString()); + tbShopUser.setMiniOpenId(tbUserInfo.getMiniAppOpenId()); + shopUserMapper.updateByPrimaryKeySelective(tbShopUser); + return Result.success(CodeEnum.SUCCESS); + } + tbShopUser = new TbShopUser(); + tbShopUser.setName(StringUtils.isNotBlank(memberVo.getNickName()) ? memberVo.getNickName() : null); + tbShopUser.setSex(Byte.parseByte("1")); + tbShopUser.setBirthDay(StringUtils.isNotBlank(memberVo.getBirthDay()) ? memberVo.getBirthDay() : null); + tbShopUser.setLevel(Byte.parseByte("1")); + String dynamicCode = RandomUtil.randomNumbers(8); + tbShopUser.setCode(dynamicCode); + 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); + tbShopUser.setLevelConsume(BigDecimal.ZERO); + tbShopUser.setStatus(Byte.parseByte("1")); + tbShopUser.setShopId(memberVo.getShopId().toString()); + tbShopUser.setUserId(tbUserInfo.getId().toString()); + tbShopUser.setMiniOpenId(tbUserInfo.getMiniAppOpenId()); + tbShopUser.setCreatedAt(System.currentTimeMillis()); + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + shopUserMapper.insertSelective(tbShopUser); + } + return Result.success(CodeEnum.SUCCESS); + } + + public Result upVipPhont(OpenMemberVo memberVo) { + TbShopUser shopUser = new TbShopUser(); + shopUser.setId(memberVo.getId().toString()); + shopUser.setTelephone(memberVo.getTelephone()); + shopUserMapper.updateByPrimaryKeySelective(shopUser); return Result.success(CodeEnum.SUCCESS); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallQueueServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallQueueServiceImpl.java new file mode 100644 index 0000000..1f861de --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallQueueServiceImpl.java @@ -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 + implements TbCallQueueService{ + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallServiceImpl.java new file mode 100644 index 0000000..b1afb2c --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallServiceImpl.java @@ -0,0 +1,212 @@ +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 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> infoList = new ArrayList<>(); + List list = callTableService.lambdaQuery() + .eq(TbCallTable::getShopId, shopId).list(); + list.forEach(item -> { + Map map = BeanUtil.beanToMap(item, false, false); + Integer count = callQueueService.lambdaQuery() + .eq(TbCallQueue::getCallTableId, item.getId()) + .eq(TbCallQueue::getShopId, shopId) + .eq(TbCallQueue::getCreateDay, DateUtil.date().toString("yyyy-MM-dd")) + .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::getCallTime, DateUtil.date()) + .set(TbCallQueue::getState, -1).update(); + } + + + @Override + public Object getState(String openId, Integer shopId, Integer queueId) { + List 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() + .eq(TbCallQueue::getId, callQueueInfoVO.getId()) + .set(TbCallQueue::getOpenId, openId)); + } + TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(shopId); + HashMap 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() + .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); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallTableServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallTableServiceImpl.java new file mode 100644 index 0000000..d702ee2 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbCallTableServiceImpl.java @@ -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 + implements TbCallTableService{ + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbFreeDineConfigServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbFreeDineConfigServiceImpl.java new file mode 100644 index 0000000..cc6840f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbFreeDineConfigServiceImpl.java @@ -0,0 +1,33 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineConfig; +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineRecord; +import com.chaozhanggui.system.cashierservice.service.TbFreeDineConfigService; +import com.chaozhanggui.system.cashierservice.mapper.TbFreeDineConfigMapper; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +/** +* @author Administrator +* @description 针对表【tb_free_dine_config(霸王餐配置信息表)】的数据库操作Service实现 +* @createDate 2024-10-25 14:22:41 +*/ +@Service +@Primary +public class TbFreeDineConfigServiceImpl extends ServiceImpl + implements TbFreeDineConfigService{ + + @Override + public TbFreeDineConfig getByShopId(String shopId) { + return getOne(new LambdaQueryWrapper() + .eq(TbFreeDineConfig::getShopId, shopId)); + } + + +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbFreeDineRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbFreeDineRecordServiceImpl.java new file mode 100644 index 0000000..21bb18c --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbFreeDineRecordServiceImpl.java @@ -0,0 +1,39 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.constant.TableConstant; +import com.chaozhanggui.system.cashierservice.entity.TbFreeDineRecord; +import com.chaozhanggui.system.cashierservice.service.TbFreeDineRecordService; +import com.chaozhanggui.system.cashierservice.mapper.TbFreeDineRecordMapper; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +/** +* @author Administrator +* @description 针对表【tb_free_dine_record(霸王餐充值记录)】的数据库操作Service实现 +* @createDate 2024-10-30 09:48:31 +*/ +@Service +@Primary +public class TbFreeDineRecordServiceImpl extends ServiceImpl + implements TbFreeDineRecordService{ + + @Override + public TbFreeDineRecord selectByOrderId(Integer orderId) { + return getOne(new LambdaQueryWrapper() + .eq(TbFreeDineRecord::getOrderId, orderId)); + } + + @Override + public boolean updateStateByOrderId(TableConstant.FreeDineRecord.State state, Integer orderId) { + return update(new LambdaUpdateWrapper() + .eq(TbFreeDineRecord::getOrderId, orderId) + .set(TbFreeDineRecord::getState, state.getValue())); + } +} + + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsLogServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsLogServiceImpl.java new file mode 100644 index 0000000..31b4d67 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsLogServiceImpl.java @@ -0,0 +1,63 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPointsLog; +import com.chaozhanggui.system.cashierservice.mapper.TbMemberPointsLogMapper; +import com.chaozhanggui.system.cashierservice.service.TbMemberPointsLogService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +@Primary +public class TbMemberPointsLogServiceImpl extends ServiceImpl implements TbMemberPointsLogService { + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String beginDate = mapProxy.getStr("beginDate"); + String endDate = mapProxy.getStr("endDate"); + TbMemberPointsLog param = BeanUtil.toBean(params, TbMemberPointsLog.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbMemberPointsLog::getShopId, param.getShopId()); + wrapper.eq(param.getMemberId() != null, TbMemberPointsLog::getMemberId, param.getMemberId()); + wrapper.like(StrUtil.isNotEmpty(param.getMemberName()), TbMemberPointsLog::getMemberName, param.getMemberName()); + wrapper.like(StrUtil.isNotEmpty(param.getMobile()), TbMemberPointsLog::getMobile, param.getMobile()); + wrapper.like(StrUtil.isNotEmpty(param.getContent()), TbMemberPointsLog::getContent, param.getContent()); + wrapper.eq(StrUtil.isNotEmpty(param.getFloatType()), TbMemberPointsLog::getFloatType, param.getFloatType()); + wrapper.eq(StrUtil.isNotEmpty(param.getOrderNo()), TbMemberPointsLog::getOrderNo, param.getOrderNo()); + if (StrUtil.isNotEmpty(beginDate)) { + wrapper.apply("create_time >= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", beginDate + " 00:00:00"); + } + if (StrUtil.isNotEmpty(endDate)) { + wrapper.apply("create_time <= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", endDate + " 23:59:59"); + } + wrapper.orderByDesc(TbMemberPointsLog::getId); + return wrapper; + } + + @Override + public PageInfo page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + PageInfo page = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(wrapper)); + //Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return page; + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java new file mode 100644 index 0000000..396e787 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java @@ -0,0 +1,290 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPoints; +import com.chaozhanggui.system.cashierservice.entity.TbMemberPointsLog; +import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo; +import com.chaozhanggui.system.cashierservice.entity.TbPointsBasicSetting; +import com.chaozhanggui.system.cashierservice.entity.dto.OrderDeductionPointsDTO; +import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.mapper.TbMemberPointsLogMapper; +import com.chaozhanggui.system.cashierservice.mapper.TbMemberPointsMapper; +import com.chaozhanggui.system.cashierservice.mapper.TbPointsBasicSettingMapper; +import com.chaozhanggui.system.cashierservice.service.TbMemberPointsService; +import com.chaozhanggui.system.cashierservice.service.TbPointsBasicSettingService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; +import java.util.Map; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +@Primary +public class TbMemberPointsServiceImpl extends ServiceImpl implements TbMemberPointsService { + + @Autowired + private TbMemberPointsLogMapper tbMemberPointsLogMapper; + @Autowired + private TbPointsBasicSettingMapper tbPointsBasicSettingMapper; + @Autowired + private TbShopUserMapper tbShopUserMapper; + @Autowired + private TbOrderInfoMapper tbOrderInfoMapper; + @Autowired + private TbPointsBasicSettingService tbPointsBasicSettingService; + + private LambdaQueryWrapper getWrapper(Map params) { + //MapProxy mapProxy = MapProxy.create(params); + TbMemberPoints param = BeanUtil.toBean(params, TbMemberPoints.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbMemberPoints::getShopId, param.getShopId()); + wrapper.like(StrUtil.isNotEmpty(param.getMemberName()), TbMemberPoints::getMemberName, param.getMemberName()); + wrapper.like(StrUtil.isNotEmpty(param.getMobile()), TbMemberPoints::getMobile, param.getMobile()); + + wrapper.orderByDesc(TbMemberPoints::getId); + return wrapper; + } + + @Override + public PageInfo page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + PageInfo page = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(wrapper)); + //Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return page; + } + + @Override + public TbMemberPoints getMemberPoints(Long memberId) { + return initMemberPoints(memberId); + } + + @Override + public TbMemberPoints initMemberPoints(Long memberId) { + TbMemberPoints entity = super.getOne(Wrappers.lambdaQuery().eq(TbMemberPoints::getMemberId, memberId)); + if (entity == null) { + throw new MsgException("会员信息不存在"); + } + if(entity.getAccountPoints() == null){ + entity.setAccountPoints(0); + } + super.updateById(entity); + return entity; + } + + @Override + public OrderDeductionPointsDTO getMemberUsablePoints(Long memberId, BigDecimal orderAmount) { + TbMemberPoints entity = initMemberPoints(memberId); + Long shopId = entity.getShopId(); + Integer accountPoints = entity.getAccountPoints(); + OrderDeductionPointsDTO dto = new OrderDeductionPointsDTO(); + dto.setAccountPoints(accountPoints); + dto.setUsable(false); + dto.setMaxDeductionAmount(BigDecimal.ZERO); + dto.setMinDeductionAmount(BigDecimal.ZERO); + TbPointsBasicSetting basic = tbPointsBasicSettingMapper.selectOne(Wrappers.lambdaQuery().eq(TbPointsBasicSetting::getShopId, shopId)); + if (basic == null) { + dto.setUnusableReason("商家未启用积分抵扣功能"); + return dto; + } + if (basic.getEnableDeduction() == 0) { + dto.setUnusableReason("商家未启用积分抵扣功能"); + return dto; + } + dto.setMinDeductionPoints(basic.getMinDeductionPoint()); + if (accountPoints == 0 || accountPoints < basic.getMinDeductionPoint()) { + dto.setUnusableReason("积分不足或小于最低使用门槛" + basic.getMinDeductionPoint()); + return dto; + } + // 下单抵扣积分比例 1元=?积分 + Integer equivalentPoints = basic.getEquivalentPoints(); + // 计算账户积分=?元 + BigDecimal accountYuan = NumberUtil.div(accountPoints, equivalentPoints); + // 下单最高抵扣比例 + BigDecimal maxDeductionRatio = basic.getMaxDeductionRatio(); + // 计算订单最多可以抵扣多少元 + BigDecimal orderYuan = NumberUtil.mul(orderAmount, NumberUtil.div(maxDeductionRatio, new BigDecimal("100"))); + // 积分余额足够 + if (NumberUtil.isGreaterOrEqual(accountYuan, orderYuan)) { + dto.setMaxDeductionAmount(orderYuan); + } else { + dto.setMaxDeductionAmount(NumberUtil.roundDown(accountYuan, 2)); + } + if (NumberUtil.isLess(dto.getMaxDeductionAmount(), new BigDecimal("0.01"))) { + dto.setUnusableReason("积分不足0.01元,无法进行抵扣"); + return dto; + } + // 计算抵扣门槛=?元 + BigDecimal minYuan = NumberUtil.div(basic.getMinDeductionPoint(), equivalentPoints); + if (NumberUtil.isLess(minYuan, new BigDecimal("0.01"))) { + dto.setMinDeductionAmount(new BigDecimal("0.01")); + } else { + dto.setMinDeductionAmount(NumberUtil.roundDown(minYuan, 2)); + } + dto.setEquivalentPoints(equivalentPoints); + dto.setOrderAmount(orderAmount); + dto.setUsable(true); + // 计算最多可抵扣的积分 + BigDecimal mul = NumberUtil.mul(dto.getMaxDeductionAmount(), equivalentPoints); + BigDecimal round = NumberUtil.round(mul, 0, RoundingMode.CEILING); + dto.setMaxUsablePoints(round.intValue()); + return dto; + } + + @Override + public int calcUsedPoints(Long memberId, BigDecimal orderAmount, BigDecimal deductionAmount) { + OrderDeductionPointsDTO core = getMemberUsablePoints(memberId, orderAmount); + if (!core.getUsable()) { + throw new MsgException(core.getUnusableReason()); + } + if (NumberUtil.isGreater(deductionAmount, core.getMaxDeductionAmount())) { + throw new MsgException(StrUtil.format("抵扣金额不能超过最大抵扣金额{}元", core.getMaxDeductionAmount())); + } + if (NumberUtil.isGreater(deductionAmount, orderAmount)) { + throw new MsgException(StrUtil.format("抵扣金额不能超过订单金额{}元", orderAmount)); + } + // 计算可抵扣的积分 + BigDecimal mul = NumberUtil.mul(deductionAmount, core.getEquivalentPoints()); + BigDecimal round = NumberUtil.round(mul, 0, RoundingMode.CEILING); + return round.intValue(); + } + + @Override + public BigDecimal calcDeductionAmount(Long memberId, BigDecimal orderAmount, int points) { + OrderDeductionPointsDTO core = getMemberUsablePoints(memberId, orderAmount); + if (!core.getUsable()) { + throw new MsgException(core.getUnusableReason()); + } + if (points < core.getMinDeductionPoints()) { + throw new MsgException(StrUtil.format("使用积分不能低于使用门槛(每次最少使用{}积分)", core.getMinDeductionPoints())); + } + if (points > core.getMaxUsablePoints()) { + throw new MsgException(StrUtil.format("使用积分不能超过最大使用限制{}", core.getMaxUsablePoints())); + } + BigDecimal mul = NumberUtil.mul(new BigDecimal("0.01"), core.getEquivalentPoints()); + int minPoints = NumberUtil.round(mul, 0, RoundingMode.CEILING).intValue(); + if (points < minPoints) { + throw new MsgException(StrUtil.format("使用积分不能低于{}(0.01元)", minPoints)); + } + BigDecimal money = NumberUtil.mul(points, NumberUtil.div(BigDecimal.ONE, core.getEquivalentPoints())); + return NumberUtil.roundDown(money, 2); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean deductPoints(Long memberId, int points, String content, Long orderId) { + TbMemberPoints entity = initMemberPoints(memberId); + // 扣除账户积分 + entity.setAccountPoints(entity.getAccountPoints() - points); + entity.setLastPointsChangeTime(new Date()); + entity.setLastFloatPoints(-points); + + // 记录积分变动记录 + TbMemberPointsLog log = new TbMemberPointsLog(); + log.setShopId(entity.getShopId()); + log.setMemberId(entity.getMemberId()); + log.setMemberName(entity.getMemberName()); + log.setAvatarUrl(entity.getAvatarUrl()); + log.setMobile(entity.getMobile()); + log.setContent(content); + log.setFloatType("subtract"); + log.setFloatPoints(-points); + log.setCreateTime(new Date()); + // 有关联订单的需要回置订单表的相关积分使用字段 + if (orderId != null) { + TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Convert.toInt(orderId)); + if (orderInfo != null) { + log.setOrderNo(orderInfo.getOrderNo()); + // TODO 是否需要回执“使用的积分数量(points_num)”和“积分抵扣金额(points_discount_amount)”,目前不清楚是创建订单的时候置入还是支付完成后回调时置入需要商议后决定 + } + } + super.updateById(entity); + tbMemberPointsLogMapper.insert(log); + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean addPoints(Long memberId, int points, String content, Long orderId) { + TbMemberPoints entity = initMemberPoints(memberId); + // 增加账户积分 + entity.setAccountPoints(entity.getAccountPoints() + points); + entity.setLastPointsChangeTime(new Date()); + entity.setLastFloatPoints(points); + // 记录积分变动记录 + TbMemberPointsLog log = new TbMemberPointsLog(); + log.setShopId(entity.getShopId()); + log.setMemberId(entity.getMemberId()); + log.setMemberName(entity.getMemberName()); + log.setAvatarUrl(entity.getAvatarUrl()); + log.setMobile(entity.getMobile()); + log.setContent(content); + log.setFloatType("add"); + log.setFloatPoints(points); + log.setCreateTime(new Date()); + // 有关联订单的需要回置订单表的相关积分使用字段 + if (orderId != null) { + TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Convert.toInt(orderId)); + if (orderInfo != null) { + log.setOrderNo(orderInfo.getOrderNo()); + } + } + super.updateById(entity); + tbMemberPointsLogMapper.insert(log); + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void consumeAwardPoints(Long memberId, Long orderId) { + TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Convert.toInt(orderId)); + if (orderInfo == null) { + throw new MsgException("订单不存在"); + } + BigDecimal payAmount = orderInfo.getPayAmount(); + if (NumberUtil.isLessOrEqual(payAmount, BigDecimal.ZERO)) { + return; + } + TbPointsBasicSetting basicSetting = tbPointsBasicSettingService.getByShopId(Convert.toLong(orderInfo.getShopId())); + if (basicSetting == null) { + return; + } + Integer enableRewards = basicSetting.getEnableRewards(); + if (enableRewards == 0) { + return; + } + BigDecimal consumeAmount = basicSetting.getConsumeAmount(); + if (consumeAmount == null) { + return; + } + if (NumberUtil.isLessOrEqual(consumeAmount, BigDecimal.ZERO)) { + return; + } + BigDecimal awardPoints = NumberUtil.roundDown(NumberUtil.div(payAmount, consumeAmount), 0); + addPoints(memberId, awardPoints.intValue(), StrUtil.format("消费¥{}送{}积分", payAmount, awardPoints.intValue()), orderId); + } + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsBasicSettingServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsBasicSettingServiceImpl.java new file mode 100644 index 0000000..f0305cb --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsBasicSettingServiceImpl.java @@ -0,0 +1,53 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.lang.Assert; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.entity.TbPointsBasicSetting; +import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.mapper.TbPointsBasicSettingMapper; +import com.chaozhanggui.system.cashierservice.service.TbPointsBasicSettingService; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +@Primary +public class TbPointsBasicSettingServiceImpl extends ServiceImpl implements TbPointsBasicSettingService { + + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean save(TbPointsBasicSetting entity) { + try { + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id","shopId"); + Assert.notNull(entity.getEnableRewards(), "{}({})不能为空", "开启消费赠送积分","enableRewards"); + Assert.notNull(entity.getConsumeAmount(), "{}({})不能为空", "每消费xx元赠送1积分","consumeAmount"); + Assert.notNull(entity.getEnableDeduction(), "{}({})不能为空", "开启下单积分抵扣","enableDeduction"); + Assert.notNull(entity.getMinDeductionPoint(), "{}({})不能为空", "下单积分抵扣门槛","minDeductionPoint"); + Assert.notNull(entity.getMaxDeductionRatio(), "{}({})不能为空", "下单最高抵扣比例","maxDeductionRatio"); + Assert.notNull(entity.getEquivalentPoints(), "{}({})不能为空", "下单抵扣积分比例","equivalentPoints"); + Assert.notNull(entity.getEnablePointsMall(), "{}({})不能为空", "开启积分商城","enablePointsMall"); + Assert.notEmpty(entity.getBrowseMode(), "{}({})不能为空", "浏览模式","browseMode"); + } catch (IllegalArgumentException e) { + throw new MsgException(e.getMessage()); + } + entity.setCreateTime(new Date()); + super.remove(Wrappers.lambdaQuery().eq(TbPointsBasicSetting::getShopId, entity.getShopId())); + super.save(entity); + return true; + } + + @Override + public TbPointsBasicSetting getByShopId(Long shopId) { + return super.getOne(Wrappers.lambdaQuery().eq(TbPointsBasicSetting::getShopId, shopId)); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsExchangeRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsExchangeRecordServiceImpl.java new file mode 100644 index 0000000..3a59c99 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsExchangeRecordServiceImpl.java @@ -0,0 +1,204 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.mapper.*; +import com.chaozhanggui.system.cashierservice.service.TbPointsExchangeRecordService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +@Primary +public class TbPointsExchangeRecordServiceImpl extends ServiceImpl implements TbPointsExchangeRecordService { + + @Autowired + private TbPointsBasicSettingMapper tbPointsBasicSettingMapper; + + @Autowired + private TbPointsGoodsSettingMapper tbPointsGoodsSettingMapper; + + @Autowired + private TbMemberPointsMapper tbMemberPointsMapper; + + @Autowired + private TbMemberPointsLogMapper tbMemberPointsLogMapper; + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String keywords = mapProxy.getStr("keywords"); + String beginDate = mapProxy.getStr("beginDate"); + String endDate = mapProxy.getStr("endDate"); + TbPointsExchangeRecord param = BeanUtil.toBean(params, TbPointsExchangeRecord.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbPointsExchangeRecord::getShopId, param.getShopId()); + wrapper.eq(StrUtil.isNotEmpty(param.getPickupMethod()), TbPointsExchangeRecord::getPickupMethod, param.getPickupMethod()); + wrapper.eq(StrUtil.isNotEmpty(param.getStatus()), TbPointsExchangeRecord::getStatus, param.getStatus()); + wrapper.eq(param.getMemberId() != null, TbPointsExchangeRecord::getMemberId, param.getMemberId()); + if (StrUtil.isNotEmpty(keywords)) { + wrapper.nested(i -> i.like(TbPointsExchangeRecord::getOrderNo, keywords).or().like(TbPointsExchangeRecord::getCouponCode, keywords)); + } + if (StrUtil.isNotEmpty(beginDate)) { + wrapper.apply("create_time >= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", beginDate + " 00:00:00"); + } + if (StrUtil.isNotEmpty(endDate)) { + wrapper.apply("create_time <= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", endDate + " 23:59:59"); + } + wrapper.orderByDesc(TbPointsExchangeRecord::getId); + return wrapper; + } + + @Override + public PageInfo page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + PageInfo page = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(wrapper)); + //Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return page; + } + + @Override + public TbPointsExchangeRecord get(Long id) { + return super.getById(id); + } + + @Override + public void checkout(String couponCode) { + if (StrUtil.isBlank(couponCode)) { + throw new MsgException("兑换券券码不能为空"); + } + TbPointsExchangeRecord entity = super.getOne(Wrappers.lambdaQuery().eq(TbPointsExchangeRecord::getCouponCode, couponCode)); + if (entity == null) { + throw new MsgException("兑换券券码无效"); + } + entity.setStatus("done"); + entity.setUpdateTime(new Date()); + super.updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbPointsExchangeRecord exchange(TbPointsExchangeRecord record) { + try { + Assert.notNull(record.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notNull(record.getPointsGoodsId(), "{}({})不能为空", "积分商品id", "pointsGoodsId"); + Assert.notEmpty(record.getPickupMethod(), "{}({})不能为空", "领取方式", "pickupMethod"); + Assert.notNull(record.getMemberId(), "{}({})不能为空", "会员id", "memberId"); + Assert.notEmpty(record.getMemberName(), "{}({})不能为空", "会员名称", "memberName"); + Assert.notEmpty(record.getMobile(), "{}({})不能为空", "手机号码", "mobile"); + } catch (IllegalArgumentException e) { + throw new MsgException(e.getMessage()); + } + TbPointsBasicSetting basic = tbPointsBasicSettingMapper.selectOne(Wrappers.lambdaQuery().eq(TbPointsBasicSetting::getShopId, record.getShopId())); + if (basic == null) { + throw new MsgException("未配置积分锁客基本设置"); + } + if (basic.getEnablePointsMall() != 1) { + throw new MsgException("积分商城未开启"); + } + TbPointsGoodsSetting goods = tbPointsGoodsSettingMapper.selectById(record.getPointsGoodsId()); + if (goods == null) { + throw new MsgException("兑换的商品信息不存在"); + } + if (goods.getDelFlag() == 1) { + throw new MsgException("兑换的商品信息不存在"); + } + record.setPointsGoodsName(goods.getGoodsName()); + record.setGoodsImageUrl(goods.getGoodsImageUrl()); + + Integer status = goods.getStatus(); + if (status != 1) { + throw new MsgException("兑换的商品已下架"); + } + Integer quantity = goods.getQuantity(); + if (quantity <= 0) { + throw new MsgException("兑换的商品库存不足"); + } + TbMemberPoints memberPoints = tbMemberPointsMapper.selectOne(Wrappers.lambdaQuery().eq(TbMemberPoints::getMemberId, record.getMemberId())); + if (memberPoints == null) { + throw new MsgException("该会员积分不足无法兑换这个商品"); + } + Integer accountPoints = memberPoints.getAccountPoints(); + Integer requiredPoints = goods.getRequiredPoints(); + if (accountPoints < requiredPoints) { + throw new MsgException("该会员积分不足无法兑换这个商品"); + } + BigDecimal extraPrice = goods.getExtraPrice(); + record.setExtraPaymentAmount(extraPrice); + record.setSpendPoints(requiredPoints); + Snowflake seqNo = IdUtil.getSnowflake(0, 0); + String orderNo = DateUtil.format(new Date(), "yyyyMMddHH") + StrUtil.subSuf(seqNo.nextIdStr(), -12); + record.setOrderNo(orderNo); + record.setCouponCode(IdUtil.getSnowflakeNextIdStr()); + record.setStatus("waiting"); + record.setCreateTime(new Date()); + // 生成订单 + super.save(record); + // 扣减积分 + memberPoints.setAccountPoints(accountPoints - requiredPoints); + memberPoints.setLastPointsChangeTime(new Date()); + memberPoints.setLastFloatPoints(-requiredPoints); + tbMemberPointsMapper.updateById(memberPoints); + // 扣减库存 + goods.setQuantity(quantity - 1); + goods.setUpdateTime(new Date()); + tbPointsGoodsSettingMapper.updateById(goods); + // 记录积分浮动流水 + TbMemberPointsLog log = new TbMemberPointsLog(); + log.setShopId(record.getShopId()); + log.setMemberId(record.getMemberId()); + log.setMemberName(record.getMemberName()); + log.setMobile(record.getMobile()); + log.setAvatarUrl(record.getAvatarUrl()); + log.setContent(StrUtil.format("兑换商品:{} * {}", record.getPointsGoodsName(), "1")); + log.setFloatType("subtract"); + log.setFloatPoints(-requiredPoints); + log.setCreateTime(new Date()); + tbMemberPointsLogMapper.insert(log); + // 更新累计兑换数量 + goods.setTotalExchangeCount(goods.getTotalExchangeCount() + 1); + goods.setUpdateTime(new Date()); + tbPointsGoodsSettingMapper.updateById(goods); + return record; + } + + @Override + public Map total(Map params) { + LambdaQueryWrapper wrapper = getWrapper(params); + wrapper.select(TbPointsExchangeRecord::getCount, TbPointsExchangeRecord::getTotalAmount); + TbPointsExchangeRecord summary = baseMapper.selectOne(wrapper); + Map result = new HashMap<>(2); + result.put("count", summary.getCount()); + result.put("totalAmount", NumberUtil.null2Zero(summary.getTotalAmount())); + return result; + } + +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsGoodsSettingServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsGoodsSettingServiceImpl.java new file mode 100644 index 0000000..89d6735 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbPointsGoodsSettingServiceImpl.java @@ -0,0 +1,103 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.entity.TbPointsGoodsSetting; +import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.mapper.TbPointsGoodsSettingMapper; +import com.chaozhanggui.system.cashierservice.service.TbPointsGoodsSettingService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.Map; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +@Primary +public class TbPointsGoodsSettingServiceImpl extends ServiceImpl implements TbPointsGoodsSettingService { + + + @Override + public PageInfo page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + TbPointsGoodsSetting param = BeanUtil.toBean(params, TbPointsGoodsSetting.class); + Page pg = new Page<>(pageNum, pageSize); + pg.addOrder(OrderItem.desc("sort")); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .eq(TbPointsGoodsSetting::getShopId, param.getShopId()) + .like(StrUtil.isNotEmpty(param.getGoodsName()), TbPointsGoodsSetting::getGoodsName, param.getGoodsName()) + .like(StrUtil.isNotEmpty(param.getGoodsCategory()), TbPointsGoodsSetting::getGoodsCategory, param.getGoodsCategory()) + .eq(param.getStatus() != null, TbPointsGoodsSetting::getStatus, param.getStatus()) + .eq(TbPointsGoodsSetting::getDelFlag, 0) + .orderByDesc(TbPointsGoodsSetting::getId); + PageInfo page = PageHelper.startPage(pageNum, pageSize,"sort desc").doSelectPageInfo(() -> baseMapper.selectList(wrapper)); + return page; + } + + @Override + public boolean save(TbPointsGoodsSetting entity) { + try { + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notEmpty(entity.getGoodsCategory(), "{}({})不能为空", "商品类型", "goodsCategory"); + Assert.notEmpty(entity.getGoodsName(), "{}({})不能为空", "商品名称", "goodsName"); + //Assert.notNull(entity.getGoodsImageUrl(), "{}({})不能为空", "商品图片URL","goodsImageUrl"); + Assert.notNull(entity.getRequiredPoints(), "{}({})不能为空", "所需积分", "requiredPoints"); + Assert.notNull(entity.getExtraPrice(), "{}({})不能为空", "额外价格", "extraPrice"); + Assert.notNull(entity.getSort(), "{}({})不能为空", "排序(权重)", "sort"); + Assert.notNull(entity.getQuantity(), "{}({})不能为空", "数量", "quantity"); + //Assert.notEmpty(entity.getGoodsDescription(), "{}({})不能为空", "商品详情","goodsDescription"); + Assert.notNull(entity.getStatus(), "{}({})不能为空", "是否上架", "status"); + } catch (IllegalArgumentException e) { + throw new MsgException(e.getMessage()); + } + entity.setCreateTime(new Date()); + return super.save(entity); + } + + @Override + public boolean update(TbPointsGoodsSetting dto) { + try { + Assert.notNull(dto.getId(), "{}不能为空", "商品id"); + Assert.notNull(dto.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notEmpty(dto.getGoodsCategory(), "{}({})不能为空", "商品类型", "goodsCategory"); + Assert.notEmpty(dto.getGoodsName(), "{}({})不能为空", "商品名称", "goodsName"); + //Assert.notNull(entity.getGoodsImageUrl(), "{}({})不能为空", "商品图片URL","goodsImageUrl"); + Assert.notNull(dto.getRequiredPoints(), "{}({})不能为空", "所需积分", "requiredPoints"); + Assert.notNull(dto.getExtraPrice(), "{}({})不能为空", "额外价格", "extraPrice"); + Assert.notNull(dto.getSort(), "{}({})不能为空", "排序(权重)", "sort"); + Assert.notNull(dto.getQuantity(), "{}({})不能为空", "数量", "quantity"); + //Assert.notEmpty(entity.getGoodsDescription(), "{}({})不能为空", "商品详情","goodsDescription"); + Assert.notNull(dto.getStatus(), "{}({})不能为空", "是否上架", "status"); + } catch (IllegalArgumentException e) { + throw new MsgException(e.getMessage()); + } + TbPointsGoodsSetting entity = super.getById(dto.getId()); + BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(false).setIgnoreProperties("createTime")); + entity.setUpdateTime(new Date()); + return super.updateById(entity); + } + + @Override + public void delete(Long id) { + super.update(Wrappers.lambdaUpdate().set(TbPointsGoodsSetting::getDelFlag, 1).eq(TbPointsGoodsSetting::getId, id)); + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java new file mode 100644 index 0000000..2b1cc86 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java @@ -0,0 +1,209 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import com.chaozhanggui.system.cashierservice.dao.*; +import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto; +import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; +import com.chaozhanggui.system.cashierservice.service.TbShopCouponService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.google.gson.JsonObject; +import org.apache.commons.lang3.StringUtils; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 优惠券(TbShopCoupon)表服务实现类 + * + * @author ww + * @since 2024-10-23 15:37:37 + */ +@Primary +@Service +public class TbShopCouponServiceImpl implements TbShopCouponService { + @Resource + private TbOrderDetailMapper orderDetailMapper; + @Resource + private TbShopUserMapper shopUserMapper; + @Resource + private TbShopCouponMapper couponMapper; + @Resource + private TbOrderInfoMapper orderInfoMapper; + @Resource + private TbActivateInRecordMapper inRecordMapper; + @Resource + private TbActivateOutRecordMapper outRecordMapper; + + @Override + public List getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount) { + TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, String.valueOf(shopId)); + List tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Arrays.asList(Integer.valueOf(tbShopUser.getId())), shopId); + ArrayList canUseCoupon = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(tbUserCouponVos)) { + String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周"); + LocalTime now = LocalTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + //券id 券使用描述 + Map coupons = new HashMap<>(); + for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { + if (tbUserCouponVo.getType() != null && tbUserCouponVo.getType() == 1 && + tbUserCouponVo.getFullAmount().compareTo(amount) <= 0) { + if (!coupons.containsKey(tbUserCouponVo.getCouponId())) { + setCouponInfo(coupons, tbUserCouponVo, amount, week, now, formatter); + } + JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId()); + tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString()); + if (tbUserCouponVo.getType().equals(1)) { + tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean()); + } + canUseCoupon.add(tbUserCouponVo); + } + + } + canUseCoupon.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime)); + } + return canUseCoupon; + } + + private void setCouponInfo( Map coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) { + JsonObject json = new JsonObject(); + boolean isUse = true; + TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId()); + StringBuilder useRestrictions = new StringBuilder("每天 "); + if (tbShopCoupon.getType().equals(1)) { + if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) { + isUse = false; + } + } + if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) { + String[] split = tbShopCoupon.getUserDays().split(","); + if (split.length != 7) { + useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " "); + } + if (!tbShopCoupon.getUserDays().contains(week)) { + isUse = false; + } + } + if (tbShopCoupon.getUseTimeType().equals("custom")) { + if (now.isBefore(tbShopCoupon.getUseStartTime()) || now.isAfter(tbShopCoupon.getUseEndTime())) { + isUse = false; + } + useRestrictions.append( + tbShopCoupon.getUseStartTime().format(formatter) + + "-" + + tbShopCoupon.getUseEndTime().format(formatter)); + } else { + useRestrictions.append("全时段"); + } + useRestrictions.append(" 可用"); + json.addProperty("isUse", isUse); + json.addProperty("useRestrictions", useRestrictions.toString()); + + coupons.put(tbUserCouponVo.getCouponId(), json); + } + + + @Override + public Result find(CouponDto param) { + if (param.getOrderId() != null) { + TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(param.getUserId().toString(), param.getShopId().toString()); + TbOrderInfo tbOrderInfo = orderInfoMapper.selectByPrimaryKey(param.getOrderId()); + List tbOrderDetails = orderDetailMapper.selectAllByOrderId(param.getOrderId()); + Set pros = tbOrderDetails.stream().map(TbOrderDetail::getProductId).collect(Collectors.toSet()); + if (CollectionUtil.isNotEmpty(tbOrderDetails)) { + List tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Arrays.asList(Integer.valueOf(tbShopUser.getId())), param.getShopId()); + if (CollectionUtil.isNotEmpty(tbUserCouponVos)) { + String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周"); + LocalTime now = LocalTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + + //券id 券使用描述 + Map coupons = new HashMap<>(); + for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { + if (!coupons.containsKey(tbUserCouponVo.getCouponId())) { + setCouponInfo(coupons, tbUserCouponVo, tbOrderInfo.getAmount(), week, now, formatter); + } + JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId()); + tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString()); + if (tbUserCouponVo.getType().equals(1)) { + tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean()); + } else if (tbUserCouponVo.getType().equals(2) && couponJson.get("isUse").getAsBoolean()) { + if (!pros.contains(tbUserCouponVo.getProId())) { + tbUserCouponVo.setUse(false); + } + } + } + tbUserCouponVos.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime)); + return new Result(CodeEnum.SUCCESS, tbUserCouponVos); + } + } + } else { + List tbShopUser = shopUserMapper.selectAllByUserId(param.getUserId().toString()); + List ids = tbShopUser.stream().map(TbShopUser::getId).map(Integer::valueOf).collect(Collectors.toList()); + if (param.getStatus().equals(1)) { + return new Result(CodeEnum.SUCCESS, inRecordMapper.queryByVipIdAndShopId(ids, param.getShopId())); + } else if (param.getStatus().equals(-1)) { + return new Result(CodeEnum.SUCCESS, inRecordMapper.queryByVipIdAndShopIdExpire(ids, param.getShopId())); + } else if (param.getStatus().equals(2)) { + return new Result(CodeEnum.SUCCESS, outRecordMapper.queryByVipIdAndShopId(ids, param.getShopId())); + } + } + return new Result(CodeEnum.SUCCESS); + } + + + /** + * 使用券 + * + * @param shopId + * @param orderId + * @param vipUserId + * @param param giveId 和 useNum 必传 + * @return + */ + @Override + public boolean use(Integer shopId, Integer orderId, Integer vipUserId, List param) { + for (TbActivateOutRecord outRecord : param) { + TbActivateInRecord inRecord = inRecordMapper.queryById(outRecord.getGiveId()); + inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum()); + inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum()); + + outRecord.setType(inRecord.getType()); + outRecord.setShopId(shopId); + outRecord.setOrderId(orderId.toString()); + outRecord.setVipUserId(vipUserId); + outRecord.setStatus("closed"); + outRecord.setCreateTime(new Date()); + } + outRecordMapper.insertBatch(param); + return true; + } + + /** + * 退还券 + * + * @param param giveId和 refNum 必传 + * @return + */ + @Override + public boolean refund(List param) { + for (TbActivateOutRecord outRecord : param) { + outRecord.setUpdateTime(new Date()); + outRecordMapper.updateRefNum(outRecord.getId(), outRecord.getRefNum()); + TbActivateInRecord inRecord = inRecordMapper.queryById(outRecord.getGiveId()); + inRecord.setOverNum(inRecord.getOverNum() + outRecord.getRefNum()); + inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum()); + } + return true; + } + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/task/TaskScheduler.java b/src/main/java/com/chaozhanggui/system/cashierservice/task/TaskScheduler.java index 4aa7ea9..b67ce3c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/task/TaskScheduler.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/task/TaskScheduler.java @@ -1,178 +1,22 @@ package com.chaozhanggui.system.cashierservice.task; -import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.service.TbShopSongOrderService; -import com.chaozhanggui.system.cashierservice.util.DateUtils; -import com.chaozhanggui.system.cashierservice.util.NicknameGenerator; -import com.chaozhanggui.system.cashierservice.util.RandomUtil; -import lombok.SneakyThrows; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.ParseException; -import java.util.*; -import java.util.concurrent.*; - @Component public class TaskScheduler { private static final Logger log = LoggerFactory.getLogger(TaskScheduler.class); - @Autowired - private TbWiningUserMapper tbWiningUserMapper; - @Autowired - private TbOrderInfoMapper orderInfoMapper; - @Autowired - private TbWiningParamsMapper winingParamsMapper; - @Autowired - private TbUserInfoMapper userInfoMapper; - @Autowired - private TbReleaseFlowMapper releaseFlowMapper; - @Autowired - private TbUserCouponsMapper userCouponsMapper; - private final TbShopSongOrderService shopSongOrderService; public TaskScheduler(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) { this.shopSongOrderService = shopSongOrderService; } - //更新订单状态 -// @Scheduled(fixedRate = 1000000) - public void orderStatus() throws InterruptedException { - for (int i = 0;i<10;i++){ - TbReleaseFlow releaseFlow = new TbReleaseFlow(); - BigDecimal orderAmount = RandomUtil.getRandomBigDecimal(BigDecimal.ONE, new BigDecimal("100")); - releaseFlow.setNum(orderAmount); - releaseFlow.setCreateTime(new Date()); - releaseFlow.setFromSource("OWER"); - releaseFlow.setUserId("15"); - releaseFlow.setOperationType("ADD"); - releaseFlow.setType("EXCHANGEADD"); - releaseFlow.setRemark("兑换增加"); - releaseFlowMapper.insert(releaseFlow); - } - for (int i = 0;i<10;i++){ - TbReleaseFlow releaseFlow = new TbReleaseFlow(); - BigDecimal orderAmount = RandomUtil.getRandomBigDecimal(BigDecimal.ONE, new BigDecimal("100")); - releaseFlow.setNum(orderAmount); - releaseFlow.setCreateTime(new Date()); - releaseFlow.setFromSource("OWER"); - releaseFlow.setUserId("15"); - releaseFlow.setOperationType("SUB"); - releaseFlow.setType("BUYSUB"); - releaseFlow.setRemark("购买商品扣除"); - releaseFlowMapper.insert(releaseFlow); - } - for (int i = 0;i<10;i++){ - TbReleaseFlow releaseFlow = new TbReleaseFlow(); - BigDecimal orderAmount = RandomUtil.getRandomBigDecimal(BigDecimal.ONE, new BigDecimal("100")); - releaseFlow.setNum(orderAmount); - releaseFlow.setCreateTime(new Date()); - releaseFlow.setFromSource("OWER"); - releaseFlow.setOperationType("ADD"); - releaseFlow.setUserId("15"); - releaseFlow.setType("THREEADD"); - releaseFlow.setRemark("退货增加"); - releaseFlowMapper.insert(releaseFlow); - } - } - - - @Scheduled(cron = "0 1 0 * * ?") - public void winningUser() { - String day = DateUtils.getDay(); - List list = winingParamsMapper.selectAll(); - ThreadPoolExecutor es = new ThreadPoolExecutor(5, 10, 60L, TimeUnit.SECONDS, - new LinkedBlockingQueue(), new ThreadFactory() { - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r); - t.setDaemon(true); - return t; - } - }); - for (TbWiningParams winingParams : list) { - es.submit(new winingUser(winingParams, day)); - } - es.shutdown(); - - } - - class winingUser implements Runnable { - private TbWiningParams winingParams; - private String day; - - public winingUser(TbWiningParams winingParams, String day) { - this.winingParams = winingParams; - this.day = day; - } - - @Override - public void run() { - try { - List list = orderInfoMapper.selectByTradeDay(day, winingParams.getMinPrice(), winingParams.getMaxPrice()); - int num = winingParams.getWiningUserNum(); - List newList = new ArrayList<>(); - Map map = new HashMap<>(); - int noUserNum = winingParams.getWiningNum() - num; - if (list.size() < num) { - noUserNum = winingParams.getWiningNum(); - } else { - for (int i = 0; i < num; i++) { - TbOrderInfo orderInfo = RandomUtil.selectWinner(list, map); - newList.add(orderInfo); - map.put(orderInfo.getId(), 1); - } - } - for (int i = 0; i < noUserNum; i++) { - long endDate = DateUtils.convertDate1(day + " 00:00:00").getTime(); - long startDate = DateUtils.convertDate1(DateUtils.getSdfDayTimes(DateUtils.getNewDate(new Date(), 3, -1))+" 00:00:00").getTime(); - String orderNo = generateOrderNumber(startDate, endDate); - String userName = NicknameGenerator.generateRandomWeChatNickname(); - BigDecimal orderAmount = RandomUtil.getRandomBigDecimal(winingParams.getMinPrice(), winingParams.getMaxPrice()); - TbWiningUser winingUser = new TbWiningUser(userName, orderNo, orderAmount, "false", day); - tbWiningUserMapper.insert(winingUser); - } - for (TbOrderInfo orderInfo:newList){ - TbUserInfo userInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId())); - TbWiningUser winingUser = new TbWiningUser(userInfo.getNickName(), orderInfo.getOrderNo(), orderInfo.getPayAmount(), "true", day); - tbWiningUserMapper.insert(winingUser); - TbUserCoupons userCoupons = new TbUserCoupons(); - userCoupons.setUserId(orderInfo.getUserId()); - userCoupons.setCouponsAmount(orderInfo.getOrderAmount().subtract(orderInfo.getUserCouponAmount())); - userCoupons.setStatus("0"); - userCoupons.setOrderId(orderInfo.getId()); - userCoupons.setCouponsPrice(userCoupons.getCouponsAmount().multiply(new BigDecimal("0.5"))); - userCoupons.setCreateTime(new Date()); - userCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,30)); - //执行插入方法 - userCouponsMapper.insert(userCoupons); - } - } catch (ParseException e) { - e.printStackTrace(); - } - } - } - - public String generateOrderNumber(long startTimestamp, long endTimestamp) { - long date = getRandomTimestamp(startTimestamp, endTimestamp); - Random random = new Random(); - int randomNum = random.nextInt(900) + 100; - return "WX" + date + randomNum; - } - - public static long getRandomTimestamp(long startTimestamp, long endTimestamp) { - long randomMilliseconds = ThreadLocalRandom.current().nextLong(startTimestamp, endTimestamp); - return randomMilliseconds; - } - @Scheduled(fixedRate = 60000 * 60) public void clearSongOrder() { log.info("定时任务执行,清楚过期歌曲订单"); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java index c0320eb..fd532be 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java @@ -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(""+pickupNumber+"

"); builder.append("时间: "+date+"


"); - + remark = StrUtil.emptyToDefault(remark, ""); if(productName.length()>4||remark.length()>4){ - builder.append(""+productName+" "+number+"

"); + builder.append(""+productName+" x "+number+"

"); builder.append(""+remark+"


"); }else { - builder.append(""+productName+" "+number+"

"); + builder.append(""+productName+" x "+number+"

"); builder.append(""+remark+"


"); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/MQUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/MQUtils.java index d7178fd..3970eda 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/MQUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/MQUtils.java @@ -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 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 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); + } + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java index 16f3cbd..25ae0f2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java @@ -1,7 +1,9 @@ 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; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -14,6 +16,7 @@ import java.util.*; /** * 打印机 */ +@Slf4j public class PrinterUtils { //请求地址 private static final String URL_STR = "https://ioe.car900.com/v1/openApi/dev/customPrint.json"; @@ -69,12 +72,12 @@ public class PrinterUtils { StringBuilder builder = new StringBuilder(); builder.append(""+pickupNumber+"

"); builder.append("时间: "+date+"


"); - + remark = StrUtil.emptyToDefault(remark, ""); if(productName.length()>4||remark.length()>4){ - builder.append(""+productName+" "+number+"
"); + builder.append(""+productName+" x "+number+"
"); builder.append(""+remark+"
"); }else { - builder.append(""+productName+" "+number+"
"); + builder.append(""+productName+" x "+number+"
"); builder.append(""+remark+"
"); } builder.append(""); @@ -83,6 +86,41 @@ public class PrinterUtils { return builder.toString(); } + /** + * 厨房打印机 + * + * @param pickupNumber + * @param date + * @param productName + * @param number + * @param remark + * @return + */ + public static String getPrintData(String type, String pickupNumber, String date, String productName, Integer number, String remark) { + StringBuilder builder = new StringBuilder(); + if ("return".equals(type)) { + builder.append("" + pickupNumber + "【退】

"); + } else { + builder.append("" + pickupNumber + "

"); + } + + + builder.append("时间: " + date + "


"); + remark = StrUtil.emptyToDefault(remark, ""); + if (productName.length() > 4 || remark.length() > 4) { + builder.append("" + productName + " x " + number + "
"); + builder.append("" + remark + "
"); + } else { + builder.append("" + productName + " x " + number + "
"); + builder.append("" + remark + "
"); + } + builder.append(""); + builder.append(""); + + return builder.toString(); + } + + public static String getCashPrintData(OrderDetailPO detailPO,String type){ StringBuilder sb = new StringBuilder(); @@ -162,7 +200,46 @@ public class PrinterUtils { + /** + * 打印票据 + * + * @throws Exception + */ + public static void printTickets(String voiceJson, Integer actWay, Integer cn, String devName, String data) { + log.info("开始请求云享印,请求数据:{}, {}", voiceJson, data); + //设备名称 + //行为方式 1:只打印数据 2:只播放信息 3:打印数据并播放信息 +// actWay = 3; +// //打印联数 +// int cn = 1; + //打印内容 + //播报语音数据体,字段参考文档IOT_XY_API11001 + String time = String.valueOf(System.currentTimeMillis()); + String uuid = UUID.randomUUID().toString(); + Map param = getToken(time, uuid); + //参数 + MultiValueMap multiValueMap = new LinkedMultiValueMap<>(); + multiValueMap.add("token", param.get("TOKEN")); + multiValueMap.add("devName", devName); + multiValueMap.add("actWay", actWay); + multiValueMap.add("cn", cn); + multiValueMap.add("data", data); + multiValueMap.add("voiceJson", voiceJson); + multiValueMap.add("appId", APP_ID); + multiValueMap.add("timestamp", time); + multiValueMap.add("requestId", uuid); + multiValueMap.add("userCode", USER_CODE); + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders header = new HttpHeaders(); + header.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + + HttpEntity> httpEntity = new HttpEntity<>(multiValueMap, header); + String httpResponse = restTemplate.postForObject(URL_STR, + httpEntity, String.class); + + System.out.println("map" + httpResponse); + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java new file mode 100644 index 0000000..80abd0a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ShopUtils.java @@ -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() + .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() + .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); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java new file mode 100644 index 0000000..f10aabc --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java @@ -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 void catchErrNoReturn(Supplier supplier) { + try { + supplier.get(); + }catch (Exception e) { + log.error("执行方法出现异常", e); + } + } + + public static void runFunAndRetryNoReturn( + Supplier function, + Function check, Consumer 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 runFunAndCheckKey(Supplier 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 R runFunAndRetry( + Supplier function, + Function check, Consumer 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; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java index 73baaa9..d91d442 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/wxUtil/WxAccountUtil.java @@ -23,11 +23,11 @@ import java.util.Map; @Slf4j @Component public class WxAccountUtil { - @Value("${wx.ysk.appId}") +// @Value("${wx.ysk.appId}") private static String appId = "wx212769170d2c6b2a"; - @Value("${wx.ysk.secrete}") +// @Value("${wx.ysk.secrete}") private static String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0"; - @Value("${wx.ysk.warnMsgTmpId}") +// @Value("${wx.ysk.warnMsgTmpId}") private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0"; private final TbShopMsgStateMapper shopMsgStateMapper; diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 638ac33..897205d 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,19 +1,25 @@ spring: datasource: -# url: jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false + 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@ +# 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: mysqlroot@123 - url: jdbc:mysql://101.37.12.135:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true - username: fycashier - password: Twc6MrzzjBiWSsjh - driver-class-name: com.mysql.cj.jdbc.Driver +# 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 @@ -41,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 diff --git a/src/main/resources/application-dev2.yml b/src/main/resources/application-pre.yml similarity index 61% rename from src/main/resources/application-dev2.yml rename to src/main/resources/application-pre.yml index c4924e0..4110b3c 100644 --- a/src/main/resources/application-dev2.yml +++ b/src/main/resources/application-pre.yml @@ -1,8 +1,9 @@ spring: datasource: - url: jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false - username: root - password: mysqlroot@123 + # 内网地址 + url: jdbc:mysql://rm-bp1kn7h89nz62cno1.mysql.rds.aliyuncs.com:3306/fycashier_pre?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 initialSize: 5 minIdle: 5 @@ -15,7 +16,7 @@ spring: # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突 database: 0 # redis服务器地址(默认为localhost) - host: 101.37.12.135 + host: localhost # redis端口(默认为6379) port: 6379 # redis访问密码(默认为空) @@ -33,12 +34,11 @@ spring: main: allow-circular-references: true rabbitmq: - host: 101.37.12.135 + host: localhost port: 5672 username: admin password: Czg666888 - mybatis: configuration: map-underscore-to-camel-case: true @@ -47,17 +47,20 @@ mybatis: ysk: url: https://gatewaytestapi.sxczgkj.cn/gate-service/ callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack - callBackGroupurl: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup + callBackGroupurl: https://pre-cashier.sxczgkj.cn/cashierService/notify/notifyCallBackGroup callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack default: 18710449883 thirdPay: - callInBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/fstmemberInCallBack - callFSTBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyfstCallBack - songOrderBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/songOrderCallBack + callInBack: https://pre-cashier.sxczgkj.cn/cashierService/notify/fstmemberInCallBack + callFSTBack: https://pre-cashier.sxczgkj.cn/cashierService/notify/notifyfstCallBack + songOrderBack: https://pre-cashier.sxczgkj.cn/cashierService/notify/songOrderCallBack server: - port: 9889 -prod: devyhq -queue: cart_queue_putdevyhq + port: 9888 +prod: dev1 +queue: cart_queue_putdev1 +subscribe: + message: + miniprogramState: trial diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index d65b90c..8af19f6 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -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 diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml deleted file mode 100644 index 891e93b..0000000 --- a/src/main/resources/application-test.yml +++ /dev/null @@ -1,53 +0,0 @@ -spring: - datasource: - url: jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false - username: root - password: mysqlroot@123 - driver-class-name: com.mysql.cj.jdbc.Driver - initialSize: 5 - minIdle: 5 - maxActive: 20 - maxWait: 60000 - logging: - level: - com.chaozhanggui.system.openness: info - redis: - # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突 - database: 0 - # redis服务器地址(默认为localhost) - host: 101.37.12.135 - # redis端口(默认为6379) - port: 6379 - # redis访问密码(默认为空) - password: 111111 - # redis连接超时时间(单位为毫秒) - timeout: 1000 - block-when-exhausted: true - # redis连接池配置 - jedis: - pool: - max-active: 8 - max-idle: 1024 - min-idle: 0 - max-wait: -1 - main: - allow-circular-references: true - rabbitmq: - host: 101.37.12.135 - port: 5672 - 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 -ysk: - url: https://gatewaytestapi.sxczgkj.cn/gate-service/ - callBackurl: https://cashierapplet.sxczgkj.cn/cashierService/notify/notifyCallBack - callBackGroupurl: https://cashierapplet.sxczgkj.cn/cashierService/notify/notifyCallBackGroup - callBackIn: https://cashierapplet.sxczgkj.cn/cashierService/notify/memberInCallBack - default: 18710449883 - - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b31734b..85cb678 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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.mybatis: 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 diff --git a/src/main/resources/mapper/TbActivateInRecordMapper.xml b/src/main/resources/mapper/TbActivateInRecordMapper.xml new file mode 100644 index 0000000..0c5af4d --- /dev/null +++ b/src/main/resources/mapper/TbActivateInRecordMapper.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json + + + + + + + + + + + + + + + + + + insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json) + values (#{vipUserId}, #{couponId}, #{name}, #{type}, #{proId}, #{fullAmount}, #{discountAmount}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{useStartTime}, #{useEndTime}, #{createTime}, #{updateTime}, #{couponJson}) + + + + insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json) + values + + (#{entity.vipUserId}, #{entity.couponId}, #{entity.name}, #{entity.type}, #{entity.proId}, #{entity.fullAmount}, #{entity.discountAmount}, #{entity.num}, #{entity.overNum}, #{entity.shopId}, #{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.useStartTime}, #{entity.useEndTime}, #{entity.createTime}, #{entity.updateTime}, #{entity.couponJson}) + + + + + + update tb_activate_in_record + + + vip_user_id = #{vipUserId}, + + + coupon_id = #{couponId}, + + + name = #{name}, + + + type = #{type}, + + + pro_id = #{proId}, + + + full_amount = #{fullAmount}, + + + discount_amount = #{discountAmount}, + + + num = #{num}, + + + over_num = #{overNum}, + + + shop_id = #{shopId}, + + + source_act_id = #{sourceActId}, + + + source_flow_id = #{sourceFlowId}, + + + use_start_time = #{useStartTime}, + + + use_end_time = #{useEndTime}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + coupon_json = #{couponJson}, + + + where id = #{id} + + + + update tb_activate_in_record + set over_num = #{overNum} + where id = #{id} + + + + + delete from tb_activate_in_record where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbActivateMapper.xml b/src/main/resources/mapper/TbActivateMapper.xml index 50d204a..4e32f51 100644 --- a/src/main/resources/mapper/TbActivateMapper.xml +++ b/src/main/resources/mapper/TbActivateMapper.xml @@ -1,125 +1,143 @@ - - - - - - - - - - - id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del - - - - delete from tb_activate - where id = #{id,jdbcType=INTEGER} - - - insert into tb_activate (id, shop_id, min_num, - max_num, handsel_num, handsel_type, - is_del) - values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{minNum,jdbcType=INTEGER}, - #{maxNum,jdbcType=INTEGER}, #{handselNum,jdbcType=DECIMAL}, #{handselType,jdbcType=VARCHAR}, - #{isDel,jdbcType=VARCHAR}) - - - insert into tb_activate - - - id, - - - shop_id, - - - min_num, - - - max_num, - - - handsel_num, - - - handsel_type, - - - is_del, - - - - - #{id,jdbcType=INTEGER}, - - - #{shopId,jdbcType=INTEGER}, - - - #{minNum,jdbcType=INTEGER}, - - - #{maxNum,jdbcType=INTEGER}, - - - #{handselNum,jdbcType=DECIMAL}, - - - #{handselType,jdbcType=VARCHAR}, - - - #{isDel,jdbcType=VARCHAR}, - - - - - update tb_activate - - - shop_id = #{shopId,jdbcType=INTEGER}, - - - min_num = #{minNum,jdbcType=INTEGER}, - - - max_num = #{maxNum,jdbcType=INTEGER}, - - - handsel_num = #{handselNum,jdbcType=DECIMAL}, - - - handsel_type = #{handselType,jdbcType=VARCHAR}, - - - is_del = #{isDel,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_activate - set shop_id = #{shopId,jdbcType=INTEGER}, - min_num = #{minNum,jdbcType=INTEGER}, - max_num = #{maxNum,jdbcType=INTEGER}, - handsel_num = #{handselNum,jdbcType=DECIMAL}, - handsel_type = #{handselType,jdbcType=VARCHAR}, - is_del = #{isDel,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - + select + + + from tb_activate + where shop_id = #{shopId} - - \ No newline at end of file + + + + + + + + + + + + insert into tb_activate(shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time) + values (#{shopId}, #{amount}, #{giftAmount}, #{isUseCoupon}, #{couponId}, #{num}, #{createTime}, #{updateTime}) + + + + insert into tb_activate(shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time) + values + + (#{entity.shopId}, #{entity.amount}, #{entity.giftAmount}, #{entity.isUseCoupon}, #{entity.couponId}, + #{entity.num}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_activate + + + shop_id = #{shopId}, + + + amount = #{amount}, + + + gift_amount = #{giftAmount}, + + + is_use_coupon = #{isUseCoupon}, + + + coupon_id = #{couponId}, + + + num = #{num}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + + + delete + from tb_activate + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbActivateOutRecordMapper.xml b/src/main/resources/mapper/TbActivateOutRecordMapper.xml new file mode 100644 index 0000000..df0e2e1 --- /dev/null +++ b/src/main/resources/mapper/TbActivateOutRecordMapper.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + id + , shop_id, order_id, give_id, vip_user_id, type, use_num, ref_num, status, create_time, update_time + + + + + + + + + + + + + insert into tb_activate_out_record(shop_id, order_id, give_id, vip_user_id, type, use_num, ref_num, status, + create_time, update_time) + values (#{shopId}, #{orderId}, #{giveId}, #{vipUserId}, #{type}, #{useNum}, #{refNum}, #{status}, #{createTime}, + #{updateTime}) + + + + insert into tb_activate_out_record(shop_id, order_id, give_id, vip_user_id, type, use_num, ref_num, status, + create_time, update_time) + values + + (#{entity.shopId}, #{entity.orderId}, #{entity.giveId}, #{entity.vipUserId}, #{entity.type}, + #{entity.useNum}, #{entity.refNum}, #{entity.status}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_activate_out_record + + + shop_id = #{shopId}, + + + order_id = #{orderId}, + + + give_id = #{giveId}, + + + vip_user_id = #{vipUserId}, + + + type = #{type}, + + + use_num = #{useNum}, + + + ref_num = #{refNum}, + + + status = #{status}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + + update tb_activate_out_record + set ref_num = ref_num + #{refNum} + where id = #{id} + + + + + delete + from tb_activate_out_record + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbCallQueueMapper.xml b/src/main/resources/mapper/TbCallQueueMapper.xml new file mode 100644 index 0000000..2e732c7 --- /dev/null +++ b/src/main/resources/mapper/TbCallQueueMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + diff --git a/src/main/resources/mapper/TbCallTableMapper.xml b/src/main/resources/mapper/TbCallTableMapper.xml new file mode 100644 index 0000000..2e1f86e --- /dev/null +++ b/src/main/resources/mapper/TbCallTableMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + id,name,note, + wait_time,prefix,start, + near_num,state,shop_id, + qrcode,create_time,update_time + + diff --git a/src/main/resources/mapper/TbCashierCartMapper.xml b/src/main/resources/mapper/TbCashierCartMapper.xml index 0674893..74ed684 100644 --- a/src/main/resources/mapper/TbCashierCartMapper.xml +++ b/src/main/resources/mapper/TbCashierCartMapper.xml @@ -33,11 +33,12 @@ + id, master_id, order_id, ref_order_id, total_amount, product_id, cover_img, is_sku,pack_fee,is_pack,is_gift,pending_at, sku_id, name, sale_price, number, total_number, refund_number, category_id, status, - type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name + type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name,is_vip - \ No newline at end of file + diff --git a/src/main/resources/mapper/TbCouponProductMapper.xml b/src/main/resources/mapper/TbCouponProductMapper.xml new file mode 100644 index 0000000..251e1b6 --- /dev/null +++ b/src/main/resources/mapper/TbCouponProductMapper.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + id + , coupon_id, product_id, num, create_time, update_time + + + + + + + + + + + + + + insert into tb_coupon_product(coupon_id, product_id, num, create_time, update_time) + values (#{couponId}, #{productId}, #{num}, #{createTime}, #{updateTime}) + + + + insert into tb_coupon_product(coupon_id, product_id, num, create_time, update_time) + values + + (#{entity.couponId}, #{entity.productId}, #{entity.num}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_coupon_product + + + coupon_id = #{couponId}, + + + product_id = #{productId}, + + + num = #{num}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + + + delete + from tb_coupon_product + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbDeviceOperateInfoMapper.xml b/src/main/resources/mapper/TbDeviceOperateInfoMapper.xml deleted file mode 100644 index bd36c49..0000000 --- a/src/main/resources/mapper/TbDeviceOperateInfoMapper.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - id, deviceNo, type, shop_id, createTime, remark - - - - delete from tb_device_operate_info - where id = #{id,jdbcType=INTEGER} - - - insert into tb_device_operate_info (id, deviceNo, type, - shop_id, createTime, remark - ) - values (#{id,jdbcType=INTEGER}, #{deviceno,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, - #{shopId,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR} - ) - - - insert into tb_device_operate_info - - - id, - - - deviceNo, - - - type, - - - shop_id, - - - createTime, - - - remark, - - - - - #{id,jdbcType=INTEGER}, - - - #{deviceno,jdbcType=VARCHAR}, - - - #{type,jdbcType=VARCHAR}, - - - #{shopId,jdbcType=VARCHAR}, - - - #{createtime,jdbcType=TIMESTAMP}, - - - #{remark,jdbcType=VARCHAR}, - - - - - update tb_device_operate_info - - - deviceNo = #{deviceno,jdbcType=VARCHAR}, - - - type = #{type,jdbcType=VARCHAR}, - - - shop_id = #{shopId,jdbcType=VARCHAR}, - - - createTime = #{createtime,jdbcType=TIMESTAMP}, - - - remark = #{remark,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_device_operate_info - set deviceNo = #{deviceno,jdbcType=VARCHAR}, - type = #{type,jdbcType=VARCHAR}, - shop_id = #{shopId,jdbcType=VARCHAR}, - createTime = #{createtime,jdbcType=TIMESTAMP}, - remark = #{remark,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbDeviceStockMapper.xml b/src/main/resources/mapper/TbDeviceStockMapper.xml deleted file mode 100644 index a4e401e..0000000 --- a/src/main/resources/mapper/TbDeviceStockMapper.xml +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id, code, snNo, orderNo, price, type, groupNo, buyMercName, buyMercId, actMercName, - actMercId, status, createTime, createBy, delFlag, remarks, updateTime, deviceNo, - belongUserId, extractUserId, roleCode, inStockTime, transferStatus, bindTime - - - - delete from tb_device_stock - where id = #{id,jdbcType=INTEGER} - - - insert into tb_device_stock (id, code, snNo, - orderNo, price, type, - groupNo, buyMercName, buyMercId, - actMercName, actMercId, status, - createTime, createBy, delFlag, - remarks, updateTime, deviceNo, - belongUserId, extractUserId, roleCode, - inStockTime, transferStatus, bindTime - ) - values (#{id,jdbcType=INTEGER}, #{code,jdbcType=VARCHAR}, #{snno,jdbcType=VARCHAR}, - #{orderno,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{type,jdbcType=VARCHAR}, - #{groupno,jdbcType=VARCHAR}, #{buymercname,jdbcType=VARCHAR}, #{buymercid,jdbcType=VARCHAR}, - #{actmercname,jdbcType=VARCHAR}, #{actmercid,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, - #{createtime,jdbcType=TIMESTAMP}, #{createby,jdbcType=VARCHAR}, #{delflag,jdbcType=VARCHAR}, - #{remarks,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP}, #{deviceno,jdbcType=VARCHAR}, - #{belonguserid,jdbcType=INTEGER}, #{extractuserid,jdbcType=INTEGER}, #{rolecode,jdbcType=VARCHAR}, - #{instocktime,jdbcType=TIMESTAMP}, #{transferstatus,jdbcType=VARCHAR}, #{bindtime,jdbcType=TIMESTAMP} - ) - - - insert into tb_device_stock - - - id, - - - code, - - - snNo, - - - orderNo, - - - price, - - - type, - - - groupNo, - - - buyMercName, - - - buyMercId, - - - actMercName, - - - actMercId, - - - status, - - - createTime, - - - createBy, - - - delFlag, - - - remarks, - - - updateTime, - - - deviceNo, - - - belongUserId, - - - extractUserId, - - - roleCode, - - - inStockTime, - - - transferStatus, - - - bindTime, - - - - - #{id,jdbcType=INTEGER}, - - - #{code,jdbcType=VARCHAR}, - - - #{snno,jdbcType=VARCHAR}, - - - #{orderno,jdbcType=VARCHAR}, - - - #{price,jdbcType=DECIMAL}, - - - #{type,jdbcType=VARCHAR}, - - - #{groupno,jdbcType=VARCHAR}, - - - #{buymercname,jdbcType=VARCHAR}, - - - #{buymercid,jdbcType=VARCHAR}, - - - #{actmercname,jdbcType=VARCHAR}, - - - #{actmercid,jdbcType=VARCHAR}, - - - #{status,jdbcType=VARCHAR}, - - - #{createtime,jdbcType=TIMESTAMP}, - - - #{createby,jdbcType=VARCHAR}, - - - #{delflag,jdbcType=VARCHAR}, - - - #{remarks,jdbcType=VARCHAR}, - - - #{updatetime,jdbcType=TIMESTAMP}, - - - #{deviceno,jdbcType=VARCHAR}, - - - #{belonguserid,jdbcType=INTEGER}, - - - #{extractuserid,jdbcType=INTEGER}, - - - #{rolecode,jdbcType=VARCHAR}, - - - #{instocktime,jdbcType=TIMESTAMP}, - - - #{transferstatus,jdbcType=VARCHAR}, - - - #{bindtime,jdbcType=TIMESTAMP}, - - - - - update tb_device_stock - - - code = #{code,jdbcType=VARCHAR}, - - - snNo = #{snno,jdbcType=VARCHAR}, - - - orderNo = #{orderno,jdbcType=VARCHAR}, - - - price = #{price,jdbcType=DECIMAL}, - - - type = #{type,jdbcType=VARCHAR}, - - - groupNo = #{groupno,jdbcType=VARCHAR}, - - - buyMercName = #{buymercname,jdbcType=VARCHAR}, - - - buyMercId = #{buymercid,jdbcType=VARCHAR}, - - - actMercName = #{actmercname,jdbcType=VARCHAR}, - - - actMercId = #{actmercid,jdbcType=VARCHAR}, - - - status = #{status,jdbcType=VARCHAR}, - - - createTime = #{createtime,jdbcType=TIMESTAMP}, - - - createBy = #{createby,jdbcType=VARCHAR}, - - - delFlag = #{delflag,jdbcType=VARCHAR}, - - - remarks = #{remarks,jdbcType=VARCHAR}, - - - updateTime = #{updatetime,jdbcType=TIMESTAMP}, - - - deviceNo = #{deviceno,jdbcType=VARCHAR}, - - - belongUserId = #{belonguserid,jdbcType=INTEGER}, - - - extractUserId = #{extractuserid,jdbcType=INTEGER}, - - - roleCode = #{rolecode,jdbcType=VARCHAR}, - - - inStockTime = #{instocktime,jdbcType=TIMESTAMP}, - - - transferStatus = #{transferstatus,jdbcType=VARCHAR}, - - - bindTime = #{bindtime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_device_stock - set code = #{code,jdbcType=VARCHAR}, - snNo = #{snno,jdbcType=VARCHAR}, - orderNo = #{orderno,jdbcType=VARCHAR}, - price = #{price,jdbcType=DECIMAL}, - type = #{type,jdbcType=VARCHAR}, - groupNo = #{groupno,jdbcType=VARCHAR}, - buyMercName = #{buymercname,jdbcType=VARCHAR}, - buyMercId = #{buymercid,jdbcType=VARCHAR}, - actMercName = #{actmercname,jdbcType=VARCHAR}, - actMercId = #{actmercid,jdbcType=VARCHAR}, - status = #{status,jdbcType=VARCHAR}, - createTime = #{createtime,jdbcType=TIMESTAMP}, - createBy = #{createby,jdbcType=VARCHAR}, - delFlag = #{delflag,jdbcType=VARCHAR}, - remarks = #{remarks,jdbcType=VARCHAR}, - updateTime = #{updatetime,jdbcType=TIMESTAMP}, - deviceNo = #{deviceno,jdbcType=VARCHAR}, - belongUserId = #{belonguserid,jdbcType=INTEGER}, - extractUserId = #{extractuserid,jdbcType=INTEGER}, - roleCode = #{rolecode,jdbcType=VARCHAR}, - inStockTime = #{instocktime,jdbcType=TIMESTAMP}, - transferStatus = #{transferstatus,jdbcType=VARCHAR}, - bindTime = #{bindtime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbFreeDineConfigMapper.xml b/src/main/resources/mapper/TbFreeDineConfigMapper.xml new file mode 100644 index 0000000..9844c15 --- /dev/null +++ b/src/main/resources/mapper/TbFreeDineConfigMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + id,enable,recharge_times, + recharge_threshold,with_coupon,with_points, + recharge_desc,use_type,shop_id, + create_time,update_time,child_shop_id_list + + diff --git a/src/main/resources/mapper/TbFreeDineRecordMapper.xml b/src/main/resources/mapper/TbFreeDineRecordMapper.xml new file mode 100644 index 0000000..07ebb46 --- /dev/null +++ b/src/main/resources/mapper/TbFreeDineRecordMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + id,state,order_id, + order_amount,recharge_amount,pay_amount, + user_id,vip_user_id,shop_id, + coupon_info,points_num,recharge_times, + recharge_threshold,create_time + + diff --git a/src/main/resources/mapper/TbIntegralFlowMapper.xml b/src/main/resources/mapper/TbIntegralFlowMapper.xml deleted file mode 100644 index 046f61b..0000000 --- a/src/main/resources/mapper/TbIntegralFlowMapper.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - id, user_id, num, create_time, update_time - - - - delete from tb_integral_flow - where id = #{id,jdbcType=INTEGER} - - - insert into tb_integral_flow (id, user_id, num, - create_time, update_time) - values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{num,jdbcType=DECIMAL}, - #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}) - - - insert into tb_integral_flow - - - id, - - - user_id, - - - num, - - - create_time, - - - update_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{userId,jdbcType=VARCHAR}, - - - #{num,jdbcType=DECIMAL}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{updateTime,jdbcType=TIMESTAMP}, - - - - - update tb_integral_flow - - - user_id = #{userId,jdbcType=VARCHAR}, - - - num = #{num,jdbcType=DECIMAL}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_integral_flow - set user_id = #{userId,jdbcType=VARCHAR}, - num = #{num,jdbcType=DECIMAL}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbIntegralMapper.xml b/src/main/resources/mapper/TbIntegralMapper.xml deleted file mode 100644 index 86c3c68..0000000 --- a/src/main/resources/mapper/TbIntegralMapper.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - id, user_id, num, status, create_time, update_time - - - - - delete from tb_integral - where id = #{id,jdbcType=INTEGER} - - - insert into tb_integral (id, user_id, num, - status, create_time, update_time - ) - values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{num,jdbcType=DECIMAL}, - #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} - ) - - - insert into tb_integral - - - id, - - - user_id, - - - num, - - - status, - - - create_time, - - - update_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{userId,jdbcType=VARCHAR}, - - - #{num,jdbcType=DECIMAL}, - - - #{status,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{updateTime,jdbcType=TIMESTAMP}, - - - - - update tb_integral - - - user_id = #{userId,jdbcType=VARCHAR}, - - - num = #{num,jdbcType=DECIMAL}, - - - status = #{status,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_integral - set user_id = #{userId,jdbcType=VARCHAR}, - num = #{num,jdbcType=DECIMAL}, - status = #{status,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbMemberPointsLogMapper.xml b/src/main/resources/mapper/TbMemberPointsLogMapper.xml new file mode 100644 index 0000000..d128044 --- /dev/null +++ b/src/main/resources/mapper/TbMemberPointsLogMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbMemberPointsMapper.xml b/src/main/resources/mapper/TbMemberPointsMapper.xml new file mode 100644 index 0000000..d2dea21 --- /dev/null +++ b/src/main/resources/mapper/TbMemberPointsMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbMerchantCouponMapper.xml b/src/main/resources/mapper/TbMerchantCouponMapper.xml deleted file mode 100644 index 37ceb45..0000000 --- a/src/main/resources/mapper/TbMerchantCouponMapper.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/mapper/TbMerchantThirdApplyMapper.xml b/src/main/resources/mapper/TbMerchantThirdApplyMapper.xml index 619e306..02f37a7 100644 --- a/src/main/resources/mapper/TbMerchantThirdApplyMapper.xml +++ b/src/main/resources/mapper/TbMerchantThirdApplyMapper.xml @@ -11,13 +11,14 @@ + - 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 app_token diff --git a/src/main/resources/mapper/TbOrderDetailMapper.xml b/src/main/resources/mapper/TbOrderDetailMapper.xml index b7645cb..a9040a3 100644 --- a/src/main/resources/mapper/TbOrderDetailMapper.xml +++ b/src/main/resources/mapper/TbOrderDetailMapper.xml @@ -8,6 +8,7 @@ + @@ -20,7 +21,7 @@ id, order_id, shop_id, product_id, product_sku_id, num, product_name, product_sku_name, - product_img, create_time, update_time, price, price_amount,status,pack_amount + product_img, create_time, update_time, price, price_amount,status,pack_amount,is_vip select - + * from tb_order_info where id = #{id,jdbcType=INTEGER} - - delete from tb_order_info - where id = #{id,jdbcType=INTEGER} - + + + + + + update tb_order_info + set is_del = 1 + where id = #{id,jdbcType=INTEGER} + - insert into tb_order_info (id, order_no, settlement_amount, - pack_fee, origin_amount, product_amount, - amount, refund_amount, pay_type, - pay_amount, order_amount, freight_amount, - discount_ratio, discount_amount, table_id, - small_change, send_type, order_type, - product_type, status, billing_id, - merchant_id, shop_id, is_vip, - member_id, user_id, product_score, - deduct_score, user_coupon_id, user_coupon_amount, - refund_able, paid_time, is_effect, - is_group, updated_at, system_time, + insert into tb_order_info (id, order_no, settlement_amount, + pack_fee, origin_amount, product_amount, + amount, refund_amount, pay_type, + pay_amount, order_amount, freight_amount, + discount_ratio, discount_amount, table_id, + small_change, send_type, order_type, + product_type, status, billing_id, + merchant_id, shop_id, is_vip, + member_id, user_id, product_score, + deduct_score, user_coupon_id, user_coupon_amount, + refund_able, paid_time, is_effect, + is_group, updated_at, system_time, created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,is_buy_coupon,is_use_coupon,out_number ) - values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}, - #{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL}, - #{amount,jdbcType=DECIMAL}, #{refundAmount,jdbcType=DECIMAL}, #{payType,jdbcType=VARCHAR}, - #{payAmount,jdbcType=DECIMAL}, #{orderAmount,jdbcType=DECIMAL}, #{freightAmount,jdbcType=DECIMAL}, - #{discountRatio,jdbcType=DECIMAL}, #{discountAmount,jdbcType=DECIMAL}, #{tableId,jdbcType=VARCHAR}, - #{smallChange,jdbcType=DECIMAL}, #{sendType,jdbcType=VARCHAR}, #{orderType,jdbcType=VARCHAR}, - #{productType,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{billingId,jdbcType=VARCHAR}, - #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{isVip,jdbcType=TINYINT}, - #{memberId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{productScore,jdbcType=INTEGER}, - #{deductScore,jdbcType=INTEGER}, #{userCouponId,jdbcType=VARCHAR}, #{userCouponAmount,jdbcType=DECIMAL}, - #{refundAble,jdbcType=TINYINT}, #{paidTime,jdbcType=BIGINT}, #{isEffect,jdbcType=TINYINT}, - #{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT}, + values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}, + #{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL}, + #{amount,jdbcType=DECIMAL}, #{refundAmount,jdbcType=DECIMAL}, #{payType,jdbcType=VARCHAR}, + #{payAmount,jdbcType=DECIMAL}, #{orderAmount,jdbcType=DECIMAL}, #{freightAmount,jdbcType=DECIMAL}, + #{discountRatio,jdbcType=DECIMAL}, #{discountAmount,jdbcType=DECIMAL}, #{tableId,jdbcType=VARCHAR}, + #{smallChange,jdbcType=DECIMAL}, #{sendType,jdbcType=VARCHAR}, #{orderType,jdbcType=VARCHAR}, + #{productType,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{billingId,jdbcType=VARCHAR}, + #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{isVip,jdbcType=TINYINT}, + #{memberId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{productScore,jdbcType=INTEGER}, + #{deductScore,jdbcType=INTEGER}, #{userCouponId,jdbcType=VARCHAR}, #{userCouponAmount,jdbcType=DECIMAL}, + #{refundAble,jdbcType=TINYINT}, #{paidTime,jdbcType=BIGINT}, #{isEffect,jdbcType=TINYINT}, + #{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT}, #{createdAt,jdbcType=BIGINT}, #{isAccepted,jdbcType=TINYINT}, #{payOrderNo,jdbcType=VARCHAR}, #{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{masterId,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, #{isBuyCoupon,jdbcType=VARCHAR}, #{isUseCoupon,jdbcType=VARCHAR},#{outNumber,jdbcType=VARCHAR} @@ -486,9 +491,10 @@ is_buy_coupon = #{isBuyCoupon,jdbcType=VARCHAR}, - - is_use_coupon = #{isUseCoupon,jdbcType=VARCHAR}, + + user_id = #{userId,jdbcType=VARCHAR}, + where id = #{id,jdbcType=INTEGER} @@ -549,6 +555,7 @@ where user_id = #{userId} and order_type='miniapp' + and is_del != 1 @@ -576,4 +583,4 @@ left join tb_user_info tui on tui.id = toi.user_id where toi.user_id = #{userId} - \ No newline at end of file + diff --git a/src/main/resources/mapper/TbParamsMapper.xml b/src/main/resources/mapper/TbParamsMapper.xml deleted file mode 100644 index 9696d6d..0000000 --- a/src/main/resources/mapper/TbParamsMapper.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - id, integral_ratio, trade_ratio - - - - delete from tb_params - where id = #{id,jdbcType=INTEGER} - - - insert into tb_params (id, integral_ratio, trade_ratio - ) - values (#{id,jdbcType=INTEGER}, #{integralRatio,jdbcType=DECIMAL}, #{tradeRatio,jdbcType=DECIMAL} - ) - - - insert into tb_params - - - id, - - - integral_ratio, - - - trade_ratio, - - - - - #{id,jdbcType=INTEGER}, - - - #{integralRatio,jdbcType=DECIMAL}, - - - #{tradeRatio,jdbcType=DECIMAL}, - - - - - update tb_params - - - integral_ratio = #{integralRatio,jdbcType=DECIMAL}, - - - trade_ratio = #{tradeRatio,jdbcType=DECIMAL}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_params - set integral_ratio = #{integralRatio,jdbcType=DECIMAL}, - trade_ratio = #{tradeRatio,jdbcType=DECIMAL} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbPlussDeviceGoodsMapper.xml b/src/main/resources/mapper/TbPlussDeviceGoodsMapper.xml deleted file mode 100644 index b67bfe7..0000000 --- a/src/main/resources/mapper/TbPlussDeviceGoodsMapper.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - id, code, name, deviceLogo, introDesc, sort, status, tagId, depositFlag, createTime, - updateTime - - - detail - - - - delete from tb_pluss_device_goods - where id = #{id,jdbcType=INTEGER} - - - insert into tb_pluss_device_goods (id, code, name, - deviceLogo, introDesc, sort, - status, tagId, depositFlag, - createTime, updateTime, detail - ) - values (#{id,jdbcType=INTEGER}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, - #{devicelogo,jdbcType=VARCHAR}, #{introdesc,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, - #{status,jdbcType=INTEGER}, #{tagid,jdbcType=INTEGER}, #{depositflag,jdbcType=VARCHAR}, - #{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP}, #{detail,jdbcType=LONGVARCHAR} - ) - - - insert into tb_pluss_device_goods - - - id, - - - code, - - - name, - - - deviceLogo, - - - introDesc, - - - sort, - - - status, - - - tagId, - - - depositFlag, - - - createTime, - - - updateTime, - - - detail, - - - - - #{id,jdbcType=INTEGER}, - - - #{code,jdbcType=VARCHAR}, - - - #{name,jdbcType=VARCHAR}, - - - #{devicelogo,jdbcType=VARCHAR}, - - - #{introdesc,jdbcType=VARCHAR}, - - - #{sort,jdbcType=INTEGER}, - - - #{status,jdbcType=INTEGER}, - - - #{tagid,jdbcType=INTEGER}, - - - #{depositflag,jdbcType=VARCHAR}, - - - #{createtime,jdbcType=TIMESTAMP}, - - - #{updatetime,jdbcType=TIMESTAMP}, - - - #{detail,jdbcType=LONGVARCHAR}, - - - - - update tb_pluss_device_goods - - - code = #{code,jdbcType=VARCHAR}, - - - name = #{name,jdbcType=VARCHAR}, - - - deviceLogo = #{devicelogo,jdbcType=VARCHAR}, - - - introDesc = #{introdesc,jdbcType=VARCHAR}, - - - sort = #{sort,jdbcType=INTEGER}, - - - status = #{status,jdbcType=INTEGER}, - - - tagId = #{tagid,jdbcType=INTEGER}, - - - depositFlag = #{depositflag,jdbcType=VARCHAR}, - - - createTime = #{createtime,jdbcType=TIMESTAMP}, - - - updateTime = #{updatetime,jdbcType=TIMESTAMP}, - - - detail = #{detail,jdbcType=LONGVARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_pluss_device_goods - set code = #{code,jdbcType=VARCHAR}, - name = #{name,jdbcType=VARCHAR}, - deviceLogo = #{devicelogo,jdbcType=VARCHAR}, - introDesc = #{introdesc,jdbcType=VARCHAR}, - sort = #{sort,jdbcType=INTEGER}, - status = #{status,jdbcType=INTEGER}, - tagId = #{tagid,jdbcType=INTEGER}, - depositFlag = #{depositflag,jdbcType=VARCHAR}, - createTime = #{createtime,jdbcType=TIMESTAMP}, - updateTime = #{updatetime,jdbcType=TIMESTAMP}, - detail = #{detail,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=INTEGER} - - - update tb_pluss_device_goods - set code = #{code,jdbcType=VARCHAR}, - name = #{name,jdbcType=VARCHAR}, - deviceLogo = #{devicelogo,jdbcType=VARCHAR}, - introDesc = #{introdesc,jdbcType=VARCHAR}, - sort = #{sort,jdbcType=INTEGER}, - status = #{status,jdbcType=INTEGER}, - tagId = #{tagid,jdbcType=INTEGER}, - depositFlag = #{depositflag,jdbcType=VARCHAR}, - createTime = #{createtime,jdbcType=TIMESTAMP}, - updateTime = #{updatetime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbPointsBasicSettingMapper.xml b/src/main/resources/mapper/TbPointsBasicSettingMapper.xml new file mode 100644 index 0000000..827c436 --- /dev/null +++ b/src/main/resources/mapper/TbPointsBasicSettingMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbPointsExchangeRecordMapper.xml b/src/main/resources/mapper/TbPointsExchangeRecordMapper.xml new file mode 100644 index 0000000..813071c --- /dev/null +++ b/src/main/resources/mapper/TbPointsExchangeRecordMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbPointsGoodsSettingMapper.xml b/src/main/resources/mapper/TbPointsGoodsSettingMapper.xml new file mode 100644 index 0000000..673fca5 --- /dev/null +++ b/src/main/resources/mapper/TbPointsGoodsSettingMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbPrintMachineMapper.xml b/src/main/resources/mapper/TbPrintMachineMapper.xml index d376c38..1bd0f83 100644 --- a/src/main/resources/mapper/TbPrintMachineMapper.xml +++ b/src/main/resources/mapper/TbPrintMachineMapper.xml @@ -18,6 +18,14 @@ + + + + + + + + @@ -25,7 +33,7 @@ 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 config, category_list diff --git a/src/main/resources/mapper/TbProductGroupMapper.xml b/src/main/resources/mapper/TbProductGroupMapper.xml index a8f0112..ef0d20b 100644 --- a/src/main/resources/mapper/TbProductGroupMapper.xml +++ b/src/main/resources/mapper/TbProductGroupMapper.xml @@ -27,7 +27,7 @@ product_ids - \ No newline at end of file + diff --git a/src/main/resources/mapper/TbProductMapper.xml b/src/main/resources/mapper/TbProductMapper.xml index 66fee1f..615d6fd 100644 --- a/src/main/resources/mapper/TbProductMapper.xml +++ b/src/main/resources/mapper/TbProductMapper.xml @@ -31,7 +31,6 @@ - @@ -64,6 +63,7 @@ + @@ -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 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} ) @@ -239,9 +238,6 @@ type_enum, - - is_distribute, - is_del, @@ -356,6 +352,9 @@ stock_number, + + warn_line, + @@ -445,9 +444,6 @@ #{typeEnum,jdbcType=VARCHAR}, - - #{isDistribute,jdbcType=TINYINT}, - #{isDel,jdbcType=TINYINT}, @@ -556,12 +552,15 @@ #{selectSpec,jdbcType=LONGVARCHAR}, - - #{groupCategoryId,jdbcType=VARCHAR}, - - - #{stockNumber,jdbcType=INTEGER}, - + + #{groupCategoryId,jdbcType=VARCHAR}, + + + #{stockNumber,jdbcType=INTEGER}, + + + #{warnLine,jdbcType=INTEGER}, + @@ -651,9 +650,6 @@ type_enum = #{typeEnum,jdbcType=VARCHAR}, - - is_distribute = #{isDistribute,jdbcType=TINYINT}, - is_del = #{isDel,jdbcType=TINYINT}, @@ -768,143 +764,146 @@ stock_number = #{stockNumber,jdbcType=INTEGER}, + + warn_line = #{warnLine,jdbcType=INTEGER}, + where id = #{id,jdbcType=INTEGER} 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 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} @@ -1001,7 +1000,7 @@ - select - - from tb_receipt_sales - where id = #{id,jdbcType=INTEGER} - - - delete from tb_receipt_sales - where id = #{id,jdbcType=INTEGER} - - - insert into tb_receipt_sales (id, title, logo, - show_contact_info, show_member, show_member_code, - show_member_score, show_member_wallet, footer_remark, - show_cash_charge, show_serial_no, big_serial_no, - header_text, header_text_align, footer_text, - footer_text_align, footer_image, pre_print, - created_at, updated_at) - values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{logo,jdbcType=VARCHAR}, - #{showContactInfo,jdbcType=BIT}, #{showMember,jdbcType=BIT}, #{showMemberCode,jdbcType=BIT}, - #{showMemberScore,jdbcType=BIT}, #{showMemberWallet,jdbcType=BIT}, #{footerRemark,jdbcType=VARCHAR}, - #{showCashCharge,jdbcType=BIT}, #{showSerialNo,jdbcType=BIT}, #{bigSerialNo,jdbcType=BIT}, - #{headerText,jdbcType=VARCHAR}, #{headerTextAlign,jdbcType=VARCHAR}, #{footerText,jdbcType=VARCHAR}, - #{footerTextAlign,jdbcType=VARCHAR}, #{footerImage,jdbcType=VARCHAR}, #{prePrint,jdbcType=VARCHAR}, - #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}) - - - insert into tb_receipt_sales - - - id, - - - title, - - - logo, - - - show_contact_info, - - - show_member, - - - show_member_code, - - - show_member_score, - - - show_member_wallet, - - - footer_remark, - - - show_cash_charge, - - - show_serial_no, - - - big_serial_no, - - - header_text, - - - header_text_align, - - - footer_text, - - - footer_text_align, - - - footer_image, - - - pre_print, - - - created_at, - - - updated_at, - - - - - #{id,jdbcType=INTEGER}, - - - #{title,jdbcType=VARCHAR}, - - - #{logo,jdbcType=VARCHAR}, - - - #{showContactInfo,jdbcType=BIT}, - - - #{showMember,jdbcType=BIT}, - - - #{showMemberCode,jdbcType=BIT}, - - - #{showMemberScore,jdbcType=BIT}, - - - #{showMemberWallet,jdbcType=BIT}, - - - #{footerRemark,jdbcType=VARCHAR}, - - - #{showCashCharge,jdbcType=BIT}, - - - #{showSerialNo,jdbcType=BIT}, - - - #{bigSerialNo,jdbcType=BIT}, - - - #{headerText,jdbcType=VARCHAR}, - - - #{headerTextAlign,jdbcType=VARCHAR}, - - - #{footerText,jdbcType=VARCHAR}, - - - #{footerTextAlign,jdbcType=VARCHAR}, - - - #{footerImage,jdbcType=VARCHAR}, - - - #{prePrint,jdbcType=VARCHAR}, - - - #{createdAt,jdbcType=BIGINT}, - - - #{updatedAt,jdbcType=BIGINT}, - - - - - update tb_receipt_sales - - - title = #{title,jdbcType=VARCHAR}, - - - logo = #{logo,jdbcType=VARCHAR}, - - - show_contact_info = #{showContactInfo,jdbcType=BIT}, - - - show_member = #{showMember,jdbcType=BIT}, - - - show_member_code = #{showMemberCode,jdbcType=BIT}, - - - show_member_score = #{showMemberScore,jdbcType=BIT}, - - - show_member_wallet = #{showMemberWallet,jdbcType=BIT}, - - - footer_remark = #{footerRemark,jdbcType=VARCHAR}, - - - show_cash_charge = #{showCashCharge,jdbcType=BIT}, - - - show_serial_no = #{showSerialNo,jdbcType=BIT}, - - - big_serial_no = #{bigSerialNo,jdbcType=BIT}, - - - header_text = #{headerText,jdbcType=VARCHAR}, - - - header_text_align = #{headerTextAlign,jdbcType=VARCHAR}, - - - footer_text = #{footerText,jdbcType=VARCHAR}, - - - footer_text_align = #{footerTextAlign,jdbcType=VARCHAR}, - - - footer_image = #{footerImage,jdbcType=VARCHAR}, - - - pre_print = #{prePrint,jdbcType=VARCHAR}, - - - created_at = #{createdAt,jdbcType=BIGINT}, - - - updated_at = #{updatedAt,jdbcType=BIGINT}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_receipt_sales - set title = #{title,jdbcType=VARCHAR}, - logo = #{logo,jdbcType=VARCHAR}, - show_contact_info = #{showContactInfo,jdbcType=BIT}, - show_member = #{showMember,jdbcType=BIT}, - show_member_code = #{showMemberCode,jdbcType=BIT}, - show_member_score = #{showMemberScore,jdbcType=BIT}, - show_member_wallet = #{showMemberWallet,jdbcType=BIT}, - footer_remark = #{footerRemark,jdbcType=VARCHAR}, - show_cash_charge = #{showCashCharge,jdbcType=BIT}, - show_serial_no = #{showSerialNo,jdbcType=BIT}, - big_serial_no = #{bigSerialNo,jdbcType=BIT}, - header_text = #{headerText,jdbcType=VARCHAR}, - header_text_align = #{headerTextAlign,jdbcType=VARCHAR}, - footer_text = #{footerText,jdbcType=VARCHAR}, - footer_text_align = #{footerTextAlign,jdbcType=VARCHAR}, - footer_image = #{footerImage,jdbcType=VARCHAR}, - pre_print = #{prePrint,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbReleaseFlowMapper.xml b/src/main/resources/mapper/TbReleaseFlowMapper.xml deleted file mode 100644 index 4d7f97b..0000000 --- a/src/main/resources/mapper/TbReleaseFlowMapper.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - id, user_id, num, type, remark, from_source, create_time,operation_type - - - - - - delete from tb_release_flow - where id = #{id,jdbcType=INTEGER} - - - insert into tb_release_flow (id, user_id, num, - type, remark, from_source, - create_time,operation_type) - values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{num,jdbcType=DECIMAL}, - #{type,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{fromSource,jdbcType=VARCHAR}, - #{createTime,jdbcType=TIMESTAMP}, #{operationType,jdbcType=VARCHAR}) - - - insert into tb_release_flow - - - id, - - - user_id, - - - num, - - - type, - - - remark, - - - from_source, - - - create_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{userId,jdbcType=VARCHAR}, - - - #{num,jdbcType=DECIMAL}, - - - #{type,jdbcType=VARCHAR}, - - - #{remark,jdbcType=VARCHAR}, - - - #{fromSource,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - - - update tb_release_flow - - - user_id = #{userId,jdbcType=VARCHAR}, - - - num = #{num,jdbcType=DECIMAL}, - - - type = #{type,jdbcType=VARCHAR}, - - - remark = #{remark,jdbcType=VARCHAR}, - - - from_source = #{fromSource,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_release_flow - set user_id = #{userId,jdbcType=VARCHAR}, - num = #{num,jdbcType=DECIMAL}, - type = #{type,jdbcType=VARCHAR}, - remark = #{remark,jdbcType=VARCHAR}, - from_source = #{fromSource,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbRenewalsPayLogMapper.xml b/src/main/resources/mapper/TbRenewalsPayLogMapper.xml deleted file mode 100644 index ea09b30..0000000 --- a/src/main/resources/mapper/TbRenewalsPayLogMapper.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - id, pay_type, shop_id, order_id, open_id, user_id, transaction_id, amount, status, - remark, attach, expired_at, created_at, updated_at - - - - delete from tb_renewals_pay_log - where id = #{id,jdbcType=INTEGER} - - - insert into tb_renewals_pay_log (id, pay_type, shop_id, - order_id, open_id, user_id, - transaction_id, amount, status, - remark, attach, expired_at, - created_at, updated_at) - values (#{id,jdbcType=INTEGER}, #{payType,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, - #{orderId,jdbcType=VARCHAR}, #{openId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, - #{transactionId,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{status,jdbcType=TINYINT}, - #{remark,jdbcType=VARCHAR}, #{attach,jdbcType=VARCHAR}, #{expiredAt,jdbcType=BIGINT}, - #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}) - - - insert into tb_renewals_pay_log - - - id, - - - pay_type, - - - shop_id, - - - order_id, - - - open_id, - - - user_id, - - - transaction_id, - - - amount, - - - status, - - - remark, - - - attach, - - - expired_at, - - - created_at, - - - updated_at, - - - - - #{id,jdbcType=INTEGER}, - - - #{payType,jdbcType=VARCHAR}, - - - #{shopId,jdbcType=VARCHAR}, - - - #{orderId,jdbcType=VARCHAR}, - - - #{openId,jdbcType=VARCHAR}, - - - #{userId,jdbcType=VARCHAR}, - - - #{transactionId,jdbcType=VARCHAR}, - - - #{amount,jdbcType=DECIMAL}, - - - #{status,jdbcType=TINYINT}, - - - #{remark,jdbcType=VARCHAR}, - - - #{attach,jdbcType=VARCHAR}, - - - #{expiredAt,jdbcType=BIGINT}, - - - #{createdAt,jdbcType=BIGINT}, - - - #{updatedAt,jdbcType=BIGINT}, - - - - - update tb_renewals_pay_log - - - pay_type = #{payType,jdbcType=VARCHAR}, - - - shop_id = #{shopId,jdbcType=VARCHAR}, - - - order_id = #{orderId,jdbcType=VARCHAR}, - - - open_id = #{openId,jdbcType=VARCHAR}, - - - user_id = #{userId,jdbcType=VARCHAR}, - - - transaction_id = #{transactionId,jdbcType=VARCHAR}, - - - amount = #{amount,jdbcType=DECIMAL}, - - - status = #{status,jdbcType=TINYINT}, - - - remark = #{remark,jdbcType=VARCHAR}, - - - attach = #{attach,jdbcType=VARCHAR}, - - - expired_at = #{expiredAt,jdbcType=BIGINT}, - - - created_at = #{createdAt,jdbcType=BIGINT}, - - - updated_at = #{updatedAt,jdbcType=BIGINT}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_renewals_pay_log - set pay_type = #{payType,jdbcType=VARCHAR}, - shop_id = #{shopId,jdbcType=VARCHAR}, - order_id = #{orderId,jdbcType=VARCHAR}, - open_id = #{openId,jdbcType=VARCHAR}, - user_id = #{userId,jdbcType=VARCHAR}, - transaction_id = #{transactionId,jdbcType=VARCHAR}, - amount = #{amount,jdbcType=DECIMAL}, - status = #{status,jdbcType=TINYINT}, - remark = #{remark,jdbcType=VARCHAR}, - attach = #{attach,jdbcType=VARCHAR}, - expired_at = #{expiredAt,jdbcType=BIGINT}, - created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbShopCashSpreadMapper.xml b/src/main/resources/mapper/TbShopCashSpreadMapper.xml deleted file mode 100644 index 87c41c7..0000000 --- a/src/main/resources/mapper/TbShopCashSpreadMapper.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - id, created_at, updated_at - - - sale_receipt, triplicate_receipt, screen_config, tag_config, scale_config - - - - delete from tb_shop_cash_spread - where id = #{id,jdbcType=INTEGER} - - - insert into tb_shop_cash_spread (id, created_at, updated_at, - sale_receipt, triplicate_receipt, - screen_config, tag_config, scale_config - ) - values (#{id,jdbcType=INTEGER}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, - #{saleReceipt,jdbcType=LONGVARCHAR}, #{triplicateReceipt,jdbcType=LONGVARCHAR}, - #{screenConfig,jdbcType=LONGVARCHAR}, #{tagConfig,jdbcType=LONGVARCHAR}, #{scaleConfig,jdbcType=LONGVARCHAR} - ) - - - insert into tb_shop_cash_spread - - - id, - - - created_at, - - - updated_at, - - - sale_receipt, - - - triplicate_receipt, - - - screen_config, - - - tag_config, - - - scale_config, - - - - - #{id,jdbcType=INTEGER}, - - - #{createdAt,jdbcType=BIGINT}, - - - #{updatedAt,jdbcType=BIGINT}, - - - #{saleReceipt,jdbcType=LONGVARCHAR}, - - - #{triplicateReceipt,jdbcType=LONGVARCHAR}, - - - #{screenConfig,jdbcType=LONGVARCHAR}, - - - #{tagConfig,jdbcType=LONGVARCHAR}, - - - #{scaleConfig,jdbcType=LONGVARCHAR}, - - - - - update tb_shop_cash_spread - - - created_at = #{createdAt,jdbcType=BIGINT}, - - - updated_at = #{updatedAt,jdbcType=BIGINT}, - - - sale_receipt = #{saleReceipt,jdbcType=LONGVARCHAR}, - - - triplicate_receipt = #{triplicateReceipt,jdbcType=LONGVARCHAR}, - - - screen_config = #{screenConfig,jdbcType=LONGVARCHAR}, - - - tag_config = #{tagConfig,jdbcType=LONGVARCHAR}, - - - scale_config = #{scaleConfig,jdbcType=LONGVARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_shop_cash_spread - set created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT}, - sale_receipt = #{saleReceipt,jdbcType=LONGVARCHAR}, - triplicate_receipt = #{triplicateReceipt,jdbcType=LONGVARCHAR}, - screen_config = #{screenConfig,jdbcType=LONGVARCHAR}, - tag_config = #{tagConfig,jdbcType=LONGVARCHAR}, - scale_config = #{scaleConfig,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=INTEGER} - - - update tb_shop_cash_spread - set created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbShopCouponMapper.xml b/src/main/resources/mapper/TbShopCouponMapper.xml new file mode 100644 index 0000000..32d2beb --- /dev/null +++ b/src/main/resources/mapper/TbShopCouponMapper.xml @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + , shop_id, title, type, full_amount, discount_amount, description, number, left_number, validity_type, valid_days, days_to_take_effect, valid_start_time, valid_end_time, user_days, use_time_type, use_start_time, use_end_time, use_number, editor, status, create_time, update_time + + + + + + + + + + + insert into tb_shop_coupon(shop_id, title, type, full_amount, discount_amount, description, number, left_number, + validity_type, valid_days, days_to_take_effect, valid_start_time, valid_end_time, + user_days, use_time_type, use_start_time, use_end_time, use_number, editor, status, + create_time, update_time) + values (#{shopId}, #{title}, #{type}, #{fullAmount}, #{discountAmount}, #{description}, #{number}, + #{leftNumber}, #{validityType}, #{validDays}, #{daysToTakeEffect}, #{validStartTime}, #{validEndTime}, + #{userDays}, #{useTimeType}, #{useStartTime}, #{useEndTime}, #{useNumber}, #{editor}, #{status}, + #{createTime}, #{updateTime}) + + + + insert into tb_shop_coupon(shop_id, title, type, full_amount, discount_amount, description, number, left_number, + validity_type, valid_days, days_to_take_effect, valid_start_time, valid_end_time, user_days, use_time_type, + use_start_time, use_end_time, use_number, editor, status, create_time, update_time) + values + + (#{entity.shopId}, #{entity.title}, #{entity.type}, #{entity.fullAmount}, #{entity.discountAmount}, + #{entity.description}, #{entity.number}, #{entity.leftNumber}, #{entity.validityType}, #{entity.validDays}, + #{entity.daysToTakeEffect}, #{entity.validStartTime}, #{entity.validEndTime}, #{entity.userDays}, + #{entity.useTimeType}, #{entity.useStartTime}, #{entity.useEndTime}, #{entity.useNumber}, #{entity.editor}, + #{entity.status}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_shop_coupon + + + shop_id = #{shopId}, + + + title = #{title}, + + + type = #{type}, + + + full_amount = #{fullAmount}, + + + discount_amount = #{discountAmount}, + + + description = #{description}, + + + number = #{number}, + + + left_number = #{leftNumber}, + + + validity_type = #{validityType}, + + + valid_days = #{validDays}, + + + days_to_take_effect = #{daysToTakeEffect}, + + + valid_start_time = #{validStartTime}, + + + valid_end_time = #{validEndTime}, + + + user_days = #{userDays}, + + + use_time_type = #{useTimeType}, + + + use_start_time = #{useStartTime}, + + + use_end_time = #{useEndTime}, + + + use_number = #{useNumber}, + + + editor = #{editor}, + + + status = #{status}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + + + delete + from tb_shop_coupon + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbShopCurrencyMapper.xml b/src/main/resources/mapper/TbShopCurrencyMapper.xml deleted file mode 100644 index 503f4e0..0000000 --- a/src/main/resources/mapper/TbShopCurrencyMapper.xml +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id, shop_id, prepare_amount, currency, decimals_digits, discount_round, merchant_id, - small_change, enable_custom_discount, max_discount, max_percent, biz_duration, allow_web_pay, - is_auto_to_zero, is_include_tax_price, tax_number, created_at, updated_at, auto_lock_screen, - voice_notification - - - discount_configs, service_charge - - - - delete from tb_shop_currency - where id = #{id,jdbcType=INTEGER} - - - insert into tb_shop_currency (id, shop_id, prepare_amount, - currency, decimals_digits, discount_round, - merchant_id, small_change, enable_custom_discount, - max_discount, max_percent, biz_duration, - allow_web_pay, is_auto_to_zero, is_include_tax_price, - tax_number, created_at, updated_at, - auto_lock_screen, voice_notification, discount_configs, - service_charge) - values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=VARCHAR}, #{prepareAmount,jdbcType=DECIMAL}, - #{currency,jdbcType=VARCHAR}, #{decimalsDigits,jdbcType=TINYINT}, #{discountRound,jdbcType=VARCHAR}, - #{merchantId,jdbcType=VARCHAR}, #{smallChange,jdbcType=TINYINT}, #{enableCustomDiscount,jdbcType=TINYINT}, - #{maxDiscount,jdbcType=DECIMAL}, #{maxPercent,jdbcType=DOUBLE}, #{bizDuration,jdbcType=VARCHAR}, - #{allowWebPay,jdbcType=TINYINT}, #{isAutoToZero,jdbcType=TINYINT}, #{isIncludeTaxPrice,jdbcType=TINYINT}, - #{taxNumber,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, - #{autoLockScreen,jdbcType=TINYINT}, #{voiceNotification,jdbcType=TINYINT}, #{discountConfigs,jdbcType=LONGVARCHAR}, - #{serviceCharge,jdbcType=LONGVARCHAR}) - - - insert into tb_shop_currency - - - id, - - - shop_id, - - - prepare_amount, - - - currency, - - - decimals_digits, - - - discount_round, - - - merchant_id, - - - small_change, - - - enable_custom_discount, - - - max_discount, - - - max_percent, - - - biz_duration, - - - allow_web_pay, - - - is_auto_to_zero, - - - is_include_tax_price, - - - tax_number, - - - created_at, - - - updated_at, - - - auto_lock_screen, - - - voice_notification, - - - discount_configs, - - - service_charge, - - - - - #{id,jdbcType=INTEGER}, - - - #{shopId,jdbcType=VARCHAR}, - - - #{prepareAmount,jdbcType=DECIMAL}, - - - #{currency,jdbcType=VARCHAR}, - - - #{decimalsDigits,jdbcType=TINYINT}, - - - #{discountRound,jdbcType=VARCHAR}, - - - #{merchantId,jdbcType=VARCHAR}, - - - #{smallChange,jdbcType=TINYINT}, - - - #{enableCustomDiscount,jdbcType=TINYINT}, - - - #{maxDiscount,jdbcType=DECIMAL}, - - - #{maxPercent,jdbcType=DOUBLE}, - - - #{bizDuration,jdbcType=VARCHAR}, - - - #{allowWebPay,jdbcType=TINYINT}, - - - #{isAutoToZero,jdbcType=TINYINT}, - - - #{isIncludeTaxPrice,jdbcType=TINYINT}, - - - #{taxNumber,jdbcType=VARCHAR}, - - - #{createdAt,jdbcType=BIGINT}, - - - #{updatedAt,jdbcType=BIGINT}, - - - #{autoLockScreen,jdbcType=TINYINT}, - - - #{voiceNotification,jdbcType=TINYINT}, - - - #{discountConfigs,jdbcType=LONGVARCHAR}, - - - #{serviceCharge,jdbcType=LONGVARCHAR}, - - - - - update tb_shop_currency - - - shop_id = #{shopId,jdbcType=VARCHAR}, - - - prepare_amount = #{prepareAmount,jdbcType=DECIMAL}, - - - currency = #{currency,jdbcType=VARCHAR}, - - - decimals_digits = #{decimalsDigits,jdbcType=TINYINT}, - - - discount_round = #{discountRound,jdbcType=VARCHAR}, - - - merchant_id = #{merchantId,jdbcType=VARCHAR}, - - - small_change = #{smallChange,jdbcType=TINYINT}, - - - enable_custom_discount = #{enableCustomDiscount,jdbcType=TINYINT}, - - - max_discount = #{maxDiscount,jdbcType=DECIMAL}, - - - max_percent = #{maxPercent,jdbcType=DOUBLE}, - - - biz_duration = #{bizDuration,jdbcType=VARCHAR}, - - - allow_web_pay = #{allowWebPay,jdbcType=TINYINT}, - - - is_auto_to_zero = #{isAutoToZero,jdbcType=TINYINT}, - - - is_include_tax_price = #{isIncludeTaxPrice,jdbcType=TINYINT}, - - - tax_number = #{taxNumber,jdbcType=VARCHAR}, - - - created_at = #{createdAt,jdbcType=BIGINT}, - - - updated_at = #{updatedAt,jdbcType=BIGINT}, - - - auto_lock_screen = #{autoLockScreen,jdbcType=TINYINT}, - - - voice_notification = #{voiceNotification,jdbcType=TINYINT}, - - - discount_configs = #{discountConfigs,jdbcType=LONGVARCHAR}, - - - service_charge = #{serviceCharge,jdbcType=LONGVARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_shop_currency - set shop_id = #{shopId,jdbcType=VARCHAR}, - prepare_amount = #{prepareAmount,jdbcType=DECIMAL}, - currency = #{currency,jdbcType=VARCHAR}, - decimals_digits = #{decimalsDigits,jdbcType=TINYINT}, - discount_round = #{discountRound,jdbcType=VARCHAR}, - merchant_id = #{merchantId,jdbcType=VARCHAR}, - small_change = #{smallChange,jdbcType=TINYINT}, - enable_custom_discount = #{enableCustomDiscount,jdbcType=TINYINT}, - max_discount = #{maxDiscount,jdbcType=DECIMAL}, - max_percent = #{maxPercent,jdbcType=DOUBLE}, - biz_duration = #{bizDuration,jdbcType=VARCHAR}, - allow_web_pay = #{allowWebPay,jdbcType=TINYINT}, - is_auto_to_zero = #{isAutoToZero,jdbcType=TINYINT}, - is_include_tax_price = #{isIncludeTaxPrice,jdbcType=TINYINT}, - tax_number = #{taxNumber,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT}, - auto_lock_screen = #{autoLockScreen,jdbcType=TINYINT}, - voice_notification = #{voiceNotification,jdbcType=TINYINT}, - discount_configs = #{discountConfigs,jdbcType=LONGVARCHAR}, - service_charge = #{serviceCharge,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=INTEGER} - - - update tb_shop_currency - set shop_id = #{shopId,jdbcType=VARCHAR}, - prepare_amount = #{prepareAmount,jdbcType=DECIMAL}, - currency = #{currency,jdbcType=VARCHAR}, - decimals_digits = #{decimalsDigits,jdbcType=TINYINT}, - discount_round = #{discountRound,jdbcType=VARCHAR}, - merchant_id = #{merchantId,jdbcType=VARCHAR}, - small_change = #{smallChange,jdbcType=TINYINT}, - enable_custom_discount = #{enableCustomDiscount,jdbcType=TINYINT}, - max_discount = #{maxDiscount,jdbcType=DECIMAL}, - max_percent = #{maxPercent,jdbcType=DOUBLE}, - biz_duration = #{bizDuration,jdbcType=VARCHAR}, - allow_web_pay = #{allowWebPay,jdbcType=TINYINT}, - is_auto_to_zero = #{isAutoToZero,jdbcType=TINYINT}, - is_include_tax_price = #{isIncludeTaxPrice,jdbcType=TINYINT}, - tax_number = #{taxNumber,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT}, - auto_lock_screen = #{autoLockScreen,jdbcType=TINYINT}, - voice_notification = #{voiceNotification,jdbcType=TINYINT} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbShopExtendMapper.xml b/src/main/resources/mapper/TbShopExtendMapper.xml new file mode 100644 index 0000000..817bd30 --- /dev/null +++ b/src/main/resources/mapper/TbShopExtendMapper.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + id + , shop_id, type, name, autoKey, value, update_time, create_time + + + + + + + + + + + diff --git a/src/main/resources/mapper/TbShopInfoMapper.xml b/src/main/resources/mapper/TbShopInfoMapper.xml index 9844f1a..f531d27 100644 --- a/src/main/resources/mapper/TbShopInfoMapper.xml +++ b/src/main/resources/mapper/TbShopInfoMapper.xml @@ -1,81 +1,82 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id - , account, shop_code, sub_title, merchant_id, shop_name, chain_name, back_img, - front_img, contact_name, phone, logo, is_deposit, is_supply, cover_img, share_img, - 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 - - - view - - select - , - from tb_shop_info where id = #{id,jdbcType=INTEGER} @@ -108,544 +109,6 @@ - - delete - from tb_shop_info - where id = #{id,jdbcType=INTEGER} - - - insert into tb_shop_info (id, account, shop_code, - sub_title, merchant_id, shop_name, - chain_name, back_img, front_img, - contact_name, phone, logo, - is_deposit, is_supply, cover_img, - share_img, detail, lat, - lng, mch_id, register_type, - is_wx_ma_independent, address, city, - type, industry, industry_name, - 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, view) - values (#{id,jdbcType=INTEGER}, #{account,jdbcType=VARCHAR}, #{shopCode,jdbcType=VARCHAR}, - #{subTitle,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{shopName,jdbcType=VARCHAR}, - #{chainName,jdbcType=VARCHAR}, #{backImg,jdbcType=VARCHAR}, #{frontImg,jdbcType=VARCHAR}, - #{contactName,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{logo,jdbcType=VARCHAR}, - #{isDeposit,jdbcType=TINYINT}, #{isSupply,jdbcType=TINYINT}, #{coverImg,jdbcType=VARCHAR}, - #{shareImg,jdbcType=VARCHAR}, #{detail,jdbcType=VARCHAR}, #{lat,jdbcType=VARCHAR}, - #{lng,jdbcType=VARCHAR}, #{mchId,jdbcType=VARCHAR}, #{registerType,jdbcType=VARCHAR}, - #{isWxMaIndependent,jdbcType=TINYINT}, #{address,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, - #{type,jdbcType=VARCHAR}, #{industry,jdbcType=VARCHAR}, #{industryName,jdbcType=VARCHAR}, - #{businessTime,jdbcType=VARCHAR}, #{postTime,jdbcType=VARCHAR}, #{postAmountLine,jdbcType=DECIMAL}, - #{onSale,jdbcType=TINYINT}, #{settleType,jdbcType=TINYINT}, #{settleTime,jdbcType=VARCHAR}, - #{enterAt,jdbcType=INTEGER}, #{expireAt,jdbcType=BIGINT}, #{status,jdbcType=TINYINT}, - #{average,jdbcType=REAL}, #{orderWaitPayMinute,jdbcType=INTEGER}, - #{supportDeviceNumber,jdbcType=INTEGER}, - #{distributeLevel,jdbcType=TINYINT}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, - #{proxyId,jdbcType=VARCHAR}, #{view,jdbcType=LONGVARCHAR}) - - - insert into tb_shop_info - - - id, - - - account, - - - shop_code, - - - sub_title, - - - merchant_id, - - - shop_name, - - - chain_name, - - - back_img, - - - front_img, - - - contact_name, - - - phone, - - - logo, - - - is_deposit, - - - is_supply, - - - cover_img, - - - share_img, - - - detail, - - - lat, - - - lng, - - - mch_id, - - - register_type, - - - is_wx_ma_independent, - - - address, - - - city, - - - type, - - - industry, - - - industry_name, - - - 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, - - - view, - - - - - #{id,jdbcType=INTEGER}, - - - #{account,jdbcType=VARCHAR}, - - - #{shopCode,jdbcType=VARCHAR}, - - - #{subTitle,jdbcType=VARCHAR}, - - - #{merchantId,jdbcType=VARCHAR}, - - - #{shopName,jdbcType=VARCHAR}, - - - #{chainName,jdbcType=VARCHAR}, - - - #{backImg,jdbcType=VARCHAR}, - - - #{frontImg,jdbcType=VARCHAR}, - - - #{contactName,jdbcType=VARCHAR}, - - - #{phone,jdbcType=VARCHAR}, - - - #{logo,jdbcType=VARCHAR}, - - - #{isDeposit,jdbcType=TINYINT}, - - - #{isSupply,jdbcType=TINYINT}, - - - #{coverImg,jdbcType=VARCHAR}, - - - #{shareImg,jdbcType=VARCHAR}, - - - #{detail,jdbcType=VARCHAR}, - - - #{lat,jdbcType=VARCHAR}, - - - #{lng,jdbcType=VARCHAR}, - - - #{mchId,jdbcType=VARCHAR}, - - - #{registerType,jdbcType=VARCHAR}, - - - #{isWxMaIndependent,jdbcType=TINYINT}, - - - #{address,jdbcType=VARCHAR}, - - - #{city,jdbcType=VARCHAR}, - - - #{type,jdbcType=VARCHAR}, - - - #{industry,jdbcType=VARCHAR}, - - - #{industryName,jdbcType=VARCHAR}, - - - #{businessTime,jdbcType=VARCHAR}, - - - #{postTime,jdbcType=VARCHAR}, - - - #{postAmountLine,jdbcType=DECIMAL}, - - - #{onSale,jdbcType=TINYINT}, - - - #{settleType,jdbcType=TINYINT}, - - - #{settleTime,jdbcType=VARCHAR}, - - - #{enterAt,jdbcType=INTEGER}, - - - #{expireAt,jdbcType=BIGINT}, - - - #{status,jdbcType=TINYINT}, - - - #{average,jdbcType=REAL}, - - - #{orderWaitPayMinute,jdbcType=INTEGER}, - - - #{supportDeviceNumber,jdbcType=INTEGER}, - - - #{distributeLevel,jdbcType=TINYINT}, - - - #{createdAt,jdbcType=BIGINT}, - - - #{updatedAt,jdbcType=BIGINT}, - - - #{proxyId,jdbcType=VARCHAR}, - - - #{view,jdbcType=LONGVARCHAR}, - - - - - update tb_shop_info - - - account = #{account,jdbcType=VARCHAR}, - - - shop_code = #{shopCode,jdbcType=VARCHAR}, - - - sub_title = #{subTitle,jdbcType=VARCHAR}, - - - merchant_id = #{merchantId,jdbcType=VARCHAR}, - - - shop_name = #{shopName,jdbcType=VARCHAR}, - - - chain_name = #{chainName,jdbcType=VARCHAR}, - - - back_img = #{backImg,jdbcType=VARCHAR}, - - - front_img = #{frontImg,jdbcType=VARCHAR}, - - - contact_name = #{contactName,jdbcType=VARCHAR}, - - - phone = #{phone,jdbcType=VARCHAR}, - - - logo = #{logo,jdbcType=VARCHAR}, - - - is_deposit = #{isDeposit,jdbcType=TINYINT}, - - - is_supply = #{isSupply,jdbcType=TINYINT}, - - - cover_img = #{coverImg,jdbcType=VARCHAR}, - - - share_img = #{shareImg,jdbcType=VARCHAR}, - - - detail = #{detail,jdbcType=VARCHAR}, - - - lat = #{lat,jdbcType=VARCHAR}, - - - lng = #{lng,jdbcType=VARCHAR}, - - - mch_id = #{mchId,jdbcType=VARCHAR}, - - - register_type = #{registerType,jdbcType=VARCHAR}, - - - is_wx_ma_independent = #{isWxMaIndependent,jdbcType=TINYINT}, - - - address = #{address,jdbcType=VARCHAR}, - - - city = #{city,jdbcType=VARCHAR}, - - - type = #{type,jdbcType=VARCHAR}, - - - industry = #{industry,jdbcType=VARCHAR}, - - - industry_name = #{industryName,jdbcType=VARCHAR}, - - - business_time = #{businessTime,jdbcType=VARCHAR}, - - - post_time = #{postTime,jdbcType=VARCHAR}, - - - post_amount_line = #{postAmountLine,jdbcType=DECIMAL}, - - - on_sale = #{onSale,jdbcType=TINYINT}, - - - settle_type = #{settleType,jdbcType=TINYINT}, - - - settle_time = #{settleTime,jdbcType=VARCHAR}, - - - enter_at = #{enterAt,jdbcType=INTEGER}, - - - expire_at = #{expireAt,jdbcType=BIGINT}, - - - status = #{status,jdbcType=TINYINT}, - - - average = #{average,jdbcType=REAL}, - - - order_wait_pay_minute = #{orderWaitPayMinute,jdbcType=INTEGER}, - - - support_device_number = #{supportDeviceNumber,jdbcType=INTEGER}, - - - distribute_level = #{distributeLevel,jdbcType=TINYINT}, - - - created_at = #{createdAt,jdbcType=BIGINT}, - - - updated_at = #{updatedAt,jdbcType=BIGINT}, - - - proxy_id = #{proxyId,jdbcType=VARCHAR}, - - - view = #{view,jdbcType=LONGVARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_shop_info - set account = #{account,jdbcType=VARCHAR}, - shop_code = #{shopCode,jdbcType=VARCHAR}, - sub_title = #{subTitle,jdbcType=VARCHAR}, - merchant_id = #{merchantId,jdbcType=VARCHAR}, - shop_name = #{shopName,jdbcType=VARCHAR}, - chain_name = #{chainName,jdbcType=VARCHAR}, - back_img = #{backImg,jdbcType=VARCHAR}, - front_img = #{frontImg,jdbcType=VARCHAR}, - contact_name = #{contactName,jdbcType=VARCHAR}, - phone = #{phone,jdbcType=VARCHAR}, - logo = #{logo,jdbcType=VARCHAR}, - is_deposit = #{isDeposit,jdbcType=TINYINT}, - is_supply = #{isSupply,jdbcType=TINYINT}, - cover_img = #{coverImg,jdbcType=VARCHAR}, - share_img = #{shareImg,jdbcType=VARCHAR}, - detail = #{detail,jdbcType=VARCHAR}, - lat = #{lat,jdbcType=VARCHAR}, - lng = #{lng,jdbcType=VARCHAR}, - mch_id = #{mchId,jdbcType=VARCHAR}, - register_type = #{registerType,jdbcType=VARCHAR}, - is_wx_ma_independent = #{isWxMaIndependent,jdbcType=TINYINT}, - address = #{address,jdbcType=VARCHAR}, - city = #{city,jdbcType=VARCHAR}, - type = #{type,jdbcType=VARCHAR}, - industry = #{industry,jdbcType=VARCHAR}, - industry_name = #{industryName,jdbcType=VARCHAR}, - business_time = #{businessTime,jdbcType=VARCHAR}, - post_time = #{postTime,jdbcType=VARCHAR}, - post_amount_line = #{postAmountLine,jdbcType=DECIMAL}, - on_sale = #{onSale,jdbcType=TINYINT}, - settle_type = #{settleType,jdbcType=TINYINT}, - settle_time = #{settleTime,jdbcType=VARCHAR}, - enter_at = #{enterAt,jdbcType=INTEGER}, - expire_at = #{expireAt,jdbcType=BIGINT}, - status = #{status,jdbcType=TINYINT}, - average = #{average,jdbcType=REAL}, - order_wait_pay_minute = #{orderWaitPayMinute,jdbcType=INTEGER}, - support_device_number = #{supportDeviceNumber,jdbcType=INTEGER}, - distribute_level = #{distributeLevel,jdbcType=TINYINT}, - created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT}, - proxy_id = #{proxyId,jdbcType=VARCHAR}, - view = #{view,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=INTEGER} - - - update tb_shop_info - set account = #{account,jdbcType=VARCHAR}, - shop_code = #{shopCode,jdbcType=VARCHAR}, - sub_title = #{subTitle,jdbcType=VARCHAR}, - merchant_id = #{merchantId,jdbcType=VARCHAR}, - shop_name = #{shopName,jdbcType=VARCHAR}, - chain_name = #{chainName,jdbcType=VARCHAR}, - back_img = #{backImg,jdbcType=VARCHAR}, - front_img = #{frontImg,jdbcType=VARCHAR}, - contact_name = #{contactName,jdbcType=VARCHAR}, - phone = #{phone,jdbcType=VARCHAR}, - logo = #{logo,jdbcType=VARCHAR}, - is_deposit = #{isDeposit,jdbcType=TINYINT}, - is_supply = #{isSupply,jdbcType=TINYINT}, - cover_img = #{coverImg,jdbcType=VARCHAR}, - share_img = #{shareImg,jdbcType=VARCHAR}, - detail = #{detail,jdbcType=VARCHAR}, - lat = #{lat,jdbcType=VARCHAR}, - lng = #{lng,jdbcType=VARCHAR}, - mch_id = #{mchId,jdbcType=VARCHAR}, - register_type = #{registerType,jdbcType=VARCHAR}, - is_wx_ma_independent = #{isWxMaIndependent,jdbcType=TINYINT}, - address = #{address,jdbcType=VARCHAR}, - city = #{city,jdbcType=VARCHAR}, - type = #{type,jdbcType=VARCHAR}, - industry = #{industry,jdbcType=VARCHAR}, - industry_name = #{industryName,jdbcType=VARCHAR}, - business_time = #{businessTime,jdbcType=VARCHAR}, - post_time = #{postTime,jdbcType=VARCHAR}, - post_amount_line = #{postAmountLine,jdbcType=DECIMAL}, - on_sale = #{onSale,jdbcType=TINYINT}, - settle_type = #{settleType,jdbcType=TINYINT}, - settle_time = #{settleTime,jdbcType=VARCHAR}, - enter_at = #{enterAt,jdbcType=INTEGER}, - expire_at = #{expireAt,jdbcType=BIGINT}, - status = #{status,jdbcType=TINYINT}, - average = #{average,jdbcType=REAL}, - order_wait_pay_minute = #{orderWaitPayMinute,jdbcType=INTEGER}, - support_device_number = #{supportDeviceNumber,jdbcType=INTEGER}, - distribute_level = #{distributeLevel,jdbcType=TINYINT}, - created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT}, - proxy_id = #{proxyId,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - select - , - from tb_shop_info where id IN #{item} - \ No newline at end of file + + + diff --git a/src/main/resources/mapper/TbShopSongMapper.xml b/src/main/resources/mapper/TbShopSongMapper.xml index 6f213b7..f3f104c 100644 --- a/src/main/resources/mapper/TbShopSongMapper.xml +++ b/src/main/resources/mapper/TbShopSongMapper.xml @@ -36,7 +36,7 @@ select @@ -24,13 +26,13 @@ delete from tb_shop_user_flow where id = #{id,jdbcType=INTEGER} - + insert into tb_shop_user_flow (id, shop_user_id, amount, balance, biz_code, biz_name, - create_time, type) + create_time, type,is_return,remark) values (#{id,jdbcType=INTEGER}, #{shopUserId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, #{balance,jdbcType=DECIMAL}, #{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR}, - #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR}) + #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR},#{isReturn,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR}) insert into tb_shop_user_flow diff --git a/src/main/resources/mapper/TbShopUserMapper.xml b/src/main/resources/mapper/TbShopUserMapper.xml index e13ffa6..c476b4c 100644 --- a/src/main/resources/mapper/TbShopUserMapper.xml +++ b/src/main/resources/mapper/TbShopUserMapper.xml @@ -31,12 +31,13 @@ + 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 + + + + - - select - - from tb_split_accounts - where id = #{id,jdbcType=INTEGER} - - - delete from tb_split_accounts - where id = #{id,jdbcType=INTEGER} - - - insert into tb_split_accounts (id, merchant_id, shop_id, - coupons_price, conpons_amount, is_split, - order_amount, create_time, split_time, - trade_day,origin_amount) - values (#{id,jdbcType=INTEGER}, #{merchantId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, - #{couponsPrice,jdbcType=DECIMAL}, #{conponsAmount,jdbcType=DECIMAL}, #{isSplit,jdbcType=VARCHAR}, - #{orderAmount,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{splitTime,jdbcType=TIMESTAMP}, - #{tradeDay,jdbcType=VARCHAR},#{originAmount,jdbcType=DECIMAL}) - - - insert into tb_split_accounts - - - id, - - - merchant_id, - - - shop_id, - - - coupons_price, - - - conpons_amount, - - - is_split, - - - order_amount, - - - create_time, - - - split_time, - - - trade_day, - - - - - #{id,jdbcType=INTEGER}, - - - #{merchantId,jdbcType=INTEGER}, - - - #{shopId,jdbcType=INTEGER}, - - - #{couponsPrice,jdbcType=DECIMAL}, - - - #{conponsAmount,jdbcType=DECIMAL}, - - - #{isSplit,jdbcType=VARCHAR}, - - - #{orderAmount,jdbcType=DECIMAL}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{splitTime,jdbcType=TIMESTAMP}, - - - #{tradeDay,jdbcType=VARCHAR}, - - - - - update tb_split_accounts - - - merchant_id = #{merchantId,jdbcType=INTEGER}, - - - shop_id = #{shopId,jdbcType=INTEGER}, - - - coupons_price = #{couponsPrice,jdbcType=DECIMAL}, - - - conpons_amount = #{conponsAmount,jdbcType=DECIMAL}, - - - is_split = #{isSplit,jdbcType=VARCHAR}, - - - order_amount = #{orderAmount,jdbcType=DECIMAL}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - split_time = #{splitTime,jdbcType=TIMESTAMP}, - - - trade_day = #{tradeDay,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_split_accounts - set merchant_id = #{merchantId,jdbcType=INTEGER}, - shop_id = #{shopId,jdbcType=INTEGER}, - coupons_price = #{couponsPrice,jdbcType=DECIMAL}, - conpons_amount = #{conponsAmount,jdbcType=DECIMAL}, - is_split = #{isSplit,jdbcType=VARCHAR}, - order_amount = #{orderAmount,jdbcType=DECIMAL}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - split_time = #{splitTime,jdbcType=TIMESTAMP}, - trade_day = #{tradeDay,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbSystemCouponsMapper.xml b/src/main/resources/mapper/TbSystemCouponsMapper.xml deleted file mode 100644 index 115e91f..0000000 --- a/src/main/resources/mapper/TbSystemCouponsMapper.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - id, name, coupons_price, coupons_amount, status, create_time, update_time, end_time,type_name - - - - - - delete from tb_system_coupons - where id = #{id,jdbcType=INTEGER} - - - insert into tb_system_coupons (id, name, coupons_price, - coupons_amount, status, create_time, - update_time, end_time,type_name) - values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{couponsPrice,jdbcType=DECIMAL}, - #{couponsAmount,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, - #{updateTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{typeName,jdbcType=VARCHAR}) - - - insert into tb_system_coupons - - - id, - - - name, - - - coupons_price, - - - coupons_amount, - - - status, - - - create_time, - - - update_time, - - - end_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{name,jdbcType=VARCHAR}, - - - #{couponsPrice,jdbcType=DECIMAL}, - - - #{couponsAmount,jdbcType=DECIMAL}, - - - #{status,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{updateTime,jdbcType=TIMESTAMP}, - - - #{endTime,jdbcType=TIMESTAMP}, - - - - - update tb_system_coupons - - - name = #{name,jdbcType=VARCHAR}, - - - coupons_price = #{couponsPrice,jdbcType=DECIMAL}, - - - coupons_amount = #{couponsAmount,jdbcType=DECIMAL}, - - - status = #{status,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - - - end_time = #{endTime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_system_coupons - set name = #{name,jdbcType=VARCHAR}, - coupons_price = #{couponsPrice,jdbcType=DECIMAL}, - coupons_amount = #{couponsAmount,jdbcType=DECIMAL}, - status = #{status,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP}, - end_time = #{endTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbUserCouponsMapper.xml b/src/main/resources/mapper/TbUserCouponsMapper.xml deleted file mode 100644 index b746d3c..0000000 --- a/src/main/resources/mapper/TbUserCouponsMapper.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - - - - - - - - id, user_id, coupons_price, coupons_amount, status, create_time, update_time, end_time,is_double - - - - - - - delete from tb_user_coupons - where id = #{id,jdbcType=INTEGER} - - - insert into tb_user_coupons (id, user_id, coupons_price, - coupons_amount, status, create_time, - update_time, end_time,is_double) - values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{couponsPrice,jdbcType=DECIMAL}, - #{couponsAmount,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, - #{updateTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{isDouble,jdbcType=VARCHAR}) - - - insert into tb_user_coupons - - - id, - - - user_id, - - - coupons_price, - - - coupons_amount, - - - status, - - - create_time, - - - update_time, - - - end_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{userId,jdbcType=VARCHAR}, - - - #{couponsPrice,jdbcType=DECIMAL}, - - - #{couponsAmount,jdbcType=DECIMAL}, - - - #{status,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{updateTime,jdbcType=TIMESTAMP}, - - - #{endTime,jdbcType=TIMESTAMP}, - - - - - update tb_user_coupons - - - user_id = #{userId,jdbcType=VARCHAR}, - - - coupons_price = #{couponsPrice,jdbcType=DECIMAL}, - - - coupons_amount = #{couponsAmount,jdbcType=DECIMAL}, - - - status = #{status,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - - - end_time = #{endTime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_user_coupons - set user_id = #{userId,jdbcType=VARCHAR}, - coupons_price = #{couponsPrice,jdbcType=DECIMAL}, - coupons_amount = #{couponsAmount,jdbcType=DECIMAL}, - status = #{status,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - update_time = #{updateTime,jdbcType=TIMESTAMP}, - end_time = #{endTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbWiningParamsMapper.xml b/src/main/resources/mapper/TbWiningParamsMapper.xml deleted file mode 100644 index 00f9f38..0000000 --- a/src/main/resources/mapper/TbWiningParamsMapper.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - id, min_price, max_price, wining_num, wining_user_num,status - - - - - delete from tb_wining_params - where id = #{id,jdbcType=INTEGER} - - - insert into tb_wining_params (id, min_price, max_price, - wining_num, wining_user_num) - values (#{id,jdbcType=INTEGER}, #{minPrice,jdbcType=DECIMAL}, #{maxPrice,jdbcType=DECIMAL}, - #{winingNum,jdbcType=INTEGER}, #{winingUserNum,jdbcType=INTEGER}) - - - insert into tb_wining_params - - - id, - - - min_price, - - - max_price, - - - wining_num, - - - wining_user_num, - - - - - #{id,jdbcType=INTEGER}, - - - #{minPrice,jdbcType=DECIMAL}, - - - #{maxPrice,jdbcType=DECIMAL}, - - - #{winingNum,jdbcType=INTEGER}, - - - #{winingUserNum,jdbcType=INTEGER}, - - - - - update tb_wining_params - - - min_price = #{minPrice,jdbcType=DECIMAL}, - - - max_price = #{maxPrice,jdbcType=DECIMAL}, - - - wining_num = #{winingNum,jdbcType=INTEGER}, - - - wining_user_num = #{winingUserNum,jdbcType=INTEGER}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_wining_params - set min_price = #{minPrice,jdbcType=DECIMAL}, - max_price = #{maxPrice,jdbcType=DECIMAL}, - wining_num = #{winingNum,jdbcType=INTEGER}, - wining_user_num = #{winingUserNum,jdbcType=INTEGER} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbWiningUserMapper.xml b/src/main/resources/mapper/TbWiningUserMapper.xml deleted file mode 100644 index 99bc24d..0000000 --- a/src/main/resources/mapper/TbWiningUserMapper.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - id, user_name, order_no, order_amount, is_user, create_time, is_refund, refund_amount, - refund_no, refund_pay_type, trade_day, refund_time - - - - delete from tb_wining_user - where id = #{id,jdbcType=INTEGER} - - - insert into tb_wining_user (id, user_name, order_no, - order_amount, is_user, create_time, - is_refund, refund_amount, refund_no, - refund_pay_type, trade_day, refund_time - ) - values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, - #{orderAmount,jdbcType=DECIMAL}, #{isUser,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, - #{isRefund,jdbcType=VARCHAR}, #{refundAmount,jdbcType=DECIMAL}, #{refundNo,jdbcType=VARCHAR}, - #{refundPayType,jdbcType=VARCHAR}, #{tradeDay,jdbcType=VARCHAR}, #{refundTime,jdbcType=TIMESTAMP} - ) - - - insert into tb_wining_user - - - id, - - - user_name, - - - order_no, - - - order_amount, - - - is_user, - - - create_time, - - - is_refund, - - - refund_amount, - - - refund_no, - - - refund_pay_type, - - - trade_day, - - - refund_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{userName,jdbcType=VARCHAR}, - - - #{orderNo,jdbcType=VARCHAR}, - - - #{orderAmount,jdbcType=DECIMAL}, - - - #{isUser,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{isRefund,jdbcType=VARCHAR}, - - - #{refundAmount,jdbcType=DECIMAL}, - - - #{refundNo,jdbcType=VARCHAR}, - - - #{refundPayType,jdbcType=VARCHAR}, - - - #{tradeDay,jdbcType=VARCHAR}, - - - #{refundTime,jdbcType=TIMESTAMP}, - - - - - update tb_wining_user - - - user_name = #{userName,jdbcType=VARCHAR}, - - - order_no = #{orderNo,jdbcType=VARCHAR}, - - - order_amount = #{orderAmount,jdbcType=DECIMAL}, - - - is_user = #{isUser,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - is_refund = #{isRefund,jdbcType=VARCHAR}, - - - refund_amount = #{refundAmount,jdbcType=DECIMAL}, - - - refund_no = #{refundNo,jdbcType=VARCHAR}, - - - refund_pay_type = #{refundPayType,jdbcType=VARCHAR}, - - - trade_day = #{tradeDay,jdbcType=VARCHAR}, - - - refund_time = #{refundTime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_wining_user - set user_name = #{userName,jdbcType=VARCHAR}, - order_no = #{orderNo,jdbcType=VARCHAR}, - order_amount = #{orderAmount,jdbcType=DECIMAL}, - is_user = #{isUser,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - is_refund = #{isRefund,jdbcType=VARCHAR}, - refund_amount = #{refundAmount,jdbcType=DECIMAL}, - refund_no = #{refundNo,jdbcType=VARCHAR}, - refund_pay_type = #{refundPayType,jdbcType=VARCHAR}, - trade_day = #{tradeDay,jdbcType=VARCHAR}, - refund_time = #{refundTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=INTEGER} - - - \ No newline at end of file diff --git a/src/main/resources/mapper/TbYhqParamsMapper.xml b/src/main/resources/mapper/TbYhqParamsMapper.xml deleted file mode 100644 index 6636929..0000000 --- a/src/main/resources/mapper/TbYhqParamsMapper.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - id, name, min_price, max_price, status - - - - - delete from tb_yhq_params - where id = #{id,jdbcType=INTEGER} - - - insert into tb_yhq_params (id, name, min_price, - max_price, status) - values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{minPrice,jdbcType=DECIMAL}, - #{maxPrice,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}) - - - insert into tb_yhq_params - - - id, - - - name, - - - min_price, - - - max_price, - - - status, - - - - - #{id,jdbcType=INTEGER}, - - - #{name,jdbcType=VARCHAR}, - - - #{minPrice,jdbcType=DECIMAL}, - - - #{maxPrice,jdbcType=DECIMAL}, - - - #{status,jdbcType=VARCHAR}, - - - - - update tb_yhq_params - - - name = #{name,jdbcType=VARCHAR}, - - - min_price = #{minPrice,jdbcType=DECIMAL}, - - - max_price = #{maxPrice,jdbcType=DECIMAL}, - - - status = #{status,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update tb_yhq_params - set name = #{name,jdbcType=VARCHAR}, - min_price = #{minPrice,jdbcType=DECIMAL}, - max_price = #{maxPrice,jdbcType=DECIMAL}, - status = #{status,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/ViewOrderMapper.xml b/src/main/resources/mapper/ViewOrderMapper.xml deleted file mode 100644 index ad79f52..0000000 --- a/src/main/resources/mapper/ViewOrderMapper.xml +++ /dev/null @@ -1,305 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cart_list - - - insert into view_order (ali_paid_amount, id, amount, - bank_paid_amount, billing_id, cash_paid_amount, - created_at, deduct_score, deposit_paid_amount, - discount_amount, freight_amount, is_master, - is_vip, master_id, member_id, - order_no, order_type, other_paid_amount, - paid_time, pay_amount, product_score, - product_type, ref_order_id, refund_able, - refund_amount, send_type, settlement_amount, - shop_id, small_change, status, - table_id, table_party, terminal_snap, - user_id, virtual_paid_amount, wx_paid_amount, - cart_list) - values (#{aliPaidAmount,jdbcType=DECIMAL}, #{id,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, - #{bankPaidAmount,jdbcType=DECIMAL}, #{billingId,jdbcType=VARCHAR}, #{cashPaidAmount,jdbcType=DECIMAL}, - #{createdAt,jdbcType=BIGINT}, #{deductScore,jdbcType=INTEGER}, #{depositPaidAmount,jdbcType=DECIMAL}, - #{discountAmount,jdbcType=DECIMAL}, #{freightAmount,jdbcType=DECIMAL}, #{isMaster,jdbcType=TINYINT}, - #{isVip,jdbcType=TINYINT}, #{masterId,jdbcType=VARCHAR}, #{memberId,jdbcType=VARCHAR}, - #{orderNo,jdbcType=VARCHAR}, #{orderType,jdbcType=VARCHAR}, #{otherPaidAmount,jdbcType=DECIMAL}, - #{paidTime,jdbcType=BIGINT}, #{payAmount,jdbcType=DECIMAL}, #{productScore,jdbcType=INTEGER}, - #{productType,jdbcType=VARCHAR}, #{refOrderId,jdbcType=VARCHAR}, #{refundAble,jdbcType=TINYINT}, - #{refundAmount,jdbcType=DECIMAL}, #{sendType,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}, - #{shopId,jdbcType=VARCHAR}, #{smallChange,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, - #{tableId,jdbcType=VARCHAR}, #{tableParty,jdbcType=VARCHAR}, #{terminalSnap,jdbcType=VARCHAR}, - #{userId,jdbcType=VARCHAR}, #{virtualPaidAmount,jdbcType=DECIMAL}, #{wxPaidAmount,jdbcType=DECIMAL}, - #{cartList,jdbcType=LONGVARCHAR}) - - - insert into view_order - - - ali_paid_amount, - - - id, - - - amount, - - - bank_paid_amount, - - - billing_id, - - - cash_paid_amount, - - - created_at, - - - deduct_score, - - - deposit_paid_amount, - - - discount_amount, - - - freight_amount, - - - is_master, - - - is_vip, - - - master_id, - - - member_id, - - - order_no, - - - order_type, - - - other_paid_amount, - - - paid_time, - - - pay_amount, - - - product_score, - - - product_type, - - - ref_order_id, - - - refund_able, - - - refund_amount, - - - send_type, - - - settlement_amount, - - - shop_id, - - - small_change, - - - status, - - - table_id, - - - table_party, - - - terminal_snap, - - - user_id, - - - virtual_paid_amount, - - - wx_paid_amount, - - - cart_list, - - - - - #{aliPaidAmount,jdbcType=DECIMAL}, - - - #{id,jdbcType=INTEGER}, - - - #{amount,jdbcType=DECIMAL}, - - - #{bankPaidAmount,jdbcType=DECIMAL}, - - - #{billingId,jdbcType=VARCHAR}, - - - #{cashPaidAmount,jdbcType=DECIMAL}, - - - #{createdAt,jdbcType=BIGINT}, - - - #{deductScore,jdbcType=INTEGER}, - - - #{depositPaidAmount,jdbcType=DECIMAL}, - - - #{discountAmount,jdbcType=DECIMAL}, - - - #{freightAmount,jdbcType=DECIMAL}, - - - #{isMaster,jdbcType=TINYINT}, - - - #{isVip,jdbcType=TINYINT}, - - - #{masterId,jdbcType=VARCHAR}, - - - #{memberId,jdbcType=VARCHAR}, - - - #{orderNo,jdbcType=VARCHAR}, - - - #{orderType,jdbcType=VARCHAR}, - - - #{otherPaidAmount,jdbcType=DECIMAL}, - - - #{paidTime,jdbcType=BIGINT}, - - - #{payAmount,jdbcType=DECIMAL}, - - - #{productScore,jdbcType=INTEGER}, - - - #{productType,jdbcType=VARCHAR}, - - - #{refOrderId,jdbcType=VARCHAR}, - - - #{refundAble,jdbcType=TINYINT}, - - - #{refundAmount,jdbcType=DECIMAL}, - - - #{sendType,jdbcType=VARCHAR}, - - - #{settlementAmount,jdbcType=DECIMAL}, - - - #{shopId,jdbcType=VARCHAR}, - - - #{smallChange,jdbcType=DECIMAL}, - - - #{status,jdbcType=VARCHAR}, - - - #{tableId,jdbcType=VARCHAR}, - - - #{tableParty,jdbcType=VARCHAR}, - - - #{terminalSnap,jdbcType=VARCHAR}, - - - #{userId,jdbcType=VARCHAR}, - - - #{virtualPaidAmount,jdbcType=DECIMAL}, - - - #{wxPaidAmount,jdbcType=DECIMAL}, - - - #{cartList,jdbcType=LONGVARCHAR}, - - - - \ No newline at end of file diff --git a/src/main/resources/spy.properties b/src/main/resources/spy.properties new file mode 100644 index 0000000..1a0d1db --- /dev/null +++ b/src/main/resources/spy.properties @@ -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