diff --git a/eladmin-logging/src/main/java/cn/ysk/cashier/service/impl/LogServiceImpl.java b/eladmin-logging/src/main/java/cn/ysk/cashier/service/impl/LogServiceImpl.java index 32095301..22087c1c 100644 --- a/eladmin-logging/src/main/java/cn/ysk/cashier/service/impl/LogServiceImpl.java +++ b/eladmin-logging/src/main/java/cn/ysk/cashier/service/impl/LogServiceImpl.java @@ -96,8 +96,7 @@ public class LogServiceImpl implements LogService { String value = SpelUtil.generateKeyBySpEL(split[1], joinPoint); // 描述 log.setDescription(split[0] + ":" + value); - } - if (split.length == 3) { + } else if (split.length == 3) { // String v1 = SpelUtil.generateKeyBySpEL(split[1], joinPoint); String v2 = SpelUtil.generateKeyBySpEL(split[2], joinPoint); if (methodName.contains("createOutAndONOperate")) { diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml index 1acadac4..406ea226 100644 --- a/eladmin-system/pom.xml +++ b/eladmin-system/pom.xml @@ -19,6 +19,10 @@ + + org.springframework.boot + spring-boot-starter-validation + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java new file mode 100644 index 00000000..a565149a --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -0,0 +1,89 @@ +package cn.ysk.cashier.controller.product; + +import cn.ysk.cashier.annotation.AnonymousAccess; +import cn.ysk.cashier.annotation.Log; +import cn.ysk.cashier.dto.shoptable.AddCartDTO; +import cn.ysk.cashier.dto.shoptable.ClearCartDTO; +import cn.ysk.cashier.dto.shoptable.RemoveCartDTO; +import cn.ysk.cashier.service.product.TbProductService; +import cn.ysk.cashier.service.shop.TbShopTableService; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.BeanPropertyBindingResult; +import org.springframework.validation.BindingResult; +import org.springframework.validation.Validator; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.xml.bind.ValidationException; + +@RestController +@RequestMapping("/api/place") +public class TbPlaceController { + + private final TbShopTableService tbShopTableService; + + private final TbProductService tbProductService; + private final Validator validator; + + + @AnonymousAccess + @GetMapping ("/activate") + @ApiOperation("查询/product") + public ResponseEntity queryActivateTbProductInfo( + @RequestParam(defaultValue = "0") Integer page, + @RequestParam(defaultValue = "30") Integer size, + @RequestParam(required = false) Integer categoryId, + @RequestParam Integer shopId, + @RequestParam(required = false) Integer productId + ){ + return new ResponseEntity<>(tbProductService.activateProduct(page, size, categoryId, shopId, productId),HttpStatus.OK); + } + + public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator) { + this.tbShopTableService = tbShopTableService; + this.tbProductService = tbProductService; + this.validator = validator; + } + @AnonymousAccess + @PostMapping("/addCart") + @Log("代客下单:#addCartDTO.tableId") + @ApiOperation("代客下单/shop/table") + public ResponseEntity addCartForUser(@Valid @RequestBody AddCartDTO addCartDTO) { + tbShopTableService.addCartForUser(addCartDTO); + return new ResponseEntity<>(HttpStatus.OK); + } + @AnonymousAccess + @DeleteMapping("/removeCart") + @Log("代客下单 删除购物车商品") + @ApiOperation("代客下单 清空购物车 /shop/table") + public ResponseEntity removeCart(@Validated @RequestBody RemoveCartDTO removeCartDTO) { + tbShopTableService.removeCart(removeCartDTO); + return new ResponseEntity<>(HttpStatus.OK); + } + @AnonymousAccess + + @DeleteMapping("/clearCart") + @Log("代客下单 清空购物车") + @ApiOperation("代客下单 清空购物车 /shop/table") + public ResponseEntity clearCart(@Validated @RequestBody ClearCartDTO clearCartDTO) { + tbShopTableService.clearCart(clearCartDTO); + return new ResponseEntity<>(HttpStatus.OK); + } + @AnonymousAccess + + @GetMapping("/cart") + @Log("代客下单 查询购物车") + @ApiOperation("代客下单 查询购物车 /shop/table") + public ResponseEntity getCart( + @RequestParam Long tableId, + @RequestParam(defaultValue = "1") Integer page, + @RequestParam(defaultValue = "10") Integer size, + @RequestParam Integer shopId + ) { + return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId)); + } + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java index 134e1799..7bff4e5b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.controller.product; +import cn.ysk.cashier.annotation.AnonymousAccess; import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.dto.product.TbProductSortCriteria; import cn.ysk.cashier.vo.TbProductVo; @@ -32,6 +33,8 @@ public class TbProductController { return new ResponseEntity<>(tbProductService.queryAll(criteria, false),HttpStatus.OK); } + + @GetMapping("/list") @ApiOperation("查询/productForAdmin") public ResponseEntity queryTbProductForAdmin(TbProductQueryCriteria criteria){ @@ -49,12 +52,15 @@ public class TbProductController { public Object queryTbProductInfo(@PathVariable("product") Integer product)throws Exception{ return tbProductService.findByProductId(product); } + @GetMapping ("/productList") @ApiOperation("查询/product") public Object queryTbProductInfo(@RequestParam List productList){ return tbProductService.findByProductList(productList); } + + @PostMapping("/upProSort") @ApiOperation("修改商品排序") public ResponseEntity upProSort(@RequestBody TbProductSortCriteria param){ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/MsgController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/MsgController.java new file mode 100644 index 00000000..83e37a35 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/MsgController.java @@ -0,0 +1,78 @@ +package cn.ysk.cashier.controller.shop; + +import cn.ysk.cashier.annotation.AnonymousAccess; +import cn.ysk.cashier.dto.shop.*; +import cn.ysk.cashier.mybatis.entity.TbShopOpenId; +import cn.ysk.cashier.pojo.shop.TbFullShopId; +import cn.ysk.cashier.service.shop.MsgService; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.HashMap; +import java.util.List; + +@RestController +@RequestMapping("/api/msg") +public class MsgController { + + + private final MsgService msgService; + + public MsgController(MsgService msgService) { + this.msgService = msgService; + } + + /** + * 获取所有订阅消息用户 + * @return + */ + @AnonymousAccess + + @GetMapping("/all") + public ResponseEntity> all( + @RequestParam(defaultValue = "1") Integer page, + @RequestParam(defaultValue = "10") Integer size, + @RequestParam Integer shopId, + @RequestParam(required = false) String nickName, + @RequestParam(required = false) String openId, + @RequestParam(required = false) Integer state, + @RequestParam(required = false) Integer type + ) { + Page all = msgService.all(page, size, shopId, nickName, openId, state, type); + return ResponseEntity.ok(all); + } + @AnonymousAccess + + @PutMapping("/shopState") + public ResponseEntity shopMsgState( + @Valid @RequestBody ShopMsgStateDTO shopMsgStateDTO + ) { + return ResponseEntity.of(msgService.updateShopState(shopMsgStateDTO)); + } + @AnonymousAccess + + @DeleteMapping + public ResponseEntity removeSubUser( + @Valid @RequestBody ShopMsgRemoveDTO shopMsgRemoveDTO + ) { + return ResponseEntity.of(msgService.removeSubUser(shopMsgRemoveDTO)); + } + @AnonymousAccess + + @PutMapping("/info") + public ResponseEntity updateInfo( + @Valid @RequestBody ShopInfoUpdateDTO shopInfoUpdateDTO + ) { + return ResponseEntity.of(msgService.updateInfo(shopInfoUpdateDTO)); + } + @AnonymousAccess + + @GetMapping("/state") + public ResponseEntity> updateInfo( + @RequestParam Integer shopId + ) { + return ResponseEntity.ok(msgService.getInfo(shopId, null)); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java index 3d62eaec..3c98a5eb 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java @@ -59,6 +59,7 @@ public class SummaryController { } @GetMapping("/table") + @AnonymousGetMapping private Object shopSummaryTable(@RequestParam Integer shopId, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopTableController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopTableController.java index feea6fb7..70ab3a66 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopTableController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopTableController.java @@ -16,10 +16,12 @@ package cn.ysk.cashier.controller.shop; import cn.ysk.cashier.annotation.Log; +import cn.ysk.cashier.dto.shoptable.AddCartDTO; +import cn.ysk.cashier.dto.shoptable.ClearCartDTO; +import cn.ysk.cashier.dto.shoptable.RemoveCartDTO; import cn.ysk.cashier.pojo.shop.TbShopTable; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria; -import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -84,4 +86,7 @@ public class TbShopTableController { tbShopTableService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); } -} \ No newline at end of file + + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopInfoUpdateDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopInfoUpdateDTO.java new file mode 100644 index 00000000..a96712b0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopInfoUpdateDTO.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.dto.shop; + +import lombok.Data; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class ShopInfoUpdateDTO { + @NotNull + private Integer shopId; + @NotNull + private String openId; + private String note; + @Range(min = 0, max = 1) + private Integer state; + private Integer type; + private String nickName; + private String avatar; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopMsgRemoveDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopMsgRemoveDTO.java new file mode 100644 index 00000000..42fa791e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopMsgRemoveDTO.java @@ -0,0 +1,14 @@ +package cn.ysk.cashier.dto.shop; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class ShopMsgRemoveDTO { + @NotNull + private Integer shopId; + @NotBlank + private String openId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopMsgStateDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopMsgStateDTO.java new file mode 100644 index 00000000..61e6a30b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopMsgStateDTO.java @@ -0,0 +1,15 @@ +package cn.ysk.cashier.dto.shop; + +import lombok.Data; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotNull; + +@Data +public class ShopMsgStateDTO { + @NotNull + private Integer shopId; + @Range(min = 0, max = 1) + private Integer state; + private Integer type; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopTypeDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopTypeDTO.java new file mode 100644 index 00000000..b56bd619 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopTypeDTO.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.dto.shop; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class ShopTypeDTO { + @NotNull + private Integer shopId; + @NotNull + private Integer type; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopUserMsgState.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopUserMsgState.java new file mode 100644 index 00000000..d3317df5 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/ShopUserMsgState.java @@ -0,0 +1,15 @@ +package cn.ysk.cashier.dto.shop; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class ShopUserMsgState { + @NotNull + private Integer state; + @NotNull + private Integer shopId; + @NotNull + private Integer id; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java new file mode 100644 index 00000000..a4642b5b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Data +public class AddCartDTO { + @NotNull + private Integer productId; + private Integer skuId; + @NotNull + private Integer shopId; + @NotEmpty + private String tableId; + @NotNull + @Min(0) + private Integer num; + private boolean isPack; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ClearCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ClearCartDTO.java new file mode 100644 index 00000000..f4783ea5 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ClearCartDTO.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class ClearCartDTO { + @NotNull + private Long tableId; + @NotNull + private String shopId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/RemoveCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/RemoveCartDTO.java new file mode 100644 index 00000000..733a7dde --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/RemoveCartDTO.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Data +public class RemoveCartDTO { + @NotNull + private Integer cartId; + @NotNull + private Integer shopId; + @NotNull + private Long tableId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/enums/ShopWxMsgTypeEnum.java b/eladmin-system/src/main/java/cn/ysk/cashier/enums/ShopWxMsgTypeEnum.java new file mode 100644 index 00000000..2b17eee0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/enums/ShopWxMsgTypeEnum.java @@ -0,0 +1,17 @@ +package cn.ysk.cashier.enums; + +public enum ShopWxMsgTypeEnum { + ALL_MSG(-1), + STOCK_MSG(0), + CONSUMABLES_MSG(1), + OPERATION_MSG(2); + private final Integer type; + + ShopWxMsgTypeEnum(Integer type) { + this.type = type; + } + + public Integer getType() { + return type; + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopMsgState.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopMsgState.java new file mode 100644 index 00000000..0f41c8af --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopMsgState.java @@ -0,0 +1,34 @@ +package cn.ysk.cashier.mybatis.entity; + +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.time.Instant; + +@Getter +@Setter +@Entity +@Table(name = "tb_shop_msg_state") +public class TbShopMsgState { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "shop_id") + private Integer shopId; + + @Column(name = "type") + private Integer type; + + @Column(name = "state") + private Integer state; + + @Column(name = "create_time") + private Instant createTime; + + @Column(name = "update_time") + private Instant updateTime; + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopOpenId.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopOpenId.java index 72c687f3..579327d6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopOpenId.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopOpenId.java @@ -1,59 +1,51 @@ package cn.ysk.cashier.mybatis.entity; -import java.io.Serializable; -import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; -/** - * 商家openid信息表 - * @TableName tb_shop_open_id - */ -@Table(name="tb_shop_open_id") -@Data -@EqualsAndHashCode -public class TbShopOpenId implements Serializable { - /** - * - */ +import javax.persistence.*; +import javax.validation.constraints.Size; +import java.time.Instant; + +@Getter +@Setter +@Entity +@Table(name = "tb_shop_open_id") +public class TbShopOpenId { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) private Integer id; - /** - * 店铺id - */ + @Column(name = "shop_id") private Integer shopId; - /** - * 已经订阅消息的商家微信号 - */ + @Size(max = 5000) + @Column(name = "open_id", length = 5000) private String openId; - /** - * - */ + @Column(name = "status") private Integer status; - /** - * - */ - private LocalDateTime createTime; + @Column(name = "create_time") + private Instant createTime; - /** - * - */ - private LocalDateTime updateTime; + @Column(name = "update_time") + private Instant updateTime; - /** - * 类型 -1 任意消息 0库存预警 - */ + @Column(name = "type") private Integer type; - private static final long serialVersionUID = 1L; + @Size(max = 255) + @Column(name = "nickname") + private String nickname; + @Size(max = 255) + @Column(name = "avatar") + private String avatar; + + @Size(max = 255) + @Column(name = "note") + private String note; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java new file mode 100644 index 00000000..82fb89d2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java @@ -0,0 +1,10 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.Activate; +import cn.ysk.cashier.pojo.order.TbCashierCart; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface TbCashierCartMapper extends BaseMapper { + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java index 3439ee38..53d7de94 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java @@ -2,10 +2,14 @@ package cn.ysk.cashier.mybatis.mapper; import cn.ysk.cashier.pojo.product.TbProductSku; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import java.util.List; + public interface TbProducSkutMapper extends BaseMapper { @@ -14,4 +18,5 @@ public interface TbProducSkutMapper extends BaseMapper { @Update("update tb_product_sku set stock_number=#{stocktakinNum} where id=#{id} and stock_number=#{stockNumber}") Integer updateStock(@Param("id") Integer id,@Param("stockNumber") Double stockNumber,@Param("stocktakinNum") Integer stocktakinNum); + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java index ada95698..4ede7725 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java @@ -1,9 +1,17 @@ package cn.ysk.cashier.mybatis.mapper; import cn.ysk.cashier.pojo.product.TbProduct; +import cn.ysk.cashier.pojo.product.TbProductSku; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.data.jpa.repository.Query; public interface TbProductMapper extends BaseMapper { + @Select("select * from tb_product_sku as sku where sku.is_del=0 and sku.is_grounding=1 and sku.is_pause_sale=0 and sku.shop_id=#{shopId} and sku.id=#{skuId}") + TbProductSku selectSkuByIdAndShopId(@Param("shopId") Integer shopId, @Param("skuId") Integer skuId); -} \ No newline at end of file + @Select("select * from tb_product product where product.id=#{id} and product.shop_id=#{shopId} and product.is_del=0") + TbProduct selectByIdAndShopId(@Param("shopId") Integer shopId, @Param("id") Integer id); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopMsgStateMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopMsgStateMapper.java new file mode 100644 index 00000000..ea16afc9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopMsgStateMapper.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbShopMsgState; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Administrator +* @description 针对表【tb_shop_msg_state】的数据库操作Mapper +* @createDate 2024-08-12 13:39:46 +* @Entity cn.ysk.cashier.mybatis.pojo.TbShopMsgStatetb +*/ +public interface TbShopMsgStateMapper extends BaseMapper { + +} + + + + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopOpenIdMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopOpenIdMapper.java index 3e088ed0..7ab9aa49 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopOpenIdMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopOpenIdMapper.java @@ -1,16 +1,48 @@ package cn.ysk.cashier.mybatis.mapper; import cn.ysk.cashier.mybatis.entity.TbShopOpenId; +import cn.ysk.cashier.pojo.shop.TbFullShopId; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; /** * @author Administrator * @description 针对表【tb_shop_open_id(商家openid信息表)】的数据库操作Mapper -* @createDate 2024-08-02 10:00:27 +* @createDate 2024-08-08 11:14:32 * @Entity cn.ysk.cashier.mybatis.entity.TbShopOpenId */ public interface TbShopOpenIdMapper extends BaseMapper { + @Update("update tb_shop_open_id set status=#{state} where shop_id=#{shopId} and status != #{state}") + int updateShopState(@Param("shopId") Integer shopId, @Param("state") Integer state); + + @Update("update tb_shop_open_id set status=#{state} and shop_id=#{shopId} and id=#{id}") + int updateStateById(@Param("state") Integer state, @Param("shopId") Integer shopId, @Param("id") Integer id); + + @Update("update tb_shop_open_id set type") + int updateTypeByShopId(@Param("shopId") Integer shopId, @Param("type") Integer type); + + @Select("") + Page selectAll(@Param("shopId") Integer shopId, @Param("nickName") String nickName, @Param("openId") String openId, Page page); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopMsgStateService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopMsgStateService.java new file mode 100644 index 00000000..1b6197a7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopMsgStateService.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbShopMsgState; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author Administrator +* @description 针对表【tb_shop_msg_state】的数据库操作Service +* @createDate 2024-08-12 13:39:46 +*/ +public interface TbShopMsgStateService extends IService { + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopOpenIdService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopOpenIdService.java index 554107d5..cf310c56 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopOpenIdService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopOpenIdService.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; /** * @author Administrator * @description 针对表【tb_shop_open_id(商家openid信息表)】的数据库操作Service -* @createDate 2024-08-02 10:00:27 +* @createDate 2024-08-08 11:14:32 */ public interface TbShopOpenIdService extends IService { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopMsgStateServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopMsgStateServiceImpl.java new file mode 100644 index 00000000..b398072b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopMsgStateServiceImpl.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.mybatis.entity.TbShopMsgState; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.ysk.cashier.mybatis.service.TbShopMsgStateService; +import cn.ysk.cashier.mybatis.mapper.TbShopMsgStateMapper; +import org.springframework.stereotype.Service; + +/** +* @author Administrator +* @description 针对表【tb_shop_msg_state】的数据库操作Service实现 +* @createDate 2024-08-12 13:39:46 +*/ +@Service +public class TbShopMsgStateServiceImpl extends ServiceImpl + implements TbShopMsgStateService{ + +} + + + + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopOpenIdServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopOpenIdServiceImpl.java index bf99c448..40f8a872 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopOpenIdServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopOpenIdServiceImpl.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Service; /** * @author Administrator * @description 针对表【tb_shop_open_id(商家openid信息表)】的数据库操作Service实现 -* @createDate 2024-08-02 10:00:27 +* @createDate 2024-08-08 11:14:32 */ @Service public class TbShopOpenIdServiceImpl extends ServiceImpl diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductAndSku.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductAndSku.java new file mode 100644 index 00000000..140c2dd2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductAndSku.java @@ -0,0 +1,328 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package cn.ysk.cashier.pojo.product; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import lombok.EqualsAndHashCode; + +import javax.persistence.*; +import javax.validation.constraints.*; +import java.math.BigDecimal; +import java.io.Serializable; + +/** + * @website https://eladmin.vip + * @description / + * @author lyf + * @date 2023-12-11 + **/ +@Entity +@Data +@Table(name="tb_product") +@TableName("tb_product") +public class TbProductAndSku implements Serializable { + + @Id + @Column(name = "`id`") + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "id") + @TableId(type = IdType.AUTO) + private Integer id; + + @Column(name = "`source_path`") + @ApiModelProperty(value = "商品来源 NORMAL普通商品 --,SCORE积分商品") + private String sourcePath="NORMAL"; + + @Column(name = "`merchant_id`") + @ApiModelProperty(value = "商户Id") + private String merchantId = "PLANT_ID"; + + @Column(name = "`shop_id`") + @ApiModelProperty(value = "店铺id") + private String shopId; + + @Column(name = "`name`") + @ApiModelProperty(value = "商品名称") + private String name; + + @Column(name = "`type`") + @ApiModelProperty(value = "商品类型(属性):REAL- 实物商品 VIR---虚拟商品") + private String type = "REAL"; + + @Column(name = "`pack_fee`") + @ApiModelProperty(value = "包装费") + private BigDecimal packFee; + + @Column(name = "`low_price`",nullable = false) + @NotNull + @ApiModelProperty(value = "商品最低价") + private BigDecimal lowPrice; + + @Column(name = "`unit_id`") + @ApiModelProperty(value = "单位Id") + private Integer unitId; + + @Column(name = "`cover_img`") + @ApiModelProperty(value = "商品封面图") + private String coverImg; + + @Column(name = "`category_id`") + @ApiModelProperty(value = "categoryId") + private String categoryId; + + @Column(name = "`spec_id`") + @ApiModelProperty(value = "商品规格") + private Integer specId; + + @Column(name = "`brand_id`") + @ApiModelProperty(value = "品牌Id") + private Integer brandId; + + @Column(name = "`short_title`") + @ApiModelProperty(value = "短标题--促销语") + private String shortTitle; + + @Column(name = "`low_member_price`") + @ApiModelProperty(value = "lowMemberPrice") + private BigDecimal lowMemberPrice; + + @Column(name = "`unit_snap`") + @ApiModelProperty(value = "单位镜像") + private String unitSnap; + + @Column(name = "`share_img`") + @ApiModelProperty(value = "商品分享图") + private String shareImg; + + @Column(name = "`images`") + @ApiModelProperty(value = "商品图片(第一张为缩略图,其他为详情)") + private String images; + + @Column(name = "`video`") + @ApiModelProperty(value = "商品视频URL地址") + private String video; + + @Column(name = "`video_cover_img`") + @ApiModelProperty(value = "视频封面图") + private String videoCoverImg; + + @Column(name = "`sort`") + @ApiModelProperty(value = "排序") + private Integer sort = 0; + + @Column(name = "`limit_number`") + @ApiModelProperty(value = "0-不限购") + private Integer limitNumber = 0; + + @Column(name = "`product_score`") + @ApiModelProperty(value = "商品赚送积分") + private Integer productScore; + + @Column(name = "`status`",nullable = false) + @NotNull + @ApiModelProperty(value = "0--待审核 1审核通过 -1审核失败 -2违规下架") + private Integer status = 0; + + @Column(name = "`fail_msg`") + @ApiModelProperty(value = "审核失败原因") + private String failMsg; + + @Column(name = "`is_recommend`") + @ApiModelProperty(value = "是否推荐,店铺推荐展示") + private Integer isRecommend = 0; + + @Column(name = "`is_hot`") + @ApiModelProperty(value = "是否热销") + private Integer isHot = 0; + + @Column(name = "`is_new`") + @ApiModelProperty(value = "是否新品") + private Integer isNew; + + @Column(name = "`is_on_sale`") + @ApiModelProperty(value = "是否促销1-是0-否") + private Integer isOnSale = 0; + + @Column(name = "`is_show`") + @ApiModelProperty(value = "是否展示0-下架 1上架---废弃") + private Integer isShow = 0; + + @Column(name = "`type_enum`") + @ApiModelProperty(value = "商品规格:0-单规格 1多规格") + private String typeEnum; + + @Column(name = "`is_distribute`") + @ApiModelProperty(value = "是否共享库存") + private Integer isDistribute = 0; + + @Column(name = "`is_del`",nullable = false) + @NotNull + @ApiModelProperty(value = "是否回收站 0-否,1回收站") + private Integer isDel = 0; + + @Column(name = "`is_stock`") + @ApiModelProperty(value = "是否开启库存") + private Integer isStock = 1; + + @Column(name = "`is_pause_sale`") + @ApiModelProperty(value = "是否暂停销售") + private Integer isPauseSale = 0; + + @Column(name = "`is_free_freight`",nullable = false) + @NotNull + @ApiModelProperty(value = "是否免邮1-是 0-否") + private Integer isFreeFreight=1; + + @Column(name = "`freight_id`") + @ApiModelProperty(value = "邮费模版") + private Long freightId; + + @Column(name = "`strategy_type`") + @ApiModelProperty(value = "商品当前生效策略") + private String strategyType; + + @Column(name = "`strategy_id`") + @ApiModelProperty(value = "策略Id") + private Integer strategyId = 1; + + @Column(name = "`is_vip`") + @ApiModelProperty(value = "vip专属") + private Integer isVip = 0; + + @Column(name = "`is_delete`",nullable = false) + @NotNull + @ApiModelProperty(value = "是否删除") + private Integer isDelete = 0; + + @Column(name = "`notice`") + @ApiModelProperty(value = "购买须知") + private String notice; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "createdAt") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + @Column(name = "`base_sales_number`") + @ApiModelProperty(value = "基础出售数量") + private Double baseSalesNumber =0.00; + + @Column(name = "`real_sales_number`") + @ApiModelProperty(value = "实际销量") + private Double realSalesNumber = (double) 0; + + @Column(name = "`sales_number`") + @ApiModelProperty(value = "合计销量") + private Integer salesNumber = 0; + + @Column(name = "`thumb_count`") + @ApiModelProperty(value = "点赞次数") + private Integer thumbCount = 0; + + @Column(name = "`store_count`") + @ApiModelProperty(value = "收藏次数") + private Integer storeCount = 0; + + @Column(name = "`furnish_meal`") + @ApiModelProperty(value = "支持堂食") + private Integer furnishMeal = 0; + + @Column(name = "`furnish_express`") + @ApiModelProperty(value = "支持配送") + private Integer furnishExpress = 0; + + @Column(name = "`furnish_draw`") + @ApiModelProperty(value = "支持自提") + private Integer furnishDraw = 0; + + @Column(name = "`furnish_vir`") + @ApiModelProperty(value = "支持虚拟") + private Integer furnishVir = 0; + + @Column(name = "`is_combo`") + @ApiModelProperty(value = "是否套餐") + private Integer isCombo =0; + + @Column(name = "`group_snap`") + @ApiModelProperty(value = "套餐内容") + private String groupSnap; + + @Column(name = "`is_show_cash`") + @ApiModelProperty(value = "isShowCash") + private Integer isShowCash =0; + + @Column(name = "`is_show_mall`") + @ApiModelProperty(value = "isShowMall") + private Integer isShowMall = 0; + + @Column(name = "`is_need_examine`") + @ApiModelProperty(value = "是否需要审核") + private Integer isNeedExamine = 0; + + @Column(name = "`show_on_mall_status`") + @ApiModelProperty(value = "线上商城展示状态0待审核 -1 异常 1正常") + private Integer showOnMallStatus = 1; + + @Column(name = "`show_on_mall_time`") + @ApiModelProperty(value = "提交审核时间") + private Long showOnMallTime; + + @Column(name = "`show_on_mall_error_msg`") + @ApiModelProperty(value = "线上商城展示失败原因") + private String showOnMallErrorMsg; + + @Column(name = "`enable_label`") + @ApiModelProperty(value = "使用标签打印 选择 是 并在 前台>本机设置 勾选打印标签后,收银完成后会自动打印对应数量的标签数") + private Integer enableLabel = 0; + + @Column(name = "`tax_config_id`") + @ApiModelProperty(value = "税率") + private String taxConfigId; + + @Column(name = "spec_info") + @ApiModelProperty(value = "specInfo") + private String specInfo; + + @Column(name = "select_spec") + @ApiModelProperty(value = "selectSpec") + private String selectSpec; + + @Column(name = "spec_table_headers") + @ApiModelProperty(value = "specTableHeaders") + private String specTableHeaders; + + @Column(name = "group_category_id") + @ApiModelProperty(value = "团购卷分类Id") + private String groupCategoryId; + + @Column(name = "stock_number") + @ApiModelProperty("库存数量") + private Double stockNumber = (double) 0; + + + public void copy(TbProduct source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbFullShopId.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbFullShopId.java new file mode 100644 index 00000000..dc1111c5 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbFullShopId.java @@ -0,0 +1,14 @@ +package cn.ysk.cashier.pojo.shop; + +import cn.ysk.cashier.mybatis.entity.TbShopOpenId; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class TbFullShopId extends TbShopOpenId { + private Integer proState; + private Integer conState; + private Integer opeState; + private Integer allState; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbCashierCartRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbCashierCartRepository.java index 9e1fb8b3..80634103 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbCashierCartRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbCashierCartRepository.java @@ -2,10 +2,15 @@ package cn.ysk.cashier.repository.order; import cn.ysk.cashier.pojo.order.TbCashierCart; import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.PageRequest; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.transaction.annotation.Transactional; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; /** * @website https://eladmin.vip @@ -18,4 +23,12 @@ public interface TbCashierCartRepository extends JpaRepository queryShopTableVoByShopId(@Param("shopId") Integer shopId); + @Query("SELECT new cn.ysk.cashier.vo.ShopTableSaleInfoVo(" + "info.id," + "info.shopId," + @@ -185,10 +200,9 @@ public interface TbOrderInfoRepository extends JpaRepository :startTime AND info.createdAt < :endTime " + "AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) " + - "AND info.tableId = :qrcode ") - ShopTableSaleInfoVo queryShopTableSaleInfo(@Param("shopId") String shopId, @Param("qrcode") String qrcode, + "AND table.qrcode is not null " + + "AND table.qrcode != '' " + + "GROUP BY info.tableId ") + List queryShopTableSaleInfo(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); - - @Query("select table.qrcode from TbShopTable table where table.shopId = :shopId") - List queryShopTableIds(@Param("shopId") Integer shopId); -} \ No newline at end of file +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java index 1da35b54..8ec66a96 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java @@ -3,6 +3,7 @@ package cn.ysk.cashier.repository.product; import cn.ysk.cashier.pojo.product.TbProduct; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Update; +import org.springframework.data.domain.PageRequest; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; @@ -56,7 +57,7 @@ public interface TbProductRepository extends JpaRepository, @Query("update TbProduct set stockNumber=stockNumber+:num where id=:id") void incrStock(@Param("id") Integer id, @Param("num") Integer num); - @Query("select product from TbProduct product where product.id=:id and product.shopId=:shopId") + @Query("select product from TbProduct product where product.id=:id and product.shopId=:shopId and product.isDel=0") TbProduct selectByShopIdAndId(Integer id, String shopId); @Query("select product from TbProduct product where product.shopId=:shopId") @@ -64,4 +65,5 @@ public interface TbProductRepository extends JpaRepository, @Query(value = "select b.* from tb_product_sku as a left join tb_product as b on a.product_id=b.id where a.id=:skuId", nativeQuery = true) TbProduct selectBySkuId(@Param("skuId") Integer skuId); + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java index 08c736fa..0f818a00 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java @@ -18,6 +18,8 @@ package cn.ysk.cashier.repository.product; import cn.ysk.cashier.pojo.product.TbProductSkuResult; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; /** * @website https://eladmin.vip @@ -25,4 +27,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; * @date 2024-02-08 **/ public interface TbProductSkuResultRepository extends JpaRepository, JpaSpecificationExecutor { + + @Modifying + @Query(value = "delete from tb_product_sku_result where id = ?1", nativeQuery = true) + void deleteByIdN(Integer id); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopTableRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopTableRepository.java index bee14784..6a29053b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopTableRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopTableRepository.java @@ -4,7 +4,9 @@ import cn.ysk.cashier.pojo.shop.TbShopTable; import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -26,4 +28,9 @@ public interface TbShopTableRepository extends JpaRepository findByShopId(@Param("shopId") Integer shopId); + + @Query("delete from TbCashierCart cart where cart.tableId=:tableId and cart.shopId=:shopId and cart.status='create'") + @Modifying + @Transactional + void deleteByTableIdAndShopId(Long tableId, String shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java index 15c158ca..d38473e8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java @@ -39,6 +39,8 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.function.Function; +import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -504,7 +506,7 @@ public class SummaryServiceImpl implements SummaryService { @Override public List selectSummaryTable(Integer shopId, Date startTime, Date endTime) { - List shopTableCodes = tbOrderInfoRepository.queryShopTableIds(shopId); + List tableVos = tbOrderInfoRepository.queryShopTableVoByShopId(shopId); long start = 1704038400000L; long end = Instant.now().toEpochMilli(); @@ -513,24 +515,23 @@ public class SummaryServiceImpl implements SummaryService { end = endTime.getTime(); } - List list = new ArrayList<>(); - for (String shopTableCode : shopTableCodes) { - ShopTableSaleInfoVo shopTableSaleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), shopTableCode, start, end); - if (shopTableSaleInfoVo.getTableId() == null) { - TbShopTable table = shopTableRepository.findByQrcode(shopTableCode); - if (table != null) { - shopTableSaleInfoVo.setShopId(shopId); - shopTableSaleInfoVo.setTableId(table.getId()); - shopTableSaleInfoVo.setTableName(table.getName()); - shopTableSaleInfoVo.setAreaId(table.getAreaId()); - shopTableSaleInfoVo.setAreaName(tbShopAreaRepository.findById(table.getAreaId()).get().getName()); - } - } - list.add(shopTableSaleInfoVo); - } + List saleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), start, end); - if (!list.isEmpty()) { - list.sort((a, b) -> { + Map tableMap = tableVos.stream() + .collect(Collectors.toMap(ShopTableVo::getQrcode, Function.identity())); + saleInfoVo.parallelStream().forEach(vo -> { + ShopTableVo tableVo = tableMap.get(vo.getTableId()); + if (tableVo != null) { + vo.setShopId(shopId); + vo.setTableId(tableVo.getTableId()); + vo.setTableName(tableVo.getTableName()); + vo.setAreaId(tableVo.getAreaId()); + vo.setAreaName(tableVo.getAreaName()); + } + }); + + if (!saleInfoVo.isEmpty()) { + saleInfoVo.sort((a, b) -> { // 先比较 orderAmount BigDecimal aAmount = a.getOrderAmount() == null ? BigDecimal.ZERO : new BigDecimal(a.getOrderAmount().toString()); BigDecimal bAmount = b.getOrderAmount() == null ? BigDecimal.ZERO : new BigDecimal(b.getOrderAmount().toString()); @@ -547,7 +548,7 @@ public class SummaryServiceImpl implements SummaryService { }); } - return list; + return saleInfoVo; } @Override diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java index 4511db70..3f49b4c4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java @@ -352,7 +352,7 @@ public class StockServiceImpl implements StockService { TbProductSku tbProductSku = tbProductSkuRepository.findById(Integer.valueOf(updateValueVO.getTargetId())).orElse(null); // 推送微信操作消息 if (product != null && tbProductSku != null) { - wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭sku售罄: " : "开启sku售罄: ") + product.getName() + "/"+ tbProductSku.getSpecSnap()); + wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product.getName() + "/"+ tbProductSku.getSpecSnap(), Integer.valueOf(updateValueVO.getShopId())); }else { log.warn("推送微信操作消息失败,未查询到商品信息,skuId: {}", updateValueVO.getTargetId()); } @@ -368,7 +368,7 @@ public class StockServiceImpl implements StockService { TbProduct product1 = tbProductRepository.selectBySkuId(Integer.valueOf(updateValueVO.getTargetId())); // 推送微信操作消息 if (product1 != null) { - wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product1.getName()); + wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product1.getName(), Integer.valueOf(updateValueVO.getShopId())); }else { log.warn("推送微信操作消息失败,未查询到商品信息,skuId: {}", updateValueVO.getTargetId()); } @@ -410,7 +410,7 @@ public class StockServiceImpl implements StockService { TbProduct product = tbProductRepository.selectByShopIdAndId(Integer.parseInt(tbProductSku.getProductId()), String.valueOf(shopId)); // 推送微信操作消息 - wxMsgUtils.aboardOperationMsg((isGrounding ? "上架商品: " : "下架商品: ") + product.getName()); + wxMsgUtils.aboardOperationMsg((isGrounding ? "上架商品: " : "下架商品: ") + product.getName(), shopId); // 共享库存下架所有sku if (product.getIsDistribute().equals(1)) { tbProductSkuRepository.updateGroundingByProId(product.getId().toString(), isGrounding ? 1 : 0); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java index bb84510a..5a3345b4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java @@ -96,18 +96,22 @@ public class TbProductGroupServiceImpl implements TbProductGroupService { @Override @Transactional(rollbackFor = Exception.class) public void update(TbProductGroup resources) { + TbProductGroup tbProductGroup = tbProductGroupRepository.findById(resources.getId()).orElseGet(TbProductGroup::new); // TbProductGroup byName = tbProductGroupRepository.findByName(resources.getName(), resources.getShopId()); // if (byName != null){ // throw new BadRequestException("名称重复"); // } + // 推送微信操作消息 + if (!tbProductGroup.getIsShow().equals(resources.getIsShow())) { + wxMsgUtils.aboardOperationMsg((resources.getIsShow() == 0 ? "关闭分组: " : "开启分组: ") + tbProductGroup.getName(), resources.getShopId()); + } tbProductGroup.setUpdatedAt(Instant.now().toEpochMilli()); ValidationUtil.isNull( tbProductGroup.getId(),"TbProductGroup","id",resources.getId()); tbProductGroup.copy(resources); tbProductGroupRepository.save(tbProductGroup); - // 推送微信操作消息 - wxMsgUtils.aboardOperationMsg((resources.getIsShow() == 0 ? "关闭分组: " : "开启分组: ") + tbProductGroup.getName()); + } @Transactional(rollbackFor = Exception.class) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 7edab52c..d4107fbd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.service.impl.productimpl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.dto.TbPlatformDictDto; import cn.ysk.cashier.dto.product.TbProductDto; import cn.ysk.cashier.dto.product.TbProductQueryCriteria; @@ -11,6 +12,7 @@ import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.product.TbProductMapper; import cn.ysk.cashier.mapper.product.TbProductSkuMapper; import cn.ysk.cashier.mybatis.entity.TagProductDepts; +import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper; import cn.ysk.cashier.mybatis.service.TagProductDeptsService; import cn.ysk.cashier.pojo.product.*; import cn.ysk.cashier.pojo.shop.TbPurchaseNotice; @@ -25,6 +27,9 @@ import cn.ysk.cashier.service.shop.TbCouponCategoryService; import cn.ysk.cashier.utils.*; import cn.ysk.cashier.vo.TbProductVo; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -70,6 +75,10 @@ public class TbProductServiceImpl implements TbProductService { private final TbPlatformDictService tbPlatformDictService; private final TagProductDeptsService tagProductService; private final TbPurchaseNoticeRepository noticeRepository; + private final TbProducSkutMapper producSkutMapper; + private final cn.ysk.cashier.mybatis.mapper.TbProductMapper productMapper; + private final TbProductSkuResultRepository productSkuResultRepository; + private final RedisUtils redisUtils; @@ -83,9 +92,9 @@ public class TbProductServiceImpl implements TbProductService { case "weight": return "称重商品"; case "currentPrice": - return "套餐商品/团购卷"; - case "group": return "时价商品"; + case "group": + return "套餐商品/团购卷"; default: return type; } @@ -328,6 +337,9 @@ public class TbProductServiceImpl implements TbProductService { TbProduct product = new TbProduct(); //组装 BeanUtil.copyProperties(resources, product, CopyOptions.create().setIgnoreNullValue(true)); + if(CollectionUtils.isEmpty(resources.getSkuList())){ + throw new BadRequestException("商品规格不可为空"); + } if (!"group".equals(resources.getTypeEnum())) { if (resources.getCategoryId() == null) { throw new BadRequestException("必填内容未填写"); @@ -436,6 +448,23 @@ public class TbProductServiceImpl implements TbProductService { TbProduct product = new TbProduct(); //组装 BeanUtils.copyProperties(resources, product); + if(CollectionUtils.isEmpty(resources.getSkuList())){ + throw new BadRequestException("规格内容不可为空"); + } else if (!"sku".equals(product.getTypeEnum())) { + product.setSelectSpec("[]"); + product.setSpecTableHeaders("[]"); + if (resources.getSkuList().size() > 1) { + throw new BadRequestException("规格数据异常"); + } + } + if (!"group".equals(product.getTypeEnum())) { + if (resources.getCategoryId() == null) throw new BadRequestException("商品分类不可为空"); + product.setIsCombo(0); + product.setGroupSnap(null); + if (resources.getNotices() != null && resources.getNotices().getId() != null) { + noticeRepository.deleteById(resources.getNotices().getId()); + } + } product.setIsDel(0); product.setIsDelete(0); product.setIsFreeFreight(1); @@ -471,24 +500,7 @@ public class TbProductServiceImpl implements TbProductService { //sku if (resources.getSkuList() != null) { -// List skuList = new ArrayList<>(); -// for (TbProductSku sku : resources.getSkuList()) { -// TbProductSku tbProductSku = tbProductSkuRepository.searchBarCode(sku.getBarCode()); -// if (tbProductSku != null) { -// tbProductSkuRepository.updateByBarCode(sku.getBarCode(), sku.getCostPrice(), sku.getCoverImg(), sku.getFirstShared(), sku.getMemberPrice(), -// sku.getOriginPrice(), sku.getSalePrice(), sku.getSpecSnap(), tbProductSku.getId()); -// } else { -// if ("sku".equals(save.getTypeEnum())) { -// tbProductSkuRepository.deleteByProductId(String.valueOf(save.getId())); -// } -// sku.setProductId(String.valueOf(save.getId())); -// sku.setShopId(save.getShopId()); -// sku.setCreatedAt(Instant.now().toEpochMilli()); -// sku.setUpdatedAt(Instant.now().toEpochMilli()); -// skuList.add(sku); -// } -// } - if ("sku".equals(save.getTypeEnum())) { +// if ("sku".equals(save.getTypeEnum())) { List collect = resources.getSkuList().stream().map(TbProductSku::getId).collect(Collectors.toList()); List tbProductSkus = tbProductSkuRepository.searchSku(resources.getId().toString()); for (TbProductSku productSkus : tbProductSkus) { @@ -496,7 +508,7 @@ public class TbProductServiceImpl implements TbProductService { tbProductSkuRepository.deleteBySkuId(productSkus.getId()); } } - } +// } tbProductSkuRepository.saveAll(resources.getSkuList()); } //保存到sku_result @@ -507,15 +519,19 @@ public class TbProductServiceImpl implements TbProductService { productSkuResult.setTagSnap(resources.getSkuSnap()); productSkuResult.setId(save.getId()); tbProductSkuResultRepository.save(productSkuResult); - }else if ("group".equals(resources.getTypeEnum())) { - TbPurchaseNotice notices = resources.getNotices(); - if (StringUtils.isBlank(notices.getDateUsed()) - && StringUtils.isBlank(notices.getAvailableTime()) - && StringUtils.isBlank(notices.getBookingType()) - && StringUtils.isBlank(notices.getRefundPolicy())) { - throw new BadRequestException("修改购买须知失败,必填项未填写"); + }else { + tbProductSkuResultRepository.deleteByIdN(save.getId()); + if ("group".equals(resources.getTypeEnum())) { + TbPurchaseNotice notices = resources.getNotices(); + if (StringUtils.isBlank(notices.getDateUsed()) + && StringUtils.isBlank(notices.getAvailableTime()) + && StringUtils.isBlank(notices.getBookingType()) + && StringUtils.isBlank(notices.getRefundPolicy())) { + throw new BadRequestException("修改购买须知失败,必填项未填写"); + } + resources.getNotices().setCouponId(save.getId()); + noticeRepository.save(resources.getNotices()); } - noticeRepository.save(resources.getNotices()); } } @@ -688,4 +704,111 @@ public class TbProductServiceImpl implements TbProductService { tbProductSkuRepository.incrStock(productSkuId, Double.valueOf(num)); } } + + @Override + public Object activateProduct(Integer page, Integer size, Integer categoryId, Integer shopId, Integer productId) { + com.baomidou.mybatisplus.extension.plugins.pagination.Page page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_del", 0) + .eq("shop_id", shopId) + .eq("is_delete", 0) + .eq("status", 1) + .eq("is_pause_sale", 0); + + // 查询skuResult + + ArrayList> infoList = new ArrayList<>(); + if (categoryId != null) { + queryWrapper.eq("category_id", categoryId); + } + + if (productId != null) { + queryWrapper.eq("id", productId); + } + + com.baomidou.mybatisplus.extension.plugins.pagination.Page tbProductPage = productMapper.selectPage(page1, queryWrapper); + tbProductPage.getRecords().stream().parallel().forEach(item -> { + TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null); + List tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper().eq(TbProductSku::getIsDel, 0) + .eq(TbProductSku::getIsPauseSale, 0) + .eq(TbProductSku::getProductId, item.getId()) + .eq(TbProductSku::getIsGrounding, 1) + .select(TbProductSku::getId, TbProductSku::getSpecSnap, TbProductSku::getStockNumber, TbProductSku::getSalePrice, TbProductSku::getSuit)); + + String tagSnap = null; + if (skuResult != null) { + tagSnap = skuResult.getTagSnap(); + } + List result = new ArrayList<>(); + + if (StrUtil.isNotBlank(tagSnap)) { + JSONArray tagSnaps = JSONObject.parseArray(tagSnap); + List> valuesList = new ArrayList<>(); + + // 提取所有 value 的列表 + for (int i = 0; i < tagSnaps.size(); i++) { + JSONObject jsonObject = tagSnaps.getJSONObject(i); + String[] values = jsonObject.getString("value").split(","); + valuesList.add(Arrays.asList(values)); + } + // 生成所有可能的排列组合 + generateCombinations(valuesList, 0, new ArrayList<>(), result); + + } + ArrayList> specList = new ArrayList<>(); + + tbProductSkus.forEach(item2 -> { + Map itemMap = BeanUtil.beanToMap(item2, false, true); + + if (item.getIsDistribute().equals(1)) { + itemMap.put("stockNumber", item.getStockNumber()); + }else { + itemMap.put("stockNumber", item2.getStockNumber()); + } + specList.add(itemMap); + }); + + ArrayList> otherVal = new ArrayList<>(); + for (String res : result) { + boolean found = false; + for (Map spec : specList) { + if (res.equals(spec.get("specSnap").toString())) { + spec.put("isGrounding", true); + found = true; + break; + } + } + if (!found) { + HashMap itemMap = new HashMap<>(); + itemMap.put("specSnap", res); + itemMap.put("skuId", null); + itemMap.put("isGrounding", false); + otherVal.add(itemMap); + } + } + specList.addAll(otherVal); + + Map map = BeanUtil.beanToMap(item, false, false); + map.put("skuResult", skuResult); + map.put("specList", specList); + infoList.add(map); + }); + + Map map = BeanUtil.beanToMap(tbProductPage, false, false); + map.put("records", infoList); + return map; + } + + private static void generateCombinations(List> valuesList, int index, List current, List 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); // 回溯 + } + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/MsgServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/MsgServiceImpl.java new file mode 100644 index 00000000..d399c1ae --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/MsgServiceImpl.java @@ -0,0 +1,139 @@ +package cn.ysk.cashier.service.impl.shopimpl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.shop.ShopInfoUpdateDTO; +import cn.ysk.cashier.dto.shop.ShopMsgRemoveDTO; +import cn.ysk.cashier.dto.shop.ShopMsgStateDTO; +import cn.ysk.cashier.mybatis.entity.TbShopMsgState; +import cn.ysk.cashier.mybatis.entity.TbShopOpenId; +import cn.ysk.cashier.mybatis.mapper.TbShopOpenIdMapper; +import cn.ysk.cashier.mybatis.service.TbShopMsgStateService; +import cn.ysk.cashier.pojo.shop.TbFullShopId; +import cn.ysk.cashier.service.shop.MsgService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +@Service +public class MsgServiceImpl implements MsgService { + private final TbShopOpenIdMapper shopOpenIdMapper; + private final TbShopMsgStateService shopMsgStateService; + + public MsgServiceImpl(TbShopOpenIdMapper shopOpenIdMapper, TbShopMsgStateService shopMsgStateService) { + this.shopOpenIdMapper = shopOpenIdMapper; + this.shopMsgStateService = shopMsgStateService; + } + + @Override + public Page all(Integer page, Integer size, Integer shopId, String nickName, String openId, Integer state, Integer type) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TbShopOpenId::getShopId, shopId); + + return shopOpenIdMapper.selectAll(shopId, nickName, openId, new Page<>(page, size)); + } + + @Override + public Optional updateShopState(ShopMsgStateDTO shopMsgStateDTO) { + + TbShopOpenId shopOpenId = new TbShopOpenId(); + shopOpenId.setStatus(shopMsgStateDTO.getState()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(TbShopOpenId::getShopId, shopMsgStateDTO.getShopId()); + if (shopMsgStateDTO.getType() != null) { + queryWrapper.eq(TbShopOpenId::getType, shopMsgStateDTO.getType()); + } + if (shopMsgStateDTO.getType() == null) { + shopMsgStateDTO.setType(-1); + } + TbShopMsgState msgState = shopMsgStateService.lambdaQuery().eq(TbShopMsgState::getType, shopMsgStateDTO.getType()) + .eq(TbShopMsgState::getShopId, shopMsgStateDTO.getShopId()).one(); + if (msgState == null) { + msgState = new TbShopMsgState(); + msgState.setShopId(shopMsgStateDTO.getShopId()); + msgState.setCreateTime(DateUtil.date().toInstant()); + msgState.setState(shopMsgStateDTO.getType()); + shopMsgStateService.save(msgState); + }else { + shopMsgStateService.lambdaUpdate().eq(TbShopMsgState::getShopId, shopMsgStateDTO.getShopId()) + .eq(TbShopMsgState::getType, shopMsgStateDTO.getType()) + .set(TbShopMsgState::getState, shopMsgStateDTO.getState()) + .set(TbShopMsgState::getUpdateTime, DateUtil.date().toInstant()).update(); + } + return Optional.of(shopOpenIdMapper.update(shopOpenId, queryWrapper) > 0); + } + + @Override + public Optional removeSubUser(ShopMsgRemoveDTO shopMsgRemoveDTO) { + int delete = shopOpenIdMapper.delete(new LambdaQueryWrapper().eq(TbShopOpenId::getShopId, shopMsgRemoveDTO.getShopId()) + .eq(TbShopOpenId::getOpenId, shopMsgRemoveDTO.getOpenId())); + return Optional.of(delete > 0); + } + + + @Override + public Optional updateInfo(ShopInfoUpdateDTO shopInfoUpdateDTO) { + TbShopOpenId shopOpenId = new TbShopOpenId(); + if (StrUtil.isNotBlank(shopInfoUpdateDTO.getNote())) { + shopOpenId.setNote(shopInfoUpdateDTO.getNote()); + } + if (shopInfoUpdateDTO.getState() != null) { + shopOpenId.setStatus(shopInfoUpdateDTO.getState()); + } + if (shopInfoUpdateDTO.getType() != null) { + shopOpenId.setType(shopInfoUpdateDTO.getType()); + } + if (StrUtil.isNotBlank(shopInfoUpdateDTO.getNickName())) { + shopOpenId.setNickname(shopInfoUpdateDTO.getNickName()); + } + if (StrUtil.isNotBlank(shopInfoUpdateDTO.getAvatar())) { + shopOpenId.setAvatar(shopInfoUpdateDTO.getAvatar()); + } + + if (BeanUtil.isNotEmpty(shopOpenId)) { + shopOpenIdMapper.update(shopOpenId, new LambdaQueryWrapper() + .eq(TbShopOpenId::getOpenId, shopInfoUpdateDTO.getOpenId()) + .eq(TbShopOpenId::getType, shopInfoUpdateDTO.getType()) + .eq(TbShopOpenId::getShopId, shopInfoUpdateDTO.getShopId())); + } + return Optional.of( true); + } + + private static final HashMap MSG_TYPE = new HashMap<>(); + static { + MSG_TYPE.put("0", "stockState"); + MSG_TYPE.put("1", "conState"); + MSG_TYPE.put("2", "opeState"); + MSG_TYPE.put("-1", "allState"); + } + @Override + public HashMap getInfo(Integer shopId, Integer type) { + List list = shopMsgStateService.lambdaQuery().eq(TbShopMsgState::getShopId, shopId).list(); + HashMap data = new HashMap<>(); + MSG_TYPE.forEach((k, v) -> { + TbShopMsgState have = null; + for (TbShopMsgState tbShopMsgState : list) { + if (tbShopMsgState.getType().equals(Integer.valueOf(k))) { + have = tbShopMsgState; + break; + } + } + if (have == null) { + TbShopMsgState msgState = new TbShopMsgState(); + msgState.setShopId(shopId); + msgState.setCreateTime(DateUtil.date().toInstant()); + msgState.setType(Integer.valueOf(k)); + msgState.setState(0); + shopMsgStateService.save(msgState); + } + data.put(v, have != null ? have.getState() : 0); + }); + + return data; + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 2b799c80..0af726ed 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -15,10 +15,25 @@ */ package cn.ysk.cashier.service.impl.shopimpl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import cn.ysk.cashier.dto.shoptable.AddCartDTO; +import cn.ysk.cashier.dto.shoptable.ClearCartDTO; +import cn.ysk.cashier.dto.shoptable.RemoveCartDTO; import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper; +import cn.ysk.cashier.mybatis.mapper.TbProductMapper; +import cn.ysk.cashier.pojo.order.TbCashierCart; +import cn.ysk.cashier.pojo.product.TbProduct; +import cn.ysk.cashier.pojo.product.TbProductSku; import cn.ysk.cashier.pojo.shop.TbShopTable; +import cn.ysk.cashier.repository.order.TbCashierCartRepository; +import cn.ysk.cashier.repository.product.TbProductRepository; +import cn.ysk.cashier.repository.product.TbProductSkuRepository; import cn.ysk.cashier.utils.ValidationUtil; import cn.ysk.cashier.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.dianguang.cloud.ossservice.model.DateUtils; import lombok.RequiredArgsConstructor; import cn.ysk.cashier.repository.shop.TbShopTableRepository; import cn.ysk.cashier.service.shop.TbShopTableService; @@ -26,12 +41,14 @@ import cn.ysk.cashier.dto.shop.TbShopTableDto; import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria; import cn.ysk.cashier.mapper.shop.TbShopTableMapper; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import cn.ysk.cashier.utils.QueryHelp; +import java.math.BigDecimal; import java.time.Instant; import java.util.*; import java.io.IOException; @@ -50,6 +67,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { private final TbShopTableRepository tbShopTableRepository; private final TbShopTableMapper tbShopTableMapper; + private final TbProductRepository productRepository; + private final TbProductSkuRepository productSkuRepository; + private final TbCashierCartRepository cashierCartRepository; + private final TbProductMapper productMapper; + private final TbCashierCartMapper cashierCartMapper; /** *桌码前缀 @@ -79,14 +101,18 @@ public class TbShopTableServiceImpl implements TbShopTableService { criteria.setAreaId(null); } List tbShopTableList = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)); + ArrayList> infoList = new ArrayList<>(); for (TbShopTable date : tbShopTableList) { + Map itemMap = BeanUtil.beanToMap(date, false, false); if (!"".equals(date.getQrcode())){ - date.setQrcode(QRCODE+date.getQrcode().trim()); + itemMap.put("qrcode",QRCODE+date.getQrcode().trim()); + itemMap.put("tableId",date.getQrcode()); } + infoList.add(itemMap); } int i = tbShopTableRepository.countAllByShopId(criteria.getShopId()); HashMap map = new HashMap<>(); - map.put("content",tbShopTableList); + map.put("content",infoList); map.put("total",i); return map; } @@ -174,4 +200,112 @@ public class TbShopTableServiceImpl implements TbShopTableService { } FileUtil.downloadExcel(list, response); } + + + @Override + public void addCartForUser(AddCartDTO addCartDTO) { + TbProductSku productSku = productMapper.selectSkuByIdAndShopId(addCartDTO.getShopId(), addCartDTO.getSkuId()); + TbProduct product = productMapper.selectByIdAndShopId(addCartDTO.getShopId(), addCartDTO.getProductId()); + + if (product == null || productSku == null) { + throw new BadRequestException("商品不存在或已下架, id: " + addCartDTO.getSkuId()); + } + + if ((product.getIsDistribute().equals(1) && product.getStockNumber() < 1 ) + || (!product.getIsDistribute().equals(1) && productSku.getStockNumber() < 1) + ) { + throw new BadRequestException("商品库存不足"); + } + + TbShopTable shopTable = tbShopTableRepository.findByQrcode(addCartDTO.getTableId()); + if (shopTable == null) { + throw new BadRequestException("桌码不存在,桌码" + addCartDTO.getTableId()); + } + + TbCashierCart tbCashierCart = cashierCartRepository.selectActivateBySkuId(String.valueOf(addCartDTO.getSkuId()), String.valueOf(addCartDTO.getShopId()), Long.valueOf(addCartDTO.getTableId())); + // 首次加入 + if (tbCashierCart == null) { + tbCashierCart = new TbCashierCart(); + tbCashierCart.setCoverImg(product.getCoverImg()); + tbCashierCart.setCreatedAt(System.currentTimeMillis()); + tbCashierCart.setIsSku(product.getTypeEnum()); + tbCashierCart.setTableId(Long.valueOf(addCartDTO.getTableId())); + tbCashierCart.setName(product.getName()); + tbCashierCart.setProductId(String.valueOf(product.getId())); + tbCashierCart.setSalePrice(productSku.getSalePrice()); + tbCashierCart.setSkuId(productSku.getId().toString()); + tbCashierCart.setShopId(String.valueOf(addCartDTO.getShopId())); + tbCashierCart.setTradeDay(DateUtils.getDay()); + tbCashierCart.setStatus("create"); + tbCashierCart.setIsPack(String.valueOf(false)); + tbCashierCart.setIsGift(String.valueOf(false)); + tbCashierCart.setSalePrice(productSku.getSalePrice()); + tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice())); + if (!addCartDTO.isPack()){ + tbCashierCart.setPackFee(BigDecimal.ZERO); + }else { + tbCashierCart.setPackFee(new BigDecimal(addCartDTO.getNum()).multiply(product.getPackFee())); + tbCashierCart.setTotalAmount(tbCashierCart.getTotalAmount().add(tbCashierCart.getPackFee())); + + } + tbCashierCart.setTotalNumber(addCartDTO.getNum()); + tbCashierCart.setNumber(addCartDTO.getNum()); + tbCashierCart.setCategoryId(product.getCategoryId()); + cashierCartRepository.save(tbCashierCart); + }else { + tbCashierCart.setTotalNumber(addCartDTO.getNum()); + tbCashierCart.setNumber(addCartDTO.getNum()); + // 数量0删除 + if (tbCashierCart.getNumber() == 0) { + cashierCartRepository.deleteById(tbCashierCart.getId()); + return; + } + tbCashierCart.setUpdatedAt(DateUtil.current()); + tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice())); + cashierCartRepository.save(tbCashierCart); + } + } + + @Override + public void removeCart(RemoveCartDTO removeCartDTO) { + cashierCartRepository.deleteByIdAndShopId(String.valueOf(removeCartDTO.getShopId()), removeCartDTO.getCartId(), removeCartDTO.getTableId()); + } + + @Override + public void clearCart(ClearCartDTO clearCartDTO) { + tbShopTableRepository.deleteByTableIdAndShopId(clearCartDTO.getTableId(), clearCartDTO.getShopId()); + } + + @Override + public com.baomidou.mybatisplus.extension.plugins.pagination.Page getCart(Long tableId, Integer page, Integer size, Integer shopId) { + com.baomidou.mybatisplus.extension.plugins.pagination.Page cartPage = cashierCartMapper.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size), new LambdaQueryWrapper() + .eq(TbCashierCart::getTableId, tableId) + .eq(TbCashierCart::getStatus, "create") + .eq(TbCashierCart::getShopId, shopId)); + List records = cartPage.getRecords(); + + ArrayList skuIds = new ArrayList<>(); + records.forEach(item -> { + skuIds.add(Integer.valueOf(item.getSkuId())); + }); + + if (!skuIds.isEmpty()) { + List skuList = productSkuRepository.findAllById(skuIds); + HashMap skuMap = new HashMap<>(); + skuList.forEach(item -> skuMap.put(item.getId().toString(), item)); + + ArrayList> infos = new ArrayList<>(); + records.forEach(item -> { + Map map = BeanUtil.beanToMap(item, false, false); + TbProductSku tbProductSku = skuMap.get(item.getSkuId()); + map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null); + infos.add(map); + }); + + com.baomidou.mybatisplus.extension.plugins.pagination.Page copyPage = BeanUtil.copyProperties(cartPage, com.baomidou.mybatisplus.extension.plugins.pagination.Page.class); + copyPage.setRecords(infos); + return copyPage; + } + return cartPage; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java index 3ee7c092..158eddef 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java @@ -104,4 +104,6 @@ public interface TbProductService { * @param num 数量 */ void returnStockByPro(Integer productId, Integer productSkuId, Integer num); + + Object activateProduct(Integer page, Integer size, Integer categoryId, Integer shopId, Integer productId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/MsgService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/MsgService.java new file mode 100644 index 00000000..b893b711 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/MsgService.java @@ -0,0 +1,23 @@ +package cn.ysk.cashier.service.shop; + +import cn.ysk.cashier.dto.shop.ShopInfoUpdateDTO; +import cn.ysk.cashier.dto.shop.ShopMsgRemoveDTO; +import cn.ysk.cashier.dto.shop.ShopMsgStateDTO; +import cn.ysk.cashier.mybatis.entity.TbShopOpenId; +import cn.ysk.cashier.pojo.shop.TbFullShopId; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.HashMap; +import java.util.Optional; + +public interface MsgService { + Page all(Integer page, Integer size, Integer shopId, String nickName, String openId, Integer state, Integer type); + + Optional updateShopState(ShopMsgStateDTO shopMsgStateDTO); + + Optional removeSubUser(ShopMsgRemoveDTO shopMsgRemoveDTO); + + Optional updateInfo(ShopInfoUpdateDTO shopInfoUpdateDTO); + + HashMap getInfo(Integer shopId, Integer type); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index 93a9b367..e8adec8b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -15,9 +15,14 @@ */ package cn.ysk.cashier.service.shop; +import cn.ysk.cashier.dto.shoptable.AddCartDTO; +import cn.ysk.cashier.dto.shoptable.ClearCartDTO; +import cn.ysk.cashier.dto.shoptable.RemoveCartDTO; +import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.shop.TbShopTable; import cn.ysk.cashier.dto.shop.TbShopTableDto; import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; @@ -92,4 +97,12 @@ public interface TbShopTableService { * @throws IOException / */ void download(List all, HttpServletResponse response) throws IOException; + + void addCartForUser(AddCartDTO addCartDTO); + + void removeCart(RemoveCartDTO removeCartDTO); + + void clearCart(ClearCartDTO clearCartDTO); + + Page getCart(Long tableId, Integer page, Integer size, Integer shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java b/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java index 79d74135..bd7525aa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java @@ -1,15 +1,19 @@ package cn.ysk.cashier.utils; +import cn.ysk.cashier.enums.ShopWxMsgTypeEnum; +import cn.ysk.cashier.mybatis.entity.TbShopMsgState; import cn.ysk.cashier.mybatis.entity.TbShopOpenId; +import cn.ysk.cashier.mybatis.service.TbShopMsgStateService; import cn.ysk.cashier.mybatis.service.TbShopOpenIdService; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.function.Consumer; @Component @Slf4j @@ -20,14 +24,22 @@ public class WxMsgUtils { private final RedisUtils redisUtils; private final WxAccountUtil wxAccountUtil; + private final TbShopMsgStateService shopMsgStateService; - public WxMsgUtils(TbShopOpenIdService tbShopOpenIdService, RedisUtils redisUtils, WxAccountUtil wxAccountUtil) { + public WxMsgUtils(TbShopOpenIdService tbShopOpenIdService, RedisUtils redisUtils, WxAccountUtil wxAccountUtil, TbShopMsgStateService shopMsgStateService) { this.tbShopOpenIdService = tbShopOpenIdService; this.redisUtils = redisUtils; this.wxAccountUtil = wxAccountUtil; + this.shopMsgStateService = shopMsgStateService; } - public void aboardOperationMsg(String operationDesc) { + public void aboardOperationMsg(String operationDesc, Integer shopId1) { + TbShopMsgState msgState = shopMsgStateService.lambdaQuery().eq(TbShopMsgState::getShopId, shopId1) + .eq(TbShopMsgState::getType, 2).one(); + if (msgState == null || msgState.getState().equals(0)) { + log.info("店铺未开启推送"); + return; + } HttpServletRequest request = RequestHolder.getHttpServletRequest(); Object o = redisUtils.get("online-token-"+getToken(request)); @@ -39,7 +51,12 @@ public class WxMsgUtils { jsonObject = JSONObject.parseObject(jsonString); shopId = (Integer) jsonObject.get("shopId"); nickName = jsonObject.get("nickName") == null ? "" : jsonObject.get("nickName").toString(); - List openIds = tbShopOpenIdService.lambdaQuery().eq(TbShopOpenId::getShopId, shopId).list(); + List openIds = tbShopOpenIdService.lambdaQuery() + .eq(TbShopOpenId::getShopId, shopId) + .eq(TbShopOpenId::getStatus, 1) + .and((queryWrapper) -> queryWrapper.eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.ALL_MSG.getType()) + .or().eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.OPERATION_MSG.getType())) + .list(); log.info("即将开始推送敏感操作消息, 接收推送openId列表: {}", openIds); String finalNickName = nickName; wxAccountUtil.sendOperationMsg(openIds, finalNickName, operationDesc); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopTableVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopTableVo.java new file mode 100644 index 00000000..1ab3ca28 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopTableVo.java @@ -0,0 +1,27 @@ +package cn.ysk.cashier.vo; + +import lombok.Data; + +import java.util.stream.Stream; + +/** + * @author GYJ + */ +@Data +public class ShopTableVo { + private String qrcode; + private Object shopId; + private Object tableId; + private Object tableName; + private Object areaId; + private Object areaName; + + public ShopTableVo(String qrcode, Object shopId, Object tableId, Object tableName, Object areaId, Object areaName) { + this.qrcode = qrcode; + this.shopId = shopId; + this.tableId = tableId; + this.tableName = tableName; + this.areaId = areaId; + this.areaName = areaName; + } +} diff --git a/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml b/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml new file mode 100644 index 00000000..a6ccca7d --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + id,shop_id,type, + state,create_time,update_time + + diff --git a/eladmin-system/src/main/resources/mapper/TbShopOpenIdMapper.xml b/eladmin-system/src/main/resources/mapper/TbShopOpenIdMapper.xml index 131b90c7..7128a504 100644 --- a/eladmin-system/src/main/resources/mapper/TbShopOpenIdMapper.xml +++ b/eladmin-system/src/main/resources/mapper/TbShopOpenIdMapper.xml @@ -12,11 +12,14 @@ + + id,shop_id,open_id, status,create_time,update_time, - type + type,nickname,avatar + diff --git a/eladmin-tools/src/main/java/cn/ysk/cashier/rest/QiniuController.java b/eladmin-tools/src/main/java/cn/ysk/cashier/rest/QiniuController.java index 8acd9808..48db46a1 100644 --- a/eladmin-tools/src/main/java/cn/ysk/cashier/rest/QiniuController.java +++ b/eladmin-tools/src/main/java/cn/ysk/cashier/rest/QiniuController.java @@ -77,7 +77,7 @@ public class QiniuController { return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK); } - @Log("上传文件") +// @Log("上传文件") @ApiOperation("上传文件") @AnonymousPostMapping public ResponseEntity uploadQiNiu(@RequestParam MultipartFile file){ @@ -90,7 +90,7 @@ public class QiniuController { } - @Log("上传文件") +// @Log("上传文件") @ApiOperation("上传文件") @PostMapping(value = "updloadFile") public ResponseEntity updloadFile(@RequestParam MultipartFile file){