37 Commits

Author SHA1 Message Date
2b7ca62abf 1.增加台桌状态 2024-08-21 09:21:07 +08:00
da9f1ab68f 1.增加台桌状态 2024-08-21 09:12:52 +08:00
eb424d8eb4 Merge remote-tracking branch 'origin/test' into dkxd2
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
2024-08-21 09:11:59 +08:00
a12a1d2e1f 1.增加台桌状态 2024-08-21 09:09:44 +08:00
牛叉闪闪
af3ea12121 Merge remote-tracking branch 'origin/hph' into test 2024-08-20 17:18:26 +08:00
牛叉闪闪
653254f9f3 添加员工折扣 2024-08-20 17:17:55 +08:00
d8027c92b2 1.增加mybatisplus依赖 2024-08-20 17:03:51 +08:00
8d9deb43a3 Merge remote-tracking branch 'origin/hph' into zs 2024-08-20 14:30:24 +08:00
牛叉闪闪
6b436da4d3 加入购物车取消耗材控制 2024-08-20 14:06:06 +08:00
796f43299f 1.代客下单相关接口修改 2024-08-20 13:23:13 +08:00
46133d7d16 1.查询商品返回规格上下架信息字段 2024-08-19 14:35:55 +08:00
61157d730c 1.耗材check值错误修复 2024-08-17 15:00:46 +08:00
牛叉闪闪
563541d929 Merge remote-tracking branch 'origin/dev' into hph 2024-08-16 15:39:01 +08:00
牛叉闪闪
8f7ea02d06 加入购物车添加耗材控制 2024-08-16 15:38:47 +08:00
cee4643925 1.修改库存增加库存记录 2024-08-16 14:46:30 +08:00
牛叉闪闪
4d462a1d3e 加入购物车添加耗材控制 2024-08-16 14:16:15 +08:00
牛叉闪闪
397c1b4df3 Merge remote-tracking branch 'origin/dev' into hph 2024-08-16 14:15:51 +08:00
38b03b556c 1.推送校验耗材是否开启check 2024-08-16 13:51:06 +08:00
牛叉闪闪
178f3c0831 加入购物车添加耗材控制 2024-08-14 16:01:11 +08:00
df75a74822 1.推送 2024-08-14 15:48:39 +08:00
dad47eb0c8 1.商品查询库存不准确问题 2024-08-14 15:41:49 +08:00
b0243a9ddd 1.推送校验状态 2024-08-14 14:58:50 +08:00
5a0112132d Merge remote-tracking branch 'origin/dev' into zs
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
2024-08-14 14:11:53 +08:00
牛叉闪闪
4a0a548565 加入购物车添加耗材控制 2024-08-14 11:35:39 +08:00
牛叉闪闪
6c6a447a5e 加入购物车添加耗材控制 2024-08-14 11:16:28 +08:00
146cb0f00b Merge remote-tracking branch 'origin/dev' into zs
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java
2024-08-14 09:44:53 +08:00
牛叉闪闪
dc6df17a3f 修改商品规格加入购物车 2024-08-14 09:43:56 +08:00
牛叉闪闪
780707e55c 修改商品规格加入购物车 2024-08-14 09:40:41 +08:00
牛叉闪闪
b5bc0f2e0a 修改商品规格加入购物车 2024-08-14 09:38:44 +08:00
e640226629 1.推送 2024-08-13 14:36:16 +08:00
148440cb31 1.无法修改库存fix 2024-08-13 14:33:12 +08:00
牛叉闪闪
d93bfd24a1 添加获取最大折扣接口 2024-08-13 14:30:22 +08:00
f7b845201c 1.无法修改库存fix 2024-08-13 09:06:07 +08:00
a8b9223454 Merge remote-tracking branch 'origin/zs2' into dev 2024-08-12 15:13:43 +08:00
22eadf7193 1.推送增加店铺开关校验 2024-08-12 14:35:27 +08:00
923ee6f1cb 1.上下架售罄接口 2024-08-12 14:25:14 +08:00
86df7addd6 1.代客下单相关接口 2024-08-09 16:07:00 +08:00
62 changed files with 1779 additions and 270 deletions

85
pom.xml
View File

@@ -48,11 +48,11 @@
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>4.5.18</version> <version>4.5.18</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>--> <!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>--> <!-- <artifactId>fastjson</artifactId>-->
<!-- <version>1.2.9</version>--> <!-- <version>1.2.9</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
@@ -185,30 +185,57 @@
<version>2.2.0</version> <version>2.2.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<!-- <profiles>--> <!-- <profiles>-->
<!-- <profile>--> <!-- <profile>-->
<!-- <id>dev</id>--> <!-- <id>dev</id>-->
<!-- <properties>--> <!-- <properties>-->
<!-- <env>dev</env>--> <!-- <env>dev</env>-->
<!-- </properties>--> <!-- </properties>-->
<!-- <activation>--> <!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>--> <!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>--> <!-- </activation>-->
<!-- </profile>--> <!-- </profile>-->
<!-- <profile>--> <!-- <profile>-->
<!-- <id>test</id>--> <!-- <id>test</id>-->
<!-- <properties>--> <!-- <properties>-->
<!-- <env>test</env>--> <!-- <env>test</env>-->
<!-- </properties>--> <!-- </properties>-->
<!-- </profile>--> <!-- </profile>-->
<!-- <profile>--> <!-- <profile>-->
<!-- <id>pro</id>--> <!-- <id>pro</id>-->
<!-- <properties>--> <!-- <properties>-->
<!-- <env>pro</env>--> <!-- <env>pro</env>-->
<!-- </properties>--> <!-- </properties>-->
<!-- </profile>--> <!-- </profile>-->
<!-- </profiles>--> <!-- </profiles>-->
<build> <build>
<plugins> <plugins>
@@ -266,4 +293,4 @@
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -1,7 +1,6 @@
package com.chaozhanggui.system.cashierservice; package com.chaozhanggui.system.cashierservice;
import com.chaozhanggui.system.cashierservice.task.ConsInfoTask;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -45,7 +44,6 @@ public class Shell {
@Bean @Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) { public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return (args) -> { return (args) -> {
// ctx.getBean(ConsInfoTask.class).init();
logger.info("=========================启动完成=========================="); logger.info("=========================启动完成==========================");
}; };
} }

View File

