Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/dao/TbCashierCartMapper.java
#	src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CartVo.java
#	src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
This commit is contained in:
SongZhang 2024-09-13 10:06:15 +08:00
commit 20d2683708
88 changed files with 3100 additions and 654 deletions

83
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>

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

@ -10,7 +10,7 @@ import lombok.Getter;
@Getter @Getter
public enum LogTag { public enum LogTag {
JPUSH("极光"), CLIENT("安卓"), JPUSH("极光"), CLIENT("安卓"),
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"); LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"), PLACE("下单");
private final String value; private final String value;
LogTag(String value) { LogTag(String value) {

View File

@ -0,0 +1,6 @@
package com.chaozhanggui.system.cashierservice.bean;
public class PrintProductInfo {
private Integer orderDetailId;
private Integer num;
}

View File

@ -0,0 +1,15 @@
package com.chaozhanggui.system.cashierservice.bean;
public enum TableStateEnum {
IDLE("idle"),
CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using");
private String state = "closed";
TableStateEnum(String state) {
this.state = state;
}
public String getState() {
return state;
}
}

View File

@ -23,6 +23,8 @@ public class LoginContoller {
@Autowired @Autowired
LoginService loginService; LoginService loginService;
@RequestMapping(value = "login",method = RequestMethod.POST) @RequestMapping(value = "login",method = RequestMethod.POST)
public Result login(@RequestBody LoginReq loginReq, HttpServletRequest request){ public Result login(@RequestBody LoginReq loginReq, HttpServletRequest request){
try { try {
@ -34,6 +36,11 @@ public class LoginContoller {
return Result.fail(CodeEnum.FAIL); return Result.fail(CodeEnum.FAIL);
} }
@RequestMapping(value = "findVersion",method = RequestMethod.POST)
public Result findVersion() {
return loginService.findVersion();
}
@RequestMapping("logout") @RequestMapping("logout")
public Result logout( @RequestHeader("token") String token, public Result logout( @RequestHeader("token") String token,
@ -51,4 +58,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,12 +1,12 @@
package com.chaozhanggui.system.cashierservice.controller; package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.service.MemberService; import com.chaozhanggui.system.cashierservice.service.MemberService;
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.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.servlet.http.HttpServletRequest;
import java.util.Map; import java.util.Map;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@ -26,10 +26,11 @@ public class MemberController {
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("shopId") String shopId, @RequestParam("shopId") String shopId,
@RequestParam("phone") String phone, @RequestParam("phone") String phone,
@RequestParam(value = "isFlag",required = false,defaultValue = "0") String isFlag,
@RequestParam("page") int page, @RequestParam("page") int page,
@RequestParam("pageSize") int pageSize @RequestParam("pageSize") int pageSize
){ ) {
return memberService.queryMember(shopId,phone,page,pageSize); return memberService.queryMember(shopId, phone, isFlag,page, pageSize);
} }
@ -37,8 +38,8 @@ public class MemberController {
public Result createMember(@RequestHeader("token") String token, public Result createMember(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map @RequestBody Map<String, Object> map
){ ) {
return memberService.createMember(map); return memberService.createMember(map);
} }
@ -48,32 +49,35 @@ public class MemberController {
@RequestHeader("token") String token, @RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map @RequestBody Map<String, Object> map
){ ) {
return memberService.memberScanPay(map,token); return memberService.memberScanPay(map, token);
} }
@GetMapping("queryScanPay") @GetMapping("queryScanPay")
public Result queryScanPay(@RequestHeader("token") String token, public Result queryScanPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("flowId") String flowId @RequestParam("flowId") String flowId
){ ) {
return memberService.queryScanPay(flowId,token); return memberService.queryScanPay(flowId, token);
} }
@RequestMapping("accountPay") @RequestMapping("accountPay")
public Result accountPay( @RequestHeader("token") String token, public Result accountPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map @RequestBody Map<String, Object> map
){ ) {
return memberService.memberAccountPay(map,token); try {
return memberService.memberAccountPay(map, token);
} catch (Exception e) {
e.printStackTrace();
}
return Result.fail(CodeEnum.SYS_EXCEPTION);
} }
@ -85,7 +89,20 @@ public class MemberController {
@RequestParam("page") int page, @RequestParam("page") int page,
@RequestParam("pageSize") int pageSize @RequestParam("pageSize") int pageSize
) {
return memberService.queryMemberAccount(memberId, page, pageSize);
}
@RequestMapping("returnFlow")
public Result returnFlow(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("flowId") String flowId,
@RequestParam("remark") String remark,
@RequestParam("amount") String amount,
@RequestParam("pwd") String pwd
){ ){
return memberService.queryMemberAccount(memberId,page,pageSize); return memberService.returnAccount(token, flowId,remark,amount, pwd);
} }
} }

View File

@ -6,12 +6,15 @@ import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.annotation.MyLog; import com.chaozhanggui.system.cashierservice.annotation.MyLog;
import com.chaozhanggui.system.cashierservice.bean.LogTag; 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.*;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@ -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,
@ -68,11 +79,12 @@ public class OrderController {
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("shopId") String shopId, @RequestParam("shopId") String shopId,
@RequestParam(required = false) String tableId,
String type String type
){ ){
JSONObject jsonObject = TokenUtil.parseParamFromToken(token); JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId"); String userId = jsonObject.getString("accountId");
return orderService.createCode(shopId,clientType,userId,type); return orderService.createCode(shopId,clientType,userId,type, tableId);
} }
@GetMapping("/getCartList") @GetMapping("/getCartList")
public Result getCart(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, public Result getCart(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -90,7 +102,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,
@ -99,7 +112,7 @@ public class OrderController {
String userId = jsonObject.getString("accountId"); String userId = jsonObject.getString("accountId");
orderVo.setMerchantId(Integer.valueOf(userId)); orderVo.setMerchantId(Integer.valueOf(userId));
orderVo.setUserId(jsonObject.getString("staffId")); orderVo.setUserId(jsonObject.getString("staffId"));
return orderService.createOrder(orderVo,clientType,token); return orderService.createOrder(orderVo,clientType,token, null, orderVo.getType() != null && orderVo.getType().equals(0));
} }
@PostMapping("/createBackOrder") @PostMapping("/createBackOrder")
public Result createBackOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, public Result createBackOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -139,7 +152,9 @@ public class OrderController {
public Result orderDetail(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, public Result orderDetail(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestParam("shopId") Integer shopId, @RequestHeader("clientType") String clientType, @RequestParam("shopId") Integer shopId,
@RequestParam("id") Integer id){ @RequestParam("id") Integer id){
return orderService.orderDetail(shopId,id); JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
return orderService.orderDetail(shopId,id, clientType, token, userId, jsonObject.getString("staffId"));
} }

View File

@ -3,16 +3,20 @@ package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit; import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail; import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto; import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO;
import com.chaozhanggui.system.cashierservice.model.PaymentReq;
import com.chaozhanggui.system.cashierservice.service.PayService; import com.chaozhanggui.system.cashierservice.service.PayService;
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.IpUtil; import com.chaozhanggui.system.cashierservice.util.IpUtil;
import com.chaozhanggui.system.cashierservice.util.RedisCst;
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.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@ -44,8 +48,6 @@ public class PayController {
* @param token * @param token
* @param loginName * @param loginName
* @param clientType * @param clientType
* @param orderId
* @param authCode
* @return * @return
*/ */
@RequestMapping("scanpay") @RequestMapping("scanpay")
@ -54,11 +56,9 @@ public class PayController {
@RequestHeader("token") String token, @RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestBody PaymentReq paymentReq
@RequestParam("authCode") String authCode
) { ) {
return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token); return payService.scanPay(paymentReq.getOrderId(),paymentReq.getAuthCode(), IpUtil.getIpAddr(request),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
} }
@ -67,21 +67,17 @@ public class PayController {
* @param token * @param token
* @param loginName * @param loginName
* @param clientType * @param clientType
* @param orderId
* @param memberId
* @return * @return
*/ */
@GetMapping("accountPay") @RequestMapping("accountPay")
@LimitSubmit(key = "accountPay:%s") @LimitSubmit(key = "accountPay:%s")
public Result accountPay(@RequestHeader("token") String token, public Result accountPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestBody PaymentReq paymentReq
@RequestParam("memberId") String memberId,
@RequestParam("memberAccount") String memberAccount
){ ){
return payService.accountPay(orderId,memberId,token,memberAccount); return payService.accountPay(paymentReq.getOrderId(),paymentReq.getMemberId(),token,paymentReq.getMemberAccount(),paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
} }
@ -154,19 +150,16 @@ public class PayController {
* @param token * @param token
* @param loginName * @param loginName
* @param clientType * @param clientType
* @param orderId
* @param memberCode
* @return * @return
*/ */
@GetMapping("memberScanPay") @RequestMapping("memberScanPay")
@LimitSubmit(key = "memberScanPay:%s") @LimitSubmit(key = "memberScanPay:%s")
public Result memberScanPay(@RequestHeader("token") String token, public Result memberScanPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestBody PaymentReq paymentReq
@RequestParam("memberCode") String memberCode
){ ){
return payService.memberScanPay(orderId,memberCode,token); return payService.memberScanPay(paymentReq.getOrderId(),paymentReq.getMemberCode(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
} }
@ -176,19 +169,48 @@ public class PayController {
* @param token * @param token
* @param loginName * @param loginName
* @param clientType * @param clientType
* @param orderId
* @return * @return
*/ */
@GetMapping("cashPay") @RequestMapping("cashPay")
@LimitSubmit(key = "cashPay:%s") @LimitSubmit(key = "cashPay:%s")
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){ @RequestBody PaymentReq paymentReq){
return payService.cashPay(orderId,token); Result result = payService.cashPay(paymentReq.getOrderId(), token, paymentReq.getPayAmount(), paymentReq.getDiscountAmount());
return result;
} }
/**
* 会员支付
* @param token
* @param loginName
* @param clientType
* @return
*/
@PostMapping("vipPay")
@LimitSubmit(key = "vipPay:%s")
public Result vipPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody VipPayDTO vipPayDTO
){
if (vipPayDTO.getOrderId() == null || vipPayDTO.getVipUserId() == null) {
return Result.fail("参数缺失");
}
if (
(vipPayDTO.getPayAmount() != null && vipPayDTO.getPayAmount().compareTo(BigDecimal.ZERO) <= 0) ||
(vipPayDTO.getDiscountAmount() != null && vipPayDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0)
) {
return Result.fail("折扣金额必须大于0");
}
return payService.vipPay(vipPayDTO.getOrderId(),token, vipPayDTO.getVipUserId(), vipPayDTO.getPayAmount(), vipPayDTO.getDiscountAmount());
}
/** /**
@ -196,16 +218,15 @@ public class PayController {
* @param token * @param token
* @param loginName * @param loginName
* @param clientType * @param clientType
* @param orderId
* @return * @return
*/ */
@GetMapping("bankPay") @RequestMapping("bankPay")
@LimitSubmit(key = "bankPay:%s") @LimitSubmit(key = "bankPay:%s")
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){ @RequestBody PaymentReq paymentReq){
return payService.bankPay(orderId,token); return payService.bankPay(paymentReq.getOrderId(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
} }
@ -221,7 +242,8 @@ public class PayController {
){ ){
return payService.returnOrder(list,token,null, isOnline);
return payService.returnOrder(list,token,pwd, isOnline);
} }
@ -244,4 +266,16 @@ public class PayController {
public Result testOrder( @RequestParam("orderId") String orderId){ public Result testOrder( @RequestParam("orderId") String orderId){
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }
@RequestMapping("getOrderDiscount")
public Result getOrderDiscount(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId,
@RequestParam("staffId") String staffId
){
return payService.getOrderDiscount(staffId, orderId, token);
}
} }

View File

@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO; import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO; 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.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.sign.Result;
@ -58,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,
@ -67,11 +77,12 @@ public class ProductController {
@RequestParam("categoryId") String categoryId, @RequestParam("categoryId") String categoryId,
@RequestParam("commdityName") String commdityName, @RequestParam("commdityName") String commdityName,
@RequestParam("masterId") String masterId, @RequestParam("masterId") String masterId,
@RequestParam(value = "tableId", required = false) String tableId,
@RequestParam("page") int page, @RequestParam("page") int page,
@RequestParam("pageSize") int pageSize @RequestParam("pageSize") int pageSize
){ ){
return productService.queryNewCommodityInfo(shopId,categoryId,commdityName,page,pageSize,masterId); return productService.queryNewCommodityInfo(shopId,categoryId,commdityName, tableId,page,pageSize,masterId);
} }
@GetMapping(value = "queryCategory") @GetMapping(value = "queryCategory")

View File

@ -59,4 +59,9 @@ public class ShopInfoController {
) { ) {
return shopInfoService.queryDutyFlow(token, shopId, page,pageSize); return shopInfoService.queryDutyFlow(token, shopId, page,pageSize);
} }
@GetMapping("queryPwdInfo")
public Result queryPwdInfo(@RequestParam("shopId") String shopId) {
return shopInfoService.queryShopPwdInfo(shopId);
}
} }

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;
@ -28,10 +30,10 @@ public interface TbCashierCartMapper {
List<TbCashierCart> selectALlByMasterId(@Param("masterId") String masterId,@Param("status") String status); List<TbCashierCart> selectALlByMasterId(@Param("masterId") String masterId,@Param("status") String status);
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, @Param("tableId") String tableId);
TbCashierCart selectDetailByQrcode(@Param("tableId") Integer tableId, @Param("productId") String productId, TbCashierCart selectDetailByQrcode(@Param("tableId") String tableId, @Param("productId") String productId,
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("userId") Integer userId); @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);
@ -45,12 +47,7 @@ public interface TbCashierCartMapper {
@Param("status") String status, @Param("day") String day, @Param("uuid") String uuid); @Param("status") String status, @Param("day") String day, @Param("uuid") String uuid);
List<TbCashierCart> selectAllCreateOrder(@Param("masterId") String masterId, @Param("shopId") Integer shopId, List<TbCashierCart> selectAllCreateOrder(@Param("masterId") String masterId, @Param("shopId") Integer shopId,
@Param("day") String day, @Param("status") String status, @Param("day") String day, @Param("status") String status,@Param("uuid") String uuid);
@Param("uuid") String uuid);
List<TbCashierCart> selectAllCreateOrder2(@Param("masterId") String masterId, @Param("shopId") Integer shopId,
@Param("day") String day, @Param("status") String status,
@Param("uuid") String uuid, @Param("tableId") Integer tableId, @Param("vipUserId") Integer vipUserId);
List<CartPo> selectCartList( @Param("cartId") String shopId); List<CartPo> selectCartList( @Param("cartId") String shopId);
int updateByOrderId(@Param("orderId") String orderId,@Param("status") String status); int updateByOrderId(@Param("orderId") String orderId,@Param("status") String status);
@ -69,7 +66,16 @@ 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") Integer tableId, @Param("shopId") Integer shopId, @Param("userId") Integer userId); List<TbCashierCart> selectActivateByQrcode(@Param("tableId") String tableId, @Param("shopId") Integer shopId);
QueryCartPo selectProductNumByQrcode(@Param("tableId") Integer tableId, @Param("shopId") Integer shopId, @Param("vipUserId") Integer vipUserId); 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);
@Select("select count(*) from tb_cashier_cart where shop_id=#{shopId} and `status`='create' and table_id=#{qrcode} and order_id is not null")
int countTable(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId);
@Select("select count(*) from tb_order_detail where shop_id=#{shopId} and `status`='unpaid' and order_id=#{orderId} and order_id is not null")
int countTableByDetail(@Param("orderId") Integer orderId, @Param("shopId") Integer shopId);
} }

