1 Commits
tkk ... zs2

Author SHA1 Message Date
1455a7e64e 1.代客下单 2024-08-14 09:43:07 +08:00
128 changed files with 741 additions and 6270 deletions

102
pom.xml
View File

@@ -21,10 +21,6 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@@ -52,11 +48,11 @@
<artifactId>hutool-all</artifactId>
<version>4.5.18</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>-->
<!-- <version>1.2.9</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>-->
<!-- <version>1.2.9</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
@@ -189,70 +185,30 @@
<version>2.2.0</version>
</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>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>3.8.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- alipay -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.39.208.ALL</version>
</dependency>
</dependencies>
<!-- <profiles>-->
<!-- <profile>-->
<!-- <id>dev</id>-->
<!-- <properties>-->
<!-- <env>dev</env>-->
<!-- </properties>-->
<!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>test</id>-->
<!-- <properties>-->
<!-- <env>test</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>pro</id>-->
<!-- <properties>-->
<!-- <env>pro</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- </profiles>-->
<!-- <profiles>-->
<!-- <profile>-->
<!-- <id>dev</id>-->
<!-- <properties>-->
<!-- <env>dev</env>-->
<!-- </properties>-->
<!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>test</id>-->
<!-- <properties>-->
<!-- <env>test</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>pro</id>-->
<!-- <properties>-->
<!-- <env>pro</env>-->
<!-- </properties>-->
<!-- </profile>-->
<!-- </profiles>-->
<build>
<plugins>
@@ -310,4 +266,4 @@
</plugins>
</build>
</project>
</project>

View File

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

View File

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

View File

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

View File