@@ -0,0 +1,26 @@
package com.chaozhanggui.system.cashierservice.annotation;
import com.chaozhanggui.system.cashierservice.bean.*;
import java.lang.annotation.*;
/**
* 日志注解
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyLog {
String value() default "未命名日志";
LogTag tag();
OperationLogType operationLogType() default OperationLogType.NULL;
boolean write() default false;
GetKeyWith getKeyWith() default GetKeyWith.WITH_NULL;
String keyName() default "";
OperationLogState operationLogstate() default OperationLogState.UN_HTTP_STATE;
ActionType actionType() default ActionType.SELECT;
LogType type() default LogType.INFO;
boolean showBody() default false;
}

View File

@@ -0,0 +1,201 @@
package com.chaozhanggui.system.cashierservice.aop;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrFormatter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
import com.chaozhanggui.system.cashierservice.bean.GetKeyWith;
import lombok.extern.log4j.Log4j2;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Aspect
@Order
@Component
@Log4j2
public class LogAop {
@Pointcut("@annotation(com.chaozhanggui.system.cashierservice.annotation.MyLog)")
private void getLogPointCut() {
}
private String getRequestBodyInfo(HttpServletRequest request) {
try {
//利用InputStreamReader将字节流转换为字符流
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(request.getInputStream()));
String string;
StringBuilder stringBuffer=new StringBuilder();
//读取字符流的字符拼接在stringBufferStringBuffer在进行字符串处理时不生成新的对象在内存使用上要优于String类
while((string=bufferedReader.readLine())!=null){
stringBuffer.append(string);
}
return stringBuffer.toString();
}catch (Exception e) {
log.error(e);
}
return "";
}
@Async
public void writeLog(String remoteAddr, String url, MyLog logAnnotation, Map<String, String[]> parameterMap, String bodyInfo, Object resp, long duration) {
if (!logAnnotation.write()) return;
// 系统操作日志, 异步事件
String keyVal = null;
JSONObject jsonObject = JSON.parseObject(bodyInfo);
if (logAnnotation.keyName() != null && jsonObject != null) {
if (GetKeyWith.WITH_POST.equals(logAnnotation.getKeyWith())) {
keyVal = jsonObject.getString(logAnnotation.keyName());
}else if (GetKeyWith.WITH_GET.equals(logAnnotation.getKeyWith())) {
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
if (entry.getKey().equals(logAnnotation.keyName())) {
keyVal = entry.getValue()[0];
}
}
}
}
// SystemOperationLog operationLog = new SystemOperationLog();
// operationLog.setMsg(logAnnotation.tag().getValue() + " " + logAnnotation.value())
// .setKeyValue(keyVal)
// .setKeyName(logAnnotation.keyName())
// .setState(logAnnotation.operationLogstate())
// .setType(logAnnotation.operationLogType())
// .setRespData(resp)
// .setDuration(duration)
// .setIp(remoteAddr)
// .setUrl(url)
// .setReqData(jsonObject);
// Utils.publishEvent(operationLog, OperationLogEvent.class);
}
/**
* 配置环绕通知,使用在方法logPointcut()上注册的切入点
*
* @param joinPoint join point for advice
*/
@Around("getLogPointCut()")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
String logInfo = "\033[34m请求地址: {}, 请求ip: {}, 请求方式: {}, GET参数: {}, POST参数: {}\033[0m";
String logStr = "";
String bodyInfo = "";
Map<String, String[]> parameterMap = new HashMap<>();
HttpServletRequest request = null;
String remoteAddr = "";
if (attributes != null) {
request = attributes.getRequest();
if (request.getHeader("X-Forwarded-For") != null) {
remoteAddr = request.getHeader("X-Forwarded-For").split(",")[0];
} else {
remoteAddr = request.getRemoteAddr();
}
parameterMap = request.getParameterMap();
bodyInfo = getRequestBodyInfo(request);
logStr = StrFormatter.format(logInfo,
request.getRequestURI(), remoteAddr, request.getMethod(), request.getQueryString(), bodyInfo);
log.info(logStr);
}
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
MyLog logAnnotation = method.getAnnotation(MyLog.class);
// 开始时间
long startTime = DateUtil.current(false);
Object result = null;
Exception error = null;
try {
result = joinPoint.proceed();
return result;
}catch (Exception e) {
error = e;
throw e;
}
finally {
long endTime = DateUtil.current(false);
writeLog(remoteAddr, request != null ? request.getRequestURI() : "", logAnnotation, parameterMap, bodyInfo, result == null ? Objects.requireNonNull(error).getCause() + error.getMessage(): result, endTime - startTime);
// 异步记录日志
if (logAnnotation.showBody()) {
logInfo = "\033[32;4m包名: {}, 方法名: {}, 描述: {}, 操作类型: {}, 执行结果: {}, 执行时间: {}ms\033[0m";
}else {
logInfo = "\033[32;4m包名: {}, 方法名: {}, 描述: {}, 操作类型: {}, 执行时间: {}ms\033[0m";
}
switch (logAnnotation.type()) {
case INFO:
if (logAnnotation.showBody()) {
log.info(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.info(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
case ERROR:
if (logAnnotation.showBody()) {
log.error(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.error(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
case WARN:
if (logAnnotation.showBody()) {
log.warn(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.warn(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
default:
if (logAnnotation.showBody()) {
log.debug(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.value(), logAnnotation.actionType().getType(), result, endTime - startTime);
}else {
log.debug(logInfo,
joinPoint.getTarget().getClass().getPackage().getName(),
method.getName(), logAnnotation.tag() + logAnnotation.value(), logAnnotation.actionType().getType(), endTime - startTime);
}
break;
}
}
}
}

View File

@@ -0,0 +1,25 @@
package com.chaozhanggui.system.cashierservice.bean;
/**
* 日志操作活动枚举
*/
public enum ActionType {
SELECT("查询操作"),
UPDATE("修改操作"),
DELETE("删除操作"),
ADD("新增操作");
private String type;
ActionType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -0,0 +1,20 @@
package com.chaozhanggui.system.cashierservice.bean;
import lombok.Getter;
/**
* @author: ZhangSong
* @create: 2024-05-15 17:01
*/
@Getter
public enum GetKeyWith {
WITH_GET(0),
WITH_POST(1),
WITH_NULL(-1);
private final Integer value;
GetKeyWith(Integer value) {
this.value = value;
}
}

View File

@@ -0,0 +1,19 @@
package com.chaozhanggui.system.cashierservice.bean;
import lombok.Getter;
/**
* 日志标签
* @author: ZhangSong
* @create: 2024-05-15 16:32
*/
@Getter
public enum LogTag {
JPUSH("极光"), CLIENT("安卓"),
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"), PLACE("下单");
private final String value;
LogTag(String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,21 @@
package com.chaozhanggui.system.cashierservice.bean;
public enum LogType {
INFO("INFO"),
ERROR("ERROR"),
WARN("WARN"),
DEBUG("DEBUG");
private String value;
LogType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,24 @@
package com.chaozhanggui.system.cashierservice.bean;
/**
* 操作日志所有状态
* @author: ZhangSong
* @create: 2024-04-28 11:06
*/
public enum OperationLogState {
UN_HTTP_STATE(-1),
HTTP_FAIL_STATE(0),
HTTP_SUCCESS_STATE(1),
SQL_EXE_FAIL_STATE(2),
SQL_EXE_SUCCESS_STATE(3);
private Integer state;
OperationLogState(Integer state) {
this.state = state;
}
public Integer getState() {
return state;
}
}

View File

@@ -0,0 +1,43 @@
package com.chaozhanggui.system.cashierservice.bean;
/**
* 操作日志所有操作类型
* @author: ZhangSong
* @create: 2024-04-28 11:04
*/
public enum OperationLogType {
UM_API_QUERY_CITY_CALL(1000),
UM_API_UPDATE_ORDER_PHONE(1010),
UM_API_QUERY_DRIVER_LOCATION(1020),
UM_API_CANCEL_ORDER(1030),
UM_API_CANCEL_ORDER_SUCCESS(1040),
UM_API_PAY_ORDER_CALL(1050),
UM_API_CREATE_INVOICE_CALL(1060),
UM_API_QUERY_INVOICE_CALL(1070),
UM_API_RED_REVERSE_CALL(1080),
UM_API_RED_REVERSE_CALL_SUCCESS(1081),
UM_API_PUSH_ORDER_STATE_CALL(1090),
UM_API_PUSH_ORDER_STATE_CALL_GET_HL_STATE_FAIL(1091),
UM_API_PUSH_DRIVER_CALL(1100),
UM_API_PUSH_DRIVER_CALL_API_FAIL(1101),
UM_API_QUERY_PRICE_CALL(1110),
UM_API_CREATE_ORDER_CALL(1120),
UM_API_QUERY_ORDER_DETAIL_CALL(1130),
JPUSH_API_CALL(1140),
UM_CONTROLLER_MAKE_INVOICE_CALL(1150), UM_API_PUSH_TEMP_DRIVER_CALL(1160),
ENUOYUN_INVOICE_CALL(1170),
UM_API_CALL_UM_CHANGE_ORDER_STATE(1180),
API_CHARGEBACK_CALL(1190),
API_REDISTRIBUTE_CALL(1200), API_DRIVER_LOGIN_CALL(1210), NULL(-1),
API_CHANGXING_HANGLV_CHONGXIN_SHANGCHUAN(1220),
API_CHANGXING_HANGLV_FAPIAO_ZUOFEI(1230);
private final Integer value;
OperationLogType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
}

View File

@@ -0,0 +1,23 @@
package com.chaozhanggui.system.cashierservice.bean;
import lombok.Getter;
/**
* @author: ZhangSong
* @create: 2024-05-23 19:01
*/
@Getter
public enum Plat {
TT(1),
CX(2),
RZ(3),
JS(5),
UNDEFINED(-1);
private final Integer value;
Plat(Integer value) {
this.value = value;
}
}

View File

@@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.bean;
public enum ShopWxMsgTypeEnum {
ALL_MSG(-1),
STOCK_MSG(0),
CONSUMABLES_MSG(1),
OPERATION_MSG(2);
private final Integer type;
ShopWxMsgTypeEnum(Integer type) {
this.type = type;
}
public Integer getType() {
return type;
}
}

View File

@@ -51,4 +51,13 @@ public class LoginContoller {
@RequestHeader("clientType") String clientType){ @RequestHeader("clientType") String clientType){
return loginService.getShopInfo(token); return loginService.getShopInfo(token);
} }
@RequestMapping(value = "getStaffDiscount")
public Result getStaffDiscount(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType){
return loginService.getStaffDiscount(token);
}
} }

View File

@@ -1,19 +1,22 @@
package com.chaozhanggui.system.cashierservice.controller; package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
import com.chaozhanggui.system.cashierservice.bean.LogTag;
import com.chaozhanggui.system.cashierservice.entity.OrderVo; import com.chaozhanggui.system.cashierservice.entity.OrderVo;
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo; import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.service.OrderService; import com.chaozhanggui.system.cashierservice.service.OrderService;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.TokenUtil; import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.sql.Timestamp;
import java.util.Date;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@RestController @RestController
@Slf4j @Slf4j
@@ -24,6 +27,14 @@ public class OrderController {
@Autowired @Autowired
private OrderService orderService; private OrderService orderService;
@PutMapping("/updateVip")
@MyLog(value = "代客下单 修改会员", tag = LogTag.PLACE)
public ResponseEntity<Object> updateVip(
@Validated @RequestBody UpdateVipDTO updateVipDTO
) {
return ResponseEntity.ok(orderService.updateVip(updateVipDTO));
}
@PostMapping("/createCart") @PostMapping("/createCart")
public Result createCart(@RequestHeader("token") String token, public Result createCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@@ -34,22 +45,31 @@ public class OrderController {
String userId = jsonObject.getString("accountId"); String userId = jsonObject.getString("accountId");
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(), return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(), cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(),
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType()); cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getVipUserId(), cartVo.getTableId());
} }
@MyLog(value = "查询购物车信息", tag = LogTag.CART)
@GetMapping("/queryCart") @GetMapping("/queryCart")
public Result queryCart(@RequestHeader("token") String token, public Result queryCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("masterId") String masterId, @RequestParam(value = "masterId", required = false) String masterId,
@RequestParam(required = false) String tableId,
@RequestParam("shopId") String shopId @RequestParam("shopId") String shopId
){ ){
return orderService.queryCart(masterId,shopId); if (tableId == null && StrUtil.isBlank(masterId)) {
return Result.fail("masterId和tableId不能同时为空");
}
return orderService.queryCart(masterId,shopId, tableId);
} }
@GetMapping("/delCart") @GetMapping("/delCart")
public Result delCart(@RequestHeader("token") String token, public Result delCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("masterId") String masterId, @RequestParam(required = false) String tableId,
@RequestParam(value = "masterId", required = false) String masterId,
@RequestParam("cartId") Integer cartId @RequestParam("cartId") Integer cartId
){ ){
return orderService.delCart(masterId,cartId); return orderService.delCart(masterId,cartId);
@@ -81,7 +101,8 @@ public class OrderController {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token); JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId"); String userId = jsonObject.getString("accountId");
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),cartVo.getStatus(),userId,cartVo.getUuid(),clientType); return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),
cartVo.getStatus(),userId,cartVo.getUuid(),clientType, cartVo.getVipUserId(), cartVo.getTableId());
} }
@PostMapping("/createOrder") @PostMapping("/createOrder")
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,

View File

@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@@ -55,10 +56,12 @@ public class PayController {
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestParam("orderId") String orderId,
@RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount,
@RequestParam("authCode") String authCode @RequestParam("authCode") String authCode
) { ) {
return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token); return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token,payAmount,discountAmount);
} }
@@ -79,9 +82,11 @@ public class PayController {
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestParam("orderId") String orderId,
@RequestParam("memberId") String memberId, @RequestParam("memberId") String memberId,
@RequestParam("memberAccount") String memberAccount @RequestParam("memberAccount") String memberAccount,
@RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount
){ ){
return payService.accountPay(orderId,memberId,token,memberAccount); return payService.accountPay(orderId,memberId,token,memberAccount,payAmount,discountAmount);
} }
@@ -164,9 +169,11 @@ public class PayController {
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestParam("orderId") String orderId,
@RequestParam("memberCode") String memberCode @RequestParam("memberCode") String memberCode,
@RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount
){ ){
return payService.memberScanPay(orderId,memberCode,token); return payService.memberScanPay(orderId,memberCode,token,payAmount,discountAmount);
} }
@@ -184,8 +191,10 @@ public class PayController {
public Result cashPay(@RequestHeader("token") String token, public Result cashPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId){ @RequestParam("orderId") String orderId,
return payService.cashPay(orderId,token); @RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount){
return payService.cashPay(orderId,token,payAmount,discountAmount);
} }
@@ -204,8 +213,10 @@ public class PayController {
public Result bankPay(@RequestHeader("token") String token, public Result bankPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId){ @RequestParam("orderId") String orderId,
return payService.bankPay(orderId,token); @RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount){
return payService.bankPay(orderId,token, payAmount, discountAmount);
} }

View File

