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

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

27
pom.xml
View File

@ -185,6 +185,33 @@
<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>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<!-- <profiles>-->
<!-- <profile>-->

View File

@ -1,7 +1,6 @@
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;
@ -45,7 +44,6 @@ 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("订单购物车");
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"), PLACE("下单");
private final String value;
LogTag(String value) {

View File

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

View File

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

View File

@ -23,6 +23,8 @@ public class LoginContoller {
@Autowired
LoginService loginService;
@RequestMapping(value = "login",method = RequestMethod.POST)
public Result login(@RequestBody LoginReq loginReq, HttpServletRequest request){
try {
@ -34,6 +36,11 @@ 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,
@ -51,4 +58,13 @@ 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,10 +26,11 @@ 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,page,pageSize);
return memberService.queryMember(shopId, phone, isFlag,page, pageSize);
}
@ -55,7 +56,6 @@ public class MemberController {
}
@GetMapping("queryScanPay")
public Result queryScanPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
@ -66,14 +66,18 @@ public class MemberController {
}
@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);
}
@ -88,4 +92,17 @@ public class MemberController {
) {
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);
}
}

View File

@ -6,12 +6,15 @@ 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 = "*")
@ -24,6 +27,14 @@ 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,
@ -68,11 +79,12 @@ 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);
return orderService.createCode(shopId,clientType,userId,type, tableId);
}
@GetMapping("/getCartList")
public Result getCart(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -90,7 +102,8 @@ 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);
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),
cartVo.getStatus(),userId,cartVo.getUuid(),clientType, cartVo.getVipUserId(), cartVo.getTableId());
}
@PostMapping("/createOrder")
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -99,7 +112,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);
return orderService.createOrder(orderVo,clientType,token, null, orderVo.getType() != null && orderVo.getType().equals(0));
}
@PostMapping("/createBackOrder")
public Result createBackOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@ -139,7 +152,9 @@ public class OrderController {
public Result orderDetail(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestParam("shopId") Integer shopId,
@RequestParam("id") Integer id){
return orderService.orderDetail(shopId,id);
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId");
return orderService.orderDetail(shopId,id, clientType, token, userId, jsonObject.getString("staffId"));
}

View File

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

View File

@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.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;
@ -58,6 +59,15 @@ 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,
@ -67,11 +77,12 @@ 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,page,pageSize,masterId);
return productService.queryNewCommodityInfo(shopId,categoryId,commdityName, tableId,page,pageSize,masterId);
}
@GetMapping(value = "queryCategory")

View File

@ -59,4 +59,9 @@ 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

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
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;
@ -23,4 +24,5 @@ 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);
List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone,@Param("isFlag") String isFlag);
List<TbShopUser> selectByShopIdAndPhone(@Param("shopId") String shopId,@Param("phone") String phone);

View File

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

View File