@@ -1,15 +0,0 @@
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,8 +23,6 @@ public class LoginContoller {
@Autowired
LoginService loginService;
@RequestMapping(value = "login",method = RequestMethod.POST)
public Result login(@RequestBody LoginReq loginReq, HttpServletRequest request){
try {
@@ -36,11 +34,6 @@ public class LoginContoller {
return Result.fail(CodeEnum.FAIL);
}
@RequestMapping(value = "findVersion",method = RequestMethod.POST)
public Result findVersion() {
return loginService.findVersion();
}
@RequestMapping("logout")
public Result logout( @RequestHeader("token") String token,
@@ -58,13 +51,4 @@ public class LoginContoller {
@RequestHeader("clientType") String clientType){
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;
import com.chaozhanggui.system.cashierservice.service.MemberService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@CrossOrigin(origins = "*")
@@ -26,11 +26,10 @@ public class MemberController {
@RequestHeader("clientType") String clientType,
@RequestParam("shopId") String shopId,
@RequestParam("phone") String phone,
@RequestParam(value = "isFlag",required = false,defaultValue = "0") String isFlag,
@RequestParam("page") int page,
@RequestParam("pageSize") int pageSize
) {
return memberService.queryMember(shopId, phone, isFlag,page, pageSize);
){
return memberService.queryMember(shopId,phone,page,pageSize);
}
@@ -38,46 +37,43 @@ public class MemberController {
public Result createMember(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String, Object> map
) {
@RequestBody Map<String,Object> map
){
return memberService.createMember(map);
}
@RequestMapping("memberScanPay")
public Result memberScanPay(
@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String, Object> map
@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map
) {
return memberService.memberScanPay(map, token);
){
return memberService.memberScanPay(map,token);
}
@GetMapping("queryScanPay")
public Result queryScanPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("flowId") String flowId
) {
return memberService.queryScanPay(flowId, token);
){
return memberService.queryScanPay(flowId,token);
}
@RequestMapping("accountPay")
public Result accountPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String, Object> map
) {
try {
return memberService.memberAccountPay(map, token);
} catch (Exception e) {
e.printStackTrace();
}
return Result.fail(CodeEnum.SYS_EXCEPTION);
public Result accountPay( @RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody Map<String,Object> map
){
return memberService.memberAccountPay(map,token);
}
@@ -85,24 +81,11 @@ public class MemberController {
public Result queryMemberAccount(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("memberId") String memberId,
@RequestParam("memberId") String memberId,
@RequestParam("page") int page,
@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.returnAccount(token, flowId,remark,amount, pwd);
){
return memberService.queryMemberAccount(memberId,page,pageSize);
}
}

View File

@@ -6,15 +6,12 @@ import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
import com.chaozhanggui.system.cashierservice.bean.LogTag;
import com.chaozhanggui.system.cashierservice.entity.OrderVo;
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.service.OrderService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@CrossOrigin(origins = "*")
@@ -27,14 +24,6 @@ public class OrderController {
@Autowired
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")
public Result createCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@@ -45,7 +34,7 @@ public class OrderController {
String userId = jsonObject.getString("accountId");
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(),
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getTableId());
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getTableId(), cartVo.getVipUserId());
}
@MyLog(value = "查询购物车信息", tag = LogTag.CART)
@@ -54,13 +43,14 @@ public class OrderController {
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam(value = "masterId", required = false) String masterId,
@RequestParam(required = false) String tableId,
@RequestParam(required = false) Integer tableId,
@RequestParam(required = false) Integer vipUserId,
@RequestParam("shopId") String shopId
){
if (tableId == null && StrUtil.isBlank(masterId)) {
return Result.fail("masterId和tableId不能同时为空");
return Result.fail("masterId和tableId不能同 时为空");
}
return orderService.queryCart(masterId,shopId, tableId);
return orderService.queryCart(masterId,shopId, tableId, vipUserId);
}
@@ -68,7 +58,6 @@ public class OrderController {
public Result delCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam(required = false) String tableId,
@RequestParam(value = "masterId", required = false) String masterId,
@RequestParam("cartId") Integer cartId
){
@@ -79,12 +68,11 @@ public class OrderController {
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestParam("shopId") String shopId,
@RequestParam(required = false) String tableId,
String type
){
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
return orderService.createCode(shopId,clientType,userId,type, tableId);
return orderService.createCode(shopId,clientType,userId,type);
}
@GetMapping("/getCartList")
public Result getCart(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@@ -102,8 +90,7 @@ public class OrderController {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
String code = jsonObject.getString("code");
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),
cartVo.getStatus(),userId,cartVo.getUuid(),clientType, cartVo.getVipUserId(), cartVo.getTableId());
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),cartVo.getStatus(),userId,cartVo.getUuid(),clientType);
}
@PostMapping("/createOrder")
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@@ -112,7 +99,7 @@ public class OrderController {
String userId = jsonObject.getString("accountId");
orderVo.setMerchantId(Integer.valueOf(userId));
orderVo.setUserId(jsonObject.getString("staffId"));
return orderService.createOrder(orderVo,clientType,token, null, orderVo.getType() != null && orderVo.getType().equals(0));
return orderService.createOrder(orderVo,clientType,token);
}
@PostMapping("/createBackOrder")
public Result createBackOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@@ -152,9 +139,7 @@ public class OrderController {
public Result orderDetail(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestParam("shopId") Integer shopId,
@RequestParam("id") Integer id){
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
return orderService.orderDetail(shopId,id, clientType, token, userId, jsonObject.getString("staffId"));
return orderService.orderDetail(shopId,id);
}

View File

@@ -1,39 +1,19 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.request.AlipayUserInfoShareRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.alipay.api.response.AlipayUserInfoShareResponse;
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
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.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.IpUtil;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.RedisCst;
import com.chaozhanggui.system.cashierservice.util.WechatUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
@CrossOrigin(origins = "*")
@RestController
@@ -64,6 +44,8 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @param authCode
* @return
*/
@RequestMapping("scanpay")
@@ -72,9 +54,11 @@ public class PayController {
@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody PaymentReq paymentReq
) {
return payService.scanPay(paymentReq.getOrderId(),paymentReq.getAuthCode(), IpUtil.getIpAddr(request),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
@RequestParam("orderId") String orderId,
@RequestParam("authCode") String authCode
) {
return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token);
}
@@ -83,17 +67,21 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @param memberId
* @return
*/
@RequestMapping("accountPay")
@GetMapping("accountPay")
@LimitSubmit(key = "accountPay:%s")
public Result accountPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody PaymentReq paymentReq
@RequestParam("orderId") String orderId,
@RequestParam("memberId") String memberId,
@RequestParam("memberAccount") String memberAccount
){
return payService.accountPay(paymentReq.getOrderId(),paymentReq.getMemberId(),token,paymentReq.getMemberAccount(),paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
return payService.accountPay(orderId,memberId,token,memberAccount);
}
@@ -166,16 +154,19 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @param memberCode
* @return
*/
@RequestMapping("memberScanPay")
@GetMapping("memberScanPay")
@LimitSubmit(key = "memberScanPay:%s")
public Result memberScanPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody PaymentReq paymentReq
@RequestParam("orderId") String orderId,
@RequestParam("memberCode") String memberCode
){
return payService.memberScanPay(paymentReq.getOrderId(),paymentReq.getMemberCode(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
return payService.memberScanPay(orderId,memberCode,token);
}
@@ -185,48 +176,19 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @return
*/
@RequestMapping("cashPay")
@GetMapping("cashPay")
@LimitSubmit(key = "cashPay:%s")
public Result cashPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody PaymentReq paymentReq){
Result result = payService.cashPay(paymentReq.getOrderId(), token, paymentReq.getPayAmount(), paymentReq.getDiscountAmount());
return result;
@RequestParam("orderId") String orderId){
return payService.cashPay(orderId,token);
}
/**
* 会员支付
* @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());
}
/**
@@ -234,15 +196,16 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
* @param orderId
* @return
*/
@RequestMapping("bankPay")
@GetMapping("bankPay")
@LimitSubmit(key = "bankPay:%s")
public Result bankPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType,
@RequestBody PaymentReq paymentReq){
return payService.bankPay(paymentReq.getOrderId(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
@RequestParam("orderId") String orderId){
return payService.bankPay(orderId,token);
}
@@ -258,8 +221,7 @@ public class PayController {
){
return payService.returnOrder(list,token,pwd, isOnline);
return payService.returnOrder(list,token,null, isOnline);
}
@@ -282,155 +244,4 @@ public class PayController {
public Result testOrder( @RequestParam("orderId") String orderId){
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);
}
@RequestMapping("pcscanpay")
@LimitSubmit(key = "pcscanpay:%s")
public Result pcscanpay(HttpServletRequest request,@RequestBody PaymentReq paymentReq){
try {
return payService.pcscanpay(paymentReq.getOrderId(),IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType());
} catch (Exception e) {
e.printStackTrace();
}
return Result.fail(CodeEnum.FAIL);
}
@RequestMapping("createOrder")
public Result createOrder(HttpServletRequest request,@RequestBody PaymentReq paymentReq){
try {
return payService.createOrder(IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType(),paymentReq.getShopId(),paymentReq.getPayAmount());
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return Result.fail(CodeEnum.FAIL);
}
@GetMapping("queryOrderPay")
public Result queryOrderPay(String orderId){
return payService.queryOrderPay(orderId);
}
@Value("${wx.ysk.appId}")
private String appId;
@Value("${wx.ysk.secrete}")
private String secrete;
@Value("${ali.appId}")
private String aliAppId;
@Value("${ali.privateKey}")
private String privateKey;
@Value("${ali.publicKey}")
private String publicKey;
/**
* 获取支付宝或微信openId
* @param code
* @return
*/
@GetMapping("/openId")
public Result getOpenId(
@RequestParam String code,
@RequestParam String payType
) throws AlipayApiException {
if("WECHAT".equals(payType)){
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, appId, secrete);
log.info("SessionKeyOpenId:{}",SessionKeyOpenId.toString());
String openid = SessionKeyOpenId.getString("openid");
if(Objects.isNull(openid)){
return Result.fail("获取微信id失败");
}
return Result.success(CodeEnum.SUCCESS,openid);
}else if("ALIPAY".equals(payType)){
// 初始化SDK
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
// 构造请求参数以调用接口
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
// 设置刷新令牌
// request.setRefreshToken("201208134b203fe6c11548bcabd8da5bb087a83b");
// 设置授权码
request.setCode(code);
// 设置授权方式
request.setGrantType("authorization_code");
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
log.info("AlipaySystemOauthTokenResponse:{}", JSONUtil.toJSONString(response));
response.setAccessToken(response.getRefreshToken());
if (!response.isSuccess()) {
return Result.fail("获取支付宝userId失败");
}
return Result.success(CodeEnum.SUCCESS, ObjectUtil.isNull(response.getUserId())?response.getOpenId():response.getUserId());
}
return Result.fail(CodeEnum.FAIL);
}
private AlipayConfig getAlipayConfig() {
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
alipayConfig.setAppId(aliAppId);
alipayConfig.setPrivateKey(privateKey);
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(publicKey);
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
return alipayConfig;
}
public static void main(String[] args){
LocalDate date=LocalDate.now();
if(date.isLeapYear()){
System.out.println();
}
}
}

View File

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

View File

@@ -17,11 +17,6 @@ public class ShopInfoController {
@Autowired
ShopInfoService shopInfoService;
@GetMapping("/queryShopInfo")
public Result queryShopInfo(@RequestParam Integer shopId){
return shopInfoService.queryShopInfo(shopId);
}
@GetMapping("queryShopArea")
public Result queryShopArea(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@@ -64,9 +59,4 @@ public class ShopInfoController {
) {
return shopInfoService.queryDutyFlow(token, shopId, page,pageSize);
}
@GetMapping("queryPwdInfo")
public Result queryPwdInfo(@RequestParam("shopId") String shopId) {
return shopInfoService.queryShopPwdInfo(shopId);
}
}

View File

@@ -1,70 +0,0 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import com.chaozhanggui.system.cashierservice.service.ShopPrinterService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* 店铺打印机配置
* @author tankaikai
* @since 2024-09-24 16:56
*/
@Slf4j
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("shop-config/printer")
public class ShopPrinterController {
@Resource
private ShopPrinterService shopPrinterService;
@GetMapping("page")
public Result page(@RequestParam Map<String, Object> params) {
PageInfo<ShopPrinterDTO> page = shopPrinterService.page(params);
return Result.success(CodeEnum.SUCCESS,page);
}
@GetMapping("list")
public Result list(@RequestParam Map<String, Object> params) {
List<ShopPrinterDTO> list = shopPrinterService.list(params);
return Result.success(CodeEnum.SUCCESS,list);
}
@GetMapping("{id}")
public Result get(@PathVariable("id") Integer id) {
ShopPrinterDTO dto = shopPrinterService.get(id);
return Result.success(CodeEnum.SUCCESS,dto);
}
@PostMapping
public Result save(@RequestBody ShopPrinterDTO dto) {
shopPrinterService.save(dto);
return Result.success(CodeEnum.SUCCESS);
}
@PutMapping
public Result update(@RequestBody ShopPrinterDTO dto) {
shopPrinterService.update(dto);
return Result.success(CodeEnum.SUCCESS);
}
@DeleteMapping("{id}")
public Result delete(@PathVariable("id") Integer id){
shopPrinterService.delete(id);
return Result.success(CodeEnum.SUCCESS);
}
@PostMapping("update-status")
public Result updateStatus(@RequestBody ShopPrinterDTO dto){
shopPrinterService.updateStatus(dto.getId(),dto.getStatus());
return Result.success(CodeEnum.SUCCESS);
}
}

View File

@@ -1,25 +0,0 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService;
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
@RequestMapping("staffPermission")
public class StaffPermissionController {
@Autowired
private TbShopPermissionService permissionService;
@GetMapping
public Result getStaffPermission(String staffId, String code) {
return permissionService.getStaffPermission(staffId, code);
}
}

View File

@@ -1,40 +0,0 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbVersion;
import com.chaozhanggui.system.cashierservice.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author yijiegong
*/
@RestController
@RequestMapping("/version")
public class VersionController {
@Autowired
LoginService loginService;
@GetMapping("pcDownload")
public ResponseEntity<Void> pcDownload(HttpServletRequest request, HttpServletResponse response) {
TbVersion pcVersion = loginService.getCurrentPcVersion();
if (pcVersion == null) {
throw new RuntimeException("未找到PC版本信息");
}
// 重定向到下载地址
HttpHeaders headers = new HttpHeaders();
headers.setLocation(java.net.URI.create(pcVersion.getUrl()));
return new ResponseEntity<>(headers, HttpStatus.FOUND);
}
}

View File

@@ -1,19 +0,0 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author tankaikai
* @since 2024-09-24 17:25
*/
@Mapper
public interface ShopPrinterServiceMapper {
List<ShopPrinterDTO> getList(Map<String, Object> params);
int updateStatus(@Param("id") Integer id, @Param("status") Integer status);
}

View File

@@ -3,10 +3,8 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.po.CartPo;
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.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import java.util.List;
@@ -30,10 +28,10 @@ public interface TbCashierCartMapper {
List<TbCashierCart> selectALlByMasterId(@Param("masterId") String masterId,@Param("status") String status);
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("tableId") String tableId);
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("day") String day,@Param("uuid") String uuid);
TbCashierCart selectDetailByQrcode(@Param("tableId") String tableId, @Param("productId") String productId,
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("uuid") String uuid);
TbCashierCart selectDetailByQrcode(@Param("tableId") Integer tableId, @Param("productId") String productId,
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("userId") Integer userId);
List<TbCashierCart> selectByMaskerId(@Param("masterId")String masterId, @Param("shopId")Integer shopId,@Param("status") String status,@Param("day") String day);
@@ -47,7 +45,12 @@ public interface TbCashierCartMapper {
@Param("status") String status, @Param("day") String day, @Param("uuid") String uuid);
List<TbCashierCart> selectAllCreateOrder(@Param("masterId") String masterId, @Param("shopId") Integer shopId,
@Param("day") String day, @Param("status") String status,@Param("uuid") String uuid);
@Param("day") String day, @Param("status") String status,
@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);
int updateByOrderId(@Param("orderId") String orderId,@Param("status") String status);
@@ -66,16 +69,7 @@ public interface TbCashierCartMapper {
List<TbCashierCart> selectByOrderId(@Param("orderId") String orderId,@Param("status") String status);
List<TbCashierCart> selectActivateByQrcode(@Param("tableId") String tableId, @Param("shopId") Integer shopId);
List<TbCashierCart> selectActivateByQrcode(@Param("tableId") Integer tableId, @Param("shopId") Integer shopId, @Param("userId") Integer userId);
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);
QueryCartPo selectProductNumByQrcode(@Param("tableId") Integer tableId, @Param("shopId") Integer shopId, @Param("vipUserId") Integer vipUserId);
}

View File

@@ -25,7 +25,7 @@ public interface TbOrderDetailMapper {
int updateByPrimaryKey(TbOrderDetail record);
void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status,@Param("radio") BigDecimal radio);
void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status);
void updateStatusByOrderIdAndStatus(@Param("orderId") int orderId,@Param("status") String status);
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, @Param("tableId") String tableId);
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day);
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);

View File