@@ -1,13 +1,18 @@
package com.chaozhanggui.system.cashierservice.controller; package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.service.ProductService; import com.chaozhanggui.system.cashierservice.service.ProductService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.sign.Result;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Map; import java.util.Map;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@@ -21,6 +26,23 @@ public class ProductController {
private ProductService productService; private ProductService productService;
@PutMapping("/productStatus")
public Result productStatus(
@Valid @RequestBody ProductStatusDTO productStatusDTO
) {
productService.updateState(productStatusDTO);
return Result.success(CodeEnum.SUCCESS);
}
@PutMapping("/productStock")
public Result productStock(
@Valid @RequestBody ProductStockDTO productStockDTO
) {
productService.updateStock(productStockDTO);
return Result.success(CodeEnum.SUCCESS);
}
@GetMapping(value = "queryCommodityInfo") @GetMapping(value = "queryCommodityInfo")
public Result queryCommodityInfo( public Result queryCommodityInfo(
@RequestHeader("token") String token, @RequestHeader("token") String token,
@@ -37,6 +59,15 @@ public class ProductController {
return productService.queryCommodityInfo(shopId,categoryId,commdityName,page,pageSize,masterId); return productService.queryCommodityInfo(shopId,categoryId,commdityName,page,pageSize,masterId);
} }
@GetMapping("querySpec")
public Result querySpec(
@RequestParam Integer shopId,
@RequestParam Integer productId
) {
return Result.success(CodeEnum.SUCCESS, productService.querySpec(shopId, productId));
}
@GetMapping(value = "queryNewCommodityInfo") @GetMapping(value = "queryNewCommodityInfo")
public Result queryNewCommodityInfo( public Result queryNewCommodityInfo(
@RequestHeader("token") String token, @RequestHeader("token") String token,

View File

@@ -3,8 +3,10 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart; import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.po.CartPo; import com.chaozhanggui.system.cashierservice.entity.po.CartPo;
import com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo; import com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
@@ -30,9 +32,12 @@ public interface TbCashierCartMapper {
TbCashierCart selectByDetail(@Param("masterId") String masterId, @Param("productId") String productId, TbCashierCart selectByDetail(@Param("masterId") String masterId, @Param("productId") String productId,
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("day") String day,@Param("uuid") String uuid); @Param("shopId") String shopId, @Param("skuId") String skuId, @Param("day") String day,@Param("uuid") String uuid);
TbCashierCart selectDetailByQrcode(@Param("tableId") String tableId, @Param("productId") String productId,
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("uuid") String uuid);
List<TbCashierCart> selectByMaskerId(@Param("masterId")String masterId, @Param("shopId")Integer shopId,@Param("status") String status,@Param("day") String day); List<TbCashierCart> selectByMaskerId(@Param("masterId")String masterId, @Param("shopId")Integer shopId,@Param("status") String status,@Param("day") String day);
void deleteByCartId(@Param("masterId") String masterId, @Param("cartId")Integer cartId); void deleteByCartIdOrTableId(@Param("masterId") String masterId, @Param("cartId")Integer cartId, @Param("qrcode") String qrcode);
void updateStatus(@Param("masterId") Integer id,@Param("status") String status); void updateStatus(@Param("masterId") Integer id,@Param("status") String status);
@@ -60,4 +65,11 @@ public interface TbCashierCartMapper {
List<TbCashierCart> selectByOrderId(@Param("orderId") String orderId,@Param("status") String status); List<TbCashierCart> selectByOrderId(@Param("orderId") String orderId,@Param("status") String status);
}
List<TbCashierCart> selectActivateByQrcode(@Param("tableId") String tableId, @Param("shopId") Integer shopId);
QueryCartPo selectProductNumByQrcode(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId);
@Delete("delete from tb_cashier_cart where master_id=#{masterId} and id=#{cartId}")
int deleteByCartId(@Param("masterId") String masterId, @Param("cartId")Integer cartId);
}

View File

@@ -52,4 +52,6 @@ public interface TbOrderInfoMapper {
TbOrderInfo selectById(Integer id); TbOrderInfo selectById(Integer id);
List<TbOrderInfo> selectActivateOrder(@Param("shopId") String shopId, @Param("tableId") String qrcodeId);
} }

View File

@@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.po.ProConsSkuInfo; import com.chaozhanggui.system.cashierservice.entity.po.ProConsSkuInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -35,6 +36,7 @@ public interface TbProductMapper {
List<TbProductWithBLOBs> selectByShopIdAndShopType(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName); List<TbProductWithBLOBs> selectByShopIdAndShopType(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
List<TbProductWithBLOBs> selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName); List<TbProductWithBLOBs> selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
List<TbProductWithBLOBs> selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
@@ -53,4 +55,24 @@ public interface TbProductMapper {
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}") @Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}")
int decrStockUnCheck(String id, int num); int decrStockUnCheck(String id, int num);
@Select("select * from tb_product product where product.id=#{productId} and product.shop_id=#{shopId} and product.is_del=0")
TbProduct selectByShopIdAndId(@Param("productId") Integer productId, @Param("shopId") Integer shopId);
@Update("update tb_product_sku set is_grounding=#{isGrounding} where product_id=#{productId}")
int updateGroundingByProId(@Param("productId") Integer productId, @Param("isGrounding") int isGrounding);
@Update("update tb_product_sku set is_grounding=#{status} where id=#{skuId}")
int updateGrounding(@Param("skuId") Integer skuId, @Param("status") int status);
@Update("update tb_product set is_pause_sale=#{state} where id=#{id} and shop_id=#{shopId}")
int pauseSale(@Param("id") Integer id, @Param("shopId") Integer shopId, @Param("state") Integer state);
@Update("update tb_product_sku set is_pause_sale=#{state} where product_id=#{id} and shop_id=#{shopId}")
int pauseSkuSale(@Param("id") Integer proId, @Param("shopId") Integer shopId, @Param("state") Integer state);
@Update("update tb_product set stock_number=#{stock} where id=#{productId} and shop_id=#{shopId}")
int updateStock(@Param("shopId") Integer shopId, @Param("productId") Integer productId, @Param("stock") Integer stock);
} }

View File

@@ -51,9 +51,18 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} ") @Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} ")
int decrStockUnCheck(String id, int num); int decrStockUnCheck(String id, int num);
@Select("select * from tb_product_sku where is_grounding=1 and product_id=#{id}") @Select("select * from tb_product_sku where is_grounding=1 and product_id=#{id} and is_del=0")
List<TbProductSku> selectByProductCheckGrounding(@Param("id") Integer id); List<TbProductSku> selectByProductCheckGrounding(@Param("id") Integer id);
@Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}") @Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}")
List<TbProductSku> selectGroundingByProId(Integer id); List<TbProductSku> selectGroundingByProId(@Param("id") Integer id);
@Update("update tb_product_sku set is_pause_sale=#{state} where id=#{skuId} and shop_id=#{shopId}")
int pauseSale(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId, @Param("state") Integer state);
@Update("update tb_product_sku set stock_number=#{stock} where product_id=#{skuId} and shop_id=#{shopId}")
int updateStock(@Param("shopId") Integer shopId, @Param("skuId") Integer skuId, @Param("stock") Integer stock);
@Select("select * from tb_product_sku where product_id=#{id} and is_del=0")
List<TbProductSku> selectByProductId(Integer id);
} }

View File

@@ -24,12 +24,14 @@ public interface TbProskuConMapper {
List<TbProskuCon> selectBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); List<TbProskuCon> selectBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<TbProskuCon> selectBySkuIdAndShopIdAngCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<TbProskuCon> selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); List<TbProskuCon> selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
List<TbProskuCon> selectByShopIdAndSkuIdAndProductIdAndCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
} }

View File

@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.dao; package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopOpenId; import com.chaozhanggui.system.cashierservice.entity.TbShopOpenId;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@@ -27,4 +28,7 @@ public interface TbShopOpenIdMapper {
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1") @Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1")
List<TbShopOpenId> selectByShopId(Integer integer); List<TbShopOpenId> selectByShopId(Integer integer);
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1 and (type=#{type} or type=-1) group by open_id;")
List<TbShopOpenId> selectStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type);
} }

View File

@@ -12,4 +12,6 @@ public class OrderVo {
private Integer shopId; private Integer shopId;
private String userId; private String userId;
private Integer merchantId; private Integer merchantId;
private String tableId;
private Integer vipUserId;
} }

View File