@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
@ -57,7 +58,11 @@ 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,6 +35,8 @@ public class TbConsInfo implements Serializable {
private Date updateTime;
private String isCheck;
private static final long serialVersionUID = 1L;
public Integer getId() {
@ -156,4 +158,12 @@ 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

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

View File

@ -14,6 +14,8 @@ public class TbPlussShopStaff implements Serializable {
private String password;
private String discountType;
private BigDecimal maxDiscountAmount;
private Boolean status;
@ -72,6 +74,14 @@ 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

@ -34,6 +34,15 @@ 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;

View File

@ -1,9 +1,13 @@
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;
@ -20,58 +24,34 @@ public class TbProductWithBLOBs extends TbProduct implements Serializable {
private static final long serialVersionUID = 1L;
public List<?> getSkuList() {
return skuList;
public void setGroundingSpecInfo(Object groundingSpecInfo) {
this.groundingSpecInfo = groundingSpecInfo;
}
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,6 +92,24 @@ public class TbShopInfo implements Serializable {
private String view;
private String isCustom;
private String isReturn;
private String isMemberIn;
private String isMemberReturn;
private static final long serialVersionUID = 1L;
public Integer getId() {
@ -445,4 +463,36 @@ 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,11 +5,6 @@ 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;
@ -19,4 +14,7 @@ public class CartVo {
private String uuid;
private String type;
private Integer cartId;
private String masterId;
private String tableId;
private Integer vipUserId;
}

View File

@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.entity.vo;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
@EqualsAndHashCode(callSuper = true)
@Data
public class TbShopTableVO extends TbShopTable {
private Integer userId;
private String masterId;
private Integer orderId;
private String orderNo;
private BigDecimal orderAmount;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -94,9 +94,10 @@ public class ConsMsgConsumer {
}
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
// List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopIdAngCheck(skuId, shopId);
if (Objects.isNull(tbProskuCons) || tbProskuCons.size() <= 0) {
log.info("耗材信息未配置");
log.info("耗材信息未配置或未开启校验");
return;
}
@ -123,7 +124,8 @@ 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<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
List<TbShopOpenId> tbUserShopMsgs = shopOpenIdMapper
.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.CONSUMABLES_MSG.getType());
log.info("待推送openId列表: {}", tbUserShopMsgs);
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{
@ -133,7 +135,8 @@ 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,28 +1,29 @@
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.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 com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
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.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.ArrayList;
import java.util.Date;
import java.util.List;
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;
@Slf4j
@Component
@ -49,11 +50,23 @@ 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 {
@ -79,7 +92,7 @@ public class PrintMechineConsumer {
}
list.parallelStream().forEach(it->{
list.forEach(it -> {
if (!"network".equals(it.getConnectionType())) {
log.error("非网络打印机:{},{}", it.getAddress(), it.getConnectionType());
return;
@ -112,7 +125,6 @@ public class PrintMechineConsumer {
});
} catch (Exception e) {
e.printStackTrace();
}
@ -121,13 +133,15 @@ public class PrintMechineConsumer {
/**
* 博时结云打印机
*
* @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){
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model,
TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
@ -172,7 +186,7 @@ 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.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单";
@ -185,7 +199,9 @@ public class PrintMechineConsumer {
return;
}
if ((!orderInfo.getStatus().equals("closed"))) {
return;
}
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
@ -215,23 +231,265 @@ 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());
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "结算单";
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
PrinterUtils.printTickets(voiceJson, 3, 1, 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);
return;
} else {
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
// printNormalTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
}
break;
case "category": //分类出单
break;
}
break;
case "kitchen": //出品打印机
break;
}
}
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 -> {
@ -250,49 +508,28 @@ public class PrintMechineConsumer {
}
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 {
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);
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
});
}
}
break;
case "category": //分类出单
break;
}
break;
case "kitchen": //出品打印机
break;
}
}
/**
* 判断商品是否已打票
*
* @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) {
@ -370,7 +607,7 @@ public class PrintMechineConsumer {
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());
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 = "退款单";
@ -420,7 +657,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());
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())) {
@ -437,6 +674,10 @@ public class PrintMechineConsumer {
break;
case "one": //一菜一品
if (!orderInfo.getStatus().equals("unpaid")) {
return;
}
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
@ -460,6 +701,8 @@ public class PrintMechineConsumer {
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);
}
});

View File

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

View File

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

View File

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

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

View File

@ -66,11 +66,13 @@ public class ConsService {
List<TbConsInfoFlow> consInfoFlows=new ArrayList<>();
for (TbOrderDetail orderDetail : orderDetails) {
List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
// List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductIdAndCheck(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
if(Objects.isNull(proskuCons)||proskuCons.size()<=0){
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,6 +273,12 @@ public class DataService {
JSONObject config = JSONObject.parseObject(it.getConfig());
String model = config.getString("model");
if(!"normal".equals(model)){
log.error("打印机类型错误");
return;
}
List<HandoverInfo.PayInfo> list = null;
List<HandoverInfo.MemberData> memberData = null;
List<HandoverInfo.ProductCategory> productCategories = null;

View File

@ -3,9 +3,11 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.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;
@ -14,6 +16,7 @@ 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;
@ -47,6 +50,8 @@ public class LoginService {
@Autowired
TbTokenMapper tbTokenMapper;
@Autowired
TbVersionMapper versionMapper;
@Autowired
RabbitProducer rabbitProducer;
@ -140,6 +145,14 @@ public class LoginService {
return Result.success(CodeEnum.SUCCESS, accountMap);
}
public Result findVersion() {
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TbVersion::getSource,"PC");
queryWrapper.eq(TbVersion::getSel,1);
return new Result(SUCCESS,versionMapper.selectOne(queryWrapper));
}
public Result logout(String loginName, String clientType, String token, String status) {
@ -191,4 +204,23 @@ 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,21 +5,23 @@ 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;
@ -65,6 +67,10 @@ public class MemberService {
RestTemplate restTemplate;
@Autowired
TbActivateMapper tbActivateMapper;
@Autowired
TbmerchantAccountMapper tbmerchantAccountMapper;
@Autowired
RabbitProducer producer;
@Value("${gateway.url}")
private String gateWayUrl;
@Value("${thirdPay.payType}")
@ -74,13 +80,21 @@ public class MemberService {
@Value("${thirdPay.callBack}")
private String callBack;
@Qualifier("tbOrderInfoMapper")
@Autowired
TbmerchantAccountMapper tbmerchantAccountMapper;
private TbOrderInfoMapper tbOrderInfoMapper;
private MpShopTableMapper mpShopTableMapper;
public Result queryMember(String shopId, String phone, int page, int pageSize) {
public Result queryMember(String shopId, String phone,String isFlag, int page, int pageSize) {
PageHelperUtil.startPage(page, pageSize);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone);
if(!"1".equals(isFlag)){
isFlag=null;
}
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone,isFlag);
PageInfo pageInfo = new PageInfo(tbShopUsers);
return Result.success(CodeEnum.SUCCESS, pageInfo);
}
@ -158,9 +172,6 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS);
}
@Autowired
RabbitProducer producer;
@Transactional(rollbackFor = Exception.class)
public Result memberScanPay(Map<String, Object> map, String token) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0
@ -168,13 +179,12 @@ public class MemberService {
|| !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"));
@ -184,6 +194,32 @@ 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);
@ -196,7 +232,6 @@ public class MemberService {
String wechatpay = "";
if (Integer.valueOf(payTypeCode) >= 25 && Integer.valueOf(payTypeCode) <= 30) {
qpay = "scanCode";
} else if (Integer.valueOf(payTypeCode) >= 10 && Integer.valueOf(payTypeCode) <= 19) {
@ -211,7 +246,6 @@ public class MemberService {
}
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(shopId, qpay);
if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
@ -273,6 +307,7 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
@ -284,7 +319,6 @@ 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;
@ -302,7 +336,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, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, orderNo, thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
MainScanResp mainScanResp = publicResp.getObjData();
@ -326,9 +360,11 @@ 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;
@ -353,7 +389,9 @@ 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();
@ -362,6 +400,17 @@ public class MemberService {
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())) {
@ -382,7 +431,6 @@ public class MemberService {
}
public Result queryScanPay(String flowId, String token) {
if (ObjectUtil.isEmpty(flowId)) {
return Result.fail(CodeEnum.PARAM);
@ -438,6 +486,7 @@ 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);
}
@ -465,6 +514,7 @@ public class MemberService {
flow.setBizName("线下充值");
flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
@ -492,6 +542,7 @@ public class MemberService {
flow.setBizName("充值活动奖励");
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date());
@ -502,6 +553,16 @@ 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);
@ -516,18 +577,32 @@ public class MemberService {
return Result.success(CodeEnum.SUCCESS, memberIn);
}
@Transactional(rollbackFor = Exception.class)
public Result memberAccountPay(Map<String, Object> map,String token) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0
public Result memberAccountPay(Map<String, Object> map, String token) throws Exception {
if (ObjectUtil.isEmpty(map) || map.isEmpty()
|| !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 memberId = String.valueOf(map.get("memberId"));
String shopId = String.valueOf(map.get("shopId"));
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
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));
@ -544,16 +619,9 @@ public class MemberService {
return Result.fail(CodeEnum.PWDERROE);
}
String memberId = String.valueOf(map.get("memberId"));
String shopId = String.valueOf(map.get("shopId"));
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST);
@ -595,7 +663,9 @@ 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)) {
@ -621,8 +691,11 @@ public class MemberService {
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
fl = awardAmount;
}
@ -634,10 +707,20 @@ 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);
@ -650,4 +733,117 @@ public class MemberService {
}
public Result returnAccount(String token, String flowId, String remark, String amount, String pwd) {
if (ObjectUtil.isEmpty(flowId) || ObjectUtil.isNull(flowId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)) {
return Result.fail(CodeEnum.PARAM);
}
TbShopUserFlow flow = tbShopUserFlowMapper.selectByPrimaryKey(Integer.valueOf(flowId));
if (ObjectUtil.isNull(flow) || ObjectUtil.isEmpty(flow)) {
return Result.fail(CodeEnum.USERSHOPFLOWNOEXIST);
}
if (!"0".equals(flow.getIsReturn())) {
return Result.fail(CodeEnum.ORDERRETURN);
}
if (N.gt(new BigDecimal(amount), flow.getAmount())) {
return Result.fail(CodeEnum.INPURAMOUNTERROR);
}
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(flow.getShopUserId());
if (ObjectUtil.isEmpty(user) || ObjectUtil.isNull(user)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(user.getShopId()));
if (ObjectUtil.isEmpty(shopInfo) || shopInfo == null) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
if ("1".equals(shopInfo.getIsMemberReturn())) {
if (ObjectUtil.isEmpty(pwd)) {
return Result.fail(CodeEnum.PARAM);
}
String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
if (Objects.isNull(account)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
}
if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
return Result.fail(CodeEnum.PWDNOSET);
}
if (!account.getPwd().equals(MD5Util.encrypt(pwd.concat(account.getAccount()).concat(account.getId().toString())))) {
return Result.fail(CodeEnum.PWDERROE);
}
}
if (N.gt(new BigDecimal(amount), user.getAmount())) {
return Result.fail(CodeEnum.ACCOUNTBALANCEERROR);
}
if ("scanMemberIn".equals(flow.getBizCode())) {
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail(CodeEnum.NOCUSTOMER);
}
String no = DateUtils.getSsdfTimes();
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), no, null, flow.getRemark(), "充值退款", new BigDecimal(amount).setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
MsgException.check(true, publicResp.getMsg());
}
} else {
MsgException.check(true, "退款渠道调用失败");
}
}
} else if ("cashMemberIn".equals(flow.getBizCode())) {
} else {
return Result.fail(CodeEnum.OPARETIONERROR);
}
user.setAmount(user.getAmount().subtract(new BigDecimal(amount)));
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(user);
flow.setIsReturn("1");
flow.setRemark(remark);
tbShopUserFlowMapper.updateByPrimaryKey(flow);
TbShopUserFlow userFlow = new TbShopUserFlow();
userFlow.setShopUserId(user.getId());
userFlow.setBizCode("memberReturn");
userFlow.setBizName("会员退款");
userFlow.setType("-");
userFlow.setAmount(new BigDecimal(amount));
userFlow.setBalance(user.getAmount());
userFlow.setCreateTime(new Date());
userFlow.setIsReturn("1");
userFlow.setRemark(flowId);
tbShopUserFlowMapper.insert(userFlow);
JSONObject baObj = new JSONObject();
baObj.put("userId", user.getUserId());
baObj.put("shopId", user.getId());
baObj.put("amount", amount);
baObj.put("balance", user.getAmount());
baObj.put("type", "退款");
baObj.put("time", new Date());
producer.balance(baObj.toString());
return Result.success(CodeEnum.SUCCESS);
}
}

View File

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

View File

@ -1,8 +1,12 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
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.dto.ReturnGroupOrderDto;
@ -11,6 +15,9 @@ import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq;
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.mybatis.MpShopUserFlowMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopUserMapper;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
@ -21,6 +28,7 @@ import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -30,8 +38,10 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
@Service
@Slf4j
@ -115,18 +125,39 @@ public class PayService {
TbmerchantAccountMapper tbmerchantAccountMapper;
public static void main(String[] args) {
@Autowired
TbPlussShopStaffMapper tbPlussShopStaffMapper;
@Autowired
private MpShopUserMapper mpShopUserMapper;
@Autowired
private MpShopUserFlowMapper mpShopUserFlowMapper;
@Autowired
private MpShopTableMapper mpShopTableMapper;
System.out.printf("%.2f%n", new BigDecimal(1).setScale(2, RoundingMode.DOWN));
private final RedisTemplate<String, Object> redisTemplate;
public PayService(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
public Result queryPayType(String shopId) {
return Result.success(CodeEnum.SUCCESS, tbShopPayTypeMapper.selectByShopId(shopId));
}
private void clearTableInfoCache(TbOrderInfo orderInfo) {
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisTemplate.delete(currentOrderKey);
}
String printKey = RedisCst.ORDER_PRINT_PRO + orderInfo.getId();
// 重置打印数据
redisTemplate.delete(printKey);
}
@Transactional(rollbackFor = Exception.class)
public Result scanPay(String orderId, String authCode, String ip, String token) {
public Result scanPay(String orderId, String authCode, String ip, String token, BigDecimal payAmount, BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(authCode) || ObjectUtil.isEmpty(ip)) {
return Result.fail(CodeEnum.PARAM);
}
@ -143,6 +174,25 @@ public class PayService {
}
JSONObject tokeObj = TokenUtil.parseParamFromToken(token);
if (Objects.isNull(tokeObj)) {
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId = Integer.valueOf(tokeObj.containsKey("staffId") ? tokeObj.getString("staffId") : "0");
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if (ObjectUtil.isNotNull(staff) && ObjectUtil.isNotNull(payAmount) && ObjectUtil.isNotNull(discountAmount) && ObjectUtil.isNotEmpty(payAmount) && ObjectUtil.isNotEmpty(discountAmount)) {
if ("0".equals(staff.getDiscountType())) {
if (N.gt(discountAmount, staff.getMaxDiscountAmount())) {
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
return Result.fail(CodeEnum.CARTEXIST);
@ -194,7 +244,7 @@ public class PayService {
if (ObjectUtil.isEmpty(payment) || payment == null) {
payment = new TbOrderPayment();
payment.setPayTypeId("ysk");
payment.setAmount(orderInfo.getOrderAmount());
payment.setAmount(ObjectUtil.isEmpty(payAmount) ? orderInfo.getOrderAmount() : payAmount);
payment.setPaidAmount(orderInfo.getPayAmount());
payment.setHasRefundAmount(BigDecimal.ZERO);
payment.setPayName(payName);
@ -214,9 +264,12 @@ public class PayService {
}
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount) ? orderInfo.getOrderAmount() : payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount) ? null : discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount) ? payAmount.divide(orderInfo.getOrderAmount(), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_DOWN) : null);
orderInfo.setPayType(qpay);
orderInfo.setUpdatedAt(System.currentTimeMillis());
orderInfo.setStaffId(ObjectUtil.isNotNull(staff) ? staff.getId() : null);
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
if ("ysk".equals(thirdPayType)) {
@ -250,7 +303,7 @@ public class PayService {
log.info("更新购物车:{}", cartCount);
//更新子单状态
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
@ -261,6 +314,16 @@ public class PayService {
producer.printMechine(orderId);
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
} else {
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
@ -273,6 +336,18 @@ public class PayService {
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
payment.setUpdatedAt(System.currentTimeMillis());
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 打印结算单
producer.printMechine(orderId);
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.PAYING);
}
// orderInfo.setStatus("fail");
@ -310,8 +385,11 @@ public class PayService {
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
log.info("更新购物车:{}", cartCount);
//更新子单状态
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
@ -321,6 +399,15 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(orderId);
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 打印结算单
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.SUCCESS, mainScanResp);
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
@ -331,6 +418,17 @@ public class PayService {
payment.setTradeNumber(mainScanResp.getPayOrderId());
payment.setUpdatedAt(System.currentTimeMillis());
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 打印结算单
producer.printMechine(orderId);
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.PAYING);
}
}
@ -393,7 +491,6 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(orderId);
}
}
}
@ -410,8 +507,11 @@ public class PayService {
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
log.info("更新购物车:{}", cartCount);
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("type", "create");
@ -419,7 +519,6 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(orderId);
}
}
}
@ -432,7 +531,7 @@ public class PayService {
}
@Transactional(rollbackFor = Exception.class)
public Result accountPay(String orderId, String memberId, String token,String memberAccount) {
public Result accountPay(String orderId, String memberId, String token, String memberAccount, BigDecimal payAmount, BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) {
if (ObjectUtil.isEmpty(memberAccount)) {
if (ObjectUtil.isEmpty(memberId)) {
@ -466,6 +565,25 @@ public class PayService {
}
JSONObject tokeObj = TokenUtil.parseParamFromToken(token);
if (Objects.isNull(tokeObj)) {
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId = Integer.valueOf(tokeObj.containsKey("staffId") ? tokeObj.getString("staffId") : "0");
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if (ObjectUtil.isNotNull(staff) && ObjectUtil.isNotNull(payAmount) && ObjectUtil.isNotNull(discountAmount) && ObjectUtil.isNotEmpty(payAmount) && ObjectUtil.isNotEmpty(discountAmount)) {
if ("0".equals(staff.getDiscountType())) {
if (N.gt(discountAmount, staff.getMaxDiscountAmount())) {
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
TbShopUser user = null;
if (ObjectUtil.isNotEmpty(memberId)) {
@ -492,8 +610,11 @@ public class PayService {
return Result.fail(CodeEnum.MEMBERINSUFFICIENTFUNDS);
}
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getOrderAmount()));
if (ObjectUtil.isEmpty(payAmount) || ObjectUtil.isNull(payAmount)) {
payAmount = orderInfo.getOrderAmount();
}
user.setAmount(user.getAmount().subtract(payAmount));
user.setConsumeAmount(user.getConsumeAmount().add(payAmount));
user.setConsumeNumber(user.getConsumeNumber() + 1);
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(user);
@ -502,15 +623,19 @@ public class PayService {
TbShopUserFlow flow = new TbShopUserFlow();
flow.setShopUserId(user.getId());
flow.setBizCode("accountPay");
flow.setBizName("会员储值卡支付");
flow.setBizName("余额支付");
flow.setType("-");
flow.setAmount(orderInfo.getOrderAmount());
flow.setAmount(payAmount);
flow.setBalance(user.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount) ? orderInfo.getOrderAmount() : payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount) ? null : discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount) ? payAmount.divide(orderInfo.getOrderAmount(), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_DOWN) : null);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff) ? null : staff.getId());
orderInfo.setUserId(user.getUserId());
orderInfo.setMemberId(user.getId().toString());
orderInfo.setPayType("deposit");
@ -520,10 +645,11 @@ public class PayService {
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
@ -542,11 +668,27 @@ public class PayService {
mqData.put("type", "pc");
producer.sendStockSaleMsg(mqData);
JSONObject baObj=new JSONObject();
baObj.put("userId",user.getUserId());
baObj.put("shopId",user.getShopId());
baObj.put("amount",orderInfo.getPayAmount());
baObj.put("balance",user.getAmount());
baObj.put("type","消费");
baObj.put("time",flow.getCreateTime());
producer.balance(baObj.toString());
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.SUCCESS);
}
@Transactional(rollbackFor = Exception.class)
public Result memberScanPay(String orderId, String memberCode, String token) {
public Result memberScanPay(String orderId, String memberCode, String token, BigDecimal payAmount, BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberCode)) {
return Result.fail(CodeEnum.PARAM);
}
@ -569,13 +711,32 @@ public class PayService {
}
JSONObject tokeObj = TokenUtil.parseParamFromToken(token);
if (Objects.isNull(tokeObj)) {
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId = Integer.valueOf(tokeObj.containsKey("staffId") ? tokeObj.getString("staffId") : "0");
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if (ObjectUtil.isNotNull(staff) && ObjectUtil.isNotNull(payAmount) && ObjectUtil.isNotNull(discountAmount) && ObjectUtil.isNotEmpty(payAmount) && ObjectUtil.isNotEmpty(discountAmount)) {
if ("0".equals(staff.getDiscountType())) {
if (N.gt(discountAmount, staff.getMaxDiscountAmount())) {
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByCardNo(memberCode);
if (ObjectUtil.isEmpty(tbUserInfo)) {
return Result.fail(ACCOUNTEIXST);
}
TbShopUser user = tbShopUserMapper.selectByShopId(orderInfo.getShopId(), tbUserInfo.getId().toString()).get(0);
TbShopUser user = tbShopUserMapper.selectByShopId(orderInfo.getShopId(), tbUserInfo.getId().toString(),"2").get(0);
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST);
}
@ -594,15 +755,18 @@ public class PayService {
TbShopUserFlow flow = new TbShopUserFlow();
flow.setShopUserId(user.getId());
flow.setBizCode("accountPay");
flow.setBizName("会员储值卡支付");
flow.setBizName("余额支付");
flow.setType("-");
flow.setAmount(orderInfo.getOrderAmount());
flow.setBalance(user.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount) ? orderInfo.getOrderAmount() : payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount) ? null : discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount) ? payAmount.divide(orderInfo.getOrderAmount(), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_DOWN) : null);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff) ? null : staff.getId());
orderInfo.setMemberId(user.getUserId());
orderInfo.setPayType("deposit");
orderInfo.setStatus("closed");
@ -612,9 +776,13 @@ public class PayService {
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
@ -633,11 +801,130 @@ public class PayService {
mqData.put("type", "pc");
producer.sendStockSaleMsg(mqData);
JSONObject baObj=new JSONObject();
baObj.put("userId",user.getUserId());
baObj.put("shopId",user.getShopId());
baObj.put("amount",orderInfo.getPayAmount());
baObj.put("balance",user.getAmount());
baObj.put("type","消费");
baObj.put("time",flow.getCreateTime());
producer.balance(baObj.toString());
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.SUCCESS);
}
public Result vipPay(Integer orderId, String token, Integer vipUserId, BigDecimal payAmount, BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM);
}
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
if (ObjectUtil.isEmpty(orderInfo)) {
return Result.fail(CodeEnum.ORDERNOEXIST);
}
if (!"unpaid".equals(orderInfo.getStatus())) {
return Result.fail(CodeEnum.ORDERSTATUSERROR);
}
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
}
if (payAmount != null && discountAmount != null && payAmount.add(discountAmount).compareTo(orderInfo.getOrderAmount()) != 0) {
return Result.fail("优惠金额 + 支付金额不等于订单金额");
}
// 扣减会员余额
TbShopUser shopUser = mpShopUserMapper.selectOne(new LambdaUpdateWrapper<TbShopUser>()
.eq(TbShopUser::getStatus, 1)
.eq(TbShopUser::getId, vipUserId));
if (shopUser == null) {
return Result.fail("用户不存在或已被禁用");
}
long flag = mpShopUserMapper.decrBalance(vipUserId, (payAmount != null && discountAmount != null) ? payAmount : orderInfo.getOrderAmount());
if (flag < 1) {
return Result.fail("余额不足或扣除余额失败");
}
TbShopUserFlow userFlow = new TbShopUserFlow();
userFlow.setAmount((payAmount != null && discountAmount != null) ? payAmount : orderInfo.getOrderAmount());
userFlow.setBalance(shopUser.getAmount().subtract((payAmount != null && discountAmount != null) ? payAmount : orderInfo.getOrderAmount()));
userFlow.setShopUserId(shopUser.getId());
userFlow.setBizCode("vipCardCash");
userFlow.setBizName("余额支付");
userFlow.setCreateTime(DateUtil.date());
userFlow.setType("-");
userFlow.setIsReturn("0");
mpShopUserFlowMapper.insert(userFlow);
if (payAmount != null && discountAmount != null) {
orderInfo.setPayAmount(payAmount);
orderInfo.setDiscountAmount(discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount) ? payAmount.divide(orderInfo.getOrderAmount(), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_DOWN) : null);
} else {
orderInfo.setPayAmount(orderInfo.getOrderAmount());
}
orderInfo.setPayType("deposit");
orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
orderInfo.setMemberId(vipUserId.toString());
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(String.valueOf(orderId), "final");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("type", "create");
jsonObject.put("orderId", orderId);
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(String.valueOf(orderId));
// 发送库存记录mq消息
JSONObject mqData = new JSONObject();
mqData.put("orderId", orderId);
mqData.put("type", "pc");
producer.sendStockSaleMsg(mqData);
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.SUCCESS);
}
@Transactional(rollbackFor = Exception.class)
public Result cashPay(String orderId, String token) {
public Result cashPay(String orderId, String token, BigDecimal payAmount, BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM);
}
@ -654,21 +941,48 @@ public class PayService {
}
JSONObject tokeObj = TokenUtil.parseParamFromToken(token);
if (Objects.isNull(tokeObj)) {
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId = Integer.valueOf(tokeObj.containsKey("staffId") ? tokeObj.getString("staffId") : "0");
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if (ObjectUtil.isNotNull(staff) && ObjectUtil.isNotNull(payAmount) && ObjectUtil.isNotNull(discountAmount) && ObjectUtil.isNotEmpty(payAmount) && ObjectUtil.isNotEmpty(discountAmount)) {
if ("0".equals(staff.getDiscountType())) {
if (N.gt(discountAmount, staff.getMaxDiscountAmount())) {
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
}
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount) ? orderInfo.getOrderAmount() : payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount) ? null : discountAmount);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff) ? null : staff.getId());
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount) ? payAmount.divide(orderInfo.getOrderAmount(), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_DOWN) : null);
orderInfo.setPayType("cash");
orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
JSONObject jsonObject = new JSONObject();
@ -687,11 +1001,25 @@ public class PayService {
mqData.put("type", "pc");
producer.sendStockSaleMsg(mqData);
redisUtil.del("SHOP:CODE:USER:" + "pc" + ":" + orderInfo.getShopId() + ":" + DateUtils.getDay() + TokenUtil.parseParamFromToken(token).getString("accountId"));
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 小程序购物车缓存
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
orderInfo.getShopId());
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.SUCCESS);
}
@Transactional(rollbackFor = Exception.class)
public Result bankPay(String orderId, String token) {
public Result bankPay(String orderId, String token, BigDecimal payAmount, BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM);
}
@ -713,18 +1041,43 @@ public class PayService {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
}
JSONObject tokeObj = TokenUtil.parseParamFromToken(token);
if (Objects.isNull(tokeObj)) {
return Result.fail(CodeEnum.TOKENTERROR);
}
orderInfo.setPayAmount(orderInfo.getOrderAmount());
Integer staffId = Integer.valueOf(tokeObj.containsKey("staffId") ? tokeObj.getString("staffId") : "0");
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if (ObjectUtil.isNotNull(staff) && ObjectUtil.isNotNull(payAmount) && ObjectUtil.isNotNull(discountAmount) && ObjectUtil.isNotEmpty(payAmount) && ObjectUtil.isNotEmpty(discountAmount)) {
if ("0".equals(staff.getDiscountType())) {
if (N.gt(discountAmount, staff.getMaxDiscountAmount())) {
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount) ? orderInfo.getOrderAmount() : payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount) ? null : discountAmount);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff) ? null : staff.getId());
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount) ? payAmount.divide(orderInfo.getOrderAmount(), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_DOWN) : null);
orderInfo.setPayType("cash");
orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
log.info("更新购物车:{}", cartCount);
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("type", "create");
@ -740,6 +1093,14 @@ public class PayService {
mqData.put("type", "pc");
producer.sendStockSaleMsg(mqData);
redisUtil.del("SHOP:CODE:USER:" + "pc" + ":" + orderInfo.getShopId() + ":" + DateUtils.getDay() + TokenUtil.parseParamFromToken(token).getString("accountId"));
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
clearTableInfoCache(orderInfo);
return Result.success(CodeEnum.SUCCESS);
}
@ -748,22 +1109,6 @@ public class PayService {
if (ObjectUtil.isEmpty(list) || list.size() <= 0) {
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);
// }
Integer orderId = list.get(0).getOrderId();
@ -775,6 +1120,28 @@ public class PayService {
return Result.fail(CodeEnum.ORDERSTATUSERROR);
}
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
if ("1".equals(shopInfo.getIsReturn())) {
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);
}
}
List<TbOrderDetail> orderDetails = tbOrderDetailMapper.selectAllByOrderIdAndStatus(list, orderId.toString());
@ -833,8 +1200,10 @@ public class PayService {
// totalAmount = totalAmount.add(it.getPriceAmount());
totalAmount = totalAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
saleAmount = saleAmount.add(it.getPrice());
payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN)
.multiply(new BigDecimal(map1.get(it.getId()))));
//
// payAmount=payAmount.add(it.getPriceAmount());
packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
@ -845,7 +1214,8 @@ public class PayService {
detailPo.setStatus("closed");
}
BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));
BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));;
detailPo.setReturnNum(map1.get(it.getId()));
detailPos.add(detailPo);
it.setNum(map1.get(it.getId()));
@ -939,11 +1309,22 @@ public class PayService {
flow.setBizCode("accountReturnPay");
flow.setBizName("会员储值卡退款");
flow.setType("+");
flow.setAmount(newOrderInfo.getOrderAmount());
flow.setAmount(newOrderInfo.getPayAmount());
flow.setBalance(user.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
JSONObject baObj=new JSONObject();
baObj.put("userId",user.getUserId());
baObj.put("shopId",user.getShopId());
baObj.put("amount",newOrderInfo.getPayAmount());
baObj.put("balance",user.getAmount());
baObj.put("type","退款");
baObj.put("time",flow.getCreateTime());
producer.balance(baObj.toString());
}
}
@ -981,7 +1362,11 @@ public class PayService {
// jsonObject.put("data",new ReturnWTZInfo(orderId+"",newOrderInfo.getPayAmount(),details));
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(String.valueOf(newOrderInfo.getId()));
producer.printMechine(newOrderInfo.getId().toString());
@ -1033,10 +1418,18 @@ public class PayService {
tbProductStockDetail.setStockNumber(Double.valueOf(detail.getReturnNum()));
}
}
productSkuMapper.decrRealSalesNumber(productSku.getId(), detail.getReturnNum());
}
productStockDetailMapper.insert(tbProductStockDetail);
}
redisUtil.del("SHOP:CODE:USER:" + "pc" + ":" + orderInfo.getShopId() + ":" + DateUtils.getDay() + TokenUtil.parseParamFromToken(token).getString("accountId"));
// 修改台桌状态
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
return Result.success(CodeEnum.SUCCESS);
}
@ -1135,6 +1528,8 @@ public class PayService {
}
redisUtil.del("SHOP:CODE:USER:" + "pc" + ":" + shopId + ":" + DateUtils.getDay() + TokenUtil.parseParamFromToken(token).getString("accountId"));
return Result.fail(CodeEnum.FAIL);
@ -1191,6 +1586,7 @@ public class PayService {
}
}
return Result.success(CodeEnum.SUCCESS, tbQuickPay);
}
@ -1241,6 +1637,7 @@ public class PayService {
flow.setAmount(param.getRefundAmount());
flow.setBalance(user.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
} else {
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(groupOrderInfo.getMerchantId());
@ -1292,4 +1689,57 @@ public class PayService {
tbGroupOrderInfoMapper.update(groupOrderInfo);
return Result.success(CodeEnum.SUCCESS);
}
public Result getOrderDiscount(String staffId, String orderId, String token) {
if (ObjectUtil.isNull(staffId) || ObjectUtil.isNull(orderId) || ObjectUtil.isEmpty(staffId) || ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM);
}
JSONObject tokeObj = TokenUtil.parseParamFromToken(token);
if (Objects.isNull(tokeObj)) {
return Result.fail(CodeEnum.TOKENTERROR);
}
if (!tokeObj.getString("staffId").equals(staffId)) {
return Result.fail(CodeEnum.PARAM);
}
TbOrderInfo tbOrderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
if (ObjectUtil.isNull(tokeObj) || ObjectUtil.isEmpty(tbOrderInfo)) {
return Result.fail(CodeEnum.ORDERNOEXIST);
}
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(Integer.valueOf(staffId));
if (ObjectUtil.isEmpty(staff) || ObjectUtil.isNull(staff)) {
return Result.fail(CodeEnum.STAFFNOEXISTERROE);
}
if ("master".equals(staff.getType())) {
return Result.success(SUCCESS, new BigDecimal(0.1));
}
if (ObjectUtil.isEmpty(staff.getMaxDiscountAmount()) || ObjectUtil.isNull(staff.getMaxDiscountAmount())) {
return Result.success(SUCCESS, BigDecimal.ZERO);
}
if ("0".equals(staff.getDiscountType())) {
if (staff.getMaxDiscountAmount().compareTo(tbOrderInfo.getOrderAmount()) >= 0) {
staff.setMaxDiscountAmount(new BigDecimal(0.1));
} else {
staff.setMaxDiscountAmount(BigDecimal.ONE.subtract(staff.getMaxDiscountAmount().divide(tbOrderInfo.getOrderAmount(), 2, RoundingMode.HALF_DOWN).setScale(2, RoundingMode.HALF_DOWN)));
}
}
return Result.success(SUCCESS, staff.getMaxDiscountAmount());
}
public static void main(String[] args) {
System.out.println(MD5Util.encrypt("123456".concat("13718478323").concat("10")));
}
}

View File

@ -9,9 +9,11 @@ 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;
@ -46,6 +48,12 @@ 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);
@ -73,7 +81,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)){
@ -102,7 +110,7 @@ public class ProductService {
}
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, int page, int pageSize, String masterId) {
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
List<TbProductWithBLOBs> tbProductWithBLOBs=null;
PageHelperUtil.startPage(page,pageSize);
if(ObjectUtil.isEmpty(categoryId)){
@ -118,7 +126,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, tableId);
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
if(ObjectUtil.isEmpty(tbProductSpec)){
@ -127,72 +135,20 @@ 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);
@ -251,6 +207,92 @@ 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,8 +4,12 @@ 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;
@ -14,6 +18,7 @@ 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;
@ -22,7 +27,8 @@ import java.util.*;
@Service
public class ShopInfoService {
@Autowired
TbShopInfoMapper tbShopInfoMapper;
@Autowired
TbShopAreaMapper tbShopAreaMapper;
@ -36,6 +42,12 @@ 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;
@ -53,8 +65,22 @@ public class ShopInfoService {
}
PageHelperUtil.startPage(page, pageSize);
List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status);
PageInfo pageInfo=new PageInfo(shopTables);
// 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);
return Result.success(CodeEnum.SUCCESS,pageInfo);
}
@ -102,4 +128,13 @@ 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

@ -104,7 +104,25 @@ 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

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

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -123,6 +123,12 @@
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and status=1
</select>
<select id="selectBySkuIdAndShopIdAngCheck" resultMap="BaseResultMap">
select a.* from tb_prosku_con as a
left join tb_cons_info as b on a.con_info_id=b.id
where a.product_sku_id=#{skuId} and a.shop_id=#{shopId} and a.status=1 and b.is_check=1
</select>
<select id="selectIdBySkuIdAndShopId" resultType="java.lang.Integer">
SELECT
p.con_info_id
@ -139,4 +145,11 @@
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1
</select>
<select id="selectByShopIdAndSkuIdAndProductIdAndCheck" resultMap="BaseResultMap">
select a.* from tb_prosku_con as a
left join tb_cons_info as b on a.con_info_id=b.id
where a.product_sku_id=#{skuId} and a.shop_id=#{shopId} and a.product_id=#{productId} and a.status=1 and b.is_check=1
</select>
</mapper>

View File

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

View File

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

View File

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

View File

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