@@ -48,13 +48,10 @@ public interface TbProductSkuMapper {
@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);
@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} ")
int decrStockUnCheck(String id, int num);
@Select("select * from tb_product_sku where is_grounding=1 and product_id=#{id} and is_del=0")
@Select("select * from tb_product_sku where is_grounding=1 and product_id=#{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}")
@@ -65,7 +62,4 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=#{stock} where product_id=#{skuId} and shop_id=#{shopId}")
int updateStock(@Param("shopId") Integer shopId, @Param("skuId") Integer skuId, @Param("stock") Integer stock);
@Select("select * from tb_product_sku where product_id=#{id} and is_del=0")
List<TbProductSku> selectByProductId(Integer id);
}

View File

@@ -24,14 +24,12 @@ public interface TbProskuConMapper {
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<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")
List<TbShopOpenId> selectByShopId(Integer integer);
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1 and (type=#{type} or type=-1) group by open_id;")
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1 and (type=#{type} or type=-1);")
List<TbShopOpenId> selectStateByShopIdAndType(@Param("shopId") String shopId, @Param("type") int type);
}

View File

@@ -1,15 +0,0 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
/**
* (TbShopPermission)表数据库访问层
*
* @author makejava
* @since 2024-09-14 17:08:48
*/
public interface TbShopPermissionDao extends BaseMapper<TbShopPermission> {
}

View File

@@ -1,15 +0,0 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表数据库访问层
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
public interface TbShopStaffPermissionDao extends BaseMapper<TbShopStaffPermission> {
}

View File

@@ -1,7 +1,6 @@
package com.chaozhanggui.system.cashierservice.dao;
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.Param;
import org.springframework.stereotype.Component;
@@ -24,5 +23,4 @@ public interface TbShopTableMapper {
int updateByPrimaryKey(TbShopTable record);
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);
List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone,@Param("isFlag") String isFlag);
List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone);
List<TbShopUser> selectByShopIdAndPhone(@Param("shopId") String shopId,@Param("phone") String phone);

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,5 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
@@ -38,8 +37,7 @@ public class TbOrderDetail implements Serializable {
private BigDecimal priceAmount;
private BigDecimal packAmount;
@TableField(exist = false)
private String remark;
private static final long serialVersionUID = 1L;
}
}

View File

@@ -100,10 +100,6 @@ public class TbOrderInfo implements Serializable {
private String outNumber;
private Integer staffId;
private String useType;
private static final long serialVersionUID = 1L;
public TbOrderInfo(){
super();
@@ -168,4 +164,4 @@ public class TbOrderInfo implements Serializable {
this.payType=payType;
this.tableName=tableName;
}
}
}

View File

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

View File

@@ -1,10 +1,7 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.ToString;
import java.io.Serializable;
@ToString
public class TbPrintMachine implements Serializable {
private Integer id;
@@ -37,15 +34,6 @@ public class TbPrintMachine implements Serializable {
private String vendorId;
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;
@@ -176,4 +164,4 @@ public class TbPrintMachine implements Serializable {
public void setProductId(String productId) {
this.productId = productId == null ? null : productId.trim();
}
}
}

View File

@@ -1,10 +1,7 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.ToString;
import java.io.Serializable;
@ToString
public class TbPrintMachineWithBLOBs extends TbPrintMachine implements Serializable {
private String config;
@@ -27,4 +24,4 @@ public class TbPrintMachineWithBLOBs extends TbPrintMachine implements Serializa
public void setCategoryList(String categoryList) {
this.categoryList = categoryList == null ? null : categoryList.trim();
}
}
}

View File

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

View File

