菜单 子集

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

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