Merge remote-tracking branch 'origin/zs' into test

This commit is contained in:
2024-08-12 15:33:21 +08:00
48 changed files with 1472 additions and 118 deletions

View File

@@ -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")) {

View File

@@ -19,6 +19,10 @@
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- 代码生成模块 -->
<dependency>

View File

@@ -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<Object> 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<Object> addCartForUser(@Valid @RequestBody AddCartDTO addCartDTO) {
tbShopTableService.addCartForUser(addCartDTO);
return new ResponseEntity<>(HttpStatus.OK);
}
@AnonymousAccess
@DeleteMapping("/removeCart")
@Log("代客下单 删除购物车商品")
@ApiOperation("代客下单 清空购物车 /shop/table")
public ResponseEntity<Object> removeCart(@Validated @RequestBody RemoveCartDTO removeCartDTO) {
tbShopTableService.removeCart(removeCartDTO);
return new ResponseEntity<>(HttpStatus.OK);
}
@AnonymousAccess
@DeleteMapping("/clearCart")
@Log("代客下单 清空购物车")
@ApiOperation("代客下单 清空购物车 /shop/table")
public ResponseEntity<Object> clearCart(@Validated @RequestBody ClearCartDTO clearCartDTO) {
tbShopTableService.clearCart(clearCartDTO);
return new ResponseEntity<>(HttpStatus.OK);
}
@AnonymousAccess
@GetMapping("/cart")
@Log("代客下单 查询购物车")
@ApiOperation("代客下单 查询购物车 /shop/table")
public ResponseEntity<Object> 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));
}
}

View File

@@ -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<Object> 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<String> productList){
return tbProductService.findByProductList(productList);
}
@PostMapping("/upProSort")
@ApiOperation("修改商品排序")
public ResponseEntity<Object> upProSort(@RequestBody TbProductSortCriteria param){

View File

@@ -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<Page<TbFullShopId>> 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<TbFullShopId> all = msgService.all(page, size, shopId, nickName, openId, state, type);
return ResponseEntity.ok(all);
}
@AnonymousAccess
@PutMapping("/shopState")
public ResponseEntity<Boolean> shopMsgState(
@Valid @RequestBody ShopMsgStateDTO shopMsgStateDTO
) {
return ResponseEntity.of(msgService.updateShopState(shopMsgStateDTO));
}
@AnonymousAccess
@DeleteMapping
public ResponseEntity<Boolean> removeSubUser(
@Valid @RequestBody ShopMsgRemoveDTO shopMsgRemoveDTO
) {
return ResponseEntity.of(msgService.removeSubUser(shopMsgRemoveDTO));
}
@AnonymousAccess
@PutMapping("/info")
public ResponseEntity<Boolean> updateInfo(
@Valid @RequestBody ShopInfoUpdateDTO shopInfoUpdateDTO
) {
return ResponseEntity.of(msgService.updateInfo(shopInfoUpdateDTO));
}
@AnonymousAccess
@GetMapping("/state")
public ResponseEntity<HashMap<String, Object>> updateInfo(
@RequestParam Integer shopId
) {
return ResponseEntity.ok(msgService.getInfo(shopId, null));
}
}

View File

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

View File

@@ -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);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<TbCashierCart> {
}

View File

@@ -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<TbProductSku> {
@@ -14,4 +18,5 @@ public interface TbProducSkutMapper extends BaseMapper<TbProductSku> {
@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);
}

View File

@@ -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<TbProduct> {
@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);
}
@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);
}

View File

@@ -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<TbShopMsgState> {
}

View File

@@ -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<TbShopOpenId> {
@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("<script>" +
" select *,\n" +
" SUM(IF(type = 0, `status`, 0)) AS proState,\n" +
" SUM(IF(type = 1, `status`, 0)) AS conState,\n" +
" SUM(IF(type = 2, `status`, 0)) AS opeState,\n" +
" SUM(IF(type = -1, `status`, 0)) AS allState\n" +
" from tb_shop_open_id where shop_id=#{shopId}\n" +
" <if test=\"nickName !=null and nickName != ''\">\n" +
" and nickname like concat('%', #{nickName} '%')\n" +
" </if>\n" +
" <if test=\"openId !=null and openId != ''\">\n" +
" and open_id like concat('%', #{openId} '%')\n" +
" </if>\n" +
" group by shop_id, open_id" +
"</script>")
Page<TbFullShopId> selectAll(@Param("shopId") Integer shopId, @Param("nickName") String nickName, @Param("openId") String openId, Page<TbFullShopId> page);
}

View File

@@ -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<TbShopMsgState> {
}

View File

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

View File