@@ -92,31 +92,6 @@ public class TbShopInfo implements Serializable {
private String view;
private String isCustom;
private String isReturn;
private String isMemberIn;
private String isMemberReturn;
//是否开启桌位费 0否1是
private Integer isTableFee;
//桌位费
private BigDecimal tableFee;
//就餐模式 堂食 dine-in 外带 take-out
private String eatModel;
//程序码(零点八零首页)
private String smallQrcode;
//店铺收款码
private String paymentQrcode;
private static final long serialVersionUID = 1L;
public Integer getId() {
@@ -470,76 +445,4 @@ public class TbShopInfo implements Serializable {
public void setView(String view) {
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;
}
public Integer getIsTableFee() {
return isTableFee;
}
public void setIsTableFee(Integer isTableFee) {
this.isTableFee = isTableFee;
}
public BigDecimal getTableFee() {
return tableFee;
}
public void setTableFee(BigDecimal tableFee) {
this.tableFee = tableFee;
}
public String getEatModel() {
return eatModel;
}
public void setEatModel(String eatModel) {
this.eatModel = eatModel;
}
public String getSmallQrcode() {
return smallQrcode;
}
public void setSmallQrcode(String smallQrcode) {
this.smallQrcode = smallQrcode;
}
public String getPaymentQrcode() {
return paymentQrcode;
}
public void setPaymentQrcode(String paymentQrcode) {
this.paymentQrcode = paymentQrcode;
}
}

View File

@@ -1,129 +0,0 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.util.Date;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
/**
* (TbShopPermission)表实体类
*
* @author makejava
* @since 2024-09-14 17:08:48
*/
@SuppressWarnings("serial")
public class TbShopPermission extends Model<TbShopPermission> {
private Integer id;
//权限类型staff 员工,
private String type;
//权限名称
private String label;
//权限code为了区分采用汉语拼音
private String code;
//层级
private Integer level;
//上级ID
private Integer parentId;
//是否重要: 重要对应页面红色
private Integer isImportant;
//排序
private Integer sort;
private Date createTime;
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getIsImportant() {
return isImportant;
}
public void setIsImportant(Integer isImportant) {
this.isImportant = isImportant;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取主键值
*
* @return 主键值
*/
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@@ -1,77 +0,0 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表实体类
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
@SuppressWarnings("serial")
public class TbShopStaffPermission extends Model<TbShopStaffPermission> {
private Integer id;
//权限ID
private Integer permissionId;
//员工ID
private Integer staffId;
//店铺ID
private Integer shopId;
//用户ID
private Integer userId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getPermissionId() {
return permissionId;
}
public void setPermissionId(Integer permissionId) {
this.permissionId = permissionId;
}
public Integer getStaffId() {
return staffId;
}
public void setStaffId(Integer staffId) {
this.staffId = staffId;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* 获取主键值
*
* @return 主键值
*/
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@@ -3,7 +3,7 @@ package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
public class TbShopUser implements Serializable {
public class TbShopUser implements Serializable {
private Integer id;
private BigDecimal amount;
@@ -295,4 +295,4 @@ public class TbShopUser implements Serializable {
public void setDynamicCode(String dynamicCode) {
this.dynamicCode = dynamicCode;
}
}
}

View File

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

View File

@@ -1,115 +0,0 @@
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

@@ -1,12 +0,0 @@
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

@@ -1,64 +0,0 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 店铺打印机配置
*
* @author tankaikai
* @since 2024-09-24 17:13
*/
@Data
public class ShopPrinterDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private String type;
private String connectionType;
private String address;
private String port;
private String subType;
private Integer status;
private String shopId;
private String categoryIds;
private String contentType;
private String createdAt;
private String updatedAt;
private Integer sort;
private String vendorId;
private String productId;
private String config;
public String getCreatedAt() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(new Date(Long.valueOf(createdAt)));
}
public String getUpdatedAt() {
if("".equals(updatedAt) || updatedAt == null){
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(new Date(Long.valueOf(updatedAt)));
}
}

View File

@@ -1,23 +0,0 @@
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

@@ -1,14 +0,0 @@
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,9 +28,4 @@ public class OrderPo {
private String remark;
private BigDecimal discountRatio;
private BigDecimal discountAmount;
}

View File

@@ -5,6 +5,11 @@ import lombok.Data;
@Data
public class CartVo {
private String productId;
// orderId不为空为代客下单
private String masterId;
private Integer tableId;
private Integer vipUserId;
private String shopId;
private Integer skuId;
private Integer number;
@@ -14,7 +19,4 @@ public class CartVo {
private String uuid;
private String type;
private Integer cartId;
private String masterId;
private String tableId;
private Integer vipUserId;
}

View File

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

View File

@@ -37,7 +37,7 @@ public class SignInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String requestUri = request.getRequestURI();
String requestURI = request.getRequestURI();
if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
@@ -45,10 +45,6 @@ public class SignInterceptor implements HandlerInterceptor {
return true;
}
if (requestUri.contains("/version/pcDownload")) {
return true;
}
String token=request.getHeader("token");
String loginName=request.getHeader("loginName");
String clientType=request.getHeader("clientType");

View File

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

View File

@@ -35,10 +35,6 @@ public class OrderDetailPO implements Serializable {
private String outNumber;
private String discountAmount;
private String discountAdio;
@Data
public static class Detail implements Serializable{
@@ -59,9 +55,7 @@ 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,
String discountAmount,String discountAdio
) {
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) {
this.merchantName = merchantName;
this.printType = printType;
this.masterId = masterId;
@@ -74,7 +68,5 @@ public class OrderDetailPO implements Serializable {
this.integral = integral;
this.detailList = detailList;
this.remark = remark;
this.discountAmount=discountAmount;
this.discountAdio=discountAdio;
}
}

View File

@@ -1,33 +0,0 @@
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;
private String payType;
private String userId;
private String shopId;
}

View File

@@ -1,7 +0,0 @@
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

@@ -1,8 +0,0 @@
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.TbOrderDetail;
public interface MPOrderDetailMapper extends BaseMapper<TbOrderDetail> {
}

View File

@@ -1,8 +0,0 @@
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

@@ -1,8 +0,0 @@
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

@@ -1,7 +0,0 @@
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

@@ -1,13 +0,0 @@
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

@@ -1,15 +0,0 @@
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

@@ -1,179 +0,0 @@
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,10 +94,9 @@ public class ConsMsgConsumer {
}
// List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopIdAngCheck(skuId, shopId);
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
if (Objects.isNull(tbProskuCons) || tbProskuCons.size() <= 0) {
log.info("耗材信息未配置或未开启校验");
log.info("耗材信息未配置");
return;
}
@@ -124,8 +123,7 @@ public class ConsMsgConsumer {
log.info("耗材名称: {}, conwarning:{},stockNumber:{}",tbConsInfo.getConName(),
tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()))) {
List<TbShopOpenId> tbUserShopMsgs = shopOpenIdMapper
.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.CONSUMABLES_MSG.getType());
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
log.info("待推送openId列表: {}", tbUserShopMsgs);
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{
@@ -135,8 +133,7 @@ public class ConsMsgConsumer {
log.info("开始推送耗材模板消息rediskey{}", value);
if (Objects.isNull(value)) {
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) {
log.info("写入redis:{}",key);
redisUtil.saveMessage(key, "1", 30 * 60);

View File

@@ -1,460 +0,0 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
import com.chaozhanggui.system.cashierservice.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Slf4j
@Component
@Service
public class PrintConsumer {
@Autowired
TbShopUserMapper tbShopUserMapper;
@Autowired
private TbOrderInfoMapper tbOrderInfoMapper;
@Autowired
private TbPrintMachineMapper tbPrintMachineMapper;
@Autowired
private TbCashierCartMapper tbCashierCartMapper;
@Autowired
private TbProductSkuMapper tbProductSkuMapper;
@Autowired
private TbShopInfoMapper tbShopInfoMapper;
@Autowired
private TbProductMapper tbProductMapper;
@Autowired
private TbOrderDetailMapper tbOrderDetailMapper;
@Autowired
private RedisUtil redisUtils;
private final RedisTemplate<String, Object> redisTemplate;
@Autowired
private MpPrintMachineMapper mpPrintMachineMapper;
@Autowired
private MPOrderDetailMapper mPOrderDetailMapper;
private final PrinterHandler printerHandler;
public PrintConsumer(RedisTemplate<String, Object> redisTemplate, PrinterHandler printerHandler) {
this.redisTemplate = redisTemplate;
this.printerHandler = printerHandler;
}
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_DISHES})
public void printDishesListener(String msg) {
try {
log.info("打印消息mq 接收到打印菜品消息,消息内容: {}", msg);
JSONObject jsonObject = JSONObject.parseObject(msg);
Integer orderId = jsonObject.getInteger("orderId");
JSONArray orderDetailIds = jsonObject.getJSONArray("orderDetailIds");
Boolean isReturn = jsonObject.getBoolean("isReturn");
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
Utils.checkValueUnReturn(orderInfo, "订单信息不存在");
List<TbOrderDetail> orderDetails = new ArrayList<>();
for (Object orderDetail : orderDetailIds) {
orderDetails.add(JSONObject.parseObject(orderDetail.toString(), TbOrderDetail.class));
}
if (orderDetails.isEmpty()) {
return;
}
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash").forEach(machine -> {
log.info("打印机信息: {}", machine);
printerHandler.handleRequest(machine, isReturn, orderInfo, orderDetails);
});
} catch (Exception e) {
log.warn("打印菜品失败", e);
}
}
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_PLACE})
public void printPlaceListener(JSONObject jsonObject) {
try {
log.info("打印消息mq 接收到打印结算单消息,消息内容: {}", jsonObject);
Integer orderId = jsonObject.getInteger("orderId");
Boolean isReturn = jsonObject.getBoolean("isReturn");
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
Utils.checkValueUnReturn(orderInfo, "订单信息不存在");
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
Utils.checkValueUnReturn(shopInfo, "店铺信息不存在");
getPrintMachine(shopInfo.getId(), "cash").forEach(machine -> {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
printerHandler.handleRequest(machine, isReturn, orderInfo, tbOrderDetails);
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
});
} catch (Exception e) {
log.warn("打印菜品失败", e);
}
}
private boolean checkMachineModel(String type, TbPrintMachine machine) {
Utils.checkValueUnReturn(machine, "打印机为null");
JSONObject config = JSONObject.parseObject(machine.getConfig());
String model = config.getString("model");
return type.equals(model);
}
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType) {
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
if (ObjectUtil.isEmpty(shopInfo)) {
log.error("店铺信息不存在");
return new ArrayList<>();
}
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(new LambdaQueryWrapper<TbPrintMachine>()
.eq(TbPrintMachine::getStatus, 1)
.eq(TbPrintMachine::getShopId, shopId)
.eq(TbPrintMachine::getSubType, subType)
.eq(TbPrintMachine::getConnectionType, "network"));
if (list.isEmpty()) {
log.error("店铺未配置打印机店铺id: {}", shopId);
return list;
}
log.info("打印机列表: {}", list);
return list;
}
/**
* 打印菜品单
*
* @param isReturn 是否退款单
*/
private void printDishesTicket(boolean isReturn, TbPrintMachine tbPrintMachineWithBLOBs, TbOrderDetail item, TbOrderInfo orderInfo, List<CategoryInfo> categoryInfos) {
log.info("开始打印一菜一品票据,商品名:{}", item.getProductName());
if (item.getProductId().equals(-999)) {
return;
}
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
if (sku == null) {
log.error("商品不存在, id: {}", item.getProductSkuId());
return;
}
long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count == 0) {
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
return;
}
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
item.setRemark(remark);
String data;
String voiceJson;
if (isReturn) {
data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), item.getProductName(), Math.abs(item.getNum()), 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())), item.getProductName(),
item.getNum(), remark);
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
}
/**
* 打印结算单
*/
private void printPlaceTicket(boolean isReturn, TbPrintMachine printMachine, TbOrderInfo orderInfo, TbShopInfo shopInfo) {
log.info("打印机信息: {}", printMachine);
JSONObject config = JSONObject.parseObject(printMachine.getConfig());
String model = config.getString("model");
if (!"normal".equals(model)) {
log.info("当前打印机非小票打印机, {}", printMachine);
return;
}
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
if (!tbOrderDetails.isEmpty()) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
detailList.add(detail);
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (!detailList.isEmpty()) {
if (isReturn) {
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 data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 1, 1, printMachine.getAddress(), data);
} else {
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);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, printMachine.getAddress(), data);
}
}
}
}
private void fePrinter(TbPrintMachine tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
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);
}
}
});
}
break;
case "cash": //小票打印机
switch (model) {
case "normal": //普通出单
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
detailList.add(detail);
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio().toPlainString());
String printType = "退款单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
} else {
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
detailList.add(detail);
}
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "结算单";
if ("return".equals(orderInfo.getOrderType())) {
printType = "退款单";
}
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
}
}
}
break;
case "one": //一菜一品
if (!orderInfo.getStatus().equals("unpaid")) {
return;
}
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
}
});
}
break;
case "category": //分类出单
break;
}
break;
case "kitchen": //出品打印机
break;
}
}
}

View File

