菜单 子集

存酒
购买须知
团购商品
用户列表
现金统计
订单详情 储值卡支付
商品排序 分组排序
This commit is contained in:
wangw 2024-06-06 17:33:32 +08:00
parent b31148da52
commit 737d38d0a6
22 changed files with 284 additions and 167 deletions

View File

@ -1,35 +1,17 @@
/*
* 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.controller.product;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.vo.TbProductVo;
import cn.ysk.cashier.service.product.TbProductService;
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
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 java.util.List;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
@ -67,6 +49,12 @@ public class TbProductController {
return tbProductService.findByProductList(productList);
}
@PostMapping("/upProSort")
@ApiOperation("修改商品排序")
public ResponseEntity<Object> upProSort(@RequestBody TbProductSortCriteria param){
tbProductService.upProSort(param);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping
@Log("新增商品:#resources.name")

View File

@ -1,21 +1,7 @@
/*
* 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.controller.product;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.service.product.TbProductService;
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
import cn.ysk.cashier.pojo.product.TbProductGroup;
@ -69,6 +55,13 @@ public class TbProductGroupController {
return new ResponseEntity<>(tbProductGroupService.findByIdProduct(productGroup),HttpStatus.OK);
}
@PostMapping("/upGroupSort")
@ApiOperation("修改分组排序")
public ResponseEntity<Object> upProSort(@RequestBody TbProductSortCriteria param){
tbProductGroupService.upSort(param);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping
@Log("新增商品分组:#resources.name")

View File

@ -1,34 +1,15 @@
/*
* 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.controller.product;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.pojo.product.TbShopCategory;
import cn.ysk.cashier.service.product.TbShopCategoryService;
import cn.ysk.cashier.dto.product.TbShopCategoryQueryCriteria;
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

View File

@ -5,9 +5,9 @@ import cn.ysk.cashier.dto.shop.TbShopStorageNumDto;
import cn.ysk.cashier.dto.shop.TbShopStorageQueryCriteria;
import cn.ysk.cashier.dto.shop.TbShopStorageRecordQueryCriteria;
import cn.ysk.cashier.pojo.shop.TbShopStorage;
import cn.ysk.cashier.pojo.shop.TbShopStorageRecord;
import cn.ysk.cashier.service.shop.TbShopStorageRecordService;
import cn.ysk.cashier.service.shop.TbShopStorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
@ -17,13 +17,12 @@ import org.springframework.http.ResponseEntity;
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;
@RestController
@RequiredArgsConstructor
@Api(tags = "存酒管理")
@RequestMapping("/api/storage")
@Slf4j
public class TbShopStorageController {
private final TbShopStorageService tbShopStorageService;
@ -62,4 +61,11 @@ public class TbShopStorageController {
public ResponseEntity<Object> queryTbShopStorageRecord(TbShopStorageRecordQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbShopStorageRecordService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping("countRecord")
@ApiOperation("存酒统计")
public ResponseEntity<Object> queryTbOrderPayCount(@RequestBody TbShopStorageQueryCriteria criteria){
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize());
return new ResponseEntity<>(tbShopStorageService.countStorage(criteria,pageable),HttpStatus.OK);
}
}

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.dto.product;
import lombok.Data;
import java.util.List;
@Data
public class TbProductSortCriteria {
private Integer strId;
private Integer endId;
private List<Integer> ids;
}

View File

@ -0,0 +1,21 @@
package cn.ysk.cashier.dto.shop;
import lombok.Data;
@Data
public class TbCountStorageDto {
private String name;
private String imgUrl;
private Long savNum;
private Long expNum;
public TbCountStorageDto() {
}
public TbCountStorageDto(String name,String imgUrl, Long savNum, Long expNum) {
this.name = name;
this.imgUrl = imgUrl;
this.savNum = savNum;
this.expNum = expNum;
}
}

View File

@ -28,4 +28,10 @@ public class TbShopStorageGoodQueryCriteria {
private Integer page = 0;
private Integer size = 10;
public void setShopId(Integer shopId) {
if (shopId != null && shopId != 1) {
this.shopId = shopId;
}
}
}

View File

@ -3,24 +3,40 @@ package cn.ysk.cashier.dto.shop;
import cn.ysk.cashier.annotation.Query;
import lombok.Data;
import java.util.StringJoiner;
@Data
public class TbShopStorageQueryCriteria {
/** 模糊 */
/**
* 模糊
*/
@Query(type = Query.Type.INNER_LIKE)
private String name;
/** 精确 */
/**
* 精确
*/
@Query
private Integer status;
/** 精确 */
/**
* 精确
*/
@Query
private String telphone;
/** 精确 */
/**
* 精确
*/
@Query
private Integer shopId;
private Integer page=0;
private Integer size=10;
private Integer page = 0;
private Integer size = 10;
public void setShopId(Integer shopId) {
if (shopId != null && shopId != 1) {
this.shopId = shopId;
}
}
}