@@ -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<TbShopMsgStateMapper, TbShopMsgState>
implements TbShopMsgStateService{
}

View File

@@ -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<TbShopOpenIdMapper, TbShopOpenId>

View File

@@ -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));
}
}

View File

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

View File

@@ -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<TbCashierCart, In
@Modifying
void updateToFinal(@Param("id") Integer id);
}
@Query("select cart from TbCashierCart cart where cart.tableId=:tableId and cart.status='create' and cart.shopId=:shopId and cart.skuId=:skuId")
TbCashierCart selectActivateBySkuId(String skuId, String shopId, Long tableId);
@Query("delete from TbCashierCart cart where cart.shopId=:shopId and cart.id=:cartId and cart.tableId=:tableId and cart.status='create'")
@Modifying
@Transactional
void deleteByIdAndShopId(@NotNull String shopId, @NotNull Integer cartId, Long tableId);
}

View File

@@ -17,6 +17,7 @@ package cn.ysk.cashier.repository.order;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
import cn.ysk.cashier.vo.ShopTableSaleInfoVo;
import cn.ysk.cashier.vo.ShopTableVo;
import cn.ysk.cashier.vo.TbOrderPayCountByDayVo;
import cn.ysk.cashier.vo.TbOrderPayCountVo;
import org.apache.ibatis.annotations.Param;
@@ -170,6 +171,20 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) ")
TbOrderPayCountVo queryOrderPayCash(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
@Query("SELECT new cn.ysk.cashier.vo.ShopTableVo(" +
"table.qrcode," +
"table.shopId," +
"table.id," +
"table.name," +
"table.areaId," +
"area.name) " +
"FROM TbShopTable table " +
"LEFT JOIN TbShopArea as area on table.areaId = area.id " +
"WHERE table.shopId = :shopId " +
"AND table.qrcode is not null " +
"AND table.qrcode != '' ")
List<ShopTableVo> 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<TbOrderInfo, Intege
"WHERE info.shopId = :shopId " +
"AND info.createdAt > :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<ShopTableSaleInfoVo> 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<String> queryShopTableIds(@Param("shopId") Integer shopId);
}
}

View File

@@ -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<TbProduct, Integer>,
@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<TbProduct, Integer>,
@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);
}

View File

@@ -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<TbProductSkuResult, Integer>, JpaSpecificationExecutor<TbProductSkuResult> {
@Modifying
@Query(value = "delete from tb_product_sku_result where id = ?1", nativeQuery = true)
void deleteByIdN(Integer id);
}

View File

@@ -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<TbShopTable, Intege
@Query("select table from TbShopTable table where table.shopId = :shopId")
List<TbShopTable> 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);
}

View File

@@ -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<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime) {
List<String> shopTableCodes = tbOrderInfoRepository.queryShopTableIds(shopId);
List<ShopTableVo> 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<ShopTableSaleInfoVo> 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<ShopTableSaleInfoVo> saleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), start, end);
if (!list.isEmpty()) {
list.sort((a, b) -> {
Map<String, ShopTableVo> 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

View File

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

View File

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

View File

@@ -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<TbProductSku> 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<Integer> collect = resources.getSkuList().stream().map(TbProductSku::getId).collect(Collectors.toList());
List<TbProductSku> 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<TbProduct> page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size);
QueryWrapper<TbProduct> 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<Map<String, Object>> 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<TbProduct> tbProductPage = productMapper.selectPage(page1, queryWrapper);
tbProductPage.getRecords().stream().parallel().forEach(item -> {
TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null);
List<TbProductSku> tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper<TbProductSku>().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<String> result = new ArrayList<>();
if (StrUtil.isNotBlank(tagSnap)) {
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);
String[] values = jsonObject.getString("value").split(",");
valuesList.add(Arrays.asList(values));
}
// 生成所有可能的排列组合
generateCombinations(valuesList, 0, new ArrayList<>(), result);
}
ArrayList<Map<String, Object>> specList = new ArrayList<>();
tbProductSkus.forEach(item2 -> {
Map<String, Object> 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<HashMap<String, Object>> otherVal = new ArrayList<>();
for (String res : result) {
boolean found = false;
for (Map<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);
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
map.put("skuResult", skuResult);
map.put("specList", specList);
infoList.add(map);
});
Map<String, Object> map = BeanUtil.beanToMap(tbProductPage, false, false);
map.put("records", infoList);
return map;
}
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); // 回溯
}
}
}

View File