@@ -1,29 +1,28 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
import com.chaozhanggui.system.cashierservice.util.*;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.annotation.RabbitListeners;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@Component
@@ -50,23 +49,11 @@ public class PrintMechineConsumer {
@Autowired
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
public void listener(String message) {
String orderId = message;
log.info("接收到打印mq消息: {}", message);
try {
@@ -92,15 +79,15 @@ public class PrintMechineConsumer {
}
list.forEach(it -> {
list.parallelStream().forEach(it->{
if (!"network".equals(it.getConnectionType())) {
log.error("非网络打印机:{},{}", it.getAddress(), it.getConnectionType());
log.error("非网络打印机:{},{}",it.getAddress(),it.getConnectionType());
return;
}
if (!"1".equals(it.getStatus().toString())) {
log.error("打印机状态异常:{},{}", it.getAddress(), it.getStatus());
log.error("打印机状态异常:{},{}",it.getAddress(),it.getStatus());
return;
}
@@ -112,37 +99,36 @@ public class PrintMechineConsumer {
String feet = config.getString("feet");
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":
yxyPrinter(it, model, orderInfo, shopInfo, printerNum, categoryInfos);
yxyPrinter(it,model,orderInfo,shopInfo,printerNum,categoryInfos);
break;
case "fePrinter":
fePrinter(it, model, orderInfo, shopInfo, printerNum, categoryInfos);
fePrinter(it,model,orderInfo,shopInfo,printerNum,categoryInfos);
break;
}
});
} catch (Exception e) {
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 博时结云打印机
*
* 博时结云打印机
* @param tbPrintMachineWithBLOBs
* @param model
* @param orderInfo
* @param shopInfo
* @param printerNum
*/
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model,
TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
@@ -153,17 +139,17 @@ public class PrintMechineConsumer {
case "normal": //普通出单
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
if("return".equals(orderInfo.getOrderType())){
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
tbOrderDetails.parallelStream().forEach(it->{
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)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
log.info("获取当前类别是否未打印类别:{}",count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@@ -185,25 +171,23 @@ public class PrintMechineConsumer {
}
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.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
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());
String printType = "退款单";
String printType="退款单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
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;
}
if ((!orderInfo.getStatus().equals("closed"))) {
return;
}
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
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<>();
tbOrderDetails.stream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
@@ -231,40 +215,71 @@ public class PrintMechineConsumer {
balance = user.getAmount().toPlainString();
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
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.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
break;
case "one": //一菜一品
// if (StrUtil.isNotBlank(orderInfo.getUseType()) && orderInfo.getUseType().equals("postPay")
// && (!orderInfo.getStatus().equals("unpaid"))) {
// return;
// }
if ("return".equals(orderInfo.getOrderType())) {
printReturnTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
if("return".equals(orderInfo.getOrderType())){
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, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
return;
} else {
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
// printNormalTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
}else {
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
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;
case "category": //分类出单
@@ -277,291 +292,39 @@ 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();
}
log.info("已打印数量, {}, 未打印数量: {}", info, printerNum);
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();
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
cashierCarts.parallelStream().forEach(it->{
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
if(ObjectUtil.isEmpty(it.getCategoryId())){
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
Long count= categoryInfos.stream().filter(c->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
log.info("获取当前类别是否未打印类别:{}",count);
if (count > 0) {
if(count>0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
for (int i = 0; i < it.getNumber(); i++) {
for(int i=0;i<it.getNumber();i++){
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
}
}
@@ -573,17 +336,17 @@ public class PrintMechineConsumer {
switch (model) {
case "normal": //普通出单
if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
if("return".equals(orderInfo.getOrderType())){
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
tbOrderDetails.parallelStream().forEach(it->{
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)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
log.info("获取当前类别是否未打印类别:{}",count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@@ -605,27 +368,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(),
"普通打印", 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() == null ? null : orderInfo.getDiscountAmount().toPlainString(),
orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark());
String printType = "退款单";
String printType="退款单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
}
} else {
}else {
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
@@ -664,7 +420,7 @@ public class PrintMechineConsumer {
}
}
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(), null, null);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
String printType = "结算单";
if ("return".equals(orderInfo.getOrderType())) {
@@ -681,38 +437,30 @@ public class PrintMechineConsumer {
break;
case "one": //一菜一品
if (orderInfo.getPayType() != null
&& "postPay".equals(orderInfo.getPayType())
&& !orderInfo.getStatus().equals("unpaid")) {
return;
}
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
if(ObjectUtil.isEmpty(it.getCategoryId())){
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count = categoryInfos.stream().filter(c ->
Long count= categoryInfos.stream().filter(c->
c.getId().toString().equals(categoryId)
).count();
if (count > 0) {
if(count>0){
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
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

@@ -15,20 +15,20 @@ import org.springframework.context.annotation.Scope;
@Configuration
public class RabbitConfig {
@Value("${spring.rabbitmq.host}")
private String host;
@Value("${spring.rabbitmq.port}")
private int port;
@Value("${spring.rabbitmq.username}")
private String username;
@Value("${spring.rabbitmq.password}")
private String password;
@Bean
public ConnectionFactory connectionFactory() {
@@ -39,7 +39,7 @@ public class RabbitConfig {
connectionFactory.setPublisherConfirms(true);
return connectionFactory;
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
//必须是prototype类型
@@ -51,12 +51,12 @@ public class RabbitConfig {
public DirectExchange defaultExchange_Register() {
return new DirectExchange(RabbitConstants.CART_ORDER_COLLECT_PUT);
}
@Bean
public Queue queuePut_Register() {
return new Queue(RabbitConstants.CART_ORDER_COLLECT_QUEUE_PUT, true); //队列持久
}
@Bean
public Binding bindingPut_Register() {
return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT);
@@ -126,44 +126,5 @@ 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);
}
// 打印出票
@Bean
DirectExchange printExchange() {
return new DirectExchange(RabbitConstants.EXCHANGE_PRINT);
}
@Bean
Queue printDishesQueue() {
return new Queue(RabbitConstants.QUEUE_PRINT_DISHES);
}
@Bean
Binding bindingDishedPrint(Queue printDishesQueue, DirectExchange printExchange) {
return BindingBuilder.bind(printDishesQueue).to(printExchange).with(RabbitConstants.ROUTING_KEY_PRINT_DISHES);
}
@Bean
Queue printPlaceQueue() {
return new Queue(RabbitConstants.QUEUE_PRINT_PLACE);
}
@Bean
Binding bindingPlacePrint(Queue printPlaceQueue, DirectExchange printExchange) {
return BindingBuilder.bind(printPlaceQueue).to(printExchange).with(RabbitConstants.ROUTING_KEY_PRINT_PLACE);
}
}
}

View File

@@ -47,24 +47,4 @@ public interface RabbitConstants {
String EXCHANGE_STOCK_RECORD = "exchange.stock.record";
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";
// 打印出票
String EXCHANGE_PRINT = "exchange.print";
// 菜品打印
String QUEUE_PRINT_DISHES = "queue.dishes.print";
String ROUTING_KEY_PRINT_DISHES = "routing.dishes.print";
// 下单打印
String QUEUE_PRINT_PLACE = "queue.place.order.print";
String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print";
}

View File

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

@@ -1,40 +0,0 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class FeiPrinter extends PrinterHandler{
public FeiPrinter(TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper) {
super("Feie", productMapper, tbProductSkuMapper, tbShopUserMapper);
}
@Override
protected void returnDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
}
@Override
protected void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
}
@Override
protected void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
}
@Override
protected void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
}
}

View File

@@ -1,35 +0,0 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.annotation.PostConstruct;
import java.util.List;
@Configuration
public class PrintConfig {
private final YxyPrinter yxyPrinter;
private final FeiPrinter feiPrinter;
public PrintConfig(YxyPrinter yxyPrinter, FeiPrinter feiPrinter) {
this.yxyPrinter = yxyPrinter;
this.feiPrinter = feiPrinter;
}
// 初始化责任链
@PostConstruct
public void initChain() {
yxyPrinter.setNextPrinter(feiPrinter);
feiPrinter.setNextPrinter(null);
}
@Bean
@Primary
public PrinterHandler printerHandler() {
return yxyPrinter;
}
}

View File

@@ -1,153 +0,0 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import cn.hutool.core.lang.func.Func0;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import com.chaozhanggui.system.cashierservice.util.Utils;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@ToString
public abstract class PrinterHandler {
@Setter
protected PrinterHandler nextPrinter;
protected String printerBrand;
private final TbProductMapper tbProductMapper;
private final TbProductSkuMapper tbProductSkuMapper;
private final TbShopUserMapper tbShopUserMapper;
public PrinterHandler(String printerBrand, TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper) {
this.printerBrand = printerBrand;
this.tbProductMapper = productMapper;
this.tbProductSkuMapper = tbProductSkuMapper;
this.tbShopUserMapper = tbShopUserMapper;
}
protected void print(TbPrintMachine machine, boolean isReturn, TbOrderInfo orderInfo, List<TbOrderDetail> tbOrderDetailList) {
String configStr = machine.getConfig();
Utils.checkValueUnReturn(configStr, "打印机配置为空");
JSONObject config = JSONObject.parseObject(configStr);
String model = JSONObject.parseObject(configStr).getString("model");
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(), CategoryInfo.class);
switch (model) {
case "one":
tbOrderDetailList.forEach(item -> {
log.info("开始打印退单菜品,商品名:{}", item.getProductName());
// 台位费不打印
if (item.getProductId().equals(-999)) {
log.info("台位费商品,不打印");
return;
}
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
if (sku == null) {
log.error("商品不存在, id: {}", item.getProductSkuId());
return;
}
long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if (count == 0) {
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
return;
}
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
item.setRemark(remark);
String data;
String voiceJson;
if (isReturn) {
returnDishesPrint(orderInfo, item, machine);
} else {
normalDishesPrint(orderInfo, item, machine);
}
});
break;
case "normal":
if (tbOrderDetailList.isEmpty()) {
log.info("待打印列表为空");
return;
}
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetailList.forEach(it -> {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
detailList.add(detail);
});
String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString();
}
}
if (!detailList.isEmpty()) {
if (isReturn) {
returnOrderPrint(orderInfo, machine, balance, detailList);
} else {
normalOrderPrint(orderInfo, machine, balance, detailList);
}
}
default:
log.warn("未知打印类型: {}", model);
}
}
public void handleRequest(TbPrintMachine machine, boolean isReturn, TbOrderInfo orderInfo, List<TbOrderDetail> tbOrderDetailList) {
if (canHandleRequest(machine.getContentType(), machine.getConnectionType())) {
log.info("打印机: {}, 是否退款单: {}, 订单信息: {}, 订单详情信息: {}", machine, isReturn, orderInfo, tbOrderDetailList);
print(machine, isReturn, orderInfo, tbOrderDetailList);
} else if (nextPrinter != null) {
log.info("当前打印机无法处理: {},将请求传递给下一个打印机:{}...", this, nextPrinter);
nextPrinter.handleRequest(machine, isReturn, orderInfo, tbOrderDetailList);
} else {
log.warn("未找到匹配打印机");
}
}
protected abstract void returnDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine);
protected abstract void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine);
protected abstract void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList);
protected abstract void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList);
// 抽象方法,子类实现判断能否处理请求
boolean canHandleRequest(String currentBrand, String connectType) {
log.info("handle判断是否可处理: {}, 连接类型: {}, handler类型: {}", currentBrand, connectType, printerBrand);
Utils.checkValueUnReturn(printerBrand, "打印机品牌未赋值");
return printerBrand.equals(currentBrand) && "network".equals(connectType);
}
}

View File

@@ -1,86 +0,0 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Slf4j
@Component
public class YxyPrinter extends PrinterHandler{
private final TbShopInfoMapper shopInfoMapper;
public YxyPrinter(TbShopInfoMapper shopInfoMapper, TbProductMapper productMapper, TbProductSkuMapper productSkuMapper, TbShopUserMapper shopUserMapper) {
super("yxyPrinter", productMapper, productSkuMapper, shopUserMapper);
this.shopInfoMapper = shopInfoMapper;
}
@Override
protected void returnDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
String data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), Math.abs(orderDetail.getNum()), orderDetail.getRemark());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
}
@Override
protected void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
String data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
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);
}
@Override
protected void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
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 data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 1, 1, machine.getAddress(), data);
}
@Override
protected void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List<OrderDetailPO.Detail> detailList) {
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
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);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
}
}

View File

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

View File

@@ -67,12 +67,10 @@ public class ConsService {
for (TbOrderDetail orderDetail : orderDetails) {
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){
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;
}
for (TbProskuCon proskuCon : proskuCons) {
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){

View File

@@ -273,12 +273,6 @@ 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.MemberData> memberData = null;
List<HandoverInfo.ProductCategory> productCategories = null;

View File

@@ -3,11 +3,9 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
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.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
@@ -16,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;
@@ -50,8 +47,6 @@ public class LoginService {
@Autowired
TbTokenMapper tbTokenMapper;
@Autowired
TbVersionMapper versionMapper;
@Autowired
RabbitProducer rabbitProducer;
@@ -145,17 +140,6 @@ public class LoginService {
return Result.success(CodeEnum.SUCCESS, accountMap);
}
public Result findVersion() {
TbVersion pcVersion = getCurrentPcVersion();
return new Result(SUCCESS, pcVersion);
}
public TbVersion getCurrentPcVersion() {
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TbVersion::getSource,"PC");
queryWrapper.eq(TbVersion::getSel,1);
return versionMapper.selectOne(queryWrapper);
}
public Result logout(String loginName, String clientType, String token, String status) {
@@ -207,23 +191,4 @@ public class LoginService {
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,23 +5,21 @@ import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
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.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
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.PublicResp;
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
import com.chaozhanggui.system.cashierservice.util.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -67,10 +65,6 @@ public class MemberService {
RestTemplate restTemplate;
@Autowired
TbActivateMapper tbActivateMapper;
@Autowired
TbmerchantAccountMapper tbmerchantAccountMapper;
@Autowired
RabbitProducer producer;
@Value("${gateway.url}")
private String gateWayUrl;
@Value("${thirdPay.payType}")
@@ -80,21 +74,13 @@ public class MemberService {
@Value("${thirdPay.callBack}")
private String callBack;
@Qualifier("tbOrderInfoMapper")
@Autowired
private TbOrderInfoMapper tbOrderInfoMapper;
private MpShopTableMapper mpShopTableMapper;
TbmerchantAccountMapper tbmerchantAccountMapper;
public Result queryMember(String shopId, String phone,String isFlag, int page, int pageSize) {
public Result queryMember(String shopId, String phone, int page, int pageSize) {
PageHelperUtil.startPage(page, pageSize);
if(!"1".equals(isFlag)){
isFlag=null;
}
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone,isFlag);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone);
PageInfo pageInfo = new PageInfo(tbShopUsers);
return Result.success(CodeEnum.SUCCESS, pageInfo);
}
@@ -117,12 +103,12 @@ public class MemberService {
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);
}
if (tbUserInfoMapper.selectCountByPhone(phone) > 1) {
if(tbUserInfoMapper.selectCountByPhone(phone)>1){
return Result.fail(CodeEnum.SAMEUSER);
}
@@ -149,7 +135,7 @@ public class MemberService {
TbShopUser tbShopUser = new TbShopUser();
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPhone(phone);
if (tbUserInfo != null) {
if(tbUserInfo!=null){
tbShopUser.setUserId(tbUserInfo.getId().toString());
}
tbShopUser.setAmount(BigDecimal.ZERO);
@@ -172,19 +158,23 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS);
}
@Autowired
RabbitProducer producer;
@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
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|| !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount"))
|| !map.containsKey("authCode") || ObjectUtil.isEmpty(map.get("authCode"))
) {
return Result.fail(CodeEnum.PARAM);
}
String memberId = String.valueOf(map.get("memberId"));
String shopId = String.valueOf(map.get("shopId"));
@@ -194,32 +184,6 @@ public class MemberService {
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
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));
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST);
@@ -229,23 +193,25 @@ public class MemberService {
String qpay = null;
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";
} else if (Integer.valueOf(payTypeCode) >= 10 && Integer.valueOf(payTypeCode) <= 19) {
}else if(Integer.valueOf(payTypeCode)>=10&&Integer.valueOf(payTypeCode)<=19){
qpay = "scanCode";
wechatpay = "wxpay";
} else if ("62".equals(payTypeCode)) {
wechatpay="wxpay";
}else if("62".equals(payTypeCode)){
return Result.fail(CodeEnum.ERRORQR);
} else if ("01".equals(payTypeCode)) {
}else if("01".equals(payTypeCode)){
return Result.fail(CodeEnum.ERRORQR);
} else {
}else {
return Result.fail(CodeEnum.ERRORQR);
}
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(shopId, qpay);
if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
@@ -307,7 +273,6 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
@@ -319,6 +284,7 @@ public class MemberService {
producer.putOrderCollect(jsonObject.toJSONString());
return Result.success(CodeEnum.SUCCESS, memberIn);
} else {
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
@@ -336,7 +302,7 @@ public class MemberService {
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, orderNo, 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, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
MainScanResp mainScanResp = publicResp.getObjData();
@@ -360,11 +326,9 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setRemark(orderNo);
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
BigDecimal fl = null;
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
BigDecimal awardAmount = BigDecimal.ZERO;
@@ -389,28 +353,15 @@ public class MemberService {
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
fl = awardAmount;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("type", "memberIn");
jsonObject.put("amount", memberIn.getAmount());
jsonObject.put("amount",memberIn.getAmount());
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);
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
@@ -431,7 +382,8 @@ public class MemberService {
}
public Result queryScanPay(String flowId, String token) {
public Result queryScanPay(String flowId,String token) {
if (ObjectUtil.isEmpty(flowId)) {
return Result.fail(CodeEnum.PARAM);
}
@@ -486,7 +438,6 @@ public class MemberService {
flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
return Result.success(CodeEnum.SUCCESS, memberIn);
}
@@ -514,7 +465,6 @@ public class MemberService {
flow.setBizName("线下充值");
flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
@@ -542,7 +492,6 @@ public class MemberService {
flow.setBizName("充值活动奖励");
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date());
@@ -553,16 +502,6 @@ public class MemberService {
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);
}
return Result.success(CodeEnum.SUCCESS, memberIn);
@@ -577,16 +516,34 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS, memberIn);
}
@Transactional(rollbackFor = Exception.class)
public Result memberAccountPay(Map<String, Object> map, String token) throws Exception {
if (ObjectUtil.isEmpty(map) || map.isEmpty()
public Result memberAccountPay(Map<String, Object> map,String token) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|| !map.containsKey("amount") || ObjectUtil.isEmpty(map.get("amount"))
||!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);
}
String memberId = String.valueOf(map.get("memberId"));
@@ -597,31 +554,6 @@ public class MemberService {
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
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));
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST);
@@ -663,9 +595,7 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
BigDecimal fl = null;
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
@@ -691,11 +621,8 @@ public class MemberService {
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
fl = awardAmount;
}
@@ -707,20 +634,10 @@ public class MemberService {
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);
}
public Result queryMemberAccount(String memberId, int page, int pageSize) {
if (ObjectUtil.isEmpty(memberId)) {
return Result.fail(CodeEnum.PARAM);
@@ -733,117 +650,4 @@ 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

@@ -9,11 +9,9 @@ import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
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.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
@@ -48,12 +46,6 @@ public class ProductService {
@Autowired
private LimitSubmitAspect limitSubmitAspect;
private final RabbitProducer producer;
public ProductService(RabbitProducer producer) {
this.producer = producer;
}
public Result queryCategory(String shopId,Integer page,Integer pageSize){
PageHelperUtil.startPage(page, pageSize);
@@ -81,7 +73,7 @@ public class ProductService {
String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
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);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){
@@ -110,7 +102,7 @@ public class ProductService {
}
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, int page, int pageSize, String masterId) {
List<TbProductWithBLOBs> tbProductWithBLOBs=null;
PageHelperUtil.startPage(page,pageSize);
if(ObjectUtil.isEmpty(categoryId)){
@@ -126,7 +118,7 @@ public class ProductService {
String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId);
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day);
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){
@@ -135,20 +127,72 @@ public class ProductService {
it.setTbProductSpec(tbProductSpec);
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);
// 查询sku信息
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.setGroundingSpecInfo(querySpec(Integer.valueOf(shopId), it.getId()));
});
}
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);
@@ -207,92 +251,6 @@ public class ProductService {
}else {
tbProductMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock());
tbProductSkuMapper.updateStock(productStockDTO.getShopId(), productStockDTO.getProductId(), productStockDTO.getStock());
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectByProductId(product.getId());
JSONObject data = new JSONObject();
data.put("shopId", productStockDTO.getShopId());
data.put("skuId", tbProductSkus.isEmpty() ? null : tbProductSkus.get(0).getId());
data.put("productId", productStockDTO.getProductId());
data.put("type", "pc收银机修改库存");
data.put("subType", product.getStockNumber() > productStockDTO.getStock() ? -1 : 1);
data.put("number",productStockDTO.getStock() - product.getStockNumber());
producer.sendStockRecordMsg(data);
}
}
private static void generateCombinations(List<List<String>> valuesList, int index, List<String> current, List<String> result) {
if (index == valuesList.size()) {
result.add(String.join(",", current));
return;
}
for (String value : valuesList.get(index)) {
current.add(value);
generateCombinations(valuesList, index + 1, current, result);
current.remove(current.size() - 1); // 回溯
}
}
public Object querySpec(Integer shopId, Integer productId) {
TbProduct tbProduct = tbProductMapper.selectByPrimaryKey(productId);
if (tbProduct == null) {
throw new MsgException("商品不存在");
}
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(productId);
// 重组有效规格数据
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(productId);
JSONArray finalSnap = new JSONArray();
List<String> result = new ArrayList<>();
if (tagSnap != null) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
List<List<String>> valuesList = new ArrayList<>();
// 提取所有 value 的列表
for (int i = 0; i < tagSnaps.size(); i++) {
JSONObject jsonObject = tagSnaps.getJSONObject(i);
if (jsonObject.containsKey("value")) {
String[] values = jsonObject.getString("value").split(",");
valuesList.add(Arrays.asList(values));
}
}
// 生成所有可能的排列组合
generateCombinations(valuesList, 0, new ArrayList<>(), result);
}
ArrayList<HashMap<String, Object>> specList = new ArrayList<>();
tbProductSkus.forEach(item -> {
HashMap<String, Object> itemMap = new HashMap<>();
itemMap.put("specSnap", item.getSpecSnap());
itemMap.put("skuId", item.getId());
specList.add(itemMap);
});
ArrayList<HashMap<String, Object>> otherVal = new ArrayList<>();
for (String res : result) {
boolean found = false;
for (HashMap<String, Object> spec : specList) {
if (res.equals(spec.get("specSnap").toString())) {
spec.put("isGrounding", true);
found = true;
break;
}
}
if (!found) {
HashMap<String, Object> itemMap = new HashMap<>();
itemMap.put("specSnap", res);
itemMap.put("skuId", null);
itemMap.put("isGrounding", false);
otherVal.add(itemMap);
}
}
specList.addAll(otherVal);
return specList;
}
}