View File

@ -25,7 +25,7 @@ public interface TbOrderDetailMapper {
int updateByPrimaryKey(TbOrderDetail record); int updateByPrimaryKey(TbOrderDetail record);
void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status); void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status,@Param("radio") BigDecimal radio);
void updateStatusByOrderIdAndStatus(@Param("orderId") int orderId,@Param("status") String status); void updateStatusByOrderIdAndStatus(@Param("orderId") int orderId,@Param("status") String status);
void deleteByOUrderId(@Param("orderId") int orderId); void deleteByOUrderId(@Param("orderId") int orderId);

View File

@ -40,7 +40,7 @@ public interface TbProductMapper {
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day); Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day, @Param("tableId") String tableId);
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num); void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);

View File

@ -48,10 +48,13 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0") @Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0")
int decrStock(String id, int num); int decrStock(String id, int num);
@Update("update tb_product_sku set real_sales_number=real_sales_number-#{num} WHERE id=#{skuId}")
int decrRealSalesNumber(@Param("skuId") Integer skuId, @Param("num") Integer num);
@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}")
@ -62,4 +65,7 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=#{stock} where product_id=#{skuId} and shop_id=#{shopId}") @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); 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,11 +24,13 @@ 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

@ -29,6 +29,6 @@ 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);") @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); List<TbShopOpenId> selectStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type);
} }

View File

@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.dao; package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable; import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
import com.chaozhanggui.system.cashierservice.entity.vo.TbShopTableVO;
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.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,4 +24,5 @@ public interface TbShopTableMapper {
int updateByPrimaryKey(TbShopTable record); int updateByPrimaryKey(TbShopTable record);
List<TbShopTable> selectByShopIdAndStatus(@Param("shopId") String shopId,@Param("areaId") String areaId,@Param("status") String status); List<TbShopTable> selectByShopIdAndStatus(@Param("shopId") String shopId,@Param("areaId") String areaId,@Param("status") String status);
List<TbShopTableVO> selectTableInfo(@Param("shopId") String shopId, @Param("areaId") String areaId, @Param("status") String status, @Param("day") String day);
} }

View File

@ -22,7 +22,7 @@ public interface TbShopUserMapper {
int updateByPrimaryKey(TbShopUser record); int updateByPrimaryKey(TbShopUser record);
List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone); List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone,@Param("isFlag") String isFlag);
List<TbShopUser> selectByShopIdAndPhone(@Param("shopId") String shopId,@Param("phone") String phone); List<TbShopUser> selectByShopIdAndPhone(@Param("shopId") String shopId,@Param("phone") String phone);

View File