View File

@ -15,7 +15,9 @@
*/
package cn.ysk.cashier.quartz.task;
import cn.ysk.cashier.repository.shop.TbShopStorageRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -27,12 +29,15 @@ import org.springframework.stereotype.Service;
@Service
public class TestTask {
@Autowired
private TbShopStorageRepository storageRepository;
public void run(){
log.info("run 执行成功");
}
public void run1(String str){
log.info("run1 执行成功,参数为: {}" + str);
log.info("run1 执行成功,参数为: {}" , str);
}
public void run2(){
@ -40,7 +45,9 @@ public class TestTask {
}
public void orderSum(){
public void expStorage(){
log.info("存酒过期开始执行");
storageRepository.expStorage();
log.info("存酒过期执行结束");
}
}

View File

@ -151,7 +151,7 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"FROM TbOrderInfo info " +
"WHERE info.shopId = :shopId " +
"AND info.createdAt > :startTime AND info.createdAt < :endTime " +
"AND info.orderType = 'cash' " +
"AND info.payType = 'cash' " +
"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);

View File

@ -1,26 +1,12 @@
/*
* 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.repository.product;
import cn.ysk.cashier.pojo.product.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;
import java.util.List;
/**
* @website https://eladmin.vip
* @author lyf
@ -31,6 +17,10 @@ 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")
@Query("select groups from TbProductGroup groups where groups.name = :userName and groups.shopId = :shopId")
TbProductGroup findByName(@Param("userName") String userName, @Param("shopId") Integer shopId);
@Query("SELECT groups from TbProductGroup groups where groups.id in :productIds order by groups.sort")
List<TbProductGroup> findByIds(List<Integer> productIds);
}

View File

@ -1,18 +1,3 @@
/*
* 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.repository.product;
import cn.ysk.cashier.pojo.product.TbProduct;
@ -32,7 +17,7 @@ import java.util.List;
public interface TbProductRepository extends JpaRepository<TbProduct, Integer>, JpaSpecificationExecutor<TbProduct> {
@Query("SELECT product from TbProduct product where product.id in :productIds")
@Query("SELECT product from TbProduct product where product.id in :productIds order by product.sort")
List<TbProduct> findByIds(List<Integer> productIds);
@Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true)

View File

@ -1,8 +1,13 @@
package cn.ysk.cashier.repository.shop;
import cn.ysk.cashier.dto.shop.TbCountStorageDto;
import cn.ysk.cashier.dto.shop.TbShopStorageQueryCriteria;
import cn.ysk.cashier.pojo.shop.TbShopStorage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
* @website https://eladmin.vip
@ -10,4 +15,20 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @date 2024-05-21
**/
public interface TbShopStorageRepository extends JpaRepository<TbShopStorage, Integer>, JpaSpecificationExecutor<TbShopStorage> {
@Query("SELECT new cn.ysk.cashier.dto.shop.TbCountStorageDto(" +
"storage.name, " +
"storage.imgUrl, " +
"SUM( CASE WHEN storage.status = 1 THEN storage.num ELSE 0 END), " +
"SUM( CASE WHEN storage.status = 2 THEN storage.num ELSE 0 END)" +
") " +
"FROM TbShopStorage storage " +
"WHERE (:shopId IS NULL OR storage.shopId = :shopId) " +
"GROUP BY storage.name " +
"ORDER BY SUM(CASE WHEN storage.status = 1 THEN storage.num ELSE 0 END) desc")
Page<TbCountStorageDto> countStorage(Integer shopId, Pageable pageable);
@Query(value = "UPDATE tb_shop_storage SET `status` = '2' WHERE exp_time > DATE_ADD( NOW(), INTERVAL -2 DAY ) AND exp_time < NOW() AND `status` = '1'",nativeQuery = true)
void expStorage();
}

View File

@ -175,6 +175,9 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
case "wx_lite":
dto.setPayType("微信小程序支付");
break;
case "deposit":
dto.setPayType("储值卡支付");
break;
default:
dto.setPayType(tbOrderInfo.getSendType());
break;

View File

@ -1,20 +1,6 @@
/*
* 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.service.impl.productimpl;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.pojo.product.TbProductGroup;
@ -28,6 +14,8 @@ import cn.ysk.cashier.config.security.service.dto.OnlineUserDto;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.service.product.TbProductGroupService;
import cn.ysk.cashier.mapper.product.TbProductGroupMapper;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ -64,8 +52,9 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
@Override
public Map<String,Object> queryAll(TbProductGroupQueryCriteria criteria, Pageable pageable){
PageRequest sort = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort"));
Page<TbProductGroup> page = tbProductGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
QueryHelp.getPredicate(root,criteria,criteriaBuilder),sort);
return PageUtil.toPage(page.map(tbProductGroupMapper::toDto));
}
@ -98,6 +87,8 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
public TbProductGroupDto create(TbProductGroup resources) {
resources.setCreatedAt(Instant.now().toEpochMilli());
resources.setUpdatedAt(Instant.now().toEpochMilli());
TbProductGroup save = tbProductGroupRepository.save(resources);
save.setSort(save.getId());
return tbProductGroupMapper.toDto(tbProductGroupRepository.save(resources));
}
@ -115,6 +106,54 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
tbProductGroupRepository.save(tbProductGroup);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void upSort(TbProductSortCriteria param) {
Integer strSort = tbProductGroupRepository.findById(param.getStrId()).get().getSort();
Integer endSort = tbProductGroupRepository.findById(param.getEndId()).get().getSort();
List<TbProductGroup> list = tbProductGroupRepository.findByIds(param.getIds());
Integer sort = 0;
Integer strIndex = -1;
if(strSort<endSort){
for (int i = list.size() - 1; i >= 0; i--) {
TbProductGroup product = list.get(i);
if(product.getId().equals(param.getEndId())) {
sort=product.getSort();
strIndex=i;
}
if(!strIndex.equals(-1)){
if (product.getId().equals(param.getStrId())){
product.setSort(sort);
tbProductGroupRepository.save(product);
break;
}
TbProductGroup product1 = list.get(i - 1);
product.setSort(product1.getSort());
tbProductGroupRepository.save(product);
}
}
}else {
for (int i = 0; i < list.size(); i++) {
TbProductGroup product = list.get(i);
if(product.getId().equals(param.getEndId())) {
sort=product.getSort();
strIndex=i;
}
if(!strIndex.equals(-1)){
if (product.getId().equals(param.getStrId())){
product.setSort(sort);
tbProductGroupRepository.save(product);
break;
}
Integer nextIndex= i + 1;
TbProductGroup product1 = list.get(nextIndex);
product.setSort(product1.getSort());
tbProductGroupRepository.save(product);
}
}
}
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {

View File

@ -1,18 +1,3 @@
/*
* 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.service.impl.productimpl;
import cn.hutool.core.bean.BeanUtil;
@ -20,6 +5,7 @@ import cn.hutool.core.bean.copier.CopyOptions;
import cn.ysk.cashier.dto.TbPlatformDictDto;
import cn.ysk.cashier.dto.product.TbProductDto;
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.dto.shop.TbCouponCategoryDto;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.product.TbProductMapper;
@ -35,7 +21,6 @@ import cn.ysk.cashier.repository.shop.TbShopUserDutyDetailRepository;
import cn.ysk.cashier.service.TbPlatformDictService;
import cn.ysk.cashier.service.product.TbProductService;
import cn.ysk.cashier.service.shop.TbCouponCategoryService;
import cn.ysk.cashier.service.shop.TbPurchaseNoticeService;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.TbProductVo;
import com.alibaba.fastjson.JSONArray;
@ -88,7 +73,7 @@ public class TbProductServiceImpl implements TbProductService {
@Override
public Map<String, Object> queryAll(TbProductQueryCriteria criteria) {
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Sort sort = Sort.by(Sort.Direction.ASC, "sort");
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
//查询商品数据
Page<TbProduct> page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
@ -331,6 +316,10 @@ public class TbProductServiceImpl implements TbProductService {
if (resources.getUnitId() != null) {
product.setUnitId(resources.getUnitId());
}
if ("sku".equals(resources.getTypeEnum())) {
List<BigDecimal> collect = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList());
product.setLowPrice(collect.get(0));
}
if ("group".equals(resources.getTypeEnum())) {
//套餐内容
if (!resources.getGroupSnap().isEmpty()) {
@ -348,10 +337,11 @@ public class TbProductServiceImpl implements TbProductService {
}
}
TbProduct save = tbProductRepository.save(product);
if (save.getId() == null) {
throw new BadRequestException("添加商品失败");
}
save.setSort(save.getId());
tbProductRepository.save(product);
//sku
if (resources.getSkuList() != null) {
List<TbProductSku> skuList = new ArrayList<>();
@ -401,8 +391,11 @@ public class TbProductServiceImpl implements TbProductService {
product.setIsFreeFreight(1);
product.setStatus(1);
product.setUpdatedAt(Instant.now().toEpochMilli());
product.setCategoryId(resources.getCategoryId().toString());
product.setImages(resources.getImages().toString());
if ("sku".equals(resources.getTypeEnum())) {
List<BigDecimal> collect = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList());
product.setLowPrice(collect.get(0));
}
if ("group".equals(resources.getTypeEnum())) {
//套餐内容
if (!resources.getGroupSnap().isEmpty()) {
@ -420,6 +413,8 @@ public class TbProductServiceImpl implements TbProductService {
}
noticeRepository.save(resources.getNotices());
}else {
product.setCategoryId(resources.getCategoryId().toString());
}
TbProduct save = tbProductRepository.save(product);
@ -452,6 +447,15 @@ 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("修改购买须知失败,必填项未填写");
}
noticeRepository.save(resources.getNotices());
}
}
@ -462,6 +466,54 @@ public class TbProductServiceImpl implements TbProductService {
tbProductRepository.updateIsHot(id);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void upProSort(TbProductSortCriteria param) {
Integer strSort = tbProductRepository.findById(param.getStrId()).get().getSort();
Integer endSort = tbProductRepository.findById(param.getEndId()).get().getSort();
List<TbProduct> list = tbProductRepository.findByIds(param.getIds());
Integer sort = 0;
Integer strIndex = -1;
if(strSort<endSort){
for (int i = list.size() - 1; i >= 0; i--) {
TbProduct product = list.get(i);
if(product.getId().equals(param.getEndId())) {
sort=product.getSort();
strIndex=i;
}
if(!strIndex.equals(-1)){
if (product.getId().equals(param.getStrId())){
product.setSort(sort);
tbProductRepository.save(product);
break;
}
TbProduct product1 = list.get(i - 1);
product.setSort(product1.getSort());
tbProductRepository.save(product);
}
}
}else {
for (int i = 0; i < list.size(); i++) {
TbProduct product = list.get(i);
if(product.getId().equals(param.getEndId())) {
sort=product.getSort();
strIndex=i;
}
if(!strIndex.equals(-1)){
if (product.getId().equals(param.getStrId())){
product.setSort(sort);
tbProductRepository.save(product);
break;
}
Integer nextIndex= i + 1;
TbProduct product1 = list.get(nextIndex);
product.setSort(product1.getSort());
tbProductRepository.save(product);
}
}
}
}
@Override
@Transactional
public void deleteAll(Integer[] ids) {

View File

@ -15,7 +15,9 @@
*/
package cn.ysk.cashier.service.impl.productimpl;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.pojo.product.TbProductGroup;
import cn.ysk.cashier.pojo.product.TbShopCategory;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.utils.FileUtil;
@ -117,6 +119,8 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
if (StringUtils.isNotBlank(resources.getPid())){
resources.setTree(Integer.valueOf(resources.getPid().trim()));
}
TbShopCategory save = tbShopCategoryRepository.save(resources);
save.setSort(save.getId());
return tbShopCategoryRepository.save(resources);
}

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.service.impl.shopimpl;
import cn.ysk.cashier.dto.shop.TbCountStorageDto;
import cn.ysk.cashier.dto.shop.TbShopStorageDto;
import cn.ysk.cashier.dto.shop.TbShopStorageNumDto;
import cn.ysk.cashier.dto.shop.TbShopStorageQueryCriteria;
@ -53,6 +54,12 @@ public class TbShopStorageServiceImpl implements TbShopStorageService {
return tbShopStorageMapper.toDto(tbShopStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
public Map<String, Object> countStorage(TbShopStorageQueryCriteria criteria,Pageable pageable){
Page<TbCountStorageDto> page = tbShopStorageRepository.countStorage(criteria.getShopId(), pageable);
return PageUtil.toPage(page);
}
@Override
@Transactional
public TbShopStorageDto findById(Integer id) {
@ -67,7 +74,13 @@ public class TbShopStorageServiceImpl implements TbShopStorageService {
resources.setStatus(1);
resources.setSavTime(new Timestamp(System.currentTimeMillis()));
resources.setExpTime(new Timestamp(System.currentTimeMillis() + 86400000 * resources.getExpDay()));
return tbShopStorageMapper.toDto(tbShopStorageRepository.save(resources));
TbShopStorage save = tbShopStorageRepository.save(resources);
TbShopStorageRecord record = new TbShopStorageRecord();
record.setStorageId(resources.getId());
record.setTime(new Timestamp(System.currentTimeMillis()));
record.setContent("存入"+ resources.getNum() + resources.getUnit() + resources.getName());
storageRecordService.create(record);
return tbShopStorageMapper.toDto(save);
}
@Override

View File

@ -1,20 +1,6 @@
/*
* 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.service.product;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.product.TbProductGroup;
import cn.ysk.cashier.dto.product.TbProductGroupDto;
@ -73,6 +59,7 @@ public interface TbProductGroupService {
*/
void update(TbProductGroup resources);
void upSort(TbProductSortCriteria param);
/**
* 多选删除
* @param ids /

View File

@ -1,25 +1,10 @@
/*
* 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.service.product;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.vo.TbProductVo;
import cn.ysk.cashier.dto.product.TbProductDto;
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
@ -72,6 +57,8 @@ public interface TbProductService {
*/
void update(TbProductVo resources);
void upProSort(TbProductSortCriteria param);
/**
* 多选删除
* @param ids /

View File

@ -18,7 +18,6 @@ package cn.ysk.cashier.service.product;
import cn.ysk.cashier.pojo.product.TbShopCategory;
import cn.ysk.cashier.dto.product.TbShopCategoryDto;
import cn.ysk.cashier.dto.product.TbShopCategoryQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.dto.shop.TbCountStorageDto;
import cn.ysk.cashier.dto.shop.TbShopStorageDto;
import cn.ysk.cashier.dto.shop.TbShopStorageNumDto;
import cn.ysk.cashier.dto.shop.TbShopStorageQueryCriteria;
@ -31,6 +32,8 @@ public interface TbShopStorageService {
*/
List<TbShopStorageDto> queryAll(TbShopStorageQueryCriteria criteria);
Map<String,Object> countStorage(TbShopStorageQueryCriteria criteria,Pageable pageable);
/**
* 根据ID查询
* @param id ID