View File

@@ -4,12 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
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.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.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
@@ -18,7 +14,6 @@ import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -27,8 +22,7 @@ import java.util.*;
@Service
public class ShopInfoService {
@Autowired
TbShopInfoMapper tbShopInfoMapper;
@Autowired
TbShopAreaMapper tbShopAreaMapper;
@@ -42,21 +36,11 @@ public class ShopInfoService {
@Autowired
ShopUserDutyDetailMapper shopUserDutyDetailMapper;
private final TbOrderInfoMapper orderInfoMapper;
@Qualifier("tbCashierCartMapper")
@Autowired
private TbCashierCartMapper tbCashierCartMapper;
@Autowired
private MpShopTableMapper mpShopTableMapper;
public ShopInfoService(TbOrderInfoMapper orderInfoMapper) {
this.orderInfoMapper = orderInfoMapper;
}
public Result queryShopInfo(Integer shopId) {
return new Result(CodeEnum.SUCCESS,tbShopInfoMapper.selectByPrimaryKey(shopId));
}
public Result queryShopArea(String shopId){
List<TbShopArea> list= tbShopAreaMapper.selectByShopId(shopId);
return Result.success(CodeEnum.SUCCESS,list);
@@ -69,22 +53,8 @@ public class ShopInfoService {
}
PageHelperUtil.startPage(page, pageSize);
// List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status);
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);
List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status);
PageInfo pageInfo=new PageInfo(shopTables);
return Result.success(CodeEnum.SUCCESS,pageInfo);
}
@@ -132,13 +102,4 @@ public class ShopInfoService {
map.put("amount",amount);
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

@@ -1,30 +0,0 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Map;
/**
* 打印机配置
* @author tankaikai
* @since 2024-09-24 17:15
*/
public interface ShopPrinterService {
PageInfo<ShopPrinterDTO> page(Map<String, Object> params);
List<ShopPrinterDTO> list(Map<String, Object> params);
ShopPrinterDTO get(Integer id);
void save(ShopPrinterDTO dto);
void update(ShopPrinterDTO dto);
void delete(Integer id);
void updateStatus(Integer id,Integer status);
}

View File

@@ -1,21 +0,0 @@
package com.chaozhanggui.system.cashierservice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
import com.chaozhanggui.system.cashierservice.sign.Result;
/**
* (TbShopPermission)表服务接口
*
* @author makejava
* @since 2024-09-14 17:08:48
*/
public interface TbShopPermissionService extends IService<TbShopPermission> {
/**
* 查询员工是否拥有某个权限
*/
Result getStaffPermission(String staffId, String code);
}

View File

@@ -1,15 +0,0 @@
package com.chaozhanggui.system.cashierservice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表服务接口
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
public interface TbShopStaffPermissionService extends IService<TbShopStaffPermission> {
}

View File

@@ -1,79 +0,0 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapProxy;
import com.chaozhanggui.system.cashierservice.dao.ShopPrinterServiceMapper;
import com.chaozhanggui.system.cashierservice.dao.TbPrintMachineMapper;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
import com.chaozhanggui.system.cashierservice.service.ShopPrinterService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* 店铺打印配置
*
* @author tankaikai
* @since 2024-09-24 17:23
*/
@Service
public class ShopPrinterServiceImpl implements ShopPrinterService {
@Resource
private ShopPrinterServiceMapper shopPrinterServiceMapper;
@Resource
private TbPrintMachineMapper tbPrintMachineMapper;
@Override
public PageInfo<ShopPrinterDTO> page(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
Integer pageNum = mapProxy.getInt("pageNum");
Integer pageSize = mapProxy.getInt("pageSize");
PageInfo<ShopPrinterDTO> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> shopPrinterServiceMapper.getList(params));
return pageInfo;
}
@Override
public List<ShopPrinterDTO> list(Map<String, Object> params) {
return shopPrinterServiceMapper.getList(params);
}
@Override
public ShopPrinterDTO get(Integer id) {
TbPrintMachineWithBLOBs entity = tbPrintMachineMapper.selectByPrimaryKey(id);
return BeanUtil.toBean(entity, ShopPrinterDTO.class);
}
@Override
public void save(ShopPrinterDTO dto) {
TbPrintMachineWithBLOBs entity = new TbPrintMachineWithBLOBs();
BeanUtil.copyProperties(dto, entity, "createdAt", "updatedAt");
entity.setCreatedAt(System.currentTimeMillis());
entity.setUpdatedAt(System.currentTimeMillis());
tbPrintMachineMapper.insert(entity);
}
@Override
public void update(ShopPrinterDTO dto) {
TbPrintMachineWithBLOBs entity = tbPrintMachineMapper.selectByPrimaryKey(dto.getId());
BeanUtil.copyProperties(dto, entity, "createdAt", "updatedAt");
entity.setUpdatedAt(System.currentTimeMillis());
tbPrintMachineMapper.updateByPrimaryKeyWithBLOBs(entity);
}
@Override
public void delete(Integer id) {
tbPrintMachineMapper.deleteByPrimaryKey(id);
}
@Override
public void updateStatus(Integer id, Integer status) {
shopPrinterServiceMapper.updateStatus(id, status);
}
}