@ -12,4 +12,7 @@ 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;
private Integer type;
} }

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,7 +58,11 @@ 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,10 @@ public class TbOrderInfo implements Serializable {
private String outNumber; private String outNumber;
private Integer staffId;
private String useType;
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

@ -34,6 +34,15 @@ public class TbPrintMachine implements Serializable {
private String vendorId; private String vendorId;
private String productId; private String productId;
private String config;
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

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

@ -92,6 +92,24 @@ public class TbShopInfo implements Serializable {
private String view; private String view;
private String isCustom;
private String isReturn;
private String isMemberIn;
private String isMemberReturn;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer getId() { public Integer getId() {
@ -445,4 +463,36 @@ public class TbShopInfo implements Serializable {
public void setView(String view) { public void setView(String view) {
this.view = view == null ? null : view.trim(); this.view = view == null ? null : view.trim();
} }
public String getIsCustom() {
return isCustom;
}
public void setIsCustom(String isCustom) {
this.isCustom = isCustom;
}
public String getIsReturn() {
return isReturn;
}
public void setIsReturn(String isReturn) {
this.isReturn = isReturn;
}
public String getIsMemberIn() {
return isMemberIn;
}
public void setIsMemberIn(String isMemberIn) {
this.isMemberIn = isMemberIn;
}
public String getIsMemberReturn() {
return isMemberReturn;
}
public void setIsMemberReturn(String isMemberReturn) {
this.isMemberReturn = isMemberReturn;
}
} }

View File

@ -21,6 +21,10 @@ public class TbShopUserFlow implements Serializable {
private String type; private String type;
private String isReturn;
private String remark;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer getId() { public Integer getId() {
@ -86,4 +90,20 @@ public class TbShopUserFlow implements Serializable {
public void setType(String type) { public void setType(String type) {
this.type = type == null ? null : type.trim(); this.type = type == null ? null : type.trim();
} }
public String getIsReturn() {
return isReturn;
}
public void setIsReturn(String isReturn) {
this.isReturn = isReturn;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
} }

View File

@ -0,0 +1,115 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
/**
* 版本管理(TbVersion)表实体类
*
* @author ww
* @since 2024-08-28 11:22:09
*/
@SuppressWarnings("serial")
public class TbVersion extends Model<TbVersion> {
private Integer id;
//PCAPP;
private String source;
//ios;android;
private String type;
//版本号
private String version;
//是否强制更新 0 1
private Integer isUp;
//更新提示内容
private String message;
//下载地址
private String url;
//选中 0否 1是
private Integer sel;
//创建时间
private Long createdAt;
//更新时间
private Long updatedAt;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Integer getIsUp() {
return isUp;
}
public void setIsUp(Integer isUp) {
this.isUp = isUp;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getSel() {
return sel;
}
public void setSel(Integer sel) {
this.sel = sel;
}
public Long getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Long createdAt) {
this.createdAt = createdAt;
}
public Long getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Long updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

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

@ -0,0 +1,14 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class VipPayDTO {
private Integer orderId;
private Integer vipUserId;
private BigDecimal payAmount;
private BigDecimal discountAmount;
}

View File

@ -28,4 +28,9 @@ public class OrderPo {
private String remark; private String remark;
private BigDecimal discountRatio;
private BigDecimal discountAmount;
} }

View File

@ -5,11 +5,6 @@ import lombok.Data;
@Data @Data
public class CartVo { public class CartVo {
private String productId; private String productId;
// orderId不为空为代客下单
private String masterId;
private Integer tableId;
private Integer vipUserId;
private String shopId; private String shopId;
private Integer skuId; private Integer skuId;
private Integer number; private Integer number;
@ -19,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,17 @@
package com.chaozhanggui.system.cashierservice.entity.vo;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
@EqualsAndHashCode(callSuper = true)
@Data
public class TbShopTableVO extends TbShopTable {
private Integer userId;
private String masterId;
private Integer orderId;
private String orderNo;
private BigDecimal orderAmount;
}

View File

@ -1,7 +1,10 @@
package com.chaozhanggui.system.cashierservice.interceptor; package com.chaozhanggui.system.cashierservice.interceptor;
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit; import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO;
import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.PaymentReq;
import com.chaozhanggui.system.cashierservice.util.RedisUtils; import com.chaozhanggui.system.cashierservice.util.RedisUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
@ -13,6 +16,7 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List;
@Component @Component
@Aspect @Aspect
@ -36,6 +40,7 @@ public class LimitSubmitAspect {
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
Object[] args= joinPoint.getArgs(); Object[] args= joinPoint.getArgs();
String orderId=orderId(method,args);
//获取注解信息 //获取注解信息
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class); LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
@ -44,7 +49,7 @@ public class LimitSubmitAspect {
int submitTimeLimiter = limitSubmit.limit(); int submitTimeLimiter = limitSubmit.limit();
String key = getRedisKey(joinPoint, redisKey, String.valueOf(args[0])); String key = getRedisKey(joinPoint, redisKey, orderId);
Object result = redisUtil.get(key); Object result = redisUtil.get(key);
log.info("开始锁定资源信息" + key); log.info("开始锁定资源信息" + key);
@ -79,9 +84,18 @@ public class LimitSubmitAspect {
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
Object[] args= joinPoint.getArgs(); Object[] args= joinPoint.getArgs();
String orderId=orderId(method,args);
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class); LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
String redisKey = limitSubmit.key(); String redisKey = limitSubmit.key();
String key = getRedisKey1(joinPoint, redisKey, String.valueOf(args[0])); String key = getRedisKey1(joinPoint, redisKey,orderId);
log.info("正常释放了锁资源" + key); log.info("正常释放了锁资源" + key);
// 延时 1s 释放 // 延时 1s 释放
try { try {
@ -104,7 +118,8 @@ public class LimitSubmitAspect {
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class); LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
String redisKey = limitSubmit.key(); String redisKey = limitSubmit.key();
Object[] args= joinPoint.getArgs(); Object[] args= joinPoint.getArgs();
String key = getRedisKey1(joinPoint, redisKey, String.valueOf(args[0])); String orderId=orderId(method,args);
String key = getRedisKey1(joinPoint, redisKey, orderId);
log.info("发生异常释放了锁资源" + key); log.info("发生异常释放了锁资源" + key);
// 延时 1s 释放 // 延时 1s 释放
try { try {
@ -158,4 +173,40 @@ public class LimitSubmitAspect {
} }
return key.toString(); return key.toString();
} }
private String orderId(Method method,Object[] args){
String orderId=null;
if("scanpay".equals(method.getName())||
"accountPay".equals(method.getName())||
"memberScanPay".equals(method.getName())||
"cashPay".equals(method.getName())||
"bankPay".equals(method.getName())){
Object o=args[3];
if(o instanceof PaymentReq){
orderId=((PaymentReq)o).getOrderId();
}
}else if("vipPay".equals(method.getName())){
Object o=args[3];
if(o instanceof VipPayDTO){
orderId=((VipPayDTO)o).getOrderId().toString();
}
}else if("quickPay".equals(method.getName())) {
Object o=args[4];
if(o instanceof String){
orderId=o.toString();
}
}else if ("returnOrder".equals(method.getName())) {
Object o=args[3];
if(o instanceof List){
orderId= ((List<TbOrderDetail>)o).get(0).getOrderId().toString();
}
}
return orderId;
}
} }

View File

@ -18,6 +18,7 @@ public class WebAppConfigurer implements WebMvcConfigurer {
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/login/login") .excludePathPatterns("/login/login")
.excludePathPatterns("/login/getPhone") .excludePathPatterns("/login/getPhone")
.excludePathPatterns("/login/findVersion")
.excludePathPatterns("/cloudPrinter/print") .excludePathPatterns("/cloudPrinter/print")
.excludePathPatterns("/cloudPrinter/handoverPrint") .excludePathPatterns("/cloudPrinter/handoverPrint")
.excludePathPatterns("/data/handoverData") .excludePathPatterns("/data/handoverData")
@ -26,6 +27,9 @@ public class WebAppConfigurer implements WebMvcConfigurer {
.excludePathPatterns("/qrcode/getscanCode") .excludePathPatterns("/qrcode/getscanCode")
.excludePathPatterns("/order/sendMessage") .excludePathPatterns("/order/sendMessage")
.excludePathPatterns("/order/getOrderById") .excludePathPatterns("/order/getOrderById")
.excludePathPatterns("/data/handoverprint"); .excludePathPatterns("/data/handoverprint")
;
} }
} }

View File

@ -35,6 +35,10 @@ public class OrderDetailPO implements Serializable {
private String outNumber; private String outNumber;
private String discountAmount;
private String discountAdio;
@Data @Data
public static class Detail implements Serializable{ public static class Detail implements Serializable{
@ -55,7 +59,9 @@ public class OrderDetailPO implements Serializable {
} }
public OrderDetailPO(String merchantName, String printType, String masterId, String orderNo, String tradeDate, String operator, String receiptsAmount, String balance, String payType, String integral, List<Detail> detailList, String remark) { public OrderDetailPO(String merchantName, String printType, String masterId, String orderNo, String tradeDate, String operator, String receiptsAmount, String balance, String payType, String integral, List<Detail> detailList, String remark,
String discountAmount,String discountAdio
) {
this.merchantName = merchantName; this.merchantName = merchantName;
this.printType = printType; this.printType = printType;
this.masterId = masterId; this.masterId = masterId;
@ -68,5 +74,7 @@ public class OrderDetailPO implements Serializable {
this.integral = integral; this.integral = integral;
this.detailList = detailList; this.detailList = detailList;
this.remark = remark; this.remark = remark;
this.discountAmount=discountAmount;
this.discountAdio=discountAdio;
} }
} }

View File

@ -0,0 +1,26 @@
package com.chaozhanggui.system.cashierservice.model;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class PaymentReq implements Serializable {
private String orderId;
private BigDecimal payAmount;
private BigDecimal discountAmount;
private String authCode;
private String memberId;
private String memberAccount;
private String memberCode;
}

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.TbPrintMachine;
public interface MpPrintMachineMapper extends BaseMapper<TbPrintMachine> {
}

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

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

View File

@ -0,0 +1,13 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.math.BigDecimal;
public interface MpShopUserMapper extends BaseMapper<TbShopUser> {
@Update("update tb_shop_user set amount=amount-#{orderAmount}, consume_amount=consume_amount+#{orderAmount} where id=#{vipUserId} and amount-#{orderAmount} >= 0")
long decrBalance(@Param("vipUserId") Integer vipUserId, @Param("orderAmount") BigDecimal orderAmount);
}

View File

@ -0,0 +1,15 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbVersion;
/**
* 版本管理(TbVersion)表数据库访问层
*
* @author ww
* @since 2024-08-28 11:22:09
*/
public interface TbVersionMapper extends BaseMapper<TbVersion> {
}

View File

@ -0,0 +1,179 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbUserInfoMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@Slf4j
@Component
@RabbitListener(queues = {RabbitConstants.BALANCE_QUEUE_PUT})
@Service
public class BalanceConsumer {
@Value("${wx.balance.appId}")
private static String appId="wxd88fffa983758a30" ;
@Value("${wx.balance.secrete}")
private static String secrete="a34a61adc0602118b49400baa8812454" ;
@Value("${wx.balance.warnMsgTmpId}")
private static String msgTmpId = "AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ";
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
static {
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40003","不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID");
linkedHashMap.put("40014","不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40037","不合法的 template_id");
linkedHashMap.put("43101","用户未订阅消息");
linkedHashMap.put("43107","订阅消息能力封禁");
linkedHashMap.put("43108","并发下发消息给同一个粉丝");
linkedHashMap.put("45168","命中敏感词");
linkedHashMap.put("47003","参数错误");
}
@Autowired
TbUserInfoMapper tbUserInfoMapper;
@Autowired
TbShopInfoMapper tbShopInfoMapper;
public static String getAccessToken() {
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
url = url.replace("APPID", appId).replace("APPSECRET", secrete);
// url = url.replace("APPID", "wxd88fffa983758a30").replace("APPSECRET", "a34a61adc0602118b49400baa8812454");
String result = HttpUtil.get(url);
JSONObject jsonObject = JSON.parseObject(result);
return jsonObject.getString("access_token");
}
public static JSONObject sendTemplateMsg(String templateId, String toUserOpenId,String shopName,String amount,String balance,String type,String date ) {
log.info("开始发送微信模板消息, 接收用户openId: {},templateId:{},shopName:{},amount:{},balance:{},type:{},date:{}", toUserOpenId,templateId, shopName,amount,balance,type,date);
String accessToken = getAccessToken();
JSONObject data = new JSONObject();
data.put("touser", toUserOpenId);
data.put("template_id", templateId);
data.put("page", "index");
// 设置消息内容
JSONObject thing3 = new JSONObject();
thing3.put("value",shopName );
JSONObject amount1=new JSONObject();
amount1.put("value",amount);
JSONObject amount2=new JSONObject();
amount2.put("value",balance);
JSONObject thing4=new JSONObject();
thing4.put("value",type);
JSONObject time5=new JSONObject();
time5.put("value",date);
data.put("data", new JSONObject().fluentPut("thing3", thing3).fluentPut("amount1", amount1).fluentPut("amount2",amount2).fluentPut("thing4",thing4).fluentPut("time5",time5));
log.info("微信模板消息请求参数 request:{}",data.toString());
String response= HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(data.toString()).execute().body();
log.info("微信模板消息发送成功,响应内容:{}",response);
JSONObject resObj=JSONObject.parseObject(response);
if(ObjectUtil.isNotEmpty(resObj)&&ObjectUtil.isNotNull(resObj)&&"0".equals(resObj.get("errcode")+"")){
return resObj;
}
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
}
@RabbitHandler
public void listener(String message) {
try {
JSONObject object=JSONObject.parseObject(message);
String shopId=object.getString("shopId");
BigDecimal amount=object.getBigDecimal("amount").setScale(2, RoundingMode.DOWN);
BigDecimal balance=object.getBigDecimal("balance").setScale(2, RoundingMode.DOWN);
String type=object.getString("type");
Date time=object.getDate("time");
String userId=object.getString("userId");
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
if(ObjectUtil.isNull(shopInfo)){
log.info("没有对应的店铺信息");
return;
}
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
if(ObjectUtil.isNull(userInfo)||ObjectUtil.isNull(userInfo.getMiniAppOpenId())){
log.info("没有对应的openId");
return;
}
String toUserOpenId=userInfo.getMiniAppOpenId();
try {
JSONObject resObj=sendTemplateMsg(msgTmpId, toUserOpenId, shopInfo.getShopName(),amount.toPlainString(),balance.toPlainString(),type,convertDate(time));
log.info("会员变动消息发送返回:{}",resObj.toString());
}catch (Exception e) {
log.error("发送失败, openId:{}, msg: {}", toUserOpenId, e.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static String convertDate(Date date){
SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
return sdf4.format(new Date());
}
public static void main(String[] args) {
//
sendTemplateMsg("AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ","or1l862a5N_W6eoL1-sJeewpOjZw","测试店铺",new BigDecimal(0.01).toPlainString(),new BigDecimal(6.21).toPlainString(),"充值",convertDate(new Date()));
}
}

View File

@ -94,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;
} }
@ -123,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->{
@ -133,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(), ShopWxMsgTypeEnum.CONSUMABLES_MSG, shopId); 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

@ -1,28 +1,29 @@
package com.chaozhanggui.system.cashierservice.rabbit; package com.chaozhanggui.system.cashierservice.rabbit;
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.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.model.CategoryInfo; import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO; import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.*;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.annotation.RabbitListeners;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.Date; import java.util.concurrent.ConcurrentHashMap;
import java.util.List; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Component @Component
@ -49,11 +50,23 @@ public class PrintMechineConsumer {
@Autowired @Autowired
private TbOrderDetailMapper tbOrderDetailMapper; private TbOrderDetailMapper tbOrderDetailMapper;
@Autowired
private RedisUtil redisUtils;
private final RedisTemplate<String, Object> redisTemplate;
@Autowired
private MpPrintMachineMapper mpPrintMachineMapper;
public PrintMechineConsumer(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
@RabbitHandler @RabbitHandler
public void listener(String message) { public void listener(String message) {
String orderId = message; String orderId = message;
log.info("接收到打印mq消息: {}", message);
try { try {
@ -79,15 +92,15 @@ public class PrintMechineConsumer {
} }
list.parallelStream().forEach(it->{ list.forEach(it -> {
if (!"network".equals(it.getConnectionType())) { if (!"network".equals(it.getConnectionType())) {
log.error("非网络打印机:{},{}",it.getAddress(),it.getConnectionType()); log.error("非网络打印机:{},{}", it.getAddress(), it.getConnectionType());
return; return;
} }
if (!"1".equals(it.getStatus().toString())) { if (!"1".equals(it.getStatus().toString())) {
log.error("打印机状态异常:{},{}",it.getAddress(),it.getStatus()); log.error("打印机状态异常:{},{}", it.getAddress(), it.getStatus());
return; return;
} }
@ -99,21 +112,20 @@ public class PrintMechineConsumer {
String feet = config.getString("feet"); String feet = config.getString("feet");
String autoCut = config.getString("autoCut"); String autoCut = config.getString("autoCut");
List<CategoryInfo> categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class); List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(), CategoryInfo.class);
switch (it.getContentType()){ switch (it.getContentType()) {
case "yxyPrinter": case "yxyPrinter":
yxyPrinter(it,model,orderInfo,shopInfo,printerNum,categoryInfos); yxyPrinter(it, model, orderInfo, shopInfo, printerNum, categoryInfos);
break; break;
case "fePrinter": case "fePrinter":
fePrinter(it,model,orderInfo,shopInfo,printerNum,categoryInfos); fePrinter(it, model, orderInfo, shopInfo, printerNum, categoryInfos);
break; break;
} }
}); });
} catch (Exception e) {
}catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -121,14 +133,16 @@ public class PrintMechineConsumer {
/** /**
* 博时结云打印机 * 博时结云打印机
*
* @param tbPrintMachineWithBLOBs * @param tbPrintMachineWithBLOBs
* @param model * @param model
* @param orderInfo * @param orderInfo
* @param shopInfo * @param shopInfo
* @param printerNum * @param printerNum
*/ */
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){ private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model,
String orderId=orderInfo.getId().toString(); TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) { switch (tbPrintMachineWithBLOBs.getSubType()) {
@ -139,17 +153,17 @@ public class PrintMechineConsumer {
case "normal": //普通出单 case "normal": //普通出单
if("return".equals(orderInfo.getOrderType())){ if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){ if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it->{ tbOrderDetails.parallelStream().forEach(it -> {
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
log.info("获取当前类别是否未打印类别:{}",count); log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@ -171,23 +185,25 @@ public class PrintMechineConsumer {
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark()); OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
String printType="退款单"; String printType = "退款单";
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return"); String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
} }
return; return;
} }
if ((!orderInfo.getStatus().equals("closed"))) {
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); return;
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0) { }
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.stream().forEach(it -> { tbOrderDetails.stream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
@ -215,71 +231,40 @@ public class PrintMechineConsumer {
balance = user.getAmount().toPlainString(); balance = user.getAmount().toPlainString();
} }
} }
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); // OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
detailPO.setOutNumber(orderInfo.getOutNumber()); detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单"; String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType()); String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
} }
} }
break; break;
case "one": //一菜一品 case "one": //一菜一品
// if (StrUtil.isNotBlank(orderInfo.getUseType()) && orderInfo.getUseType().equals("postPay")
if("return".equals(orderInfo.getOrderType())){ // && (!orderInfo.getStatus().equals("unpaid"))) {
List<TbOrderDetail> details= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); // return;
if(ObjectUtil.isNotEmpty(details)&&details.size()>0){ // }
details.parallelStream().forEach(it->{ if ("return".equals(orderInfo.getOrderType())) {
printReturnTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c->
c.getId().toString().equals(categoryId)
).count();
if(count>0){
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("return",orderInfo.getPayType().equals("wx_lite")?orderInfo.getTableName():orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
return; return;
}else { } else {
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { // printNormalTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if(count>0){
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("",orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
} }
break; break;
case "category": //分类出单 case "category": //分类出单
@ -292,39 +277,291 @@ public class PrintMechineConsumer {
} }
} }
private void printTicket(Integer orderId, List<CategoryInfo> categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) {
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
AtomicReference<Set<Object>> printProductSet = new AtomicReference<>(redisTemplate.opsForSet().members(printKey));
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderId);
// 重置打印数据
redisTemplate.delete(printKey);
if (!tbOrderDetails.isEmpty()) {
tbOrderDetails.forEach(it -> {
log.info("开始打印一菜一品票据,:{}", it.getProductName());
String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId();
long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if (count > 0) {
// 统计已打数量
int printerNum = 0;
boolean isReturn = false;
String key = RedisCst.ORDER_PRINT + orderId + ":" + it.getProductId() + ":" + it.getProductSkuId();
String info = redisUtils.getMessage(key);
redisUtils.saveMessage(key, String.valueOf(it.getNum()), 60 * 60 * 24);
// 删除已打印数据
if (printProductSet.get() != null) {
printProductSet.set(printProductSet.get().stream().filter(r -> {
TbOrderDetail detail = (TbOrderDetail) r;
return !detail.getProductSkuId().equals(it.getProductSkuId()) || !detail.getProductId().equals(it.getProductId());
}).collect(Collectors.toSet()));
}
if (info != null) {
isReturn = it.getNum() - Integer.parseInt(info) < 0;
printerNum = it.getNum() - Integer.parseInt(info);
}else {
printerNum = it.getNum();
}
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){ log.info("已打印数量, {}, 未打印数量: {}", info, printerNum);
String orderId=orderInfo.getId().toString();
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
// 将已打印信息加入redis
it.setRemark(remark);
redisTemplate.opsForSet().add(printKey, it);
redisTemplate.expire(printKey, 24, TimeUnit.HOURS);
// 已打印不再打印
if (info != null && it.getNum() - Integer.parseInt(info) == 0) {
return;
}
String data;
String voiceJson;
if (isReturn) {
data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), Math.abs(printerNum), remark);
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
} else {
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
printerNum, remark);
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
}
});
}
// 已删除的商品打印退款信息
if (printProductSet.get() != null) {
printProductSet.get().forEach(item -> {
log.info("已删除订单,打印退款票据, {}", item);
TbOrderDetail orderDetail = (TbOrderDetail) item;
String data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
log.info("删除商品数量记录key, {}", key);
redisUtils.deleteByKey(key);
});
}
}
/**
* 打印退款订单
* @param orderId 订单id
* @param tbOrderDetails 现有订单
*/
public void printReturnTicket(Integer orderId, List<TbOrderDetail> tbOrderDetails) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(new LambdaUpdateWrapper<TbPrintMachine>()
.eq(TbPrintMachine::getContentType, "yxyPrinter")
.eq(TbPrintMachine::getConnectionType, "network")
.eq(TbPrintMachine::getSubType, "cash")
.eq(TbPrintMachine::getStatus, 1)
.eq(TbPrintMachine::getShopId, orderInfo.getShopId()));
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
Set<Object> printProductSet = redisTemplate.opsForSet().members(printKey);
Set<Object> printProductSetCopy = redisTemplate.opsForSet().members(printKey);
log.info("-------------------开始打印退款订单,打印机列表: {}", list);
log.info("-------------------待打印数据: {}", printProductSet);
if (printProductSet != null && !printProductSet.isEmpty()) {
// 过滤出已经删除的订单
if (tbOrderDetails != null && !tbOrderDetails.isEmpty()) {
for (TbOrderDetail it : tbOrderDetails) {
printProductSet = printProductSet.stream().filter(r -> {
TbOrderDetail detail = (TbOrderDetail) r;
return !detail.getProductSkuId().equals(it.getProductSkuId()) || !detail.getProductId().equals(it.getProductId());
}).collect(Collectors.toSet());
printProductSetCopy = printProductSet.stream().filter(r -> {
TbOrderDetail detail = (TbOrderDetail) r;
return detail.getProductSkuId().equals(it.getProductSkuId()) && detail.getProductId().equals(it.getProductId());
}).collect(Collectors.toSet());
}
redisTemplate.delete(printKey);
for (Object o : printProductSetCopy) {
redisTemplate.opsForSet().add(printKey, o);
}
}else if (tbOrderDetails != null) {
redisTemplate.delete(printKey);
}
log.info("-------------------打印机数量{}", list.size());
for (TbPrintMachine machine : list) {
String config = machine.getConfig();
if (config != null) {
JSONObject jsonObject = JSONObject.parseObject(config);
if (!"one".equals(jsonObject.getString("model"))) {
continue;
}
}
log.info("-------------------商品数量{}", printProductSet.size());
printProductSet.forEach(item -> {
log.info("已删除订单,打印退款票据, {}", item);
TbOrderDetail orderDetail = (TbOrderDetail) item;
String data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
log.info("删除商品数量记录key, {}", key);
redisUtils.deleteByKey(key);
});
}
}
}
/**
* 普通出菜单打印
*/
private void printNormalTicket(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos, String orderId) {
List<TbOrderDetail> tbOrderDetails;
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && !tbOrderDetails.isEmpty()) {
tbOrderDetails.parallelStream().forEach(it -> {
// 已经打印过的菜品不再打印
if ("postPay".equals(orderInfo.getUseType()) && isPrint(it, orderInfo.getId())) {
return;
}
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
}
/**
* 退款单打印
*/
private void printReturnTicket(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos, String orderId) {
List<TbOrderDetail> details = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(details) && details.size() > 0) {
details.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ? orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
}
/**
* 判断商品是否已打票
*
* @return true 已打 false 未打
*/
private boolean isPrint(TbOrderDetail orderDetail, Integer orderId) {
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
String info = redisUtils.getMessage(key);
redisUtils.saveMessage(key, String.valueOf(orderDetail.getNum()), 60 * 60 * 24);
if (info == null) {
return false;
}
orderDetail.setNum(orderDetail.getNum() - Integer.parseInt(info));
return true;
}
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) { switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机 case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it->{ cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
log.info("获取当前类别是否未打印类别:{}",count); log.info("获取当前类别是否未打印类别:{}", count);
if(count>0) { if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap(); remark = tbProductSkuWithBLOBs.getSpecSnap();
} }
for(int i=0;i<it.getNumber();i++){ for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark); FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
} }
} }
@ -336,17 +573,17 @@ public class PrintMechineConsumer {
switch (model) { switch (model) {
case "normal": //普通出单 case "normal": //普通出单
if("return".equals(orderInfo.getOrderType())){ if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){ if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it->{ tbOrderDetails.parallelStream().forEach(it -> {
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
log.info("获取当前类别是否未打印类别:{}",count); log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@ -368,20 +605,20 @@ public class PrintMechineConsumer {
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); // OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark()); OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio().toPlainString());
String printType="退款单"; String printType = "退款单";
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return"); String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; // String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); // PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
} }
}else { } else {
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
@ -420,7 +657,7 @@ public class PrintMechineConsumer {
} }
} }
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "结算单"; String printType = "结算单";
if ("return".equals(orderInfo.getOrderType())) { if ("return".equals(orderInfo.getOrderType())) {
@ -437,30 +674,36 @@ public class PrintMechineConsumer {
break; break;
case "one": //一菜一品 case "one": //一菜一品
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); if (!orderInfo.getStatus().equals("unpaid")) {
return;
}
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
if(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap(); remark = tbProductSkuWithBLOBs.getSpecSnap();
} }
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(),orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
} }
}); });
} }