@@ -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<TbFullShopId> all(Integer page, Integer size, Integer shopId, String nickName, String openId, Integer state, Integer type) {
LambdaQueryWrapper<TbShopOpenId> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TbShopOpenId::getShopId, shopId);
return shopOpenIdMapper.selectAll(shopId, nickName, openId, new Page<>(page, size));
}
@Override
public Optional<Boolean> updateShopState(ShopMsgStateDTO shopMsgStateDTO) {
TbShopOpenId shopOpenId = new TbShopOpenId();
shopOpenId.setStatus(shopMsgStateDTO.getState());
LambdaQueryWrapper<TbShopOpenId> queryWrapper = new LambdaQueryWrapper<TbShopOpenId>().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<Boolean> removeSubUser(ShopMsgRemoveDTO shopMsgRemoveDTO) {
int delete = shopOpenIdMapper.delete(new LambdaQueryWrapper<TbShopOpenId>().eq(TbShopOpenId::getShopId, shopMsgRemoveDTO.getShopId())
.eq(TbShopOpenId::getOpenId, shopMsgRemoveDTO.getOpenId()));
return Optional.of(delete > 0);
}
@Override
public Optional<Boolean> 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<TbShopOpenId>()
.eq(TbShopOpenId::getOpenId, shopInfoUpdateDTO.getOpenId())
.eq(TbShopOpenId::getType, shopInfoUpdateDTO.getType())
.eq(TbShopOpenId::getShopId, shopInfoUpdateDTO.getShopId()));
}
return Optional.of( true);
}
private static final HashMap<String, String> 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<String, Object> getInfo(Integer shopId, Integer type) {
List<TbShopMsgState> list = shopMsgStateService.lambdaQuery().eq(TbShopMsgState::getShopId, shopId).list();
HashMap<String, Object> 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;
}
}

View File

@@ -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<TbShopTable> tbShopTableList = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
ArrayList<Map<String, Object>> infoList = new ArrayList<>();
for (TbShopTable date : tbShopTableList) {
Map<String, Object> 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<String, Object> 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<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> cartPage = cashierCartMapper.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size), new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getStatus, "create")
.eq(TbCashierCart::getShopId, shopId));
List<TbCashierCart> records = cartPage.getRecords();
ArrayList<Integer> skuIds = new ArrayList<>();
records.forEach(item -> {
skuIds.add(Integer.valueOf(item.getSkuId()));
});
if (!skuIds.isEmpty()) {
List<TbProductSku> skuList = productSkuRepository.findAllById(skuIds);
HashMap<String, TbProductSku> skuMap = new HashMap<>();
skuList.forEach(item -> skuMap.put(item.getId().toString(), item));
ArrayList<Map<String, Object>> infos = new ArrayList<>();
records.forEach(item -> {
Map<String, Object> 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;
}
}

View File

@@ -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);
}

View File

@@ -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<TbFullShopId> all(Integer page, Integer size, Integer shopId, String nickName, String openId, Integer state, Integer type);
Optional<Boolean> updateShopState(ShopMsgStateDTO shopMsgStateDTO);
Optional<Boolean> removeSubUser(ShopMsgRemoveDTO shopMsgRemoveDTO);
Optional<Boolean> updateInfo(ShopInfoUpdateDTO shopInfoUpdateDTO);
HashMap<String, Object> getInfo(Integer shopId, Integer type);
}

View File

@@ -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<TbShopTableDto> all, HttpServletResponse response) throws IOException;
void addCartForUser(AddCartDTO addCartDTO);
void removeCart(RemoveCartDTO removeCartDTO);
void clearCart(ClearCartDTO clearCartDTO);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId);
}

View File

@@ -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<TbShopOpenId> openIds = tbShopOpenIdService.lambdaQuery().eq(TbShopOpenId::getShopId, shopId).list();
List<TbShopOpenId> 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);

View File

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

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbShopMsgStateMapper">
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.pojo.TbShopMsgStatetb">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,shop_id,type,
state,create_time,update_time
</sql>
</mapper>

View File

@@ -12,11 +12,14 @@
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
<result property="type" column="type" jdbcType="TINYINT"/>
<result property="nickname" column="nickname" jdbcType="VARCHAR"/>
<result property="avatar" column="avatar" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,shop_id,open_id,
status,create_time,update_time,
type
type,nickname,avatar
</sql>
</mapper>

View File

@@ -77,7 +77,7 @@ public class QiniuController {
return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK);
}
@Log("上传文件")
// @Log("上传文件")
@ApiOperation("上传文件")
@AnonymousPostMapping
public ResponseEntity<Object> uploadQiNiu(@RequestParam MultipartFile file){
@@ -90,7 +90,7 @@ public class QiniuController {
}
@Log("上传文件")
// @Log("上传文件")
@ApiOperation("上传文件")
@PostMapping(value = "updloadFile")
public ResponseEntity<Object> updloadFile(@RequestParam MultipartFile file){