View File

@@ -1,46 +0,0 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.dao.TbShopPermissionDao;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService;
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
* (TbShopPermission)表服务实现类
*
* @author makejava
* @since 2024-09-14 17:08:49
*/
@Service
@Primary
public class TbShopPermissionServiceImpl extends ServiceImpl<TbShopPermissionDao, TbShopPermission> implements TbShopPermissionService {
@Autowired
private TbShopStaffPermissionService shopStaffPermissionService;
@Override
public Result getStaffPermission(String staffId, String code) {
QueryWrapper<TbShopPermission> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", code);
TbShopPermission permission = this.getOne(queryWrapper);
if (permission == null) {
return Result.fail("权限不存在");
}
QueryWrapper<TbShopStaffPermission> staffPermissionQueryWrapper = new QueryWrapper<>();
staffPermissionQueryWrapper.eq("staff_id", staffId);
staffPermissionQueryWrapper.eq("permission_id", permission.getId());
TbShopStaffPermission staffPermission = shopStaffPermissionService.getOne(staffPermissionQueryWrapper);
return Result.success(CodeEnum.SUCCESS, staffPermission != null);
}
}

View File

@@ -1,21 +0,0 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.dao.TbShopStaffPermissionDao;
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
/**
* 店铺员工权限关联表(TbShopStaffPermission)表服务实现类
*
* @author makejava
* @since 2024-09-14 17:07:33
*/
@Service
@Primary
public class TbShopStaffPermissionServiceImpl extends ServiceImpl<TbShopStaffPermissionDao, TbShopStaffPermission> implements TbShopStaffPermissionService {
}

View File

@@ -104,25 +104,7 @@ public enum CodeEnum {
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

@@ -1,48 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class ApppayReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
/**
* 微信 WECHAT
* 支付宝 ALIPAY
*/
private String payType;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public ApppayReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

@@ -1,45 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class ChrpayReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
private String payType;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public ChrpayReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

@@ -1,47 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class H5payReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
/**
* 微信 WECHAT
* 支付宝 ALIPAY
*/
private String payType;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public H5payReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

@@ -1,53 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class JspayReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
/**
* 微信 WECHAT
* 支付宝 ALIPAY
*/
private String payType;
private String subAppid;
private String userId;
private String clientIp;
private String mchOrderNo;
private String storeId;
private String notifyUrl;
private String returnUrl;
public JspayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.payType = payType;
this.subAppid = subAppid;
this.userId = userId;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
}
}

View File

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

View File

@@ -1,35 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class ScanpayReq implements Serializable {
private String subject;
private String body;
private Long amount;
private String currency="cny";
private String clientIp;
private String mchOrderNo;
private String storeId;
public ScanpayReq(String subject, String body, Long amount, String currency, String clientIp, String mchOrderNo, String storeId) {
this.subject = subject;
this.body = body;
this.amount = amount;
this.currency = currency;
this.clientIp = clientIp;
this.mchOrderNo = mchOrderNo;
this.storeId = storeId;
}
}