@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity; package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@@ -57,8 +58,12 @@ public class TbCashierCart implements Serializable {
private Long updatedAt; private Long updatedAt;
private Integer userId; private Integer userId;
private String tableId; private String tableId;
@TableField(exist = false)
private TbProductSpec tbProductSpec; private TbProductSpec tbProductSpec;
@TableField(exist = false)
private String selectSpec=""; private String selectSpec="";
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@@ -35,6 +35,8 @@ public class TbConsInfo implements Serializable {
private Date updateTime; private Date updateTime;
private String isCheck;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer getId() { public Integer getId() {
@@ -156,4 +158,12 @@ public class TbConsInfo implements Serializable {
public void setPrice(BigDecimal price) { public void setPrice(BigDecimal price) {
this.price = price; this.price = price;
} }
}
public String getIsCheck() {
return isCheck;
}
public void setIsCheck(String isCheck) {
this.isCheck = isCheck;
}
}

View File

@@ -100,6 +100,8 @@ public class TbOrderInfo implements Serializable {
private String outNumber; private String outNumber;
private Integer staffId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public TbOrderInfo(){ public TbOrderInfo(){
super(); super();

View File

@@ -14,6 +14,8 @@ public class TbPlussShopStaff implements Serializable {
private String password; private String password;
private String discountType;
private BigDecimal maxDiscountAmount; private BigDecimal maxDiscountAmount;
private Boolean status; private Boolean status;
@@ -72,6 +74,14 @@ public class TbPlussShopStaff implements Serializable {
this.password = password == null ? null : password.trim(); this.password = password == null ? null : password.trim();
} }
public String getDiscountType() {
return discountType;
}
public void setDiscountType(String discountType) {
this.discountType = discountType;
}
public BigDecimal getMaxDiscountAmount() { public BigDecimal getMaxDiscountAmount() {
return maxDiscountAmount; return maxDiscountAmount;
} }

View File

@@ -1,9 +1,13 @@
package com.chaozhanggui.system.cashierservice.entity; package com.chaozhanggui.system.cashierservice.entity;
import lombok.Getter;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@Getter
public class TbProductWithBLOBs extends TbProduct implements Serializable { public class TbProductWithBLOBs extends TbProduct implements Serializable {
private Object groundingSpecInfo;
private String images; private String images;
private String video; private String video;
@@ -20,58 +24,34 @@ public class TbProductWithBLOBs extends TbProduct implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public List<?> getSkuList() { public void setGroundingSpecInfo(Object groundingSpecInfo) {
return skuList; this.groundingSpecInfo = groundingSpecInfo;
} }
public void setSkuList(List<?> skuList) { public void setSkuList(List<?> skuList) {
this.skuList = skuList; this.skuList = skuList;
} }
public String getImages() {
return images;
}
public void setImages(String images) { public void setImages(String images) {
this.images = images == null ? null : images.trim(); this.images = images == null ? null : images.trim();
} }
public String getVideo() {
return video;
}
public void setVideo(String video) { public void setVideo(String video) {
this.video = video == null ? null : video.trim(); this.video = video == null ? null : video.trim();
} }
public String getNotice() {
return notice;
}
public void setNotice(String notice) { public void setNotice(String notice) {
this.notice = notice == null ? null : notice.trim(); this.notice = notice == null ? null : notice.trim();
} }
public String getGroupSnap() {
return groupSnap;
}
public void setGroupSnap(String groupSnap) { public void setGroupSnap(String groupSnap) {
this.groupSnap = groupSnap == null ? null : groupSnap.trim(); this.groupSnap = groupSnap == null ? null : groupSnap.trim();
} }
public String getSpecInfo() {
return specInfo;
}
public void setSpecInfo(String specInfo) { public void setSpecInfo(String specInfo) {
this.specInfo = specInfo == null ? null : specInfo.trim(); this.specInfo = specInfo == null ? null : specInfo.trim();
} }
public String getSelectSpec() {
return selectSpec;
}
public void setSelectSpec(String selectSpec) { public void setSelectSpec(String selectSpec) {
this.selectSpec = selectSpec == null ? null : selectSpec.trim(); this.selectSpec = selectSpec == null ? null : selectSpec.trim();
} }

View File

@@ -0,0 +1,176 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.util.Date;
/**
*
* @TableName tb_shop_msg_state
*/
public class TbShopMsgState implements Serializable {
/**
*
*/
private Integer id;
/**
*
*/
private Integer shopId;
/**
*
*/
private Integer type;
/**
*
*/
private Integer state;
/**
*
*/
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 Integer getShopId() {
return shopId;
}
/**
*
*/
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
/**
*
*/
public Integer getType() {
return type;
}
/**
*
*/
public void setType(Integer type) {
this.type = type;
}
/**
*
*/
public Integer getState() {
return state;
}
/**
*
*/
public void setState(Integer state) {
this.state = state;
}
/**
*
*/
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;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
TbShopMsgState other = (TbShopMsgState) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (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 + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().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(", shopId=").append(shopId);
sb.append(", type=").append(type);
sb.append(", state=").append(state);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@@ -34,6 +34,16 @@ public class TbShopTable implements Serializable {
private Long updatedAt; private Long updatedAt;
private String qrcode;
public String getQrcode() {
return qrcode;
}
public void setQrcode(String qrcode) {
this.qrcode = qrcode;
}
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer getId() { public Integer getId() {
@@ -155,4 +165,4 @@ public class TbShopTable implements Serializable {
public void setUpdatedAt(Long updatedAt) { public void setUpdatedAt(Long updatedAt) {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
} }

View File

@@ -0,0 +1,22 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
@Data
public class ProductStatusDTO {
@NotNull
private Integer productId;
@NotNull
private Integer shopId;
@NotNull
@Range(min = 0, max = 1)
private Integer state;
// 0上下架 1售罄
@Range(min = 0, max = 1)
@NotNull
private Integer type;
}

View File

@@ -0,0 +1,18 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
@Data
public class ProductStockDTO {
@NotNull
private Integer shopId;
@NotNull
private Integer productId;
@NotNull
@Min(0)
private Integer stock;
}

View File

@@ -0,0 +1,12 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class QuerySpecDTO {
@NotNull
private Integer shopId;
private Integer productId;
}

View File

@@ -0,0 +1,23 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
public class UpdateVipDTO {
@NotNull
private Integer shopId;
@NotEmpty
private String tableId;
@NotNull
private String masterId;
private Integer vipUserId;
@NotNull
@Range(min = 0, max = 1)
private Integer type;
}

View File

@@ -5,7 +5,6 @@ import lombok.Data;
@Data @Data
public class CartVo { public class CartVo {
private String productId; private String productId;
private String masterId;
private String shopId; private String shopId;
private Integer skuId; private Integer skuId;
private Integer number; private Integer number;
@@ -15,4 +14,7 @@ public class CartVo {
private String uuid; private String uuid;
private String type; private String type;
private Integer cartId; private Integer cartId;
private String masterId;
private String tableId;
private Integer vipUserId;
} }

View File

@@ -0,0 +1,29 @@
package com.chaozhanggui.system.cashierservice.mapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopMsgState;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @author Administrator
* @description 针对表【tb_shop_msg_state】的数据库操作Mapper
* @createDate 2024-08-12 14:27:26
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopMsgState
*/
public interface TbShopMsgStateMapper {
int deleteByPrimaryKey(Long id);
int insert(TbShopMsgState record);
int insertSelective(TbShopMsgState record);
TbShopMsgState selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TbShopMsgState record);
int updateByPrimaryKey(TbShopMsgState record);
@Select("select * from tb_shop_msg_state where shop_id=#{shopId} and type=#{type};")
TbShopMsgState selectByType(@Param("type") Integer type, @Param("shopId") Integer shopId);
}

View File

@@ -0,0 +1,7 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
public interface MPCashierCartMapper extends BaseMapper<TbCashierCart> {
}

View File

@@ -0,0 +1,8 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
public interface MpShopTableMapper extends BaseMapper<TbShopTable> {
}

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.util.*; import com.chaozhanggui.system.cashierservice.util.*;
@@ -93,9 +94,10 @@ public class ConsMsgConsumer {
} }
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId); // List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopIdAngCheck(skuId, shopId);
if (Objects.isNull(tbProskuCons) || tbProskuCons.size() <= 0) { if (Objects.isNull(tbProskuCons) || tbProskuCons.size() <= 0) {
log.info("耗材信息未配置"); log.info("耗材信息未配置或未开启校验");
return; return;
} }
@@ -122,7 +124,8 @@ public class ConsMsgConsumer {
log.info("耗材名称: {}, conwarning:{},stockNumber:{}",tbConsInfo.getConName(), log.info("耗材名称: {}, conwarning:{},stockNumber:{}",tbConsInfo.getConName(),
tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume())); tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()))) { if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()))) {
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId()); List<TbShopOpenId> tbUserShopMsgs = shopOpenIdMapper
.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.CONSUMABLES_MSG.getType());
log.info("待推送openId列表: {}", tbUserShopMsgs); log.info("待推送openId列表: {}", tbUserShopMsgs);
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) { if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{ tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{
@@ -132,7 +135,8 @@ public class ConsMsgConsumer {
log.info("开始推送耗材模板消息rediskey{}", value); log.info("开始推送耗材模板消息rediskey{}", value);
if (Objects.isNull(value)) { if (Objects.isNull(value)) {
JSONObject jsonObject = wxAccountUtil.sendStockWarnMsg("耗材库存不足", tbConsInfo.getConName(), JSONObject jsonObject = wxAccountUtil.sendStockWarnMsg("耗材库存不足", tbConsInfo.getConName(),
tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).toBigInteger().intValue(), tbUserShopMsg.getOpenId()); tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).toBigInteger().intValue(), tbUserShopMsg.getOpenId(),
ShopWxMsgTypeEnum.CONSUMABLES_MSG, shopId);
if (jsonObject != null) { if (jsonObject != null) {
log.info("写入redis:{}",key); log.info("写入redis:{}",key);
redisUtil.saveMessage(key, "1", 30 * 60); redisUtil.saveMessage(key, "1", 30 * 60);

View File

@@ -47,4 +47,8 @@ public interface RabbitConstants {
String EXCHANGE_STOCK_RECORD = "exchange.stock.record"; String EXCHANGE_STOCK_RECORD = "exchange.stock.record";
String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale"; String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale";
// 库存记录
public static final String QUEUE_STOCK_RECORD = "queue.stock.record";
public static final String ROUTING_STOCK_RECORD= "routing.stock.record";
} }

View File

@@ -37,8 +37,6 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
public void cons(String content){ public void cons(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString()); CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId); rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
@@ -71,4 +69,9 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
public <T> void sendStockSaleMsg(T data) { public <T> void sendStockSaleMsg(T data) {
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, data, "商品售出增加库存记录"); sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, data, "商品售出增加库存记录");
} }
public <T> void sendStockRecordMsg(T data) {
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD, data, "增加库存记录");
}
} }

View File

@@ -66,11 +66,13 @@ public class ConsService {
List<TbConsInfoFlow> consInfoFlows=new ArrayList<>(); List<TbConsInfoFlow> consInfoFlows=new ArrayList<>();
for (TbOrderDetail orderDetail : orderDetails) { for (TbOrderDetail orderDetail : orderDetails) {
List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); // List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductIdAndCheck(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
if(Objects.isNull(proskuCons)||proskuCons.size()<=0){ if(Objects.isNull(proskuCons)||proskuCons.size()<=0){
log.info("不存在的耗材信息配置:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); log.info("耗材信息配置或未开启校验:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
continue; continue;
} }
for (TbProskuCon proskuCon : proskuCons) { for (TbProskuCon proskuCon : proskuCons) {
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){ if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){

View File

@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
@@ -191,4 +192,23 @@ public class LoginService {
return Result.success(SUCCESS,shopInfo); return Result.success(SUCCESS,shopInfo);
} }
public Result getStaffDiscount(String token){
JSONObject jsonObject= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(jsonObject)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(jsonObject.getString("staffId"));
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(Objects.nonNull(staff)&&Objects.nonNull(staff.getMaxDiscountAmount())){
return Result.success(SUCCESS,staff.getMaxDiscountAmount());
}
return Result.success(SUCCESS, BigDecimal.ZERO);
}
} }

View File

@@ -1,16 +1,23 @@
package com.chaozhanggui.system.cashierservice.service; package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.bean.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
import com.chaozhanggui.system.cashierservice.entity.po.*; import com.chaozhanggui.system.cashierservice.entity.po.*;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo; import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.sign.Result;
@@ -25,7 +32,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,6 +73,7 @@ public class OrderService {
RedisUtil redisUtil; RedisUtil redisUtil;
private final WxAccountUtil wxAccountUtil; private final WxAccountUtil wxAccountUtil;
private final MPCashierCartMapper mpCashierCartMapper;
@Autowired @Autowired
RabbitProducer producer; RabbitProducer producer;
@@ -76,6 +83,13 @@ public class OrderService {
private final TbUserShopMsgMapper tbUserShopMsgMapper; private final TbUserShopMsgMapper tbUserShopMsgMapper;
private final TbShopOpenIdMapper shopOpenIdMapper; private final TbShopOpenIdMapper shopOpenIdMapper;
private final MpShopTableMapper mpShopTableMapper;
@Autowired
private TbProskuConMapper tbProskuConMapper;
@Autowired
TbConsInfoMapper tbConsInfoMapper;
private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>(); private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>();
@@ -83,16 +97,18 @@ public class OrderService {
@Autowired @Autowired
private ProductService productService; private ProductService productService;
public OrderService(WxAccountUtil wxAccountUtil, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper) { public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper) {
this.wxAccountUtil = wxAccountUtil; this.wxAccountUtil = wxAccountUtil;
this.mpCashierCartMapper = mpCashierCartMapper;
this.wechatUtil = wechatUtil; this.wechatUtil = wechatUtil;
this.tbUserShopMsgMapper = tbUserShopMsgMapper; this.tbUserShopMsgMapper = tbUserShopMsgMapper;
this.shopOpenIdMapper = shopOpenIdMapper; this.shopOpenIdMapper = shopOpenIdMapper;
this.mpShopTableMapper = mpShopTableMapper;
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result createCart(String masterId, String productId, String shopId, Integer skuId, Integer number, public Result createCart(String masterId, String productId, String shopId, Integer skuId, Integer number,
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type) { String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, Integer vipUserId, String tableId) {
if (Objects.isNull(number) || number < 0) { if (Objects.isNull(number) || number < 0) {
return Result.fail(CodeEnum.NUMBER); return Result.fail(CodeEnum.NUMBER);
} }
@@ -121,7 +137,30 @@ public class OrderService {
return Result.fail(CodeEnum.PRODUCTSKUERROR); return Result.fail(CodeEnum.PRODUCTSKUERROR);
} }
// 台桌点单
if ((StrUtil.isNotBlank(tableId))) {
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, tableId)
.in(TbShopTable::getStatus, "idle", "using", "pending"));
if (shopTable == null) {
return Result.fail("台桌不处于开台或空闲状态");
}
}
// List<TbProskuCon> proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(skuId,shopInfo.getId(),product.getId());
// 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(product.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足"));
// }
// }
// }
// }
// }
String exists = redisUtil.getMessage(RedisCst.ORDER_CART_EXISTS + cartId); String exists = redisUtil.getMessage(RedisCst.ORDER_CART_EXISTS + cartId);
@@ -162,25 +201,43 @@ public class OrderService {
} }
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId); TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
if (Objects.nonNull(cart)) { if (Objects.nonNull(cart)) {
cart.setSkuId(skuId.toString());
cart.setNumber(number); //查询现有规格商品
cart.setIsGift(isGift); if("edit".equals(type)&&!cart.getSkuId().equals(skuId.toString())){
cart.setIsPack(isPack); TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid);
if (isPack.equals("false")){ if(Objects.nonNull(cashierCart)){
cart.setPackFee(BigDecimal.ZERO); cashierCart.setNumber(cashierCart.getNumber()+number);
cashierCart.setTotalNumber(cashierCart.getNumber()+number);
cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setUserId(vipUserId);
cashierCartMapper.updateByPrimaryKey(cashierCart);
cashierCartMapper.deleteByPrimaryKey(cart.getId());
redisUtil.deleteByKey(RedisCst.ORDER_CART_EXISTS + cart.getId());
cart=cashierCart;
}
}else { }else {
cart.setPackFee(new BigDecimal(number).multiply(product.getPackFee())); cart.setSkuId(skuId.toString());
} cart.setNumber(number);
if (isGift.equals("false")) { cart.setIsGift(isGift);
cart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()).add(cart.getPackFee())); cart.setIsPack(isPack);
} else { cart.setUserId(vipUserId);
cart.setTotalAmount(BigDecimal.ZERO);
}
cart.setTotalNumber(number); if (isPack.equals("false")){
cart.setUuid(uuid); cart.setPackFee(BigDecimal.ZERO);
cashierCartMapper.updateByPrimaryKeySelective(cart); }else {
cart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
}
if (isGift.equals("false")) {
cart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()).add(cart.getPackFee()));
} else {
cart.setTotalAmount(BigDecimal.ZERO);
}
cart.setTotalNumber(number);
cart.setUuid(uuid);
cashierCartMapper.updateByPrimaryKeySelective(cart);
}
} else { } else {
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create"); List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid); TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid);
@@ -202,6 +259,7 @@ public class OrderService {
cashierCart.setStatus("create"); cashierCart.setStatus("create");
cashierCart.setIsPack(isPack); cashierCart.setIsPack(isPack);
cashierCart.setIsGift(isGift); cashierCart.setIsGift(isGift);
cashierCart.setUserId(vipUserId);
if (isGift.equals("false")) { if (isGift.equals("false")) {
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice())); cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
} else { } else {
@@ -223,6 +281,7 @@ public class OrderService {
cashierCartMapper.insert(cashierCart); cashierCartMapper.insert(cashierCart);
cart=cashierCart; cart=cashierCart;
} else { } else {
cashierCart.setUserId(vipUserId);
if (type.equals("add")) { if (type.equals("add")) {
cashierCart.setNumber(cashierCart.getNumber() + number); cashierCart.setNumber(cashierCart.getNumber() + number);
@@ -234,8 +293,9 @@ public class OrderService {
}else { }else {
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee())); cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
} }
cashierCart.setUserId(vipUserId);
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee())); cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
cashierCartMapper.updateByPrimaryKeySelective(cashierCart); mpCashierCartMapper.updateById(cashierCart);
} }
} else { } else {
cashierCartMapper.updateStatus(cashierCart.getId(), "close"); cashierCartMapper.updateStatus(cashierCart.getId(), "close");
@@ -265,7 +325,8 @@ public class OrderService {
* @param productSku sku * @param productSku sku
*/ */
private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, Integer num) { private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, Integer num) {
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId); log.info("下单,开始校验库存预警,商品信息:{}, {}, {}", product, productSku, num);
if (productSku.getWarnLine() == null) { if (productSku.getWarnLine() == null) {
return; return;
} }
@@ -285,35 +346,62 @@ public class OrderService {
(product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine()) (product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine())
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine() || (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
) { ) {
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId())); List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType());
shopOpenIds.forEach(item -> { shopOpenIds.forEach(item -> {
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num), item.getOpenId()); product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num), item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopId);
}); });
} }
} }
public Result queryCart(String masterId, String shopId) { public Result queryCart(String masterId, String shopId, String tableId) {
if (StringUtils.isEmpty(shopId)) { if (StringUtils.isEmpty(shopId)) {
return Result.fail(CodeEnum.SHOPINFONOEXIST); return Result.fail(CodeEnum.SHOPINFONOEXIST);
} }
String day = DateUtils.getDay(); String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
if (list.size() < 1){ LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day); .eq(TbCashierCart::getShopId, shopId);
if (list.size() > 0){
if (list.size() < 1) { // 普通点单
if (StrUtil.isBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getTableId, tableId)
.and(query -> {
query.eq(TbCashierCart::getMasterId, masterId)
.or()
.isNull(TbCashierCart::getMasterId);
});
}
// List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
if (list.isEmpty()){
list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "refund"));
// list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
if (!list.isEmpty()){
if (list.isEmpty()) {
return Result.fail(CodeEnum.CARTJH); return Result.fail(CodeEnum.CARTJH);
} }
int orderId = 0; int orderId = 0;
String uuid = ""; String uuid = "";
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.valueOf(cashierCart.getOrderId()); orderId = Integer.parseInt(cashierCart.getOrderId());
break;
} }
cashierCart.setStatus("create");
ids.add(cashierCart.getId());
} }
cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid); // mpCashierCartMapper.insertOrUpdate(list);
// cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid);
mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.set(TbCashierCart::getStatus, "create")
.in(TbCashierCart::getId, ids));
if (orderId > 0) { if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled"); tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled"); orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
@@ -395,9 +483,32 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result createOrder(OrderVo orderVo, String clientType, String token) { public Result createOrder(OrderVo orderVo, String clientType, String token) {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
if (list.size() < 1) { LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid()); .eq(TbCashierCart::getShopId, orderVo.getShopId())
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(orderVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, orderVo.getMasterId())
.eq(TbCashierCart::getTradeDay, day);
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(orderVo.getTableId()) && orderVo.getVipUserId() == null) {
queryWrapper.eq(TbCashierCart::getTableId, orderVo.getTableId())
.and(query -> {
query.eq(TbCashierCart::getMasterId, orderVo.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId);
});
}
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
if (list.isEmpty()) {
list = mpCashierCartMapper.selectList(queryWrapper);
// list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
} }
if(ObjectUtil.isEmpty(list)||ObjectUtil.isNull(list)||list.size()<=0){ if(ObjectUtil.isEmpty(list)||ObjectUtil.isNull(list)||list.size()<=0){
@@ -515,7 +626,6 @@ public class OrderService {
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId())); TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId())); TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(skuWithBLOBs, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber())); CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(skuWithBLOBs, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber()));
// 已经添加的商品,修改数量 // 已经添加的商品,修改数量
@@ -685,11 +795,34 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid, String clientType) { public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid,
String clientType, Integer vipUserId, String tableId) {
String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+""; String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+"";
String day = DateUtils.getDay(); String day = DateUtils.getDay();
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId);
// 普通点单
if (StrUtil.isBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(tableId) && vipUserId == null) {
queryWrapper.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getMasterId, masterId);
// 会员点单
}else {
queryWrapper
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getUserId, vipUserId);
}
if ("true".equals(status)) { if ("true".equals(status)) {
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid); List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
if (list.size() < 1) { if (list.size() < 1) {
return Result.fail(CodeEnum.CREATEORDER); return Result.fail(CodeEnum.CREATEORDER);
} }
@@ -760,32 +893,40 @@ public class OrderService {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
flag = false; flag = false;
} }
cashierCart.setUserId(vipUserId);
cashierCart.setOrderId(orderId + ""); cashierCart.setOrderId(orderId + "");
cashierCart.setUpdatedAt(System.currentTimeMillis()); cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setPendingAt(System.currentTimeMillis()); cashierCart.setPendingAt(System.currentTimeMillis());
cashierCart.setStatus("refund"); cashierCart.setStatus("refund");
cashierCart.setUuid(newUuid); cashierCart.setUuid(newUuid);
cashierCartMapper.updateByPrimaryKeySelective(cashierCart); mpCashierCartMapper.updateById(cashierCart);
} }
if (flag) { if (flag) {
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId); redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId);
;
} }
} else { } else {
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid); .eq(TbCashierCart::getStatus, "refund"));
if (list.size() < 1) { // List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
if (list.isEmpty()) {
return Result.fail(CodeEnum.CARTJH); return Result.fail(CodeEnum.CARTJH);
} }
int orderId = 0; int orderId = 0;
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.valueOf(cashierCart.getOrderId()); orderId = Integer.parseInt(cashierCart.getOrderId());
break;
} }
ids.add(cashierCart.getId());
// cashierCart.setStatus("create");
// }
} }
cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid); mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.set(TbCashierCart::getStatus, "create")
.in(TbCashierCart::getId, ids));
// cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid);
if (orderId > 0) { if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled"); tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled"); orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
@@ -832,10 +973,30 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result clearCart(CartVo cartVo) { public Result clearCart(CartVo cartVo) {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid()); LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, cartVo.getShopId())
.eq(TbCashierCart::getTradeDay, day)
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(cartVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, cartVo.getMasterId());
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(cartVo.getTableId()) && cartVo.getVipUserId() == null) {
queryWrapper.eq(TbCashierCart::getTableId, cartVo.getTableId())
.eq(TbCashierCart::getMasterId, cartVo.getMasterId());
// 会员点单
}else {
queryWrapper.eq(TbCashierCart::getUserId, cartVo.getVipUserId());
}
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
int orderId = 0; int orderId = 0;
List<ProductSkuPo> productSkuPos=new ArrayList<>(); List<ProductSkuPo> productSkuPos = new ArrayList<>();
List<String> skuIds=new ArrayList<>(); List<String> skuIds = new ArrayList<>();
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
// 数量减少, 返还库存 // 数量减少, 返还库存
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId()); String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
@@ -1330,4 +1491,19 @@ public class OrderService {
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam)); JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam));
return jsonObject; return jsonObject;
} }
public Object updateVip(UpdateVipDTO updateVipDTO) {
LambdaUpdateWrapper<TbCashierCart> queryWrapper = new LambdaUpdateWrapper<>();
queryWrapper.eq(TbCashierCart::getTableId, updateVipDTO.getTableId())
.eq(TbCashierCart::getShopId, updateVipDTO.getShopId())
.eq(TbCashierCart::getMasterId, updateVipDTO.getMasterId());
if (updateVipDTO.getType().equals(0)) {
queryWrapper.set(TbCashierCart::getUserId, null);
queryWrapper.eq(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
}else {
queryWrapper.set(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
}
return mpCashierCartMapper.update(null, queryWrapper);
}
} }