View File

@ -126,5 +126,23 @@ public class RabbitConfig {
@Bean
public DirectExchange balance_msg_Exchange_Register() {
return new DirectExchange(RabbitConstants.BALANCE_PUT);
}
@Bean
public Queue queuebalance_msg_Register() {
return new Queue(RabbitConstants.BALANCE_QUEUE_PUT, true); //队列持久
}
@Bean
public Binding bindingbalance_msg_Register() {
return BindingBuilder.bind(queuebalance_msg_Register()).to(balance_msg_Exchange_Register()).with(RabbitConstants.BALANCE_ROUTINGKEY_PUT);
}
} }

View File

@ -47,4 +47,15 @@ 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";
public static final String BALANCE_PUT="balance_put";
public static final String BALANCE_QUEUE_PUT="balance_queue_put";
public static final String BALANCE_ROUTINGKEY_PUT="balance_routingkey_put";
} }

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);
@ -52,6 +50,14 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
} }
public void balance(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.BALANCE_PUT, RabbitConstants.BALANCE_ROUTINGKEY_PUT, content, correlationId);
}
@Override @Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) { public void confirm(CorrelationData correlationData, boolean ack, String cause) {
logger.info(" 回调id:" + correlationData); logger.info(" 回调id:" + correlationData);
@ -71,4 +77,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

@ -189,7 +189,11 @@ public class CloudPrinterService {
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); // OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark()); OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0",
detailList,orderInfo.getRemark(),null,null);
detailPO.setOutNumber(orderInfo.getOutNumber()); detailPO.setOutNumber(orderInfo.getOutNumber());
String printType="退款单"; String printType="退款单";
@ -251,7 +255,12 @@ public class CloudPrinterService {
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark()); OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
balance, (ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0",
detailList,orderInfo.getRemark(),orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
String printType="结算单"; String printType="结算单";
detailPO.setOutNumber(orderInfo.getOutNumber()); detailPO.setOutNumber(orderInfo.getOutNumber());
@ -439,7 +448,7 @@ public class CloudPrinterService {
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); // OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark()); OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark(),null,null);
String printType="退款单"; String printType="退款单";
@ -495,7 +504,12 @@ public class CloudPrinterService {
} }
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark()); OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ),
"0", detailList,orderInfo.getRemark(),null,null);
String printType="结算单"; String printType="结算单";
if(ispre){ if(ispre){
printType="预结算单"; printType="预结算单";

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

@ -273,6 +273,12 @@ public class DataService {
JSONObject config = JSONObject.parseObject(it.getConfig());
String model = config.getString("model");
if(!"normal".equals(model)){
log.error("打印机类型错误");
return;
}
List<HandoverInfo.PayInfo> list = null; List<HandoverInfo.PayInfo> list = null;
List<HandoverInfo.MemberData> memberData = null; List<HandoverInfo.MemberData> memberData = null;
List<HandoverInfo.ProductCategory> productCategories = null; List<HandoverInfo.ProductCategory> productCategories = null;

View File

@ -3,9 +3,11 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.model.LoginReq; import com.chaozhanggui.system.cashierservice.model.LoginReq;
import com.chaozhanggui.system.cashierservice.mybatis.TbVersionMapper;
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;
@ -14,6 +16,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;
@ -47,6 +50,8 @@ public class LoginService {
@Autowired @Autowired
TbTokenMapper tbTokenMapper; TbTokenMapper tbTokenMapper;
@Autowired @Autowired
TbVersionMapper versionMapper;
@Autowired
RabbitProducer rabbitProducer; RabbitProducer rabbitProducer;
@ -140,6 +145,14 @@ public class LoginService {
return Result.success(CodeEnum.SUCCESS, accountMap); return Result.success(CodeEnum.SUCCESS, accountMap);
} }
public Result findVersion() {
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TbVersion::getSource,"PC");
queryWrapper.eq(TbVersion::getSel,1);
return new Result(SUCCESS,versionMapper.selectOne(queryWrapper));
}
public Result logout(String loginName, String clientType, String token, String status) { public Result logout(String loginName, String clientType, String token, String status) {
@ -191,4 +204,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

@ -5,21 +5,23 @@ import cn.hutool.core.util.RandomUtil;
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.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.ScanPayReq; import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq; import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
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;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp; import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderReturnResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp; import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp; import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService; import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
import com.chaozhanggui.system.cashierservice.util.*; import com.chaozhanggui.system.cashierservice.util.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -65,6 +67,10 @@ public class MemberService {
RestTemplate restTemplate; RestTemplate restTemplate;
@Autowired @Autowired
TbActivateMapper tbActivateMapper; TbActivateMapper tbActivateMapper;
@Autowired
TbmerchantAccountMapper tbmerchantAccountMapper;
@Autowired
RabbitProducer producer;
@Value("${gateway.url}") @Value("${gateway.url}")
private String gateWayUrl; private String gateWayUrl;
@Value("${thirdPay.payType}") @Value("${thirdPay.payType}")
@ -74,13 +80,21 @@ public class MemberService {
@Value("${thirdPay.callBack}") @Value("${thirdPay.callBack}")
private String callBack; private String callBack;
@Qualifier("tbOrderInfoMapper")
@Autowired @Autowired
TbmerchantAccountMapper tbmerchantAccountMapper; private TbOrderInfoMapper tbOrderInfoMapper;
private MpShopTableMapper mpShopTableMapper;
public Result queryMember(String shopId, String phone, int page, int pageSize) { public Result queryMember(String shopId, String phone,String isFlag, int page, int pageSize) {
PageHelperUtil.startPage(page, pageSize); PageHelperUtil.startPage(page, pageSize);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone);
if(!"1".equals(isFlag)){
isFlag=null;
}
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone,isFlag);
PageInfo pageInfo = new PageInfo(tbShopUsers); PageInfo pageInfo = new PageInfo(tbShopUsers);
return Result.success(CodeEnum.SUCCESS, pageInfo); return Result.success(CodeEnum.SUCCESS, pageInfo);
} }
@ -103,12 +117,12 @@ public class MemberService {
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopIdAndPhone(shopId, phone); List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopIdAndPhone(shopId, phone);
if (ObjectUtil.isNotEmpty(tbShopUsers)&&tbShopUsers.stream().filter(it->"1".equals(it.getIsVip().toString())).count()>0) { if (ObjectUtil.isNotEmpty(tbShopUsers) && tbShopUsers.stream().filter(it -> "1".equals(it.getIsVip().toString())).count() > 0) {
return Result.fail(CodeEnum.MEMBERHAVED); return Result.fail(CodeEnum.MEMBERHAVED);
} }
if(tbUserInfoMapper.selectCountByPhone(phone)>1){ if (tbUserInfoMapper.selectCountByPhone(phone) > 1) {
return Result.fail(CodeEnum.SAMEUSER); return Result.fail(CodeEnum.SAMEUSER);
} }
@ -135,7 +149,7 @@ public class MemberService {
TbShopUser tbShopUser = new TbShopUser(); TbShopUser tbShopUser = new TbShopUser();
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPhone(phone); TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPhone(phone);
if(tbUserInfo!=null){ if (tbUserInfo != null) {
tbShopUser.setUserId(tbUserInfo.getId().toString()); tbShopUser.setUserId(tbUserInfo.getId().toString());
} }
tbShopUser.setAmount(BigDecimal.ZERO); tbShopUser.setAmount(BigDecimal.ZERO);
@ -158,23 +172,19 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }
@Autowired
RabbitProducer producer;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result memberScanPay(Map<String, Object> map,String token) { public Result memberScanPay(Map<String, Object> map, String token) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0 if (ObjectUtil.isEmpty(map) || map.size() <= 0
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId")) || !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId")) || !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|| !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount")) || !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount"))
|| !map.containsKey("authCode") || ObjectUtil.isEmpty(map.get("authCode")) || !map.containsKey("authCode") || ObjectUtil.isEmpty(map.get("authCode"))
) { ) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
String memberId = String.valueOf(map.get("memberId")); String memberId = String.valueOf(map.get("memberId"));
String shopId = String.valueOf(map.get("shopId")); String shopId = String.valueOf(map.get("shopId"));
@ -184,6 +194,32 @@ public class MemberService {
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) { if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST); return Result.fail(CodeEnum.SHOPINFONOEXIST);
} }
// if ("1".equals(shopInfo.getIsMemberIn())) {
// if (!map.containsKey("pwd") || ObjectUtil.isEmpty(map.get("pwd"))) {
// return Result.fail(CodeEnum.PARAM);
// }
// String pwd = map.get("pwd").toString();
// String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
//
//
// TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
// if (Objects.isNull(account)) {
// return Result.fail(CodeEnum.ACCOUNTEIXST);
// }
//
//
// if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
// return Result.fail(CodeEnum.PWDNOSET);
// }
//
// if (!account.getPwd().equals(MD5Util.encrypt(pwd.concat(account.getAccount()).concat(account.getId().toString())))) {
// return Result.fail(CodeEnum.PWDERROE);
// }
// }
TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId)); TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) { if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST); return Result.fail(CodeEnum.MEMBERNOEXIST);
@ -193,25 +229,23 @@ public class MemberService {
String qpay = null; String qpay = null;
String payTypeCode = authCode.substring(0, 2);// 判断收款码 String payTypeCode = authCode.substring(0, 2);// 判断收款码
String wechatpay=""; String wechatpay = "";
if (Integer.valueOf(payTypeCode) >= 25 && Integer.valueOf(payTypeCode) <= 30) {
if(Integer.valueOf(payTypeCode)>=25&&Integer.valueOf(payTypeCode)<=30){
qpay = "scanCode"; qpay = "scanCode";
}else if(Integer.valueOf(payTypeCode)>=10&&Integer.valueOf(payTypeCode)<=19){ } else if (Integer.valueOf(payTypeCode) >= 10 && Integer.valueOf(payTypeCode) <= 19) {
qpay = "scanCode"; qpay = "scanCode";
wechatpay="wxpay"; wechatpay = "wxpay";
}else if("62".equals(payTypeCode)){ } else if ("62".equals(payTypeCode)) {
return Result.fail(CodeEnum.ERRORQR); return Result.fail(CodeEnum.ERRORQR);
}else if("01".equals(payTypeCode)){ } else if ("01".equals(payTypeCode)) {
return Result.fail(CodeEnum.ERRORQR); return Result.fail(CodeEnum.ERRORQR);
}else { } else {
return Result.fail(CodeEnum.ERRORQR); return Result.fail(CodeEnum.ERRORQR);
} }
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(shopId, qpay); int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(shopId, qpay);
if (count < 1) { if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST); return Result.fail(CodeEnum.PAYTYPENOEXIST);
@ -273,6 +307,7 @@ public class MemberService {
flow.setAmount(amount); flow.setAmount(amount);
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
@ -284,7 +319,6 @@ public class MemberService {
producer.putOrderCollect(jsonObject.toJSONString()); producer.putOrderCollect(jsonObject.toJSONString());
return Result.success(CodeEnum.SUCCESS, memberIn); return Result.success(CodeEnum.SUCCESS, memberIn);
} else { } else {
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null; String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
@ -302,7 +336,7 @@ public class MemberService {
String orderNo = DateUtils.getSsdfTimes(); String orderNo = DateUtils.getSsdfTimes();
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken()); PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, orderNo, thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) { if ("000000".equals(publicResp.getCode())) {
MainScanResp mainScanResp = publicResp.getObjData(); MainScanResp mainScanResp = publicResp.getObjData();
@ -326,9 +360,11 @@ public class MemberService {
flow.setAmount(amount); flow.setAmount(amount);
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
flow.setRemark(orderNo);
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
BigDecimal fl = null;
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount()); TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) { if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
BigDecimal awardAmount = BigDecimal.ZERO; BigDecimal awardAmount = BigDecimal.ZERO;
@ -353,15 +389,28 @@ public class MemberService {
flow.setAmount(awardAmount); flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
fl = awardAmount;
} }
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token); jsonObject.put("token", token);
jsonObject.put("type", "memberIn"); jsonObject.put("type", "memberIn");
jsonObject.put("amount",memberIn.getAmount()); jsonObject.put("amount", memberIn.getAmount());
producer.putOrderCollect(jsonObject.toJSONString()); producer.putOrderCollect(jsonObject.toJSONString());
JSONObject baObj = new JSONObject();
baObj.put("userId", shopUser.getUserId());
baObj.put("shopId", shopInfo.getId());
baObj.put("amount", ObjectUtil.isNull(fl) ? amount : amount.add(fl));
baObj.put("balance", shopUser.getAmount());
baObj.put("type", "扫码充值");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS, memberIn); return Result.success(CodeEnum.SUCCESS, memberIn);
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) { } else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
@ -382,8 +431,7 @@ public class MemberService {
} }
public Result queryScanPay(String flowId, String token) {
public Result queryScanPay(String flowId,String token) {
if (ObjectUtil.isEmpty(flowId)) { if (ObjectUtil.isEmpty(flowId)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@ -438,6 +486,7 @@ public class MemberService {
flow.setAmount(memberIn.getAmount()); flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
return Result.success(CodeEnum.SUCCESS, memberIn); return Result.success(CodeEnum.SUCCESS, memberIn);
} }
@ -465,6 +514,7 @@ public class MemberService {
flow.setBizName("线下充值"); flow.setBizName("线下充值");
flow.setAmount(memberIn.getAmount()); flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
@ -492,6 +542,7 @@ public class MemberService {
flow.setBizName("充值活动奖励"); flow.setBizName("充值活动奖励");
flow.setAmount(awardAmount); flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
@ -502,6 +553,16 @@ public class MemberService {
producer.putOrderCollect(jsonObject.toJSONString()); producer.putOrderCollect(jsonObject.toJSONString());
JSONObject baObj = new JSONObject();
baObj.put("userId", shopUser.getUserId());
baObj.put("shopId", shopUser.getShopId());
baObj.put("amount", memberIn.getAmount().add(awardAmount));
baObj.put("balance", shopUser.getAmount());
baObj.put("type", "充值");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
} }
return Result.success(CodeEnum.SUCCESS, memberIn); return Result.success(CodeEnum.SUCCESS, memberIn);
@ -516,34 +577,16 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS, memberIn); return Result.success(CodeEnum.SUCCESS, memberIn);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result memberAccountPay(Map<String, Object> map,String token) { public Result memberAccountPay(Map<String, Object> map, String token) throws Exception {
if (ObjectUtil.isEmpty(map) || map.size() <= 0 if (ObjectUtil.isEmpty(map) || map.isEmpty()
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId")) || !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId")) || !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|| !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount")) || !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount"))
||!map.containsKey("pwd")||ObjectUtil.isEmpty(map.get("pwd"))
) { ) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
String accountId= TokenUtil.parseParamFromToken(token).getString("accountId");
TbmerchantAccount account= tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
if(Objects.isNull(account)){
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
if(Objects.isNull(account.getPwd())||ObjectUtil.isEmpty(account.getPwd())){
return Result.fail(CodeEnum.PWDNOSET);
}
if(!account.getPwd().equals(MD5Util.encrypt(map.get("pwd").toString().concat(account.getAccount()).concat(account.getId().toString())))){
return Result.fail(CodeEnum.PWDERROE);
}
String memberId = String.valueOf(map.get("memberId")); String memberId = String.valueOf(map.get("memberId"));
@ -554,6 +597,31 @@ public class MemberService {
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) { if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST); return Result.fail(CodeEnum.SHOPINFONOEXIST);
} }
if ("1".equals(shopInfo.getIsMemberIn())) {
if (!map.containsKey("pwd") || ObjectUtil.isEmpty(map.get("pwd"))) {
return Result.fail(CodeEnum.PARAM);
}
String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
if (Objects.isNull(account)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
return Result.fail(CodeEnum.PWDNOSET);
}
if (!account.getPwd().equals(MD5Util.encrypt(map.get("pwd").toString().concat(account.getAccount()).concat(account.getId().toString())))) {
return Result.fail(CodeEnum.PWDERROE);
}
}
TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId)); TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) { if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST); return Result.fail(CodeEnum.MEMBERNOEXIST);
@ -595,7 +663,9 @@ public class MemberService {
flow.setAmount(amount); flow.setAmount(amount);
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
BigDecimal fl = null;
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount()); TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) { if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
@ -621,8 +691,11 @@ public class MemberService {
flow.setAmount(awardAmount); flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount()); flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
fl = awardAmount;
} }
@ -634,10 +707,20 @@ public class MemberService {
producer.putOrderCollect(jsonObject.toJSONString()); producer.putOrderCollect(jsonObject.toJSONString());
JSONObject baObj = new JSONObject();
baObj.put("userId", shopUser.getUserId());
baObj.put("shopId", shopInfo.getId());
baObj.put("amount", ObjectUtil.isNull(fl) ? amount : amount.add(fl));
baObj.put("balance", shopUser.getAmount());
baObj.put("type", "充值");
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }
public Result queryMemberAccount(String memberId, int page, int pageSize) { public Result queryMemberAccount(String memberId, int page, int pageSize) {
if (ObjectUtil.isEmpty(memberId)) { if (ObjectUtil.isEmpty(memberId)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
@ -650,4 +733,117 @@ public class MemberService {
} }
public Result returnAccount(String token, String flowId, String remark, String amount, String pwd) {
if (ObjectUtil.isEmpty(flowId) || ObjectUtil.isNull(flowId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)) {
return Result.fail(CodeEnum.PARAM);
}
TbShopUserFlow flow = tbShopUserFlowMapper.selectByPrimaryKey(Integer.valueOf(flowId));
if (ObjectUtil.isNull(flow) || ObjectUtil.isEmpty(flow)) {
return Result.fail(CodeEnum.USERSHOPFLOWNOEXIST);
}
if (!"0".equals(flow.getIsReturn())) {
return Result.fail(CodeEnum.ORDERRETURN);
}
if (N.gt(new BigDecimal(amount), flow.getAmount())) {
return Result.fail(CodeEnum.INPURAMOUNTERROR);
}
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(flow.getShopUserId());
if (ObjectUtil.isEmpty(user) || ObjectUtil.isNull(user)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(user.getShopId()));
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
if ("1".equals(shopInfo.getIsMemberReturn())) {
if (ObjectUtil.isEmpty(pwd)) {
return Result.fail(CodeEnum.PARAM);
}
String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
if (Objects.isNull(account)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
return Result.fail(CodeEnum.PWDNOSET);
}
if (!account.getPwd().equals(MD5Util.encrypt(pwd.concat(account.getAccount()).concat(account.getId().toString())))) {
return Result.fail(CodeEnum.PWDERROE);
}
}
if (N.gt(new BigDecimal(amount), user.getAmount())) {
return Result.fail(CodeEnum.ACCOUNTBALANCEERROR);
}
if ("scanMemberIn".equals(flow.getBizCode())) {
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail(CodeEnum.NOCUSTOMER);
}
String no = DateUtils.getSsdfTimes();
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), no, null, flow.getRemark(), "充值退款", new BigDecimal(amount).setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
MsgException.check(true, publicResp.getMsg());
}
} else {
MsgException.check(true, "退款渠道调用失败");
}
}
} else if ("cashMemberIn".equals(flow.getBizCode())) {
} else {
return Result.fail(CodeEnum.OPARETIONERROR);
}
user.setAmount(user.getAmount().subtract(new BigDecimal(amount)));
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(user);
flow.setIsReturn("1");
flow.setRemark(remark);
tbShopUserFlowMapper.updateByPrimaryKey(flow);
TbShopUserFlow userFlow = new TbShopUserFlow();
userFlow.setShopUserId(user.getId());
userFlow.setBizCode("memberReturn");
userFlow.setBizName("会员退款");
userFlow.setType("-");
userFlow.setAmount(new BigDecimal(amount));
userFlow.setBalance(user.getAmount());
userFlow.setCreateTime(new Date());
userFlow.setIsReturn("1");
userFlow.setRemark(flowId);
tbShopUserFlowMapper.insert(userFlow);
JSONObject baObj = new JSONObject();
baObj.put("userId", user.getUserId());
baObj.put("shopId", user.getId());
baObj.put("amount", amount);
baObj.put("balance", user.getAmount());
baObj.put("type", "退款");
baObj.put("time", new Date());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS);
}
} }