View File

@@ -3,7 +3,6 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
@Data
public class WxScanPayReq implements Serializable {
@@ -29,20 +28,11 @@ public class WxScanPayReq implements Serializable {
private String storeId;
private int divisionMode;
private ArrayList divList;
private String divTemplateNo;
private String notifyUrl;
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,
int divisionMode,ArrayList divList,String divTemplateNo,
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, String notifyUrl, String returnUrl) {
this.subject = subject;
this.body = body;
this.amount = amount;
@@ -55,8 +45,5 @@ public class WxScanPayReq implements Serializable {
this.storeId = storeId;
this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl;
this.divisionMode=divisionMode;
this.divList=divList;
this.divTemplateNo=divTemplateNo;
}
}

View File

@@ -1,51 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
import lombok.Data;
import java.io.Serializable;
@Data
public class ApppayResp implements Serializable {
private Long amount;
private String mchOrderNo;
private String payOrderId;
private String mercNo;
private String channelSendNo;
private String channelTradeNo;
private String state;
private String payType;
private String ifCode;
private String extParam;
private String payInfo;
private String liteInfo;
private String note;
private String tradeFee;
private String storeId;
private String subject;
private String drType;
private String refundAmt;
private String refundState;
private String cashFee;
private String settlementType;
}

View File

@@ -1,51 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
import lombok.Data;
import java.io.Serializable;
@Data
public class ChrpayResp implements Serializable {
private Long amount;
private String mchOrderNo;
private String payOrderId;
private String mercNo;
private String channelSendNo;
private String channelTradeNo;
private String state;
private String payType;
private String ifCode;
private String extParam;
private String payInfo;
private String liteInfo;
private String note;
private String tradeFee;
private String storeId;
private String subject;
private String drType;
private String refundAmt;
private String refundState;
private String cashFee;
private String settlementType;
}

View File

@@ -1,50 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
import lombok.Data;
import java.io.Serializable;
@Data
public class H5payResp implements Serializable {
private Long amount;
private String mchOrderNo;
private String payOrderId;
private String mercNo;
private String channelSendNo;
private String channelTradeNo;
private String state;
private String payType;
private String ifCode;
private String extParam;
private String payInfo;
private String note;
private String tradeFee;
private String storeId;
private String subject;
private String drType;
private String refundAmt;
private String refundState;
private String cashFee;
private String settlementType;
}

View File

@@ -1,50 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
import lombok.Data;
import java.io.Serializable;
@Data
public class JspayResp implements Serializable {
private Long amount;
private String mchOrderNo;
private String payOrderId;
private String mercNo;
private String channelSendNo;
private String channelTradeNo;
private String state;
private String payType;
private String ifCode;
private String extParam;
private String payInfo;
private String note;
private String tradeFee;
private String storeId;
private String subject;
private String drType;
private String refundAmt;
private String refundState;
private String cashFee;
private String settlementType;
}

View File

@@ -1,49 +0,0 @@
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
import lombok.Data;
import java.io.Serializable;
@Data
public class ScanpayResp implements Serializable {
private Long amount;
private String mchOrderNo;
private String payOrderId;
private String mercNo;
private String channelSendNo;
private String channelTradeNo;
private String state;
private String payType;
private String ifCode;
private String extParam;
private String payInfo;
private String note;
private String tradeFee;
private String storeId;
private String subject;
private String drType;
private String refundAmt;
private String refundState;
private String cashFee;
private String settlementType;
}

View File

@@ -29,15 +29,6 @@ public class ThirdPayService {
private static String refund="/api/open/order/refund";
private static String scanpay="/api/open/payment/scanpay";
private static String h5pay="/api/open/payment/h5pay";
private static String jspay="/api/open/payment/jspay";
private static String apppay="/api/open/payment/apppay";
private static String chrpay="/api/open/payment/chrpay";
/**
* 被扫接口
* @param url
@@ -56,17 +47,8 @@ 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,
String key
) {
MainScanReq mainScanReq= new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,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()));
@@ -117,14 +99,7 @@ public class ThirdPayService {
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
String key){
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
// 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);
// }
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,notifyUrl,returnUrl);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
@@ -256,218 +231,6 @@ public class ThirdPayService {
}
/**
* Pc 扫码支付
* @param url
* @param appId
* @param key
* @param subject
* @param body
* @param amount
* @param clientIp
* @param mchOrderNo
* @param storeId
* @param notifyUrl
* @param returnUrl
* @return
*/
public PublicResp<ScanpayResp> pcscanpay(String url,String appId,String key,String subject, String body, Long amount, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl ){
ScanpayReq scanpayReq=new ScanpayReq(subject, body, amount, "cny", clientIp, mchOrderNo, storeId);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
try {
String str=JSONUtil.toJSONString(sortFields(scanpayReq));
param.setBizData(str);
String tt = sortFieldsAndPrint(param);
String MD5 = tt.concat("appSecret=" + key);
log.info("加签原传:{}", MD5);
String sign = MD5Util.encrypt(MD5);
param.setSign(sign);
String reqbody = JSONUtil.toJSONString(param);
log.info("请求参数:{}", reqbody);
String response = HttpRequest.post(url.concat(scanpay)).body(reqbody).execute().body();
log.info("返回结果:{}", response);
PublicResp<ScanpayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ScanpayResp.class));
return resp;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
/**
* 手机网页支付
* @param url
* @param appId
* @param key
* @param subject
* @param body
* @param amount
* @param payType
* @param clientIp
* @param mchOrderNo
* @param storeId
* @param notifyUrl
* @param returnUrl
* @return
*/
public PublicResp<H5payResp> h5Pay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
H5payReq h5payReq=new H5payReq(subject, body, amount, "cny", payType, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
try {
String str=JSONUtil.toJSONString(sortFields(h5payReq));
param.setBizData(str);
String tt = sortFieldsAndPrint(param);
String MD5 = tt.concat("appSecret=" + key);
log.info("加签原传:{}", MD5);
String sign = MD5Util.encrypt(MD5);
param.setSign(sign);
String reqbody = JSONUtil.toJSONString(param);
log.info("请求参数:{}", reqbody);
String response = HttpRequest.post(url.concat(h5pay)).body(reqbody).execute().body();
log.info("返回结果:{}", response);
PublicResp<H5payResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),H5payResp.class));
return resp;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
/**
* 公众号/生活号/银联js支付
* @param url
* @param appId
* @param key
* @param subject
* @param body
* @param amount
* @param payType
* @param subAppid
* @param userId
* @param clientIp
* @param mchOrderNo
* @param storeId
* @param notifyUrl
* @param returnUrl
* @return
*/
public PublicResp<JspayResp> jspay(String url,String appId,String key,String subject, String body, Long amount, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
JspayReq jspayReq=new JspayReq(subject, body, amount, "cny", payType, subAppid, userId, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
try {
String str=JSONUtil.toJSONString(sortFields(jspayReq));
param.setBizData(str);
String tt = sortFieldsAndPrint(param);
String MD5 = tt.concat("appSecret=" + key);
log.info("加签原传:{}", MD5);
String sign = MD5Util.encrypt(MD5);
param.setSign(sign);
String reqbody = JSONUtil.toJSONString(param);
log.info("请求参数:{}", reqbody);
String response = HttpRequest.post(url.concat(jspay)).body(reqbody).execute().body();
log.info("返回结果:{}", response);
PublicResp<JspayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),JspayResp.class));
return resp;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
/***
* app 支付
* @param url
* @param appId
* @param key
* @param subject
* @param body
* @param amount
* @param payType
* @param clientIp
* @param mchOrderNo
* @param storeId
* @param notifyUrl
* @param returnUrl
* @return
*/
public PublicResp<ApppayResp> apppay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
ApppayReq apppayReq=new ApppayReq(subject, body, amount, "cny", payType, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
try {
String str=JSONUtil.toJSONString(sortFields(apppayReq));
param.setBizData(str);
String tt = sortFieldsAndPrint(param);
String MD5 = tt.concat("appSecret=" + key);
log.info("加签原传:{}", MD5);
String sign = MD5Util.encrypt(MD5);
param.setSign(sign);
String reqbody = JSONUtil.toJSONString(param);
log.info("请求参数:{}", reqbody);
String response = HttpRequest.post(url.concat(apppay)).body(reqbody).execute().body();
log.info("返回结果:{}", response);
PublicResp<ApppayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ApppayResp.class));
return resp;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
/**
* 聚合收银台
* @param url
* @param appId
* @param key
* @param subject
* @param body
* @param amount
* @param clientIp
* @param mchOrderNo
* @param storeId
* @param notifyUrl
* @param returnUrl
* @return
*/
public PublicResp<ChrpayResp> chrpay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
ChrpayReq chrpayReq=new ChrpayReq(subject, body, amount, "cny",payType,clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
try {
String str=JSONUtil.toJSONString(sortFields(chrpayReq));
param.setBizData(str);
String tt = sortFieldsAndPrint(param);
String MD5 = tt.concat("appSecret=" + key);
log.info("加签原传:{}", MD5);
String sign = MD5Util.encrypt(MD5);
param.setSign(sign);
String reqbody = JSONUtil.toJSONString(param);
log.info("请求参数:{}", reqbody);
String response = HttpRequest.post(url.concat(chrpay)).body(reqbody).execute().body();
log.info("返回结果:{}", response);
PublicResp<ChrpayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ChrpayResp.class));
return resp;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More