View File

@@ -32,6 +32,7 @@ import java.math.RoundingMode;
import java.util.*; import java.util.*;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST; import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
@Service @Service
@Slf4j @Slf4j
@@ -115,6 +116,10 @@ public class PayService {
TbmerchantAccountMapper tbmerchantAccountMapper; TbmerchantAccountMapper tbmerchantAccountMapper;
@Autowired
TbPlussShopStaffMapper tbPlussShopStaffMapper;
public static void main(String[] args) { public static void main(String[] args) {
System.out.printf("%.2f%n", new BigDecimal(1).setScale(2, RoundingMode.DOWN)); System.out.printf("%.2f%n", new BigDecimal(1).setScale(2, RoundingMode.DOWN));
@@ -126,7 +131,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result scanPay(String orderId, String authCode, String ip, String token) { public Result scanPay(String orderId, String authCode, String ip, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(authCode) || ObjectUtil.isEmpty(ip)) { if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(authCode) || ObjectUtil.isEmpty(ip)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -143,6 +148,26 @@ public class PayService {
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) { if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
return Result.fail(CodeEnum.CARTEXIST); return Result.fail(CodeEnum.CARTEXIST);
@@ -194,7 +219,7 @@ public class PayService {
if (ObjectUtil.isEmpty(payment) || payment == null) { if (ObjectUtil.isEmpty(payment) || payment == null) {
payment = new TbOrderPayment(); payment = new TbOrderPayment();
payment.setPayTypeId("ysk"); payment.setPayTypeId("ysk");
payment.setAmount(orderInfo.getOrderAmount()); payment.setAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
payment.setPaidAmount(orderInfo.getPayAmount()); payment.setPaidAmount(orderInfo.getPayAmount());
payment.setHasRefundAmount(BigDecimal.ZERO); payment.setHasRefundAmount(BigDecimal.ZERO);
payment.setPayName(payName); payment.setPayName(payName);
@@ -214,9 +239,12 @@ public class PayService {
} }
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setPayType(qpay); orderInfo.setPayType(qpay);
orderInfo.setUpdatedAt(System.currentTimeMillis()); orderInfo.setUpdatedAt(System.currentTimeMillis());
orderInfo.setStaffId(ObjectUtil.isNotNull(staff)?staff.getId():null);
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
if ("ysk".equals(thirdPayType)) { if ("ysk".equals(thirdPayType)) {
@@ -432,7 +460,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result accountPay(String orderId, String memberId, String token,String memberAccount) { public Result accountPay(String orderId, String memberId, String token,String memberAccount,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) ) { if (ObjectUtil.isEmpty(orderId) ) {
if(ObjectUtil.isEmpty(memberAccount)){ if(ObjectUtil.isEmpty(memberAccount)){
if(ObjectUtil.isEmpty(memberId)){ if(ObjectUtil.isEmpty(memberId)){
@@ -460,12 +488,33 @@ public class PayService {
} }
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "deposit"); int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "deposit");
if (count < 1) { if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST); return Result.fail(CodeEnum.PAYTYPENOEXIST);
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
TbShopUser user =null; TbShopUser user =null;
if(ObjectUtil.isNotEmpty(memberId)){ if(ObjectUtil.isNotEmpty(memberId)){
@@ -510,7 +559,10 @@ public class PayService {
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setUserId(user.getUserId()); orderInfo.setUserId(user.getUserId());
orderInfo.setMemberId(user.getId().toString()); orderInfo.setMemberId(user.getId().toString());
orderInfo.setPayType("deposit"); orderInfo.setPayType("deposit");
@@ -546,7 +598,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result memberScanPay(String orderId, String memberCode, String token) { public Result memberScanPay(String orderId, String memberCode, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberCode)) { if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberCode)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -569,6 +621,26 @@ public class PayService {
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByCardNo(memberCode); TbUserInfo tbUserInfo = tbUserInfoMapper.selectByCardNo(memberCode);
if (ObjectUtil.isEmpty(tbUserInfo)) { if (ObjectUtil.isEmpty(tbUserInfo)) {
return Result.fail(ACCOUNTEIXST); return Result.fail(ACCOUNTEIXST);
@@ -601,8 +673,10 @@ public class PayService {
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setMemberId(user.getUserId()); orderInfo.setMemberId(user.getUserId());
orderInfo.setPayType("deposit"); orderInfo.setPayType("deposit");
orderInfo.setStatus("closed"); orderInfo.setStatus("closed");
@@ -637,7 +711,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result cashPay(String orderId, String token) { public Result cashPay(String orderId, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) { if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -654,13 +728,34 @@ public class PayService {
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash"); int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
if (count < 1) { if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST); return Result.fail(CodeEnum.PAYTYPENOEXIST);
} }
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setPayType("cash"); orderInfo.setPayType("cash");
orderInfo.setStatus("closed"); orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo())); orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
@@ -691,7 +786,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result bankPay(String orderId, String token) { public Result bankPay(String orderId, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) { if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -713,8 +808,29 @@ public class PayService {
return Result.fail(CodeEnum.PAYTYPENOEXIST); return Result.fail(CodeEnum.PAYTYPENOEXIST);
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
orderInfo.setPayAmount(orderInfo.getOrderAmount()); Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setPayType("cash"); orderInfo.setPayType("cash");
orderInfo.setStatus("closed"); orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo())); orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
@@ -835,6 +951,9 @@ public class PayService {
saleAmount = saleAmount.add(it.getPrice()); saleAmount = saleAmount.add(it.getPrice());
payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN) payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN)
.multiply(new BigDecimal(map1.get(it.getId())))); .multiply(new BigDecimal(map1.get(it.getId()))));
if(ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())&&ObjectUtil.isNotNull(orderInfo.getDiscountRatio())){
payAmount=payAmount.multiply(orderInfo.getDiscountRatio()).setScale(2,BigDecimal.ROUND_DOWN);
}
// payAmount=payAmount.add(it.getPriceAmount()); // payAmount=payAmount.add(it.getPriceAmount());
packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())))); packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));

View File

@@ -7,9 +7,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo; import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.interceptor.LimitSubmitAspect; import com.chaozhanggui.system.cashierservice.interceptor.LimitSubmitAspect;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils; import com.chaozhanggui.system.cashierservice.util.DateUtils;
@@ -44,6 +48,12 @@ public class ProductService {
@Autowired @Autowired
private LimitSubmitAspect limitSubmitAspect; private LimitSubmitAspect limitSubmitAspect;
private final RabbitProducer producer;
public ProductService(RabbitProducer producer) {
this.producer = producer;
}
public Result queryCategory(String shopId,Integer page,Integer pageSize){ public Result queryCategory(String shopId,Integer page,Integer pageSize){
PageHelperUtil.startPage(page, pageSize); PageHelperUtil.startPage(page, pageSize);
@@ -106,7 +116,11 @@ public class ProductService {
if(ObjectUtil.isEmpty(categoryId)){ if(ObjectUtil.isEmpty(categoryId)){
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndCheckGrounding(shopId,commdityName); tbProductWithBLOBs=tbProductMapper.selectByShopIdAndCheckGrounding(shopId,commdityName);
}else { }else {
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndShopTypeCheckGrounding(shopId,categoryId,commdityName); if (Integer.valueOf(categoryId).equals(-1)) {
tbProductWithBLOBs = tbProductMapper.selectByShopIdAndShopTypeUnGrounding(shopId,commdityName);
}else {
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndShopTypeCheckGrounding(shopId,categoryId,commdityName);
}
} }
String day = DateUtils.getDay(); String day = DateUtils.getDay();
@@ -121,72 +135,20 @@ public class ProductService {
it.setTbProductSpec(tbProductSpec); it.setTbProductSpec(tbProductSpec);
TbProductSkuResult skuResult=tbProductSkuResultMapper.selectByPrimaryKey(it.getId()); TbProductSkuResult skuResult=tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
// 上下架对应的sku
String selectSpec = it.getSelectSpec();
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
HashSet<String> specSet = new HashSet<>();
tbProductSkus.forEach(item -> {
String specSnap = item.getSpecSnap();
if (specSnap != null) {
specSet.addAll(Arrays.asList(specSnap.split(",")));
}
});
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
if (tagSnap != null) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
JSONObject snapJSON;
JSONArray finalSnap = new JSONArray();
HashMap<String, String> snapMap = new HashMap<>();
for (Object snap : tagSnaps) {
StringBuilder finalValues = new StringBuilder();
snapJSON = (JSONObject) snap;
String values = snapJSON.getString("value");
if (StrUtil.isNotBlank(values)) {
String[] valueList = values.split(",");
for (String value : valueList) {
if (specSet.contains(value)) {
finalValues.append(value).append(",");
}
}
if (StrUtil.isNotBlank(finalValues.toString())) {
finalValues = new StringBuilder(StrUtil.removeSuffix(finalValues.toString(), ","));
snapJSON.put("value", finalValues.toString());
finalSnap.add(snapJSON);
snapMap.put(snapJSON.getString("name"), snapJSON.getString("value"));
}
}
}
if (selectSpec != null) {
JSONArray selectSpecJSON = JSONObject.parseArray(selectSpec);
for (Object selectSpecInfo : selectSpecJSON) {
JSONObject specInfo = (JSONObject) selectSpecInfo;
String name = snapMap.get(specInfo.getString("name"));
if (name != null) {
specInfo.put("value", name.split(","));
specInfo.put("selectSpecResult", name.split(","));
}
}
it.setSelectSpec(selectSpecJSON.toJSONString());
}
skuResult.setTagSnap(finalSnap.toJSONString());
}
it.setProductSkuResult(skuResult); it.setProductSkuResult(skuResult);
// 查询sku信息 // 查询sku信息
List<TbProductSku> skuWithBLOBs = tbProductSkuMapper.selectByProductCheckGrounding(it.getId()); List<TbProductSku> skuWithBLOBs = tbProductSkuMapper.selectByProductCheckGrounding(it.getId());
List<TbProductSku> skus = tbProductSkuMapper.selectByProductId(it.getId());
if (it.getIsDistribute() == 0) {
int num = 0;
for (TbProductSku item : skus) {
num += item.getStockNumber();
}
it.setStockNumber(num);
}
it.setSkuList(skuWithBLOBs); it.setSkuList(skuWithBLOBs);
it.setGroundingSpecInfo(querySpec(Integer.valueOf(shopId), it.getId()));
}); });
} }
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs); PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);
@@ -222,4 +184,115 @@ public class ProductService {
} }
} }
} }
public void updateState(ProductStatusDTO productStatusDTO) {
TbProduct product = tbProductMapper.selectByShopIdAndId(productStatusDTO.getProductId(), productStatusDTO.getShopId());
if (productStatusDTO.getType().equals(0)) {
tbProductMapper.updateGroundingByProId(product.getId(), productStatusDTO.getState());
}else {
tbProductMapper.pauseSale(productStatusDTO.getProductId(), productStatusDTO.getShopId(), productStatusDTO.getState());
tbProductMapper.pauseSkuSale(productStatusDTO.getProductId(), productStatusDTO.getShopId(), productStatusDTO.getState());
}
}
public void updateStock(ProductStockDTO productStockDTO) {
TbProduct product = tbProductMapper.selectByShopIdAndId(productStockDTO.getProductId(), productStockDTO.getShopId());
if (product == null) {
throw new MsgException("商品不存在");
}
if (product.getIsDistribute() != 1 && product.getTypeEnum().equals("sku")) {
throw new MsgException("多规格非共享商品暂不支持修改库存");
}else {
tbProductMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock());
tbProductSkuMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock());
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectByProductId(product.getId());
JSONObject data = new JSONObject();
data.put("shopId", productStockDTO.getShopId());
data.put("skuId", tbProductSkus.isEmpty() ? null : tbProductSkus.get(0).getId());
data.put("productId", productStockDTO.getProductId());
data.put("type", "pc收银机修改库存");
data.put("subType", product.getStockNumber() > productStockDTO.getStock() ? -1 : 1);
data.put("number",productStockDTO.getStock() - product.getStockNumber());
producer.sendStockRecordMsg(data);
}
}
private static void generateCombinations(List<List<String>> valuesList, int index, List<String> current, List<String> result) {
if (index == valuesList.size()) {
result.add(String.join(",", current));
return;
}
for (String value : valuesList.get(index)) {
current.add(value);
generateCombinations(valuesList, index + 1, current, result);
current.remove(current.size() - 1); // 回溯
}
}
public Object querySpec(Integer shopId, Integer productId) {
TbProduct tbProduct = tbProductMapper.selectByPrimaryKey(productId);
if (tbProduct == null) {
throw new MsgException("商品不存在");
}
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(productId);
// 重组有效规格数据
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(productId);
JSONArray finalSnap = new JSONArray();
List<String> result = new ArrayList<>();
if (tagSnap != null) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
List<List<String>> valuesList = new ArrayList<>();
// 提取所有 value 的列表
for (int i = 0; i < tagSnaps.size(); i++) {
JSONObject jsonObject = tagSnaps.getJSONObject(i);
if (jsonObject.containsKey("value")) {
String[] values = jsonObject.getString("value").split(",");
valuesList.add(Arrays.asList(values));
}
}
// 生成所有可能的排列组合
generateCombinations(valuesList, 0, new ArrayList<>(), result);
}
ArrayList<HashMap<String, Object>> specList = new ArrayList<>();
tbProductSkus.forEach(item -> {
HashMap<String, Object> itemMap = new HashMap<>();
itemMap.put("specSnap", item.getSpecSnap());
itemMap.put("skuId", item.getId());
specList.add(itemMap);
});
ArrayList<HashMap<String, Object>> otherVal = new ArrayList<>();
for (String res : result) {
boolean found = false;
for (HashMap<String, Object> spec : specList) {
if (res.equals(spec.get("specSnap").toString())) {
spec.put("isGrounding", true);
found = true;
break;
}
}
if (!found) {
HashMap<String, Object> itemMap = new HashMap<>();
itemMap.put("specSnap", res);
itemMap.put("skuId", null);
itemMap.put("isGrounding", false);
otherVal.add(itemMap);
}
}
specList.addAll(otherVal);
return specList;
}
} }