View File

@ -7,11 +7,19 @@ 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.bean.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
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.PrintMechineConsumer;
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;
@ -21,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -30,6 +39,7 @@ import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.CARTEXIST; import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.CARTEXIST;
@ -67,6 +77,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,23 +87,40 @@ 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 final TbCashierCartMapper tbCashierCartMapper;
private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>(); private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HashSet<String>> userMap = new ConcurrentHashMap<>(); private static ConcurrentHashMap<String, HashSet<String>> userMap = new ConcurrentHashMap<>();
@Autowired @Autowired
private ProductService productService; private ProductService productService;
@Qualifier("printMechineConsumer")
@Autowired
private PrintMechineConsumer printMechineConsumer;
@Qualifier("tbOrderDetailMapper")
@Autowired
private TbOrderDetailMapper tbOrderDetailMapper;
public OrderService(WxAccountUtil wxAccountUtil, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper) { public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper, TbCashierCartMapper tbCashierCartMapper) {
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;
this.tbCashierCartMapper = tbCashierCartMapper;
} }
@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, Integer tableId, Integer vipId) { String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, 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,6 +149,36 @@ 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("台桌不处于开台或空闲状态");
}
}
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
// if (cart != null && cart.getNumber() > number && StrUtil.isNotBlank(cart.getOrderId()) && StrUtil.isNotBlank(cart.getTableId())) {
// 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);
// 首次加入购物车并且拥有起售数设置为起售数 // 首次加入购物车并且拥有起售数设置为起售数
@ -130,6 +188,38 @@ public class OrderService {
}else if (exists != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number < skuWithBLOBs.getSuit()){ }else if (exists != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number < skuWithBLOBs.getSuit()){
redisUtil.deleteByKey(RedisCst.ORDER_CART_EXISTS + cartId); redisUtil.deleteByKey(RedisCst.ORDER_CART_EXISTS + cartId);
delCart(masterId, cartId); delCart(masterId, cartId);
if (StrUtil.isNotBlank(cart.getOrderId()) && StrUtil.isNotBlank(cart.getTableId())) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
.eq(TbCashierCart::getShopId, cart.getShopId());
TbCashierCart finalCart = cart;
queryWrapper.eq(TbCashierCart::getTableId, cart.getTableId())
.and(q -> {
q.or(
query -> {
query.eq(TbCashierCart::getMasterId, finalCart.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
}
)
.or(query -> {
query.eq(TbCashierCart::getOrderId, finalCart.getOrderId())
.or()
.isNull(TbCashierCart::getOrderId);
});
});
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
if (list.isEmpty()) {
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(finalCart.getOrderId()));
}
}
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), false);
return Result.success(CodeEnum.SUCCESS, masterId); return Result.success(CodeEnum.SUCCESS, masterId);
} }
@ -145,6 +235,7 @@ public class OrderService {
} }
} }
if (StringUtils.isEmpty(masterId)) {
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId); boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
if (flag) { if (flag) {
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId).toString(); String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId).toString();
@ -156,14 +247,28 @@ public class OrderService {
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, "1"); redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, "1");
masterId = "#" + String.format("%03d", 1); masterId = "#" + String.format("%03d", 1);
} }
}
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
if (Objects.nonNull(cart)) { if (Objects.nonNull(cart)) {
//查询现有规格商品
if("edit".equals(type)&&!cart.getSkuId().equals(skuId.toString())){
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid, tableId);
if(Objects.nonNull(cashierCart)){
cashierCart.setNumber(cashierCart.getNumber()+number);
cashierCart.setTotalNumber(cashierCart.getNumber()+number);
cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCartMapper.updateByPrimaryKey(cashierCart);
cashierCartMapper.deleteByPrimaryKey(cart.getId());
redisUtil.deleteByKey(RedisCst.ORDER_CART_EXISTS + cart.getId());
cart=cashierCart;
}
}else {
cart.setSkuId(skuId.toString()); cart.setSkuId(skuId.toString());
cart.setNumber(number); cart.setNumber(number);
cart.setIsGift(isGift); cart.setIsGift(isGift);
cart.setIsPack(isPack); cart.setIsPack(isPack);
if (isPack.equals("false")){ if (isPack.equals("false")){
cart.setPackFee(BigDecimal.ZERO); cart.setPackFee(BigDecimal.ZERO);
}else { }else {
@ -178,13 +283,32 @@ public class OrderService {
cart.setTotalNumber(number); cart.setTotalNumber(number);
cart.setUuid(uuid); cart.setUuid(uuid);
cashierCartMapper.updateByPrimaryKeySelective(cart); cashierCartMapper.updateByPrimaryKeySelective(cart);
}
} else { } else {
List<TbCashierCart> list = userId == null && tableId == null ? cashierCartMapper.selectALlByMasterId(masterId, "create") List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
: cashierCartMapper.selectActivateByQrcode(tableId, Integer.valueOf(shopId), vipId); // TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid, tableId);
TbCashierCart cashierCart = userId == null && tableId == null ? cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid) String finalMasterId = masterId;
: cashierCartMapper.selectDetailByQrcode(tableId, productId, shopId, skuId.toString(), vipId); TbCashierCart cashierCart = mpCashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getSkuId, skuId)
.eq(TbCashierCart::getProductId, productId)
.eq(TbCashierCart::getTableId, tableId)
.in(TbCashierCart::getStatus, "create")
.and(query2 -> {
query2.and(query3 -> {
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
.eq(TbCashierCart::getMasterId, finalMasterId);
})
.or((query4 -> {
query4.isNull(TbCashierCart::getTradeDay)
.and(q -> {
q.eq(TbCashierCart::getMasterId, "")
.or()
.isNull(TbCashierCart::getMasterId);
});
}));
}));
if (number > 0) { if (number > 0) {
if (Objects.isNull(cashierCart)) { if (Objects.isNull(cashierCart)) {
@ -193,9 +317,6 @@ public class OrderService {
cashierCart.setCreatedAt(System.currentTimeMillis()); cashierCart.setCreatedAt(System.currentTimeMillis());
cashierCart.setIsSku(product.getTypeEnum()); cashierCart.setIsSku(product.getTypeEnum());
cashierCart.setMasterId(masterId); cashierCart.setMasterId(masterId);
if (tableId != null) {
cashierCart.setTableId(String.valueOf(tableId));
}
cashierCart.setUuid(uuid); cashierCart.setUuid(uuid);
cashierCart.setMerchantId(userId); cashierCart.setMerchantId(userId);
cashierCart.setName(product.getName()); cashierCart.setName(product.getName());
@ -207,7 +328,7 @@ public class OrderService {
cashierCart.setStatus("create"); cashierCart.setStatus("create");
cashierCart.setIsPack(isPack); cashierCart.setIsPack(isPack);
cashierCart.setIsGift(isGift); cashierCart.setIsGift(isGift);
cashierCart.setUserId(vipId == null ? Integer.valueOf(userId) : vipId); cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
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 {
@ -221,9 +342,11 @@ public class OrderService {
} }
cashierCart.setTotalNumber(number); cashierCart.setTotalNumber(number);
cashierCart.setUserId(Integer.valueOf(userId));
cashierCart.setNumber(number); cashierCart.setNumber(number);
cashierCart.setUuid(uuid); cashierCart.setUuid(uuid);
cashierCart.setCategoryId(product.getCategoryId()); cashierCart.setCategoryId(product.getCategoryId());
cashierCart.setTableId(tableId);
list.add(cashierCart); list.add(cashierCart);
cashierCartMapper.insert(cashierCart); cashierCartMapper.insert(cashierCart);
cart=cashierCart; cart=cashierCart;
@ -240,7 +363,7 @@ public class OrderService {
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee())); cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
} }
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");
@ -257,22 +380,52 @@ public class OrderService {
skuWithBLOBs.setUpdatedAt(System.currentTimeMillis()); skuWithBLOBs.setUpdatedAt(System.currentTimeMillis());
tbProductSkuMapper.updateByPrimaryKey(skuWithBLOBs); tbProductSkuMapper.updateByPrimaryKey(skuWithBLOBs);
if (StrUtil.isNotBlank(masterId)) { redisUtil.saveMessage("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
redisUtil.saveMessage("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(), masterId.substring(1,masterId.length()));
TbCashierCart finalCart1 = cart;
ThreadUtil.execute(() -> {
ThreadUtil.sleep(1, TimeUnit.SECONDS);
if (finalCart1.getOrderId() != null && finalCart1.getTableId() != null) {
log.info("购物车数量改变,开始校验订单是否为空");
printMechineConsumer.printReturnTicket(Integer.valueOf(finalCart1.getOrderId()), tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(finalCart1.getOrderId())));
} }
});
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), true);
return Result.success(CodeEnum.SUCCESS, masterId); return Result.success(CodeEnum.SUCCESS, masterId);
} }
private void setRedisTableCartInfo(String tableId, String shopId, List<TbCashierCart> tbCashierCartList, boolean isAdd) {
String tableCartKey = RedisCst.getTableCartKey(tableId, shopId);
String tableCart = redisUtil.getMessage(tableCartKey);
List<TbCashierCart> cartArrayList = new ArrayList<>();
if (tableCart != null) {
cartArrayList = JSONObject.parseArray(tableCart, TbCashierCart.class);
}
for (TbCashierCart cashierCart : tbCashierCartList) {
cartArrayList = cartArrayList.stream().filter(d -> !d.getId().equals(cashierCart.getId())).collect(Collectors.toList());
if (isAdd) {
cartArrayList.add(cashierCart);
}
}
List<TbCashierCart> finalCartArrayList = cartArrayList;
redisUtil.saveMessage(tableCartKey,
JSONObject.toJSONString(finalCartArrayList));
}
/** /**
* 校验商品库存警戒线并通知商户 * 校验商品库存警戒线并通知商户
* *
* @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;
} }
@ -300,45 +453,74 @@ public class OrderService {
} }
} }
public Result queryCart(String masterId, String shopId, Integer tableId, Integer vipUserId) { 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; LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
if (tableId != null) { .notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
list = cashierCartMapper.selectActivateByQrcode(tableId, Integer.valueOf(shopId), vipUserId); .eq(TbCashierCart::getShopId, shopId);
}else {
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day); // 普通点单
if (StrUtil.isBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getMasterId, masterId)
.eq(TbCashierCart::getTradeDay, day)
.and(query -> {
query.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "");
});
// 台桌点单
}else if (StrUtil.isNotBlank(tableId)) {
String finalMasterId = masterId;
queryWrapper.eq(TbCashierCart::getTableId, tableId)
.and(query -> {
query.eq(TbCashierCart::getMasterId, finalMasterId)
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
});
} }
if (StrUtil.isNotBlank(masterId) && list.isEmpty()){
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
// 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()){
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"); tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
} }
} }
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("list", list); map.put("list", list);
map.put("masterId", masterId);
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal packAmount = BigDecimal.ZERO; BigDecimal packAmount = BigDecimal.ZERO;
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
if (StrUtil.isNotBlank(cashierCart.getMasterId())) {
masterId = cashierCart.getMasterId();
}
totalAmount = totalAmount.add(cashierCart.getTotalAmount()); totalAmount = totalAmount.add(cashierCart.getTotalAmount());
if (cashierCart.getIsPack().equals("true")) { if (cashierCart.getIsPack().equals("true")) {
packAmount = packAmount.add(cashierCart.getPackFee()); packAmount = packAmount.add(cashierCart.getPackFee());
@ -358,12 +540,9 @@ public class OrderService {
// TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPr imaryKey(Integer.valueOf(cashierCart.getProductId())); // TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPr imaryKey(Integer.valueOf(cashierCart.getProductId()));
} }
QueryCartPo queryCartPo; map.put("masterId", masterId);
if (tableId == null) {
queryCartPo = cashierCartMapper.selectProductNumByMarketId(day, shopId, masterId); QueryCartPo queryCartPo = cashierCartMapper.selectProductNumByMarketId(day, shopId, masterId);
}else {
queryCartPo = cashierCartMapper.selectProductNumByQrcode(tableId, Integer.valueOf(shopId), vipUserId);
}
queryCartPo.setPackAmount(packAmount); queryCartPo.setPackAmount(packAmount);
queryCartPo.setTotalAmount(totalAmount); queryCartPo.setTotalAmount(totalAmount);
// queryCartPo.setTotalAmount(totalAmount.add(packAmount)); // queryCartPo.setTotalAmount(totalAmount.add(packAmount));
@ -373,7 +552,7 @@ public class OrderService {
return Result.success(CodeEnum.SUCCESS, map); return Result.success(CodeEnum.SUCCESS, map);
} }
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public Result delCart(String masterId, Integer cartId) { public Result delCart(String masterId, Integer cartId) {
@ -382,6 +561,10 @@ public class OrderService {
return Result.fail(CodeEnum.CARTEXIST); return Result.fail(CodeEnum.CARTEXIST);
} }
// if (cashierCart.getOrderId() != null) {
// return Result.success(CodeEnum.SUCCESS, "已打票商品不支持删除", null);
// }
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId())); TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
if(ObjectUtil.isEmpty(product)){ if(ObjectUtil.isEmpty(product)){
return Result.fail(CodeEnum.PRODUCTINFOERROR); return Result.fail(CodeEnum.PRODUCTINFOERROR);
@ -406,22 +589,119 @@ public class OrderService {
List<String> skuIds=new ArrayList<>(); List<String> skuIds=new ArrayList<>();
skuIds.add(cashierCart.getSkuId()); skuIds.add(cashierCart.getSkuId());
cashierCartMapper.deleteByCartIdOrTableId(masterId, cartId, null);
cashierCartMapper.deleteByPrimaryKey(cartId);
if (StrUtil.isNotBlank(cashierCart.getOrderId()) && StrUtil.isNotBlank(cashierCart.getTableId())) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
.eq(TbCashierCart::getShopId, cashierCart.getShopId());
queryWrapper.eq(TbCashierCart::getTableId, cashierCart.getTableId())
.and(query -> {
query.eq(TbCashierCart::getMasterId, cashierCart.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
})
.and(query -> {
query.eq(TbCashierCart::getOrderId, cashierCart.getOrderId())
.or()
.isNull(TbCashierCart::getOrderId);
});
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
if (list.isEmpty()) {
ThreadUtil.execute(() -> {
log.info("购物车数量改变,开始校验订单是否为空");
printMechineConsumer.printReturnTicket(Integer.valueOf(cashierCart.getOrderId()), null);
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cashierCart.getOrderId()));
});
}
}
if (StrUtil.isNotBlank(cashierCart.getTableId())) {
setRedisTableCartInfo(cashierCart.getTableId(), cashierCart.getShopId(), Collections.singletonList(cashierCart), false);
}
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }
@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, Integer oldOrderId, boolean isPost) {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid()); TbShopTable shopTable = null;
if (list.size() < 1) {
list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid()); String currentOrderKey = RedisCst.getCurrentOrderKey(orderVo.getTableId(),
orderVo.getShopId().toString());
String orderIdValue = redisUtil.getMessage(currentOrderKey);
Integer orderId = isPost ? orderIdValue == null ? 0 : Integer.parseInt(orderIdValue) : 0;
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, orderVo.getShopId())
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(orderVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, orderVo.getMasterId())
.eq(TbCashierCart::getTradeDay, day)
.and(query -> {
query.isNull(TbCashierCart::getTableId)
.or()
.eq(TbCashierCart::getTableId, "");
});
// 台桌点单
}else if (StrUtil.isNotBlank(orderVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getTableId, orderVo.getTableId())
.and(query2 -> {
query2.or(query3 -> {
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
.eq(TbCashierCart::getMasterId, orderVo.getMasterId());
})
.or((query4 -> {
query4.isNull(TbCashierCart::getTradeDay)
.or()
.eq(TbCashierCart::getMasterId, "")
.or()
.isNull(TbCashierCart::getMasterId);
}));
});
shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderVo.getTableId()));
if (shopTable == null) {
return Result.fail("台桌不存在");
}
}
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){
if (oldOrderId != null) {
orderDetailMapper.deleteByOUrderId(oldOrderId);
TbOrderInfo orderInfo = new TbOrderInfo();
orderInfo.setId(oldOrderId);
orderInfo.setOrderAmount(BigDecimal.ZERO);
orderInfo.setDiscountAmount(BigDecimal.ZERO);
orderInfo.setStatus("cancelled");
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
// tbOrderInfoMapper.deleteByPrimaryKey(oldOrderId);
}
return Result.fail(CARTEXIST); return Result.fail(CARTEXIST);
} }
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal packAMount = BigDecimal.ZERO; BigDecimal packAMount = BigDecimal.ZERO;
BigDecimal feeAmount = BigDecimal.ZERO; BigDecimal feeAmount = BigDecimal.ZERO;
@ -430,10 +710,11 @@ public class OrderService {
Map<Integer, TbProduct> productMap = new HashMap<>(); Map<Integer, TbProduct> productMap = new HashMap<>();
List<TbOrderDetail> orderDetails = new ArrayList<>(); List<TbOrderDetail> orderDetails = new ArrayList<>();
String masterId = ""; String masterId = "";
int orderId = 0;
if (list.size()<1 || list.isEmpty()){ if (list.size()<1 || list.isEmpty()){
return Result.fail(CARTEXIST); return Result.fail(CARTEXIST);
} }
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
TbProductSkuWithBLOBs tbProduct = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId())); TbProductSkuWithBLOBs tbProduct = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
@ -470,10 +751,14 @@ public class OrderService {
String orderNo = generateOrderNumber(); String orderNo = generateOrderNumber();
TbToken tbToken = tokenMapper.selectByToken(token); TbToken tbToken = tokenMapper.selectByToken(token);
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId); TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
if (orderId > 0) { if (orderInfo == null || !"unpaid".equals(orderInfo.getStatus())) {
redisUtil.deleteByKey(currentOrderKey);
}
if (orderInfo != null && orderId > 0) {
// if (!orderInfo.getStatus().equals("unpaid")){ // if (!orderInfo.getStatus().equals("unpaid")){
// return Result.fail(CodeEnum.ORDERCREATE); // return Result.fail(CodeEnum.ORDERCREATE);
// } // }
orderDetailMapper.deleteByOUrderId(orderId); orderDetailMapper.deleteByOUrderId(orderId);
// orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId); // orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
orderInfo.setUpdatedAt(System.currentTimeMillis()); orderInfo.setUpdatedAt(System.currentTimeMillis());
@ -488,14 +773,22 @@ public class OrderService {
orderInfo.setProductAmount(saleAmount); orderInfo.setProductAmount(saleAmount);
orderInfo.setTradeDay(DateUtils.getDay()); orderInfo.setTradeDay(DateUtils.getDay());
orderInfo.setUserId(orderVo.getUserId()); orderInfo.setUserId(orderVo.getUserId());
orderInfo.setUseType(StrUtil.isNotBlank(orderVo.getTableId()) ? "postPay" : "afterPay");
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
} else { } else {
orderInfo = new TbOrderInfo(orderNo, totalAmount, packAMount, totalAmount, saleAmount, totalAmount, feeAmount, "", orderInfo = new TbOrderInfo(orderNo, totalAmount, packAMount, totalAmount, saleAmount, totalAmount, feeAmount, "",
"table", "cash", orderVo.getMerchantId().toString(), orderVo.getShopId().toString(), "table", "cash", orderVo.getMerchantId().toString(), orderVo.getShopId().toString(),
"", (byte) 1, day, masterId); "", (byte) 1, day, masterId);
orderInfo.setMasterId(masterId); orderInfo.setMasterId(orderVo.getMasterId());
orderInfo.setRemark(orderVo.getRemark()); orderInfo.setRemark(orderVo.getRemark());
orderInfo.setUserId(orderVo.getUserId()); orderInfo.setUserId(orderVo.getUserId());
orderInfo.setUseType(StrUtil.isNotBlank(orderVo.getTableId()) ? "postPay" : "afterPay");
orderInfo.setTableName(shopTable != null ? shopTable.getName() : null);
orderInfo.setPayAmount(BigDecimal.ZERO);
if (StrUtil.isNotBlank(orderVo.getTableId())) {
orderInfo.setTableId(orderVo.getTableId());
}
if (Objects.nonNull(tbToken)){ if (Objects.nonNull(tbToken)){
orderInfo.setTokenId(tbToken.getId()); orderInfo.setTokenId(tbToken.getId());
} }
@ -524,17 +817,23 @@ public class OrderService {
tbOrderInfoMapper.insert(orderInfo); tbOrderInfoMapper.insert(orderInfo);
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId()),object.toString()); redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId()),object.toString());
orderId = orderInfo.getId(); orderId = orderInfo.getId();
if (isPost) {
redisUtil.saveMessage(currentOrderKey, orderInfo.getId().toString());
} }
}
for (TbOrderDetail orderDetail : orderDetails) { for (TbOrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(orderId); orderDetail.setOrderId(orderId);
orderDetailMapper.insert(orderDetail); orderDetailMapper.insert(orderDetail);
} }
boolean flag = true; boolean flag = true;
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
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()));
// 已经添加的商品修改数量 // 已经添加的商品修改数量
@ -565,6 +864,21 @@ public class OrderService {
} }
if (flag) { if (flag) {
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + orderVo.getShopId() + ":" + day + orderVo.getUserId()); redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + orderVo.getShopId() + ":" + day + orderVo.getUserId());
// 代课下单
if (!StrUtil.isBlank(orderVo.getTableId())) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
}
}
if (!StrUtil.isBlank(orderVo.getTableId())) {
if (isPost) {
producer.printMechine(String.valueOf(orderId));
}
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
} }
JSONObject object=new JSONObject(); JSONObject object=new JSONObject();
@ -587,8 +901,6 @@ public class OrderService {
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId().toString()),object.toString()); redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId().toString()),object.toString());
log.info("创建订单发送更新耗材消息订单id{}", orderInfo.getId()); log.info("创建订单发送更新耗材消息订单id{}", orderInfo.getId());
//修改耗材数据 //修改耗材数据
JSONObject jsonObject=new JSONObject(); JSONObject jsonObject=new JSONObject();
@ -607,9 +919,25 @@ public class OrderService {
} }
}); });
// 删除小程序购物车缓存
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
String tableCartKey = RedisCst.getTableCartKey(orderVo.getTableId(), orderVo.getShopId().toString());
redisUtil.deleteByKey(tableCartKey);
}
return Result.success(CodeEnum.SUCCESS, orderInfo); return Result.success(CodeEnum.SUCCESS, orderInfo);
} }
public synchronized void addGlobalCode(String day, String clientType, String shopId) {
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
if (StrUtil.isBlank(code)) {
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "1");
}else {
redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + (Integer.parseInt(code) + 1));
}
redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, "1");
}
public synchronized String generateOrderCode(String day, String clientType, String shopId) { public synchronized String generateOrderCode(String day, String clientType, String shopId) {
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day)+""; String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day)+"";
// 使用顺序递增的计数器生成取餐码 // 使用顺序递增的计数器生成取餐码
@ -621,19 +949,20 @@ public class OrderService {
orderCode =String.valueOf(Integer.valueOf(code)+1); orderCode =String.valueOf(Integer.valueOf(code)+1);
} }
redisUtil.getIncrNum("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "2"); redisUtil.getIncrNum("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "2");
boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode); // boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
if (flag){ // if (flag){
return generateOrderCode(day,clientType,shopId); // return generateOrderCode(day,clientType,shopId);
} // }
// 增加计数器 // 增加计数器
return orderCode; return orderCode;
} }
public Result createCode(String shopId, String clientType, String userId, String type) { public Result createCode(String shopId, String clientType, String userId, String type, String tableId) {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
String key="SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId; // String key="SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId;
String key="SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + ":" + tableId;
String userCode = redisUtil.getMessage(key)+""; String userCode = redisUtil.getMessage(key)+"";
if ("1".equals(type)) { if ("1".equals(type)) {
String code = "#" + generateOrderCode(day, clientType, shopId); String code = "#" + generateOrderCode(day, clientType, shopId);
@ -704,11 +1033,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);
} }
@ -779,35 +1131,48 @@ 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 {
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid); mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
if (list.size() < 1) { .eq(TbShopTable::getQrcode, tableId)
.set(TbShopTable::getStatus, TableStateEnum.PENDING.getState()));
} else {
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper
.eq(TbCashierCart::getStatus, "refund"));
// 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"); tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
} }
} }
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
@ -851,12 +1216,44 @@ 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.selectAllCreateOrder2( LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid(), cartVo.getTableId(), cartVo.getVipUserId()); .eq(TbCashierCart::getShopId, cartVo.getShopId())
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(cartVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, cartVo.getMasterId())
.eq(TbCashierCart::getTradeDay, day)
.and(query -> {
query.isNull(TbCashierCart::getTableId)
.or()
.eq(TbCashierCart::getTableId, "");
});
// 台桌点单
}else if (StrUtil.isNotBlank(cartVo.getTableId()) ) {
queryWrapper.eq(TbCashierCart::getTableId, cartVo.getTableId())
.and(query -> {
query.eq(TbCashierCart::getMasterId, cartVo.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId)
.or()
.eq(TbCashierCart::getMasterId, "");
});
// 会员点单
}
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<>();
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
if (StrUtil.isNotBlank(cashierCart.getOrderId())) {
orderId = Integer.parseInt(cashierCart.getOrderId());
}
ids.add(cashierCart.getId());
// 数量减少, 返还库存 // 数量减少, 返还库存
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId()); String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
redisUtil.deleteByKey(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId()); redisUtil.deleteByKey(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
@ -864,10 +1261,7 @@ public class OrderService {
if (message != null) { if (message != null) {
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), Integer.parseInt(message)); productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), Integer.parseInt(message));
} }
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.parseInt(cashierCart.getOrderId());
}
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId())); TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
if(ObjectUtil.isNotEmpty(product)&&"1".equals(product.getIsStock().toString())){ if(ObjectUtil.isNotEmpty(product)&&"1".equals(product.getIsStock().toString())){
ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber()); ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber());
@ -878,7 +1272,14 @@ public class OrderService {
} }
if (orderId > 0) { if (orderId > 0) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
if (ids.isEmpty() && "postPay".equals(orderInfo.getUseType())) {
return Result.success(CodeEnum.SUCCESS);
}
// 返还耗材 // 返还耗材
JSONObject jsonObject1=new JSONObject(); JSONObject jsonObject1=new JSONObject();
jsonObject1.put("orderId", orderId); jsonObject1.put("orderId", orderId);
@ -886,20 +1287,41 @@ public class OrderService {
log.info("清空购物车 发送返还耗材mq消息订单id{},消息内容:{}", orderId, jsonObject1); log.info("清空购物车 发送返还耗材mq消息订单id{},消息内容:{}", orderId, jsonObject1);
producer.cons(jsonObject1.toString()); producer.cons(jsonObject1.toString());
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
if (Objects.nonNull(orderInfo) && !orderInfo.getStatus().equals("pending")){ if (Objects.nonNull(orderInfo) && !orderInfo.getStatus().equals("pending")){
tbOrderInfoMapper.updateStatusById(orderId, "cancelled"); tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled"); // orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
orderDetailMapper.deleteByOUrderId(orderId);
}
if ("postPay".equals(orderInfo.getUseType())) {
tbOrderInfoMapper.deleteByPrimaryKey(orderId);
} }
} }
if (!ids.isEmpty()) {
mpCashierCartMapper.deleteBatchIds(ids);
}
// cashierCartMapper.deleteByPrimaryKey()
cashierCartMapper.deleteBymasterId(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid()); cashierCartMapper.deleteBymasterId(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
// if(ObjectUtil.isNotEmpty(productSkuPos)&&productSkuPos.size()>0){ // if(ObjectUtil.isNotEmpty(productSkuPos)&&productSkuPos.size()>0){
// tbProductSkuMapper.batchStockNum(productSkuPos); // tbProductSkuMapper.batchStockNum(productSkuPos);
// } // }
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, cartVo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 打印退款票据
int finalOrderId = orderId;
ThreadUtil.execute(() -> {
printMechineConsumer.printReturnTicket(finalOrderId, null);
});
setRedisTableCartInfo(cartVo.getTableId(), cartVo.getShopId(), list, false);
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }
@ -959,8 +1381,18 @@ public class OrderService {
@Autowired @Autowired
TbShopUserMapper tbShopUserMapper; TbShopUserMapper tbShopUserMapper;
public Result orderDetail(Integer shopId, Integer id) { public Result orderDetail(Integer shopId, Integer id, String clientType, String token, String userId, String staffId) {
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id); TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
// OrderVo orderVo = new OrderVo();
// orderVo.setMasterId(orderInfo.getMasterId());
// orderVo.setShopId(Integer.valueOf(orderInfo.getShopId()));
// orderVo.setTableId(orderInfo.getTableId());
// orderVo.setMerchantId(Integer.valueOf(userId));
// createOrder(orderVo, clientType, token, id, false);
// orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
if (Objects.nonNull(orderInfo)) { if (Objects.nonNull(orderInfo)) {
List<TbOrderDetail> list = orderDetailMapper.selectAllByOrderId(id); List<TbOrderDetail> list = orderDetailMapper.selectAllByOrderId(id);
orderInfo.setDetailList(list); orderInfo.setDetailList(list);
@ -1350,4 +1782,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

@ -9,9 +9,11 @@ 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.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO; 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;
@ -46,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);
@ -73,7 +81,7 @@ public class ProductService {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){ if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
tbProductWithBLOBs.parallelStream().forEach(it->{ tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day); Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "");
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount); it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId()); TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){ if(ObjectUtil.isEmpty(tbProductSpec)){
@ -102,7 +110,7 @@ public class ProductService {
} }
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, int page, int pageSize, String masterId) { public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
List<TbProductWithBLOBs> tbProductWithBLOBs=null; List<TbProductWithBLOBs> tbProductWithBLOBs=null;
PageHelperUtil.startPage(page,pageSize); PageHelperUtil.startPage(page,pageSize);
if(ObjectUtil.isEmpty(categoryId)){ if(ObjectUtil.isEmpty(categoryId)){
@ -118,7 +126,7 @@ public class ProductService {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){ if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
tbProductWithBLOBs.parallelStream().forEach(it->{ tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day); Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId);
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount); it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId()); TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){ if(ObjectUtil.isEmpty(tbProductSpec)){
@ -127,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);
@ -251,6 +207,92 @@ public class ProductService {
}else { }else {
tbProductMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock()); tbProductMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock());
tbProductSkuMapper.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

@ -4,8 +4,12 @@ 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 cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
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.vo.TbShopTableVO;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
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;
@ -14,6 +18,7 @@ import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -22,7 +27,8 @@ import java.util.*;
@Service @Service
public class ShopInfoService { public class ShopInfoService {
@Autowired
TbShopInfoMapper tbShopInfoMapper;
@Autowired @Autowired
TbShopAreaMapper tbShopAreaMapper; TbShopAreaMapper tbShopAreaMapper;
@ -36,6 +42,12 @@ public class ShopInfoService {
@Autowired @Autowired
ShopUserDutyDetailMapper shopUserDutyDetailMapper; ShopUserDutyDetailMapper shopUserDutyDetailMapper;
private final TbOrderInfoMapper orderInfoMapper; private final TbOrderInfoMapper orderInfoMapper;
@Qualifier("tbCashierCartMapper")
@Autowired
private TbCashierCartMapper tbCashierCartMapper;
@Autowired
private MpShopTableMapper mpShopTableMapper;
public ShopInfoService(TbOrderInfoMapper orderInfoMapper) { public ShopInfoService(TbOrderInfoMapper orderInfoMapper) {
this.orderInfoMapper = orderInfoMapper; this.orderInfoMapper = orderInfoMapper;
@ -53,8 +65,22 @@ 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); List<TbShopTableVO> tbShopTableVOList = tbShopTableMapper.selectTableInfo(shopId, areaId, status, DateUtils.getDay());
for (TbShopTableVO tbShopTableVO : tbShopTableVOList) {
if (StrUtil.isBlank(tbShopTableVO.getQrcode())) {
tbShopTableVO.setStatus("closed");
}else if (tbCashierCartMapper.countTable(tbShopTableVO.getQrcode(), tbShopTableVO.getShopId()) < 1 ||
tbCashierCartMapper.countTableByDetail(tbShopTableVO.getOrderId(), tbShopTableVO.getShopId()) < 1
) {
tbShopTableVO.setStatus("idle");
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, tbShopTableVO.getQrcode())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
}
}
PageInfo pageInfo=new PageInfo(tbShopTableVOList);
return Result.success(CodeEnum.SUCCESS,pageInfo); return Result.success(CodeEnum.SUCCESS,pageInfo);
} }
@ -102,4 +128,13 @@ public class ShopInfoService {
map.put("amount",amount); map.put("amount",amount);
return Result.success(CodeEnum.SUCCESS,map); return Result.success(CodeEnum.SUCCESS,map);
} }
public Result queryShopPwdInfo(String shopId){
TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
Map<String, String> data = new HashMap<>();
data.put("isMemberIn", tbShopInfo.getIsMemberIn());
data.put("isMemberReturn", tbShopInfo.getIsMemberReturn());
data.put("isReturn", tbShopInfo.getIsReturn());
return Result.success(CodeEnum.SUCCESS,data);
}
} }

View File

@ -104,7 +104,25 @@ public enum CodeEnum {
PWDERROE("100038",false,"操作密码错误","fail"), PWDERROE("100038",false,"操作密码错误","fail"),
STAFFNOEXISTERROE("100039",false,"员工信息不存在","fail"),
STAFFDISCOUNTAMOUNTHIGHT("100040",false,"优惠金额不能大于员工授权额度","fail"),
USERSHOPFLOWNOEXIST("100041",false,"充值记录不存在","fail"),
OPARETIONERROR("100042",false,"操作错误","fail"),
ACCOUNTAMOUNT("100043",false,"账户余额不足","fail"),
INPURAMOUNTERROR("100044",false,"输入金额不允许大于订单原始金额","fail"),
ACCOUNTBALANCEERROR("100045",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

@ -21,8 +21,6 @@ public class DateUtils {
private final static SimpleDateFormat sdfTimesSs = new SimpleDateFormat("yyyyMMddHHmmssSSS"); private final static SimpleDateFormat sdfTimesSs = new SimpleDateFormat("yyyyMMddHHmmssSSS");
private final static SimpleDateFormat sdfday = new SimpleDateFormat("MM-dd HH:mm"); private final static SimpleDateFormat sdfday = new SimpleDateFormat("MM-dd HH:mm");

View File

@ -361,8 +361,8 @@ public class FeieyunPrintUtil {
public static void main(String[] args){ public static void main(String[] args){
OrderDetailPO detailPO=new OrderDetailPO("牛叉闪闪",null,null,"DD20240312142156962",null,null,null,null,null,null,null,null); // OrderDetailPO detailPO=new OrderDetailPO("牛叉闪闪",null,null,"DD20240312142156962",null,null,null,null,null,null,null,null);
getCashPrintData(detailPO,"922690786","结算单",null); // getCashPrintData(detailPO,"922690786","结算单",null);
} }

View File

@ -5,6 +5,8 @@ import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo;
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO; import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO;
import com.chaozhanggui.system.cashierservice.model.HandoverInfo; import com.chaozhanggui.system.cashierservice.model.HandoverInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO; import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
@ -20,6 +22,7 @@ import java.util.*;
*/ */
public class PrinterUtils { public class PrinterUtils {
private static final Logger log= LoggerFactory.getLogger(PrinterUtils.class);
//请求地址 //请求地址
private static final String URL_STR = "https://ioe.car900.com/v1/openApi/dev/customPrint.json"; private static final String URL_STR = "https://ioe.car900.com/v1/openApi/dev/customPrint.json";
//APPID //APPID
@ -97,6 +100,8 @@ public class PrinterUtils {
public static String getCashPrintData(OrderDetailPO detailPO, String type, String orderType) { public static String getCashPrintData(OrderDetailPO detailPO, String type, String orderType) {
log.info("getCashPrintData detailPO:{},type:{},orderType:{}",JSONUtil.toJSONString(detailPO),type,orderType);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<C><B>" + detailPO.getMerchantName() + "</B></C><BR><BR>"); sb.append("<C><B>" + detailPO.getMerchantName() + "</B></C><BR><BR>");
@ -138,13 +143,23 @@ public class PrinterUtils {
} }
} }
if(ObjectUtil.isNotNull(detailPO.getDiscountAmount())&&ObjectUtil.isNotNull(detailPO.getDiscountAdio())){
sb.append("------------------------<BR>"); sb.append("------------------------<BR>");
String t = "" + detailPO.getReceiptsAmount(); sb.append("<S>原价:".concat(String.format("%15s", detailPO.getReceiptsAmount()).replace(' ', paddingCharacter)).concat("</S><BR>"));
sb.append("<S>折扣: ".concat(String.format("%15s", "-".concat(new BigDecimal(detailPO.getDiscountAmount()).toPlainString())).replace(' ', paddingCharacter)).concat("</S><BR>"));
}
sb.append("------------------------<BR>");
String t = "" + (ObjectUtil.isEmpty(detailPO.getDiscountAmount())||ObjectUtil.isNull(detailPO.getDiscountAmount())?detailPO.getReceiptsAmount():new BigDecimal(detailPO.getReceiptsAmount()).subtract(new BigDecimal(detailPO.getDiscountAmount())).toPlainString());
t = String.format("%11s", t).replace(' ', paddingCharacter); t = String.format("%11s", t).replace(' ', paddingCharacter);
if (orderType.equals("return")) { if (orderType.equals("return")) {
sb.append("<F>应退" + t + "</F><BR>"); sb.append("<F>应退" + t + "</F><BR>");
} else { } else {
sb.append("<F>应收" + t + "</F><BR>"); sb.append("<F>实付" + t + "</F><BR>");
} }
if (ObjectUtil.isNotEmpty(detailPO.getPayType()) && ObjectUtil.isNotNull(detailPO.getPayType()) && detailPO.getPayType().equals("deposit")) { if (ObjectUtil.isNotEmpty(detailPO.getPayType()) && ObjectUtil.isNotNull(detailPO.getPayType()) && detailPO.getPayType().equals("deposit")) {
sb.append("<S>储值¥" + detailPO.getReceiptsAmount() + " </S><BR>"); sb.append("<S>储值¥" + detailPO.getReceiptsAmount() + " </S><BR>");
@ -301,6 +316,7 @@ public class PrinterUtils {
* @throws Exception * @throws Exception
*/ */
public static void printTickets(String voiceJson, Integer actWay, Integer cn, String devName, String data) { public static void printTickets(String voiceJson, Integer actWay, Integer cn, String devName, String data) {
log.info("开始请求云享印,请求数据:{}, {}", voiceJson, data);
//设备名称 //设备名称
//行为方式 1:只打印数据 2:只播放信息 3:打印数据并播放信息 //行为方式 1:只打印数据 2:只播放信息 3:打印数据并播放信息
// actWay = 3; // actWay = 3;

View File

@ -20,4 +20,19 @@ public class RedisCst {
public static final String ORDER_MESSAGE="ORDER:MESSAGE:"; public static final String ORDER_MESSAGE="ORDER:MESSAGE:";
public static final String ORDER_PRODUCT_NUM = "ORDER_NUM:"; public static final String ORDER_PRODUCT_NUM = "ORDER_NUM:";
public static final String ORDER_CART_EXISTS = "ORDER_CART_EXISTS:"; public static final String ORDER_CART_EXISTS = "ORDER_CART_EXISTS:";
public static final String ORDER_PRINT = "ORDER_PRINT:";
public static final String ORDER_PRINT_PRO = "ORDER_PRINT_PRODUCT:";
static String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:";
public static String TABLE_CART = "TABLE:CART:";
public static String getCurrentOrderKey(String tableId, String shopId) {
return CURRENT_TABLE_ORDER + shopId + ":" + tableId;
}
public static String getTableCartKey(String tableId, String shopId) {
return TABLE_CART + tableId + "-" + shopId;
}
} }

View File

@ -646,7 +646,7 @@ public class RedisUtils {
if (database!=0) { if (database!=0) {
jedis.select(database); jedis.select(database);
} }
Object result = jedis.eval(secKillScript, Arrays.asList( key,num), new ArrayList<>()); Object result = jedis.eval(secKillScript, Collections.singletonList( key), Collections.singletonList( num));
String reString = String.valueOf(result); String reString = String.valueOf(result);
return reString; return reString;

View File

@ -23,11 +23,11 @@ import java.util.Map;
@Component @Component
public class WxAccountUtil { public class WxAccountUtil {
@Value("${wx.ysk.appId}") @Value("${wx.ysk.appId}")
private static String appId = "wx212769170d2c6b2a"; private String appId = "wx212769170d2c6b2a";
@Value("${wx.ysk.secrete}") @Value("${wx.ysk.secrete}")
private static String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0"; private String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
@Value("${wx.ysk.warnMsgTmpId}") @Value("${wx.ysk.warnMsgTmpId}")
private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0"; private String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
private final TbShopMsgStateMapper shopMsgStateMapper; private final TbShopMsgStateMapper shopMsgStateMapper;
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>(); static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
@ -49,7 +49,7 @@ public class WxAccountUtil {
// sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI"); // sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI");
} }
public static String getRadarQrCode(Integer shopId) { public String getRadarQrCode(Integer shopId) {
HashMap<String, Object> req = new HashMap<>(); HashMap<String, Object> req = new HashMap<>();
req.put("expire_seconds", 300); req.put("expire_seconds", 300);
req.put("action_name", "QR_STR_SCENE"); req.put("action_name", "QR_STR_SCENE");
@ -70,7 +70,7 @@ public class WxAccountUtil {
} }
public static String getAccessToken() { public String getAccessToken() {
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete)); String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
JSONObject respInfo = JSONObject.parseObject(resp); JSONObject respInfo = JSONObject.parseObject(resp);
if (!respInfo.containsKey("access_token")) { if (!respInfo.containsKey("access_token")) {
@ -80,7 +80,7 @@ public class WxAccountUtil {
return respInfo.getString("access_token"); return respInfo.getString("access_token");
} }
public static JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) { public JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data); log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
String accessToken = getAccessToken(); String accessToken = getAccessToken();
@ -101,6 +101,11 @@ public class WxAccountUtil {
} }
public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId, ShopWxMsgTypeEnum typeEnum, Integer shopId) { 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); TbShopMsgState shopMsgState = shopMsgStateMapper.selectByType(typeEnum.getType(), shopId);
if (shopMsgState == null || shopMsgState.getState().equals(0)) { if (shopMsgState == null || shopMsgState.getState().equals(0)) {
log.info("店铺未开启推送:{}", shopMsgState); log.info("店铺未开启推送:{}", shopMsgState);

View File

@ -4,17 +4,14 @@ spring:
application: application:
name: cashierService name: cashierService
datasource: datasource:
url: jdbc:mysql://101.37.12.135:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
username: fycashier username: cashier
password: Twc6MrzzjBiWSsjh password: Cashier@1@
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
initialSize: 5 initialSize: 5
minIdle: 5 minIdle: 5
maxActive: 20 maxActive: 20
maxWait: 60000 maxWait: 60000
logging:
level:
com.chaozhanggui.system.openness: info
redis: redis:
# redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突 # redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突
database: 0 database: 0
@ -52,6 +49,7 @@ mybatis:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:mapper/*.xml mapper-locations: classpath:mapper/*.xml
subscribe: subscribe:
message: message:
miniprogramState: trial miniprogramState: trial

View File

@ -1,10 +1,12 @@
server:
port: 10589
spring: spring:
application: application:
name: cashierService name: cashierService
datasource: datasource:
url: jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
username: root username: cashier
password: mysqlroot@123 password: Cashier@1@
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
initialSize: 5 initialSize: 5
minIdle: 5 minIdle: 5
@ -12,12 +14,12 @@ spring:
maxWait: 60000 maxWait: 60000
logging: logging:
level: level:
com.chaozhanggui.system.openness: debug com.chaozhanggui.system.openness: info
redis: redis:
# redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突 # redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突
database: 2 database: 0
# redis服务器地址默认为localhost # redis服务器地址默认为localhost
host: 101.37.12.135 host: localhost
# redis端口默认为6379 # redis端口默认为6379
port: 6379 port: 6379
# redis访问密码默认为空 # redis访问密码默认为空
@ -35,7 +37,7 @@ spring:
main: main:
allow-circular-references: true allow-circular-references: true
rabbitmq: rabbitmq:
host: 127.0.0.1 host: localhost
port: 5672 port: 5672
username: admin username: admin
password: Czg666888 password: Czg666888
@ -45,12 +47,14 @@ pagehelper:
reasonable: true reasonable: true
helperDialect: mysql helperDialect: mysql
params: count=countSql params: count=countSql
mybatis: mybatis:
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:mapper/*.xml mapper-locations: classpath:mapper/*.xml
subscribe:
message:
miniprogramState: trial

View File

@ -10,7 +10,8 @@ logging:
# web日志 # web日志
org.springframework.web: debug org.springframework.web: debug
# mybatis日志 # mybatis日志
org.mybatis: debug mybits: DEBUG
org.apache.ibatis: DEBUG
charset: charset:
# 输出控制台编码 # 输出控制台编码
console: UTF-8 console: UTF-8
@ -55,7 +56,14 @@ wx:
appId: wx212769170d2c6b2a appId: wx212769170d2c6b2a
secrete: 8492a7e8d55bbb1b57f5c8276ea1add0 secrete: 8492a7e8d55bbb1b57f5c8276ea1add0
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0 warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
balance:
appId: wxd88fffa983758a30
secrete: a34a61adc0602118b49400baa8812454
warnMsgTmpId: AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ
mybatis-plus:
global-config:
db-config:
id-type: auto

View File

@ -116,6 +116,12 @@
</update> </update>
<select id="selectByAmount" resultMap="BaseResultMap"> <select id="selectByAmount" resultMap="BaseResultMap">
select * from tb_activate where shop_id=#{shopId} and is_del=0 and min_num &lt;= #{amount} and max_num &gt;= #{amount} select *
from tb_activate
where shop_id = #{shopId}
and is_del = 0
and min_num &lt;= #{amount}
and max_num &gt;= #{amount}
ORDER BY max_num desc limit 1
</select> </select>
</mapper> </mapper>

View File

@ -58,6 +58,9 @@
<if test="uuid != null"> <if test="uuid != null">
and uuid = #{uuid} and uuid = #{uuid}
</if> </if>
<if test="tableId != null and tableId != ''">
and table_id = #{tableId}
</if>
</select> </select>
<select id="selectDetailByQrcode" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart"> <select id="selectDetailByQrcode" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">

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

@ -205,7 +205,13 @@
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<update id="updateStatusByOrderId"> <update id="updateStatusByOrderId">
update tb_order_detail set status = #{status} where order_id = #{orderId} update tb_order_detail set status = #{status}
<if test="radio != null">
,price_amount=price_amount*#{radio}
</if>
where order_id = #{orderId}
</update> </update>

View File

@ -47,6 +47,7 @@
<result column="master_id" jdbcType="VARCHAR" property="masterId"/> <result column="master_id" jdbcType="VARCHAR" property="masterId"/>
<result column="table_name" jdbcType="VARCHAR" property="tableName"/> <result column="table_name" jdbcType="VARCHAR" property="tableName"/>
<result column="out_number" jdbcType="VARCHAR" property="outNumber"/> <result column="out_number" jdbcType="VARCHAR" property="outNumber"/>
<result column="use_type" jdbcType="VARCHAR" property="useType"/>
</resultMap> </resultMap>
@ -56,7 +57,7 @@
discount_amount, table_id, small_change, send_type, order_type, product_type, status, discount_amount, table_id, small_change, send_type, order_type, product_type, status,
billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score, billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score,
user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group, user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group,
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`,out_number updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`,out_number, use_type
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
@ -77,7 +78,9 @@
toi.out_number AS outNumber, toi.out_number AS outNumber,
toi.table_name AS tableName, toi.table_name AS tableName,
toi.remark, toi.remark,
toi.master_id as masterId toi.master_id as masterId,
toi.discount_ratio as discountRatio,
toi.discount_amount as discountAmount
FROM FROM
@ -132,7 +135,7 @@
deduct_score, user_coupon_id, user_coupon_amount, deduct_score, user_coupon_id, user_coupon_amount,
refund_able, paid_time, is_effect, refund_able, paid_time, is_effect,
is_group, updated_at, system_time, is_group, updated_at, system_time,
created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,out_number created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,out_number, use_type
) )
values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}, values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
#{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL}, #{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL},
@ -148,7 +151,7 @@
#{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT}, #{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT},
#{createdAt,jdbcType=BIGINT}, #{isAccepted,jdbcType=TINYINT}, #{payOrderNo,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{isAccepted,jdbcType=TINYINT}, #{payOrderNo,jdbcType=VARCHAR},
#{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{masterId,jdbcType=VARCHAR},#{tableName,jdbcType=VARCHAR}, #{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{masterId,jdbcType=VARCHAR},#{tableName,jdbcType=VARCHAR},
#{outNumber,jdbcType=VARCHAR} #{outNumber,jdbcType=VARCHAR},#{useType,jdbcType=VARCHAR}
) )
</insert> </insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo"> <insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
@ -515,6 +518,14 @@
<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>
<if test="useType != null and useType!=''">
use_type = #{useType,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>

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

@ -962,6 +962,7 @@
AND product_id = #{productId} AND product_id = #{productId}
AND `status` = 'create' AND `status` = 'create'
and master_id = #{masterId} and master_id = #{masterId}
and table_id = #{tableId}
and trade_day = #{day} and trade_day = #{day}
group by shop_id,product_id group by shop_id,product_id
</select> </select>

View File

@ -350,7 +350,7 @@
<if test="spec != null and spec !=''"> <if test="spec != null and spec !=''">
and spec_snap = #{spec} and spec_snap = #{spec}
</if> </if>
order by id desc limit 1
</select> </select>
<select id="selectByProduct" <select id="selectByProduct"
resultType="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs"> resultType="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">

View File

@ -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>
<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> </mapper>

View File

@ -45,6 +45,12 @@
<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="proxy_id" jdbcType="VARCHAR" property="proxyId" /> <result column="proxy_id" jdbcType="VARCHAR" property="proxyId" />
<result column="is_custom" jdbcType="VARCHAR" property="isCustom" />
<result column="is_return" jdbcType="VARCHAR" property="isReturn" />
<result column="is_member_in" jdbcType="VARCHAR" property="isMemberIn" />
<result column="is_member_return" jdbcType="VARCHAR" property="isMemberReturn" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbShopInfo"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbShopInfo">
<result column="view" jdbcType="LONGVARCHAR" property="view" /> <result column="view" jdbcType="LONGVARCHAR" property="view" />
@ -55,7 +61,7 @@
detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type, detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type,
industry, industry_name, business_time, post_time, post_amount_line, on_sale, settle_type, industry, industry_name, business_time, post_time, post_amount_line, on_sale, settle_type,
settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number, settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number,
distribute_level, created_at, updated_at, proxy_id distribute_level, created_at, updated_at, proxy_id,is_custom,is_return,is_member_in,is_member_return
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
view view

View File

@ -227,5 +227,20 @@
order by `sort` asc order by `sort` asc
</select>
<select id="selectTableInfo" resultType="com.chaozhanggui.system.cashierservice.entity.vo.TbShopTableVO">
select a.*, b.user_id, b.master_id, b.id as orderId, b.order_no as orderNo, b.amount as orderAmount from tb_shop_table a
left join tb_order_info b on a.qrcode=b.table_id and (b.`status`='unpaid') and b.master_id is not null and b.shop_id=#{shopId} and b.trade_day=#{day} and b.use_type='postPay' and b.order_type='cash'
where a.shop_id=#{shopId}
<if test="areaId != null and areaId !=''">
and a.area_id = #{areaId}
</if>
<if test="status != null and status !=''">
and a.status = #{status}
</if>
GROUP BY a.id
order by a.id desc
</select> </select>
</mapper> </mapper>

View File

@ -10,9 +10,12 @@
<result column="biz_name" jdbcType="VARCHAR" property="bizName" /> <result column="biz_name" jdbcType="VARCHAR" property="bizName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="type" jdbcType="VARCHAR" property="type" /> <result column="type" jdbcType="VARCHAR" property="type" />
<result column="is_return" jdbcType="VARCHAR" property="isReturn" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type,is_return,remark
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
@ -27,10 +30,10 @@
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow"> <insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
insert into tb_shop_user_flow (id, shop_user_id, amount, insert into tb_shop_user_flow (id, shop_user_id, amount,
balance, biz_code, biz_name, balance, biz_code, biz_name,
create_time, type) create_time, type,is_return,remark)
values (#{id,jdbcType=INTEGER}, #{shopUserId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, values (#{id,jdbcType=INTEGER}, #{shopUserId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
#{balance,jdbcType=DECIMAL}, #{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR}, #{balance,jdbcType=DECIMAL}, #{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR}) #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR},#{isReturn,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow"> <insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
insert into tb_shop_user_flow insert into tb_shop_user_flow
@ -122,7 +125,8 @@
biz_code = #{bizCode,jdbcType=VARCHAR}, biz_code = #{bizCode,jdbcType=VARCHAR},
biz_name = #{bizName,jdbcType=VARCHAR}, biz_name = #{bizName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
type = #{type,jdbcType=VARCHAR} type = #{type,jdbcType=VARCHAR},
is_return=#{isReturn,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>

View File

@ -371,6 +371,11 @@
<if test="phone != null and phone !='' "> <if test="phone != null and phone !='' ">
and telephone like concat("%",#{phone},"%") and telephone like concat("%",#{phone},"%")
</if> </if>
<if test="isFlag != null ">
and amount &gt; 0
</if>
order by id desc order by id desc