收银端库存列表,商品列表
This commit is contained in:
@@ -65,4 +65,5 @@ public class AppRun {
|
||||
public String index() {
|
||||
return "Backend service started successfully";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class TbProduct implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "`id`")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@@ -170,7 +171,7 @@ public class TbProduct implements Serializable {
|
||||
@Column(name = "`is_del`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否回收站 0-否,1回收站")
|
||||
private Integer isDel;
|
||||
private Integer isDel = 0;
|
||||
|
||||
@Column(name = "`is_stock`")
|
||||
@ApiModelProperty(value = "是否开启库存")
|
||||
@@ -183,7 +184,7 @@ public class TbProduct implements Serializable {
|
||||
@Column(name = "`is_free_freight`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否免邮1-是 0-否")
|
||||
private Integer isFreeFreight;
|
||||
private Integer isFreeFreight=1;
|
||||
|
||||
@Column(name = "`freight_id`")
|
||||
@ApiModelProperty(value = "邮费模版")
|
||||
@@ -204,7 +205,7 @@ public class TbProduct implements Serializable {
|
||||
@Column(name = "`is_delete`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
private Integer isDelete;
|
||||
private Integer isDelete = 0;
|
||||
|
||||
@Column(name = "`notice`")
|
||||
@ApiModelProperty(value = "购买须知")
|
||||
|
||||
@@ -207,4 +207,6 @@ public class TbProductVo {
|
||||
private List<TbProductSku> skuList;
|
||||
|
||||
private HashMap<String,String> specsInfo;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ package me.zhengjie.modules.productInfo.product.repository;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -25,4 +28,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
* @date 2023-12-11
|
||||
**/
|
||||
public interface TbProductRepository extends JpaRepository<TbProduct, Integer>, JpaSpecificationExecutor<TbProduct> {
|
||||
|
||||
|
||||
@Query("SELECT product from TbProduct product where product.id in :productIds")
|
||||
List<TbProduct> findByIds(List<Integer> productIds);
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
@@ -67,14 +68,20 @@ public class TbProductController {
|
||||
public Object queryTbProductInfo(@PathVariable("product") Integer product)throws Exception{
|
||||
return tbProductService.findByProductId(product);
|
||||
}
|
||||
|
||||
@GetMapping ("/productList")
|
||||
@Log("查询/product")
|
||||
@ApiOperation("查询/product")
|
||||
@PreAuthorize("@el.check('tbProduct:list')")
|
||||
public Object queryTbProductInfo(@RequestParam List<String> productList){
|
||||
return tbProductService.findByProductList(productList);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/product")
|
||||
@ApiOperation("新增/product")
|
||||
@PreAuthorize("@el.check('tbProduct:add')")
|
||||
public ResponseEntity<Object> createTbProduct(@Validated @RequestBody TbProduct resources){
|
||||
public ResponseEntity<Object> createTbProduct(@Validated @RequestBody TbProductVo resources){
|
||||
return new ResponseEntity<>(tbProductService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@@ -82,7 +89,7 @@ public class TbProductController {
|
||||
@Log("修改/product")
|
||||
@ApiOperation("修改/product")
|
||||
@PreAuthorize("@el.check('tbProduct:edit')")
|
||||
public ResponseEntity<Object> updateTbProduct(@Validated @RequestBody TbProduct resources){
|
||||
public ResponseEntity<Object> updateTbProduct(@Validated @RequestBody TbProductVo resources){
|
||||
tbProductService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@@ -57,18 +57,21 @@ public interface TbProductService {
|
||||
|
||||
TbProductVo findByProductId(Integer id)throws Exception;
|
||||
|
||||
|
||||
List<TbProduct>findByProductList(List<String> productList);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbProductDto
|
||||
*/
|
||||
TbProductDto create(TbProduct resources);
|
||||
Object create(TbProductVo resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbProduct resources);
|
||||
void update(TbProductVo resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
|
||||
@@ -40,6 +40,9 @@ public class TbProductQueryCriteria{
|
||||
@Query
|
||||
private String name;
|
||||
|
||||
@Query
|
||||
private String categoryId;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private BigDecimal packFee;
|
||||
@@ -115,4 +118,7 @@ public class TbProductQueryCriteria{
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer furnishExpress;
|
||||
|
||||
@Query
|
||||
private String typeEnum;
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.product.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProductVo;
|
||||
import me.zhengjie.modules.productInfo.product.repository.TbProductRepository;
|
||||
@@ -36,9 +38,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
@@ -57,6 +61,7 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
private final TbShopUnitRepository tbShopUnitRepository;
|
||||
private final TbProductSpecRepository tbProductSpecRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbProductQueryCriteria criteria, Pageable pageable){
|
||||
//查询商品数据
|
||||
@@ -69,7 +74,9 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
productId.add(product.getId().toString());
|
||||
//记录单位id
|
||||
if (product.getUnitId() != null){
|
||||
unitId.add(Integer.valueOf(product.getUnitId()));
|
||||
if (!"".equals(product.getUnitId())){
|
||||
unitId.add(Integer.valueOf(product.getUnitId().trim()));
|
||||
}
|
||||
}
|
||||
//记录规格id
|
||||
specId.add(product.getSpecId());
|
||||
@@ -126,7 +133,7 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
tbProductVoList.add(tbProductVo);
|
||||
}
|
||||
System.out.println(tbProductVoList);
|
||||
return PageUtil.toPage(tbProductVoList,tbProductVoList.size());
|
||||
return PageUtil.toPage(tbProductVoList,page.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,13 +157,38 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put(tbProductSpec.get().getName(),tbProductSpec.get().getSpecList());
|
||||
tbProductVo.setUnitName(tbShopUnits.get().getName());
|
||||
tbProductVo.setSkuList(tbProductSkus.get());
|
||||
tbProductVo.setSpecsInfo(map);
|
||||
//商品规格
|
||||
if (tbProductSpec.get() == null){
|
||||
tbProductVo.setSpecsInfo(map);
|
||||
}else {
|
||||
map.put(tbProductSpec.get().getName(),tbProductSpec.get().getSpecList());
|
||||
tbProductVo.setSpecsInfo(map);
|
||||
}
|
||||
//单位
|
||||
if (tbShopUnits.get() == null){
|
||||
tbProductVo.setUnitName(null);
|
||||
}else {
|
||||
tbProductVo.setUnitName(tbShopUnits.get().getName());
|
||||
}
|
||||
//sku
|
||||
if (tbProductSkus.get() == null){
|
||||
tbProductVo.setSkuList(new ArrayList<>());
|
||||
}else {
|
||||
tbProductVo.setSkuList(tbProductSkus.get());
|
||||
}
|
||||
return tbProductVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProduct> findByProductList(List<String> productList) {
|
||||
List<Integer> productListInt = productList.stream()
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
List<TbProduct> byIds = tbProductRepository.findByIds(productListInt);
|
||||
|
||||
return byIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProductDto> queryAll(TbProductQueryCriteria criteria){
|
||||
return tbProductMapper.toDto(tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
@@ -173,17 +205,73 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductDto create(TbProduct resources) {
|
||||
return tbProductMapper.toDto(tbProductRepository.save(resources));
|
||||
public Object create(TbProductVo resources) {
|
||||
TbProduct product = new TbProduct();
|
||||
//组装
|
||||
BeanUtils.copyProperties(resources, product);
|
||||
product.setIsDel(0);
|
||||
product.setIsDelete(0);
|
||||
product.setIsFreeFreight(1);
|
||||
product.setStatus(1);
|
||||
product.setCreatedAt(Instant.now().toEpochMilli());
|
||||
product.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
TbProduct save = tbProductRepository.save(product);
|
||||
|
||||
if (save.getId() == null){
|
||||
throw new BadRequestException("添加商品失败");
|
||||
}
|
||||
//sku
|
||||
if (resources.getSkuList() != null) {
|
||||
List<TbProductSku> skuList = new ArrayList<>();
|
||||
for (TbProductSku sku : resources.getSkuList()) {
|
||||
sku.setProductId(String.valueOf(save.getId()));
|
||||
sku.setShopId(save.getShopId());
|
||||
sku.setCreatedAt(Instant.now().toEpochMilli());
|
||||
sku.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
skuList.add(sku);
|
||||
}
|
||||
tbProductSkuRepository.saveAll(skuList);
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(UUID.randomUUID().toString().substring(0, 16));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbProduct resources) {
|
||||
TbProduct tbProduct = tbProductRepository.findById(resources.getId()).orElseGet(TbProduct::new);
|
||||
ValidationUtil.isNull( tbProduct.getId(),"TbProduct","id",resources.getId());
|
||||
tbProduct.copy(resources);
|
||||
tbProductRepository.save(tbProduct);
|
||||
public void update(TbProductVo resources) {
|
||||
TbProduct product = new TbProduct();
|
||||
//组装
|
||||
BeanUtils.copyProperties(resources, product);
|
||||
product.setIsDel(0);
|
||||
product.setIsDelete(0);
|
||||
product.setIsFreeFreight(1);
|
||||
product.setStatus(1);
|
||||
product.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
TbProduct save = tbProductRepository.save(product);
|
||||
|
||||
//sku
|
||||
if (resources.getSkuList() != null) {
|
||||
if ("sku".equals(save.getTypeEnum())){
|
||||
tbProductSkuRepository.deleteByProductId(String.valueOf(save.getId()));
|
||||
}
|
||||
List<TbProductSku> skuList = new ArrayList<>();
|
||||
for (TbProductSku sku : resources.getSkuList()) {
|
||||
sku.setProductId(String.valueOf(save.getId()));
|
||||
sku.setShopId(save.getShopId());
|
||||
product.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
skuList.add(sku);
|
||||
}
|
||||
tbProductSkuRepository.saveAll(skuList);
|
||||
|
||||
}
|
||||
// ValidationUtil.isNull( tbProduct.getId(),"TbProduct","id",resources.getId());
|
||||
// tbProduct.copy(resources);
|
||||
// tbProductRepository.save(tbProduct);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,8 @@ package me.zhengjie.modules.productInfo.productGroup.repository;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -28,4 +30,7 @@ public interface TbProductGroupRepository extends JpaRepository<TbProductGroup,
|
||||
|
||||
// @Query("SELECT u FROM User u WHERE u.userName = :userName")
|
||||
// User findByUserName(@Param("userName") String userName);
|
||||
|
||||
@Query("select Group from TbProductGroup Group where Group.name = :userName and Group.shopId = :shopId")
|
||||
TbProductGroup findByName(@Param("userName") String userName, @Param("shopId") Integer shopId);
|
||||
}
|
||||
@@ -66,6 +66,15 @@ public class TbProductGroupController {
|
||||
return new ResponseEntity<>(tbProductGroupService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/{productGroup}")
|
||||
@Log("查询product/group")
|
||||
@ApiOperation("查询product/group")
|
||||
@PreAuthorize("@el.check('tbProductGroup:list')")
|
||||
public ResponseEntity<Object> queryTbProductGroup(@PathVariable("productGroup") Integer productGroup){
|
||||
return new ResponseEntity<>(tbProductGroupService.findByIdProduct(productGroup),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
@Log("新增product/group")
|
||||
@ApiOperation("新增product/group")
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productGroup.service;
|
||||
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupDto;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
@@ -50,6 +51,8 @@ public interface TbProductGroupService {
|
||||
*/
|
||||
List<TbProductGroupDto> queryAll(TbProductGroupQueryCriteria criteria);
|
||||
|
||||
|
||||
List<TbProduct> findByIdProduct(Integer productGroup);
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productGroup.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.repository.TbProductRepository;
|
||||
import me.zhengjie.modules.productInfo.productGroup.domain.TbProductGroup;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.vo.AddProduct;
|
||||
import me.zhengjie.modules.productInfo.productGroup.repository.TbProductGroupRepository;
|
||||
@@ -22,8 +26,7 @@ import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupDt
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.dto.TbProductGroupQueryCriteria;
|
||||
import me.zhengjie.modules.security.service.OnlineUserService;
|
||||
import me.zhengjie.modules.security.service.dto.OnlineUserDto;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.TbProductGroupService;
|
||||
import me.zhengjie.modules.productInfo.productGroup.service.mapstruct.TbProductGroupMapper;
|
||||
@@ -33,8 +36,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
@@ -55,6 +58,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
|
||||
private final TbProductGroupRepository tbProductGroupRepository;
|
||||
private final TbProductGroupMapper tbProductGroupMapper;
|
||||
private final TbProductRepository tbProductRepository;
|
||||
|
||||
@Resource
|
||||
private OnlineUserService onlineUserService;
|
||||
@@ -64,7 +68,6 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
Page<TbProductGroup> page = tbProductGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
|
||||
QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
|
||||
|
||||
return PageUtil.toPage(page.map(tbProductGroupMapper::toDto));
|
||||
}
|
||||
|
||||
@@ -73,6 +76,23 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
return tbProductGroupMapper.toDto(tbProductGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProduct> findByIdProduct(Integer productGroup) {
|
||||
TbProductGroup tbProductGroup = tbProductGroupRepository.findById(productGroup).orElseGet(TbProductGroup::new);
|
||||
if (tbProductGroup.getProductIds() != null){
|
||||
List<String> list = ListUtil.stringChangeStringList(tbProductGroup.getProductIds());
|
||||
|
||||
List<Integer> intList = new ArrayList<>();
|
||||
for (String str : list) {
|
||||
intList.add(Integer.parseInt(str));
|
||||
}
|
||||
System.out.println(intList);
|
||||
|
||||
return tbProductRepository.findByIds(ListUtil.stringChangeIntegerList(list));
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbProductGroupDto findById(Integer id) {
|
||||
@@ -84,6 +104,8 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductGroupDto create(TbProductGroup resources) {
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
return tbProductGroupMapper.toDto(tbProductGroupRepository.save(resources));
|
||||
}
|
||||
|
||||
@@ -91,6 +113,11 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
@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("名称重复");
|
||||
// }
|
||||
tbProductGroup.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
ValidationUtil.isNull( tbProductGroup.getId(),"TbProductGroup","id",resources.getId());
|
||||
tbProductGroup.copy(resources);
|
||||
tbProductGroupRepository.save(tbProductGroup);
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
package me.zhengjie.modules.productInfo.productSku.repository;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
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.data.repository.query.Param;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -36,4 +39,15 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
|
||||
@Query("SELECT sku FROM TbProductSku sku WHERE sku.productId = :productId")
|
||||
List<TbProductSku> searchSku(@Param("productId")String productId);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("DELETE FROM TbProductSku sku WHERE sku.productId = :productId")
|
||||
Integer deleteByProductId(@Param("productId") String productId);
|
||||
|
||||
// @Insert("INSERT INTO TbProductSku sku(sku.shopId,sku.barCode,sku.productId,sku.originPrice,sku.costPrice,sku.memberPrice,sku.salePrice,sku.stockNumber,sku.firstShared) " +
|
||||
// "VALUES (#{item.shopId},#{item.barCode},#{item.productId},#{item.originPrice},#{item.costPrice},#{item.memberPrice},#{item.salePrice},#{item.stockNumber},#{sku.firstShared}) ")
|
||||
// void findById(@Param("item") List<TbProductSku> skuList);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_product_stock_detail")
|
||||
public class TbProductStockDetail implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "`sku_id`")
|
||||
@ApiModelProperty(value = "skuId")
|
||||
private String skuId;
|
||||
|
||||
@Column(name = "`product_id`")
|
||||
@ApiModelProperty(value = "商品Id")
|
||||
private String productId;
|
||||
|
||||
@Column(name = "`product_name`")
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String productName;
|
||||
|
||||
@Column(name = "`is_stock`")
|
||||
@ApiModelProperty(value = "是否开启库存")
|
||||
private Integer isStock;
|
||||
|
||||
@Column(name = "`spec_snap`")
|
||||
@ApiModelProperty(value = "规格")
|
||||
private String specSnap;
|
||||
|
||||
@Column(name = "`unit_name`")
|
||||
@ApiModelProperty(value = "商品单位")
|
||||
private String unitName;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String shopId;
|
||||
|
||||
@Column(name = "`record_id`")
|
||||
@ApiModelProperty(value = "recordId")
|
||||
private String recordId;
|
||||
|
||||
@Column(name = "`batch_number`")
|
||||
@ApiModelProperty(value = "操作批次号")
|
||||
private String batchNumber;
|
||||
|
||||
@Column(name = "`source_path`")
|
||||
@ApiModelProperty(value = "库存操作来源:收银端调用 CASHIER 系统后台调用SHOP")
|
||||
private String sourcePath;
|
||||
|
||||
@Column(name = "`order_id`")
|
||||
@ApiModelProperty(value = "关联订单Id")
|
||||
private String orderId;
|
||||
|
||||
@Column(name = "`sub_type`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = " 1入库2出库")
|
||||
private Integer subType;
|
||||
|
||||
@Column(name = "`type`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "purchase采购入库 transfer调拔入库 ")
|
||||
private String type;
|
||||
|
||||
@Column(name = "`left_number`")
|
||||
@ApiModelProperty(value = "上次剩余数量")
|
||||
private Integer leftNumber;
|
||||
|
||||
@Column(name = "`stock_time`")
|
||||
@ApiModelProperty(value = "出入库时间")
|
||||
private Long stockTime;
|
||||
|
||||
@Column(name = "`stock_number`")
|
||||
@ApiModelProperty(value = "本次操作库存数量")
|
||||
private Double stockNumber;
|
||||
|
||||
@Column(name = "`cost_amount`")
|
||||
@ApiModelProperty(value = "入库合计成本金额")
|
||||
private BigDecimal costAmount;
|
||||
|
||||
@Column(name = "`sales_amount`")
|
||||
@ApiModelProperty(value = "出售合计金额")
|
||||
private BigDecimal salesAmount;
|
||||
|
||||
@Column(name = "`operator`")
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private String operator;
|
||||
|
||||
@Column(name = "`remark`")
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@Column(name = "`stock_snap`")
|
||||
@ApiModelProperty(value = "库存镜像")
|
||||
private String stockSnap;
|
||||
|
||||
@Column(name = "`bar_code`")
|
||||
@ApiModelProperty(value = "barCode")
|
||||
private String barCode;
|
||||
|
||||
@Column(name = "`cover_img`")
|
||||
@ApiModelProperty(value = "coverImg")
|
||||
private String coverImg;
|
||||
|
||||
@Column(name = "`created_at`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "createdAt")
|
||||
private Long createdAt;
|
||||
|
||||
@Column(name = "`updated_at`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
public void copy(TbProductStockDetail source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.repository;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productStock.domain.TbProductStockDetail;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
public interface TbProductStockDetailRepository extends JpaRepository<TbProductStockDetail, Long>, JpaSpecificationExecutor<TbProductStockDetail> {
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.productInfo.productStock.domain.TbProductStockDetail;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.TbProductStockDetailService;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/product/Stock管理")
|
||||
@RequestMapping("/api/tbProductStockDetail")
|
||||
public class TbProductStockDetailController {
|
||||
|
||||
private final TbProductStockDetailService tbProductStockDetailService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbProductStockDetail:list')")
|
||||
public void exportTbProductStockDetail(HttpServletResponse response, TbProductStockDetailQueryCriteria criteria) throws IOException {
|
||||
tbProductStockDetailService.download(tbProductStockDetailService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/product/Stock")
|
||||
@ApiOperation("查询/product/Stock")
|
||||
@PreAuthorize("@el.check('tbProductStockDetail:list')")
|
||||
public ResponseEntity<Object> queryTbProductStockDetail(TbProductStockDetailQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbProductStockDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/product/Stock")
|
||||
@ApiOperation("新增/product/Stock")
|
||||
@PreAuthorize("@el.check('tbProductStockDetail:add')")
|
||||
public ResponseEntity<Object> createTbProductStockDetail(@Validated @RequestBody TbProductStockDetail resources){
|
||||
return new ResponseEntity<>(tbProductStockDetailService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/product/Stock")
|
||||
@ApiOperation("修改/product/Stock")
|
||||
@PreAuthorize("@el.check('tbProductStockDetail:edit')")
|
||||
public ResponseEntity<Object> updateTbProductStockDetail(@Validated @RequestBody TbProductStockDetail resources){
|
||||
tbProductStockDetailService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/product/Stock")
|
||||
@ApiOperation("删除/product/Stock")
|
||||
@PreAuthorize("@el.check('tbProductStockDetail:del')")
|
||||
public ResponseEntity<Object> deleteTbProductStockDetail(@RequestBody Long[] ids) {
|
||||
tbProductStockDetailService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.service;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productStock.domain.TbProductStockDetail;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailDto;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
public interface TbProductStockDetailService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbProductStockDetailDto>
|
||||
*/
|
||||
List<TbProductStockDetailDto> queryAll(TbProductStockDetailQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbProductStockDetailDto
|
||||
*/
|
||||
TbProductStockDetailDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbProductStockDetailDto
|
||||
*/
|
||||
TbProductStockDetailDto create(TbProductStockDetail resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbProductStockDetail resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbProductStockDetailDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
@Data
|
||||
public class TbProductStockDetailDto implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
/** skuId */
|
||||
private String skuId;
|
||||
|
||||
/** 商品Id */
|
||||
private String productId;
|
||||
|
||||
/** 商品名称 */
|
||||
private String productName;
|
||||
|
||||
/** 是否开启库存 */
|
||||
private Integer isStock;
|
||||
|
||||
/** 规格 */
|
||||
private String specSnap;
|
||||
|
||||
/** 商品单位 */
|
||||
private String unitName;
|
||||
|
||||
/** 店铺Id */
|
||||
private String shopId;
|
||||
|
||||
private String recordId;
|
||||
|
||||
/** 操作批次号 */
|
||||
private String batchNumber;
|
||||
|
||||
/** 库存操作来源:收银端调用 CASHIER 系统后台调用SHOP */
|
||||
private String sourcePath;
|
||||
|
||||
/** 关联订单Id */
|
||||
private String orderId;
|
||||
|
||||
/** 1入库2出库 */
|
||||
private Integer subType;
|
||||
|
||||
/** purchase采购入库 transfer调拔入库
|
||||
stockpile存酒入库
|
||||
2盘点入库3退货入库4期初5生产归还入库6内部令用归还7借出归还8其它入库9调拔出库sale销售出库11盘点出库12锁定13生产领料14内部领用15借用出库16其它出库17报废出库 */
|
||||
private String type;
|
||||
|
||||
/** 上次剩余数量 */
|
||||
private Integer leftNumber;
|
||||
|
||||
/** 出入库时间 */
|
||||
private Long stockTime;
|
||||
|
||||
/** 本次操作库存数量 */
|
||||
private Double stockNumber;
|
||||
|
||||
/** 入库合计成本金额 */
|
||||
private BigDecimal costAmount;
|
||||
|
||||
/** 出售合计金额 */
|
||||
private BigDecimal salesAmount;
|
||||
|
||||
/** 操作人 */
|
||||
private String operator;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 库存镜像 */
|
||||
private String stockSnap;
|
||||
|
||||
private String barCode;
|
||||
|
||||
private String coverImg;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
@Data
|
||||
public class TbProductStockDetailQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String skuId;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String productId;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String productName;
|
||||
/** BETWEEN */
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<Long> createdAt;
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.service.impl;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productStock.domain.TbProductStockDetail;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.productInfo.productStock.repository.TbProductStockDetailRepository;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.TbProductStockDetailService;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailDto;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.mapstruct.TbProductStockDetailMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbProductStockDetailServiceImpl implements TbProductStockDetailService {
|
||||
|
||||
private final TbProductStockDetailRepository tbProductStockDetailRepository;
|
||||
private final TbProductStockDetailMapper tbProductStockDetailMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbProductStockDetail> page = tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbProductStockDetailMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProductStockDetailDto> queryAll(TbProductStockDetailQueryCriteria criteria){
|
||||
return tbProductStockDetailMapper.toDto(tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbProductStockDetailDto findById(Long id) {
|
||||
TbProductStockDetail tbProductStockDetail = tbProductStockDetailRepository.findById(id).orElseGet(TbProductStockDetail::new);
|
||||
ValidationUtil.isNull(tbProductStockDetail.getId(),"TbProductStockDetail","id",id);
|
||||
return tbProductStockDetailMapper.toDto(tbProductStockDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductStockDetailDto create(TbProductStockDetail resources) {
|
||||
return tbProductStockDetailMapper.toDto(tbProductStockDetailRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbProductStockDetail resources) {
|
||||
TbProductStockDetail tbProductStockDetail = tbProductStockDetailRepository.findById(resources.getId()).orElseGet(TbProductStockDetail::new);
|
||||
ValidationUtil.isNull( tbProductStockDetail.getId(),"TbProductStockDetail","id",resources.getId());
|
||||
tbProductStockDetail.copy(resources);
|
||||
tbProductStockDetailRepository.save(tbProductStockDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
tbProductStockDetailRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbProductStockDetailDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbProductStockDetailDto tbProductStockDetail : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("skuId", tbProductStockDetail.getSkuId());
|
||||
map.put("商品Id", tbProductStockDetail.getProductId());
|
||||
map.put("商品名称", tbProductStockDetail.getProductName());
|
||||
map.put("是否开启库存", tbProductStockDetail.getIsStock());
|
||||
map.put("规格", tbProductStockDetail.getSpecSnap());
|
||||
map.put("商品单位", tbProductStockDetail.getUnitName());
|
||||
map.put("店铺Id", tbProductStockDetail.getShopId());
|
||||
map.put(" recordId", tbProductStockDetail.getRecordId());
|
||||
map.put("操作批次号", tbProductStockDetail.getBatchNumber());
|
||||
map.put("库存操作来源:收银端调用 CASHIER 系统后台调用SHOP", tbProductStockDetail.getSourcePath());
|
||||
map.put("关联订单Id", tbProductStockDetail.getOrderId());
|
||||
map.put(" 1入库2出库", tbProductStockDetail.getSubType());
|
||||
map.put("purchase采购入库 transfer调拔入库 ", tbProductStockDetail.getType());
|
||||
map.put("上次剩余数量", tbProductStockDetail.getLeftNumber());
|
||||
map.put("出入库时间", tbProductStockDetail.getStockTime());
|
||||
map.put("本次操作库存数量", tbProductStockDetail.getStockNumber());
|
||||
map.put("入库合计成本金额", tbProductStockDetail.getCostAmount());
|
||||
map.put("出售合计金额", tbProductStockDetail.getSalesAmount());
|
||||
map.put("操作人", tbProductStockDetail.getOperator());
|
||||
map.put("备注", tbProductStockDetail.getRemark());
|
||||
map.put("库存镜像", tbProductStockDetail.getStockSnap());
|
||||
map.put(" barCode", tbProductStockDetail.getBarCode());
|
||||
map.put(" coverImg", tbProductStockDetail.getCoverImg());
|
||||
map.put(" createdAt", tbProductStockDetail.getCreatedAt());
|
||||
map.put(" updatedAt", tbProductStockDetail.getUpdatedAt());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.productInfo.productStock.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.productInfo.productStock.domain.TbProductStockDetail;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbProductStockDetailMapper extends BaseMapper<TbProductStockDetailDto, TbProductStockDetail> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_shop_table")
|
||||
public class TbShopTable implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`shop_id`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "shopId")
|
||||
private Integer shopId;
|
||||
|
||||
@Column(name = "`max_capacity`")
|
||||
@ApiModelProperty(value = "客座数,允许的客座数量")
|
||||
private Integer maxCapacity;
|
||||
|
||||
@Column(name = "`sort`")
|
||||
@ApiModelProperty(value = "台桌排序")
|
||||
private Integer sort;
|
||||
|
||||
@Column(name = "`area_id`")
|
||||
@ApiModelProperty(value = "区域Id")
|
||||
private String areaId;
|
||||
|
||||
@Column(name = "`is_predate`")
|
||||
@ApiModelProperty(value = "是否接受网络预定")
|
||||
private Integer isPredate;
|
||||
|
||||
@Column(name = "`predate_amount`")
|
||||
@ApiModelProperty(value = "网络预定台桌支付金额")
|
||||
private BigDecimal predateAmount;
|
||||
|
||||
@Column(name = "`status`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "subscribe预定,closed--关台, opening 开台中,cleaning 台桌清理中")
|
||||
private String status;
|
||||
|
||||
@Column(name = "`type`")
|
||||
@ApiModelProperty(value = "台桌计算价格类型,0-低消类型,amount 2计时类型")
|
||||
private Integer type;
|
||||
|
||||
@Column(name = "`amount`")
|
||||
@ApiModelProperty(value = "当type=0时,amount生效,为台桌的低消金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Column(name = "`perhour`")
|
||||
@ApiModelProperty(value = "当type=2时perhour生效,为计时类型,每小时收款金额")
|
||||
private BigDecimal perhour;
|
||||
|
||||
@Column(name = "`view`")
|
||||
@ApiModelProperty(value = "台桌展示图---预留")
|
||||
private String view;
|
||||
|
||||
@Column(name = "`created_at`")
|
||||
@ApiModelProperty(value = "createdAt")
|
||||
private Long createdAt;
|
||||
|
||||
@Column(name = "`updated_at`")
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
public void copy(TbShopTable source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.repository;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.table.domain.TbShopTable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
public interface TbShopTableRepository extends JpaRepository<TbShopTable, Integer>, JpaSpecificationExecutor<TbShopTable> {
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.shopInfo.table.domain.TbShopTable;
|
||||
import me.zhengjie.modules.shopInfo.table.service.TbShopTableService;
|
||||
import me.zhengjie.modules.shopInfo.table.service.dto.TbShopTableQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/shop/table管理")
|
||||
@RequestMapping("/api/tbShopTable")
|
||||
public class TbShopTableController {
|
||||
|
||||
private final TbShopTableService tbShopTableService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbShopTable:list')")
|
||||
public void exportTbShopTable(HttpServletResponse response, TbShopTableQueryCriteria criteria) throws IOException {
|
||||
tbShopTableService.download(tbShopTableService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/shop/table")
|
||||
@ApiOperation("查询/shop/table")
|
||||
@PreAuthorize("@el.check('tbShopTable:list')")
|
||||
public ResponseEntity<Object> queryTbShopTable(TbShopTableQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopTableService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/shop/table")
|
||||
@ApiOperation("新增/shop/table")
|
||||
@PreAuthorize("@el.check('tbShopTable:add')")
|
||||
public ResponseEntity<Object> createTbShopTable(@Validated @RequestBody TbShopTable resources){
|
||||
return new ResponseEntity<>(tbShopTableService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/shop/table")
|
||||
@ApiOperation("修改/shop/table")
|
||||
@PreAuthorize("@el.check('tbShopTable:edit')")
|
||||
public ResponseEntity<Object> updateTbShopTable(@Validated @RequestBody TbShopTable resources){
|
||||
tbShopTableService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/shop/table")
|
||||
@ApiOperation("删除/shop/table")
|
||||
@PreAuthorize("@el.check('tbShopTable:del')")
|
||||
public ResponseEntity<Object> deleteTbShopTable(@RequestBody Integer[] ids) {
|
||||
tbShopTableService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.service;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.table.domain.TbShopTable;
|
||||
import me.zhengjie.modules.shopInfo.table.service.dto.TbShopTableDto;
|
||||
import me.zhengjie.modules.shopInfo.table.service.dto.TbShopTableQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
public interface TbShopTableService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopTableDto>
|
||||
*/
|
||||
List<TbShopTableDto> queryAll(TbShopTableQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbShopTableDto
|
||||
*/
|
||||
TbShopTableDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbShopTableDto
|
||||
*/
|
||||
TbShopTableDto create(TbShopTable resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbShopTable resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbShopTableDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
@Data
|
||||
public class TbShopTableDto implements Serializable {
|
||||
|
||||
/** 自增id */
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer shopId;
|
||||
|
||||
/** 客座数,允许的客座数量 */
|
||||
private Integer maxCapacity;
|
||||
|
||||
/** 台桌排序 */
|
||||
private Integer sort;
|
||||
|
||||
/** 区域Id */
|
||||
private String areaId;
|
||||
|
||||
/** 是否接受网络预定 */
|
||||
private Integer isPredate;
|
||||
|
||||
/** 网络预定台桌支付金额 */
|
||||
private BigDecimal predateAmount;
|
||||
|
||||
/** subscribe预定,closed--关台, opening 开台中,cleaning 台桌清理中 */
|
||||
private String status;
|
||||
|
||||
/** 台桌计算价格类型,0-低消类型,amount 2计时类型 */
|
||||
private Integer type;
|
||||
|
||||
/** 当type=0时,amount生效,为台桌的低消金额 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 当type=2时perhour生效,为计时类型,每小时收款金额 */
|
||||
private BigDecimal perhour;
|
||||
|
||||
/** 台桌展示图---预留 */
|
||||
private String view;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
@Data
|
||||
public class TbShopTableQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String name;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer shopId;
|
||||
|
||||
@Query
|
||||
private String areaId;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.service.impl;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.table.domain.TbShopTable;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.shopInfo.table.repository.TbShopTableRepository;
|
||||
import me.zhengjie.modules.shopInfo.table.service.TbShopTableService;
|
||||
import me.zhengjie.modules.shopInfo.table.service.dto.TbShopTableDto;
|
||||
import me.zhengjie.modules.shopInfo.table.service.dto.TbShopTableQueryCriteria;
|
||||
import me.zhengjie.modules.shopInfo.table.service.mapstruct.TbShopTableMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
private final TbShopTableRepository tbShopTableRepository;
|
||||
private final TbShopTableMapper tbShopTableMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbShopTable> page = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbShopTableMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopTableDto> queryAll(TbShopTableQueryCriteria criteria){
|
||||
return tbShopTableMapper.toDto(tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbShopTableDto findById(Integer id) {
|
||||
TbShopTable tbShopTable = tbShopTableRepository.findById(id).orElseGet(TbShopTable::new);
|
||||
ValidationUtil.isNull(tbShopTable.getId(),"TbShopTable","id",id);
|
||||
return tbShopTableMapper.toDto(tbShopTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopTableDto create(TbShopTable resources) {
|
||||
return tbShopTableMapper.toDto(tbShopTableRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopTable resources) {
|
||||
TbShopTable tbShopTable = tbShopTableRepository.findById(resources.getId()).orElseGet(TbShopTable::new);
|
||||
ValidationUtil.isNull( tbShopTable.getId(),"TbShopTable","id",resources.getId());
|
||||
tbShopTable.copy(resources);
|
||||
tbShopTableRepository.save(tbShopTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbShopTableRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbShopTableDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbShopTableDto tbShopTable : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put(" name", tbShopTable.getName());
|
||||
map.put(" shopId", tbShopTable.getShopId());
|
||||
map.put("客座数,允许的客座数量", tbShopTable.getMaxCapacity());
|
||||
map.put("台桌排序", tbShopTable.getSort());
|
||||
map.put("区域Id", tbShopTable.getAreaId());
|
||||
map.put("是否接受网络预定", tbShopTable.getIsPredate());
|
||||
map.put("网络预定台桌支付金额", tbShopTable.getPredateAmount());
|
||||
map.put("subscribe预定,closed--关台, opening 开台中,cleaning 台桌清理中", tbShopTable.getStatus());
|
||||
map.put("台桌计算价格类型,0-低消类型,amount 2计时类型", tbShopTable.getType());
|
||||
map.put("当type=0时,amount生效,为台桌的低消金额", tbShopTable.getAmount());
|
||||
map.put("当type=2时perhour生效,为计时类型,每小时收款金额", tbShopTable.getPerhour());
|
||||
map.put("台桌展示图---预留", tbShopTable.getView());
|
||||
map.put(" createdAt", tbShopTable.getCreatedAt());
|
||||
map.put(" updatedAt", tbShopTable.getUpdatedAt());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 me.zhengjie.modules.shopInfo.table.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.shopInfo.table.domain.TbShopTable;
|
||||
import me.zhengjie.modules.shopInfo.table.service.dto.TbShopTableDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-18
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbShopTableMapper extends BaseMapper<TbShopTableDto, TbShopTable> {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user