View File

@@ -1,6 +1,8 @@
package com.chaozhanggui.system.cashierservice.service; package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.*;
@@ -33,6 +35,11 @@ public class ShopInfoService {
ShopUserDutyMapper shopUserDutyMapper; ShopUserDutyMapper shopUserDutyMapper;
@Autowired @Autowired
ShopUserDutyDetailMapper shopUserDutyDetailMapper; ShopUserDutyDetailMapper shopUserDutyDetailMapper;
private final TbOrderInfoMapper orderInfoMapper;
public ShopInfoService(TbOrderInfoMapper orderInfoMapper) {
this.orderInfoMapper = orderInfoMapper;
}
public Result queryShopArea(String shopId){ public Result queryShopArea(String shopId){
List<TbShopArea> list= tbShopAreaMapper.selectByShopId(shopId); List<TbShopArea> list= tbShopAreaMapper.selectByShopId(shopId);
@@ -48,6 +55,7 @@ public class ShopInfoService {
PageHelperUtil.startPage(page, pageSize); PageHelperUtil.startPage(page, pageSize);
List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status); List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status);
PageInfo pageInfo=new PageInfo(shopTables); PageInfo pageInfo=new PageInfo(shopTables);
return Result.success(CodeEnum.SUCCESS,pageInfo); return Result.success(CodeEnum.SUCCESS,pageInfo);
} }

View File

@@ -104,6 +104,11 @@ public enum CodeEnum {
PWDERROE("100038",false,"操作密码错误","fail"), PWDERROE("100038",false,"操作密码错误","fail"),
STAFFNOEXISTERROE("100039",false,"员工信息不存在","fail"),
STAFFDISCOUNTAMOUNTHIGHT("100040",false,"优惠金额不能大于员工授权额度","fail"),

View File

@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
@Data @Data
public class MainScanReq implements Serializable { public class MainScanReq implements Serializable {
@@ -25,7 +26,13 @@ public class MainScanReq implements Serializable {
private String notifyUrl; private String notifyUrl;
public MainScanReq(String subject, String body, Long amount, String subAppid, String currency, String authCode, String mchOrderNo, String storeId, String notifyUrl) { private int divisionMode;
private ArrayList divList;
private String divTemplateNo;
public MainScanReq(String subject, String body, Long amount, String subAppid, String currency, String authCode, String mchOrderNo, String storeId, String notifyUrl,int divisionMode,String divTemplateNo,ArrayList divList) {
this.subject = subject; this.subject = subject;
this.body = body; this.body = body;
this.amount = amount; this.amount = amount;
@@ -35,6 +42,9 @@ public class MainScanReq implements Serializable {
this.mchOrderNo = mchOrderNo; this.mchOrderNo = mchOrderNo;
this.storeId = storeId; this.storeId = storeId;
this.notifyUrl = notifyUrl; this.notifyUrl = notifyUrl;
this.divisionMode=divisionMode;
this.divList=divList;
this.divTemplateNo=divTemplateNo;
} }

View File

@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
@Data @Data
public class WxScanPayReq implements Serializable { public class WxScanPayReq implements Serializable {
@@ -28,11 +29,20 @@ public class WxScanPayReq implements Serializable {
private String storeId; private String storeId;
private int divisionMode;
private ArrayList divList;
private String divTemplateNo;
private String notifyUrl; private String notifyUrl;
private String returnUrl; private String returnUrl;
public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) { public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId,
int divisionMode,ArrayList divList,String divTemplateNo,
String notifyUrl, String returnUrl) {
this.subject = subject; this.subject = subject;
this.body = body; this.body = body;
this.amount = amount; this.amount = amount;
@@ -45,5 +55,8 @@ public class WxScanPayReq implements Serializable {
this.storeId = storeId; this.storeId = storeId;
this.notifyUrl = notifyUrl; this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl; this.returnUrl = returnUrl;
this.divisionMode=divisionMode;
this.divList=divList;
this.divTemplateNo=divTemplateNo;
} }
} }

View File

@@ -47,8 +47,17 @@ public class ThirdPayService {
public PublicResp<MainScanResp> mainScan(String url,String appId, String subject, String body, Long amount, String subAppId, String authCode, String orderNo, String storeId, String notifyUrl, public PublicResp<MainScanResp> mainScan(String url,String appId, String subject, String body, Long amount, String subAppId, String authCode, String orderNo, String storeId, String notifyUrl,
String key String key
) { ) {
MainScanReq mainScanReq=null;
if("66bab943ae82f63b50ae3cff".equals(appId)){
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,1,"TA1824003985261588482",null);
url="https://paymentweb.sxczgkj.cn";
}else {
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);
}
MainScanReq mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl);
PublicParam param = new PublicParam(appId, "", SignTypeEnum.MD5.getValue(), null, DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis())); PublicParam param = new PublicParam(appId, "", SignTypeEnum.MD5.getValue(), null, DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
@@ -99,7 +108,14 @@ public class ThirdPayService {
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl, String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
String key){ String key){
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,notifyUrl,returnUrl); WxScanPayReq scanPayReq=null;
if("66bab943ae82f63b50ae3cff".equals(appId)){
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,1,null,"TA1824003985261588482",notifyUrl,returnUrl);
url="https://paymentweb.sxczgkj.cn";
}else {
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
}
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis())); PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));

View File

@@ -5,7 +5,10 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.TbShopMsgState;
import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.TbShopMsgStateMapper;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -25,7 +28,7 @@ public class WxAccountUtil {
private static String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0"; private static String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
@Value("${wx.ysk.warnMsgTmpId}") @Value("${wx.ysk.warnMsgTmpId}")
private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0"; private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
private final TbShopMsgStateMapper shopMsgStateMapper;
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>(); static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
static { static {
@@ -97,7 +100,17 @@ public class WxAccountUtil {
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误")); throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
} }
public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId) { public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId, ShopWxMsgTypeEnum typeEnum, Integer shopId) {
TbShopMsgState allState = shopMsgStateMapper.selectByType(ShopWxMsgTypeEnum.ALL_MSG.getType(), shopId);
if (allState == null || allState.getState().equals(0)) {
log.info("店铺未开启全局推送:{}", allState);
return null;
}
TbShopMsgState shopMsgState = shopMsgStateMapper.selectByType(typeEnum.getType(), shopId);
if (shopMsgState == null || shopMsgState.getState().equals(0)) {
log.info("店铺未开启推送:{}", shopMsgState);
return null;
}
stock = stock < 0 ? 0 : stock; stock = stock < 0 ? 0 : stock;
Integer finalStock = stock; Integer finalStock = stock;
Map<String, Object> data = new HashMap<String, Object>() {{ Map<String, Object> data = new HashMap<String, Object>() {{

View File

@@ -57,5 +57,8 @@ wx:
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0 warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
mybatis-plus:
global-config:
db-config:
id-type: auto

View File

@@ -59,6 +59,16 @@
and uuid = #{uuid} and uuid = #{uuid}
</if> </if>
</select> </select>
<select id="selectDetailByQrcode" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
select
<include refid="Base_Column_List"/>
from tb_cashier_cart where table_id = #{tableId} and product_id = #{productId} and shop_id = #{shopId} and
sku_id = #{skuId}
<if test="uuid != null">
and uuid = #{uuid}
</if>
</select>
<select id="selectByMaskerId" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart"> <select id="selectByMaskerId" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
select * select *
from tb_cashier_cart where master_id = #{masterId} and shop_id = #{shopId} and status = #{status} and trade_day = #{day} order by id desc from tb_cashier_cart where master_id = #{masterId} and shop_id = #{shopId} and status = #{status} and trade_day = #{day} order by id desc
@@ -92,8 +102,15 @@
delete from tb_cashier_cart delete from tb_cashier_cart
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</delete> </delete>
<delete id="deleteByCartId"> <delete id="deleteByCartIdOrTableId">
delete from tb_cashier_cart where id = #{cartId} and master_id = #{masterId} delete from tb_cashier_cart where id = #{cartId} and
<if test="masterId != null">
master_id = #{masterId}
</if>
<if test="qrcode != null">
table_id =#{qrcode}
</if>
</delete> </delete>
<delete id="deleteBymasterId"> <delete id="deleteBymasterId">
delete from tb_cashier_cart where master_id = #{masterId} and shop_id = #{shopId} delete from tb_cashier_cart where master_id = #{masterId} and shop_id = #{shopId}
@@ -103,22 +120,22 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart" useGeneratedKeys="true" keyProperty="id">
insert into tb_cashier_cart (id, master_id, order_id, insert into tb_cashier_cart (id, master_id, order_id,
ref_order_id, total_amount, product_id, ref_order_id, total_amount, product_id,
cover_img, is_sku, sku_id, cover_img, is_sku, sku_id,
name, sale_price, number, name, sale_price, number,
total_number, refund_number, category_id, total_number, refund_number, category_id,
status, type, merchant_id, status, type, merchant_id,
shop_id, created_at, updated_at, pack_fee,trade_day,is_pack,is_gift,uuid shop_id, created_at, updated_at, pack_fee,trade_day,is_pack,is_gift,uuid, table_id
) )
values (#{id,jdbcType=INTEGER}, #{masterId,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR}, values (#{id,jdbcType=INTEGER}, #{masterId,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR},
#{refOrderId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{productId,jdbcType=VARCHAR}, #{refOrderId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{productId,jdbcType=VARCHAR},
#{coverImg,jdbcType=VARCHAR}, #{isSku,jdbcType=TINYINT}, #{skuId,jdbcType=VARCHAR}, #{coverImg,jdbcType=VARCHAR}, #{isSku,jdbcType=TINYINT}, #{skuId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{salePrice,jdbcType=DECIMAL}, #{number,jdbcType=REAL}, #{name,jdbcType=VARCHAR}, #{salePrice,jdbcType=DECIMAL}, #{number,jdbcType=REAL},
#{totalNumber,jdbcType=REAL}, #{refundNumber,jdbcType=REAL}, #{categoryId,jdbcType=VARCHAR}, #{totalNumber,jdbcType=REAL}, #{refundNumber,jdbcType=REAL}, #{categoryId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR},
#{shopId,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{packFee,jdbcType=DECIMAL} #{shopId,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{packFee,jdbcType=DECIMAL}
, #{tradeDay,jdbcType=VARCHAR}, #{isPack,jdbcType=VARCHAR}, #{isGift,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR} , #{tradeDay,jdbcType=VARCHAR}, #{isPack,jdbcType=VARCHAR}, #{isGift,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR},#{tableId,jdbcType=VARCHAR}
) )
</insert> </insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart"> <insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
@@ -389,5 +406,16 @@
select * from tb_cashier_cart where master_id = #{masterId} and trade_day = #{day} and shop_id = #{shopId} and status = 'create' select * from tb_cashier_cart where master_id = #{masterId} and trade_day = #{day} and shop_id = #{shopId} and status = 'create'
</select> </select>
<select id="selectActivateByQrcode"
resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
select * from tb_cashier_cart where table_id = #{tableId} and shop_id = #{shopId} and status = 'create'
</select>
<select id="selectProductNumByQrcode"
resultType="com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo">
select ifnull(count(*),0) as productNum,ifnull(sum(number),0)as productSum
from (select count(*),number
from tb_cashier_cart where table_id = #{qrcode} and shop_id = #{shopId} group by product_id ) a
</select>
</mapper>
</mapper>

View File

@@ -17,10 +17,13 @@
<result column="con_warning" jdbcType="DECIMAL" property="conWarning" /> <result column="con_warning" jdbcType="DECIMAL" property="conWarning" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_check" jdbcType="VARCHAR" property="isCheck" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, shop_id, con_type_id, con_type_name, con_code, con_name, stock_number,price,stock_consume,status, con_unit, id, shop_id, con_type_id, con_type_name, con_code, con_name, stock_number,price,stock_consume,status, con_unit,
laster_in_stock, con_warning, create_time, update_time laster_in_stock, con_warning, create_time, update_time,is_check
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select

View File

@@ -515,6 +515,10 @@
<if test="remark != null and remark!=''"> <if test="remark != null and remark!=''">
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
</if> </if>
<if test="staffId != null and staffId!=''">
staff_id = #{staffId,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
@@ -627,5 +631,9 @@ select * from tb_order_info where trade_day = #{day} and table_id = #{masterId}
</select>
<select id="selectActivateOrder" resultType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
SELECT * FROM `tb_order_info` where shop_id=#{shopId} and
table_id=#{tableId} and order_type != 'return' and `status` not in ('closed', 'refund', 'merge')
</select> </select>
</mapper> </mapper>

View File

@@ -7,6 +7,7 @@
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="account" jdbcType="VARCHAR" property="account" /> <result column="account" jdbcType="VARCHAR" property="account" />
<result column="password" jdbcType="VARCHAR" property="password" /> <result column="password" jdbcType="VARCHAR" property="password" />
<result column="discount_type" jdbcType="VARCHAR" property="discountType" />
<result column="max_discount_amount" jdbcType="DECIMAL" property="maxDiscountAmount" /> <result column="max_discount_amount" jdbcType="DECIMAL" property="maxDiscountAmount" />
<result column="status" jdbcType="BIT" property="status" /> <result column="status" jdbcType="BIT" property="status" />
<result column="employee" jdbcType="VARCHAR" property="employee" /> <result column="employee" jdbcType="VARCHAR" property="employee" />
@@ -19,7 +20,7 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id id
, code, name, account, password, max_discount_amount, status, employee, shop_id, , code, name, account, password,discount_type, max_discount_amount, status, employee, shop_id,
created_at, updated_at, type,is_manage,is_pc created_at, updated_at, type,is_manage,is_pc
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">

View File

@@ -938,6 +938,18 @@
</if> </if>
and b.is_grounding=1 GROUP BY a.id ORDER BY a.`sort` and b.is_grounding=1 GROUP BY a.id ORDER BY a.`sort`
</select>
<select id="selectByShopIdAndShopTypeUnGrounding" resultMap="ResultMapWithBLOBs">
select a.* from tb_product as a
left join tb_product_sku as b on a.id = b.product_id
where a.shop_id=#{shopId} and a.status=1 and a.is_show_cash = 1 and a.type_enum in ('normal','sku','currentPrice','weight')
<if test="commdityName != null and commdityName!='' ">
and a.name like CONCAT('%',#{commdityName},'%')
</if>
and b.is_grounding=0 GROUP BY a.id ORDER BY a.`sort`
</select> </select>
<select id="countOrderByshopIdAndProductId" resultType="INTEGER"> <select id="countOrderByshopIdAndProductId" resultType="INTEGER">

View File

@@ -15,7 +15,7 @@
id, shop_id,product_id ,product_sku_id, con_info_id, surplus_stock, status, create_time id, shop_id,product_id ,product_sku_id, con_info_id, surplus_stock, status, create_time
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from tb_prosku_con from tb_prosku_con
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
@@ -25,11 +25,11 @@
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</delete> </delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProskuCon"> <insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProskuCon">
insert into tb_prosku_con (id, shop_id, product_sku_id, insert into tb_prosku_con (id, shop_id, product_sku_id,
con_info_id, surplus_stock, status, con_info_id, surplus_stock, status,
create_time) create_time)
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER}, values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER},
#{conInfoId,jdbcType=INTEGER}, #{surplusStock,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{conInfoId,jdbcType=INTEGER}, #{surplusStock,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}) #{createTime,jdbcType=TIMESTAMP})
</insert> </insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProskuCon"> <insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProskuCon">
@@ -123,6 +123,12 @@
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and status=1 select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and status=1
</select> </select>
<select id="selectBySkuIdAndShopIdAngCheck" resultMap="BaseResultMap">
select a.* from tb_prosku_con as a
left join tb_cons_info as b on a.con_info_id=b.id
where a.product_sku_id=#{skuId} and a.shop_id=#{shopId} and a.status=1 and b.is_check=1
</select>
<select id="selectIdBySkuIdAndShopId" resultType="java.lang.Integer"> <select id="selectIdBySkuIdAndShopId" resultType="java.lang.Integer">
SELECT SELECT
p.con_info_id p.con_info_id
@@ -139,4 +145,11 @@
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1 select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1
</select> </select>
</mapper>
<select id="selectByShopIdAndSkuIdAndProductIdAndCheck" resultMap="BaseResultMap">
select a.* from tb_prosku_con as a
left join tb_cons_info as b on a.con_info_id=b.id
where a.product_sku_id=#{skuId} and a.shop_id=#{shopId} and a.product_id=#{productId} and a.status=1 and b.is_check=1
</select>
</mapper>

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.mapper.TbShopMsgStateMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,shop_id,type,
state,create_time,update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_msg_state
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from tb_shop_msg_state
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState" useGeneratedKeys="true">
insert into tb_shop_msg_state
( id,shop_id,type
,state,create_time,update_time
)
values (#{id,jdbcType=INTEGER},#{shopId,jdbcType=INTEGER},#{type,jdbcType=INTEGER}
,#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState" useGeneratedKeys="true">
insert into tb_shop_msg_state
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="shopId != null">shop_id,</if>
<if test="type != null">type,</if>
<if test="state != null">state,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
<if test="type != null">#{type,jdbcType=INTEGER},</if>
<if test="state != null">#{state,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState">
update tb_shop_msg_state
<set>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="state != null">
state = #{state,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopMsgState">
update tb_shop_msg_state
set
shop_id = #{shopId,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER},
state = #{state,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -18,11 +18,11 @@
<result column="icon" jdbcType="VARCHAR" property="icon" /> <result column="icon" jdbcType="VARCHAR" property="icon" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, pay_type, pay_name, is_show_shortcut, shop_id, is_refundable, is_open_cash_drawer, id, pay_type, pay_name, is_show_shortcut, shop_id, is_refundable, is_open_cash_drawer,
is_system, is_ideal, is_display, sorts, created_at, updated_at, icon is_system, is_ideal, is_display, sorts, created_at, updated_at, icon
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from tb_shop_pay_type from tb_shop_pay_type
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
@@ -32,15 +32,15 @@
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</delete> </delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopPayType"> <insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopPayType">
insert into tb_shop_pay_type (id, pay_type, pay_name, insert into tb_shop_pay_type (id, pay_type, pay_name,
is_show_shortcut, shop_id, is_refundable, is_show_shortcut, shop_id, is_refundable,
is_open_cash_drawer, is_system, is_ideal, is_open_cash_drawer, is_system, is_ideal,
is_display, sorts, created_at, is_display, sorts, created_at,
updated_at, icon) updated_at, icon)
values (#{id,jdbcType=INTEGER}, #{payType,jdbcType=VARCHAR}, #{payName,jdbcType=VARCHAR}, values (#{id,jdbcType=INTEGER}, #{payType,jdbcType=VARCHAR}, #{payName,jdbcType=VARCHAR},
#{isShowShortcut,jdbcType=TINYINT}, #{shopId,jdbcType=VARCHAR}, #{isRefundable,jdbcType=TINYINT}, #{isShowShortcut,jdbcType=TINYINT}, #{shopId,jdbcType=VARCHAR}, #{isRefundable,jdbcType=TINYINT},
#{isOpenCashDrawer,jdbcType=TINYINT}, #{isSystem,jdbcType=TINYINT}, #{isIdeal,jdbcType=TINYINT}, #{isOpenCashDrawer,jdbcType=TINYINT}, #{isSystem,jdbcType=TINYINT}, #{isIdeal,jdbcType=TINYINT},
#{isDisplay,jdbcType=TINYINT}, #{sorts,jdbcType=INTEGER}, #{createdAt,jdbcType=BIGINT}, #{isDisplay,jdbcType=TINYINT}, #{sorts,jdbcType=INTEGER}, #{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT}, #{icon,jdbcType=VARCHAR}) #{updatedAt,jdbcType=BIGINT}, #{icon,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopPayType"> <insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopPayType">
@@ -205,4 +205,4 @@
select count(id) from tb_shop_pay_type where shop_id=#{shopId} and is_display=1 and pay_type=#{payType} select count(id) from tb_shop_pay_type where shop_id=#{shopId} and is_display=1 and pay_type=#{payType}
</select> </select>
</mapper> </mapper>

View File

@@ -17,13 +17,14 @@
<result column="view" jdbcType="VARCHAR" property="view" /> <result column="view" jdbcType="VARCHAR" property="view" />
<result column="created_at" jdbcType="BIGINT" property="createdAt" /> <result column="created_at" jdbcType="BIGINT" property="createdAt" />
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" /> <result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="qrcode" jdbcType="VARCHAR" property="qrcode" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, name, shop_id, max_capacity, sort, area_id, is_predate, predate_amount, status, id, name, shop_id, max_capacity, sort, area_id, is_predate, predate_amount, status,
type, amount, perhour, view, created_at, updated_at type, amount, perhour, view, created_at, updated_at
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from tb_shop_table from tb_shop_table
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
@@ -33,16 +34,16 @@
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</delete> </delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopTable"> <insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopTable">
insert into tb_shop_table (id, name, shop_id, insert into tb_shop_table (id, name, shop_id,
max_capacity, sort, area_id, max_capacity, sort, area_id,
is_predate, predate_amount, status, is_predate, predate_amount, status,
type, amount, perhour, type, amount, perhour,
view, created_at, updated_at view, created_at, updated_at
) )
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{shopId,jdbcType=INTEGER}, values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{shopId,jdbcType=INTEGER},
#{maxCapacity,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER}, #{areaId,jdbcType=INTEGER}, #{maxCapacity,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER}, #{areaId,jdbcType=INTEGER},
#{isPredate,jdbcType=TINYINT}, #{predateAmount,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{isPredate,jdbcType=TINYINT}, #{predateAmount,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR},
#{type,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{perhour,jdbcType=DECIMAL}, #{type,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{perhour,jdbcType=DECIMAL},
#{view,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT} #{view,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}
) )
</insert> </insert>
@@ -227,4 +228,4 @@
</select> </select>
</mapper> </mapper>