菜单 子集

存酒
购买须知
团购商品
用户列表
This commit is contained in:
2024-05-29 15:24:50 +08:00
parent 44509e1d32
commit b31148da52
33 changed files with 457 additions and 172 deletions

View File

@@ -25,6 +25,8 @@ public interface TbPlatformDictService {
List<TbPlatformDictDto> queryByType(String type);
List<TbPlatformDictDto> queryByIds(List ids);
/**
* 根据ID查询
* @param id ID

View File

@@ -55,6 +55,11 @@ public class TbPlatformDictServiceImpl implements TbPlatformDictService {
return tbPlatformDictMapper.toDto(tbPlatformDictRepository.findAllByTypeAndIsShowCash(type,1));
}
@Override
public List<TbPlatformDictDto> queryByIds(List ids){
return tbPlatformDictRepository.findAllById(ids);
}
@Override
@Transactional
public TbPlatformDictDto findById(Integer id) {

View File

@@ -15,6 +15,7 @@ import cn.ysk.cashier.service.order.TbGroupOrderCouponService;
import cn.ysk.cashier.service.order.TbGroupOrderInfoService;
import cn.ysk.cashier.service.shop.TbMerchantThirdApplyService;
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
import cn.ysk.cashier.thirdpay.resp.GroupOrderReturnResp;
import cn.ysk.cashier.thirdpay.resp.OrderReturnResp;
import cn.ysk.cashier.thirdpay.resp.PublicResp;
import cn.ysk.cashier.thirdpay.service.ThirdPayService;
@@ -181,10 +182,11 @@ public class TbGroupOrderInfoServiceImpl implements TbGroupOrderInfoService {
thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
GroupOrderReturnResp returnInfo = JSONUtil.parseJSONStr2T(publicResp.getBizData(), GroupOrderReturnResp.class);
if ("000000".equals(publicResp.getCode())) {
//TRADE_REFUND
if (!"TRADE_SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
throw new BadRequestException("退款渠道调用失败");
if (!"SUCCESS".equals(returnInfo.getState()) && !"TRADE_SUCCESS".equals(returnInfo.getState()) && !returnInfo.getState().equals("ING")) {
throw new BadRequestException("退款渠道调用失败,"+returnInfo.getNote());
}
} else {
throw new BadRequestException("退款渠道调用失败:" + publicResp.getMsg());

View File

@@ -17,18 +17,25 @@ package cn.ysk.cashier.service.impl.productimpl;
import cn.hutool.core.bean.BeanUtil;
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.shop.TbCouponCategoryDto;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.product.TbProductMapper;
import cn.ysk.cashier.mybatis.entity.TagProductDepts;
import cn.ysk.cashier.mybatis.service.TagProductDeptsService;
import cn.ysk.cashier.pojo.product.*;
import cn.ysk.cashier.pojo.shop.TbPurchaseNotice;
import cn.ysk.cashier.pojo.shop.TbShopUnit;
import cn.ysk.cashier.repository.product.*;
import cn.ysk.cashier.repository.shop.TbPurchaseNoticeRepository;
import cn.ysk.cashier.repository.shop.TbShopUnitRepository;
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;
@@ -72,6 +79,9 @@ public class TbProductServiceImpl implements TbProductService {
private final TbShopCategoryRepository tbShopCategoryRepository;
private final TbShopUserDutyDetailRepository tbShopUserDutyDetailRe;
private final TbCouponCategoryService tbCouponCategoryService;
private final TbPlatformDictService tbPlatformDictService;
private final TagProductDeptsService tagProductService;
private final TbPurchaseNoticeRepository noticeRepository;
private final RedisUtils redisUtils;
@@ -116,13 +126,13 @@ public class TbProductServiceImpl implements TbProductService {
}
//分类
List<TbShopCategory> tbShopCategory = new ArrayList<>();
if (!categoryId.isEmpty()){
if (!categoryId.isEmpty()) {
List<Integer> categoryIdInt = ListUtil.stringChangeIntegerList(categoryId);
tbShopCategory = tbShopCategoryRepository.searchCategory(categoryIdInt);
}
//销量
List<Object[]> objects = new ArrayList<>();
if (!productIdInt.isEmpty()){
if (!productIdInt.isEmpty()) {
objects = tbShopUserDutyDetailRe.searchUUserDutyDetail(productIdInt);
}
//组装
@@ -164,24 +174,24 @@ public class TbProductServiceImpl implements TbProductService {
}
}
//分类
if (tbShopCategory.isEmpty()){
if (tbShopCategory.isEmpty()) {
tbProductVo.setCategoryName("");
}else {
for (TbShopCategory shopCategory :tbShopCategory) {
if (shopCategory.getId().toString().equals(product.getCategoryId())){
} else {
for (TbShopCategory shopCategory : tbShopCategory) {
if (shopCategory.getId().toString().equals(product.getCategoryId())) {
tbProductVo.setCategoryName(shopCategory.getName());
}
}
}
//销量
if (objects.isEmpty()){
if (objects.isEmpty()) {
tbProductVo.setRealSalesNumber(0.00);
}else {
for (Object[] o :objects) {
if (((Integer) o[1]).equals(product.getId())){
BigDecimal bigDecimal = (BigDecimal) o[0];
tbProductVo.setRealSalesNumber(bigDecimal.doubleValue());
}
} else {
for (Object[] o : objects) {
if (((Integer) o[1]).equals(product.getId())) {
BigDecimal bigDecimal = (BigDecimal) o[0];
tbProductVo.setRealSalesNumber(bigDecimal.doubleValue());
}
}
}
BeanUtils.copyProperties(product, tbProductVo);
@@ -208,7 +218,7 @@ public class TbProductServiceImpl implements TbProductService {
Threads.call(tbProductSkus, tbProductSpec);
//组装
TbProductVo tbProductVo = new TbProductVo();
tbProductVo.setCategoryId(tbProduct.getCategoryId());
tbProductVo.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId())?Integer.valueOf(tbProduct.getCategoryId()):null);
//单位
// if (tbProduct.getUnitId() == null) {
// tbProductVo.setUnitId(null);
@@ -221,9 +231,9 @@ public class TbProductServiceImpl implements TbProductService {
tbProductVo.setGroupSnap(ListUtil.stringChangeList(tbProduct.getGroupSnap()));
}
BeanUtils.copyProperties(tbProduct, tbProductVo);
if(!org.apache.commons.lang3.StringUtils.isBlank(tbProduct.getImages())){
if (!org.apache.commons.lang3.StringUtils.isBlank(tbProduct.getImages())) {
tbProductVo.setImages(ListUtil.stringChangeList(tbProduct.getImages()));
}else{
} else {
tbProductVo.setImages(new JSONArray());
}
HashMap<String, String> map = new HashMap<>();
@@ -252,6 +262,16 @@ public class TbProductServiceImpl implements TbProductService {
tbProductVo.getGroupCategoryId().add(byId);
}
}
List<TagProductDepts> tagProductDepts = tagProductService.queryAllByProductId(tbProductVo.getId());
if (!CollectionUtils.isEmpty(tagProductDepts)) {
List<Integer> collect = tagProductDepts.stream().map(TagProductDepts::getTagId).collect(Collectors.toList());
List<TbPlatformDictDto> tags = tbPlatformDictService.queryByIds(collect);
tbProductVo.setTags(tags);
}
TbPurchaseNotice notice = noticeRepository.findByCouponId(id);
if (notice != null) {
tbProductVo.setNotices(notice);
}
}
return tbProductVo;
}
@@ -286,20 +306,22 @@ public class TbProductServiceImpl implements TbProductService {
TbProduct product = new TbProduct();
//组装
BeanUtil.copyProperties(resources, product, CopyOptions.create().setIgnoreNullValue(true));
if (resources.getCategoryId() == null) {
throw new BadRequestException("必填内容未填写");
}
if (resources.getIsShowMall() == 1) {
for (TbProductSku sku : resources.getSkuList()) {
if (sku.getStockNumber() <= 0) {
throw new BadRequestException("上架区域包括小程序时,库存数量必须大于0。");
if (!"group".equals(resources.getTypeEnum())) {
if (resources.getCategoryId() == null) {
throw new BadRequestException("必填内容未填写");
}
if (resources.getIsShowMall() == 1) {
for (TbProductSku sku : resources.getSkuList()) {
if (sku.getStockNumber() <= 0) {
throw new BadRequestException("上架区域包括小程序时,库存数量必须大于0。");
}
}
}
product.setCategoryId(String.valueOf(resources.getCategoryId()));
}
if(!CollectionUtils.isEmpty(resources.getImages())){
if (!CollectionUtils.isEmpty(resources.getImages())) {
product.setImages(resources.getImages().toString());
}
product.setCategoryId(String.valueOf(resources.getCategoryId()));
product.setIsDel(0);
product.setIsDelete(0);
product.setIsFreeFreight(1);
@@ -309,16 +331,21 @@ public class TbProductServiceImpl implements TbProductService {
if (resources.getUnitId() != null) {
product.setUnitId(resources.getUnitId());
}
if("group".equals(resources.getTypeEnum())){
if ("group".equals(resources.getTypeEnum())) {
//套餐内容
if (!resources.getGroupSnap().isEmpty()) {
product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap()));
product.setIsCombo(1);
}
if(!CollectionUtils.isEmpty(resources.getGroupCategoryId())){
if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) {
List<Integer> collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList());
product.setGroupCategoryId(collect.toString());
}
if (!CollectionUtils.isEmpty(resources.getTags())) {
for (TbPlatformDictDto tag : resources.getTags()) {
tagProductService.setTag(tag.getId(), resources.getId());
}
}
}
TbProduct save = tbProductRepository.save(product);
@@ -348,6 +375,16 @@ 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("添加购买须知失败,必填项未填写");
}
resources.getNotices().setCouponId(save.getId());
noticeRepository.save(resources.getNotices());
}
return resources;
}
@@ -366,16 +403,23 @@ public class TbProductServiceImpl implements TbProductService {
product.setUpdatedAt(Instant.now().toEpochMilli());
product.setCategoryId(resources.getCategoryId().toString());
product.setImages(resources.getImages().toString());
if("group".equals(resources.getTypeEnum())){
if ("group".equals(resources.getTypeEnum())) {
//套餐内容
if (!resources.getGroupSnap().isEmpty()) {
product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap()));
product.setIsCombo(1);
}
if(!CollectionUtils.isEmpty(resources.getGroupCategoryId())){
if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) {
List<Integer> collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList());
product.setGroupCategoryId(collect.toString());
}
if (!CollectionUtils.isEmpty(resources.getTags())) {
for (TbPlatformDictDto tag : resources.getTags()) {
tagProductService.setTag(tag.getId(), resources.getId());
}
}
noticeRepository.save(resources.getNotices());
}
TbProduct save = tbProductRepository.save(product);
@@ -384,10 +428,10 @@ public class TbProductServiceImpl implements TbProductService {
List<TbProductSku> skuList = new ArrayList<>();
for (TbProductSku sku : resources.getSkuList()) {
TbProductSku tbProductSku = tbProductSkuRepository.searchBarCode(sku.getBarCode());
if (tbProductSku != null){
tbProductSkuRepository.updateByBarCode(sku.getBarCode(),sku.getCostPrice(),sku.getCoverImg(),sku.getFirstShared(),sku.getMemberPrice(),
sku.getOriginPrice(),sku.getSalePrice(),sku.getSpecSnap(),tbProductSku.getId());
}else {
if (tbProductSku != null) {
tbProductSkuRepository.updateByBarCode(sku.getBarCode(), sku.getCostPrice(), sku.getCoverImg(), sku.getFirstShared(), sku.getMemberPrice(),
sku.getOriginPrice(), sku.getSalePrice(), sku.getSpecSnap(), tbProductSku.getId());
} else {
if ("sku".equals(save.getTypeEnum())) {
tbProductSkuRepository.deleteByProductId(String.valueOf(save.getId()));
}

View File

@@ -1,5 +1,6 @@
package cn.ysk.cashier.service.impl.shopimpl;
import cn.ysk.cashier.dto.shop.ShopStorageGoodDto;
import cn.ysk.cashier.dto.shop.TbShopStorageGoodDto;
import cn.ysk.cashier.dto.shop.TbShopStorageGoodQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbShopStorageGoodMapper;
@@ -25,9 +26,9 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author ww
* @website https://eladmin.vip
* @description 服务实现
* @author ww
* @date 2024-05-21
**/
@Service
@@ -38,36 +39,56 @@ public class TbShopStorageGoodServiceImpl implements TbShopStorageGoodService {
private final TbShopStorageGoodMapper tbShopStorageGoodMapper;
@Override
public Map<String,Object> queryAll(TbShopStorageGoodQueryCriteria criteria, Pageable pageable){
Page<TbShopStorageGood> page = tbShopStorageGoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
public Map<String, Object> queryAll(TbShopStorageGoodQueryCriteria criteria, Pageable pageable) {
Page<TbShopStorageGood> page = tbShopStorageGoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(tbShopStorageGoodMapper::toDto));
}
@Override
public List<TbShopStorageGoodDto> queryAll(TbShopStorageGoodQueryCriteria criteria){
return tbShopStorageGoodMapper.toDto(tbShopStorageGoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
public List<TbShopStorageGoodDto> queryAll(TbShopStorageGoodQueryCriteria criteria) {
return tbShopStorageGoodMapper.toDto(tbShopStorageGoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public TbShopStorageGoodDto findById(Integer id) {
TbShopStorageGood tbShopStorageGood = tbShopStorageGoodRepository.findById(id).orElseGet(TbShopStorageGood::new);
ValidationUtil.isNull(tbShopStorageGood.getId(),"TbShopStorageGood","id",id);
ValidationUtil.isNull(tbShopStorageGood.getId(), "TbShopStorageGood", "id", id);
return tbShopStorageGoodMapper.toDto(tbShopStorageGood);
}
@Override
@Transactional(rollbackFor = Exception.class)
public TbShopStorageGoodDto create(TbShopStorageGood resources) {
resources.setIsDel(0);
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
return tbShopStorageGoodMapper.toDto(tbShopStorageGoodRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(ShopStorageGoodDto resources) {
List<TbShopStorageGood> storageGoodList = new ArrayList<>();
for (ShopStorageGoodDto.DetailInfo good : resources.getGoods()) {
TbShopStorageGood storageGood = new TbShopStorageGood();
storageGood.setIsDel(0);
storageGood.setCreateTime(new Timestamp(System.currentTimeMillis()));
storageGood.setName(good.getName());
storageGood.setImgUrl(good.getImgUrl());
storageGood.setPeriod(resources.getPeriod());
storageGood.setSource(resources.getSource());
storageGood.setUnit(resources.getUnit());
storageGood.setShopId(resources.getShopId());
storageGoodList.add(storageGood);
}
tbShopStorageGoodRepository.saveAll(storageGoodList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbShopStorageGood resources) {
TbShopStorageGood tbShopStorageGood = tbShopStorageGoodRepository.findById(resources.getId()).orElseGet(TbShopStorageGood::new);
ValidationUtil.isNull( tbShopStorageGood.getId(),"TbShopStorageGood","id",resources.getId());
ValidationUtil.isNull(tbShopStorageGood.getId(), "TbShopStorageGood", "id", resources.getId());
tbShopStorageGood.copy(resources);
tbShopStorageGoodRepository.save(tbShopStorageGood);
}
@@ -83,13 +104,13 @@ public class TbShopStorageGoodServiceImpl implements TbShopStorageGoodService {
public void download(List<TbShopStorageGoodDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbShopStorageGoodDto tbShopStorageGood : all) {
Map<String,Object> map = new LinkedHashMap<>();
Map<String, Object> map = new LinkedHashMap<>();
map.put("酒品名", tbShopStorageGood.getName());
map.put("图片地址", tbShopStorageGood.getImgUrl());
map.put("单位", tbShopStorageGood.getUnit());
map.put("有效期(天)", tbShopStorageGood.getPeriod());
map.put("0:未删除1:已删除", tbShopStorageGood.getIsDel());
map.put(" createTime", tbShopStorageGood.getCreateTime());
map.put(" createTime", tbShopStorageGood.getCreateTime());
map.put("0:手动1:商品;", tbShopStorageGood.getSource());
map.put("商户Id", tbShopStorageGood.getShopId());
list.add(map);

View File

@@ -64,6 +64,7 @@ public class TbShopStorageServiceImpl implements TbShopStorageService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbShopStorageDto create(TbShopStorage resources) {
resources.setStatus(1);
resources.setSavTime(new Timestamp(System.currentTimeMillis()));
resources.setExpTime(new Timestamp(System.currentTimeMillis() + 86400000 * resources.getExpDay()));
return tbShopStorageMapper.toDto(tbShopStorageRepository.save(resources));

View File

@@ -18,6 +18,9 @@ package cn.ysk.cashier.service.impl.shopimpl;
import cn.ysk.cashier.dto.shop.TbShopUserDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbShopUserMapper;
import cn.ysk.cashier.mybatis.entity.TbUserStorage;
import cn.ysk.cashier.mybatis.mapper.ShopUserMapper;
import cn.ysk.cashier.mybatis.mapper.TagProductDeptsMapper;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
import cn.ysk.cashier.service.shop.TbShopUserService;
@@ -26,7 +29,10 @@ import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.vo.ShopUserInfoVo;
import com.alipay.api.domain.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -52,25 +58,14 @@ public class TbShopUserServiceImpl implements TbShopUserService {
private final TbShopUserRepository tbShopUserRepository;
private final TbShopUserMapper tbShopUserMapper;
@Override
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
Page<ShopUserInfoVo> shopUserJoinUserInfo =
tbShopUserRepository.findShopUserJoinUserInfo(
criteria.getShopId(),
criteria.getIsVip(),
criteria.getTelephone(),
pageable);
return PageUtil.toPage(shopUserJoinUserInfo);
}
@Autowired
private ShopUserMapper shopUserMapper;
@Override
public Map<String, Object> queryAllShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
Page<ShopUserInfoVo> shopUserJoinUserInfo =
tbShopUserRepository.findAllShopUserJoinUserInfo(
criteria.getIsVip(),
criteria.getTelephone(),
pageable);
return PageUtil.toPage(shopUserJoinUserInfo);
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) {
IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria,
new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()));
return PageUtil.toPlusPage(iPage.getRecords(),Integer.valueOf(iPage.getTotal()+""));
}
@Override

View File

@@ -1,5 +1,6 @@
package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.dto.shop.ShopStorageGoodDto;
import cn.ysk.cashier.dto.shop.TbShopStorageGoodDto;
import cn.ysk.cashier.dto.shop.TbShopStorageGoodQueryCriteria;
import cn.ysk.cashier.pojo.shop.TbShopStorageGood;
@@ -43,6 +44,7 @@ public interface TbShopStorageGoodService {
* @return TbShopStorageGoodDto
*/
TbShopStorageGoodDto create(TbShopStorageGood resources);
void create(ShopStorageGoodDto resources);
/**
* 编辑

View File

@@ -18,6 +18,9 @@ package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.dto.shop.TbShopUserDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.vo.ShopUserInfoVo;
import com.alipay.api.domain.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
@@ -36,12 +39,10 @@ public interface TbShopUserService {
/**
* 商家后台 用户管理
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria, Pageable pageable);
Map<String, Object> queryAllShopUser(TbShopUserQueryCriteria criteria, Pageable pageable);
Map<String,Object> queryShopUser(TbShopUserQueryCriteria criteria);
/**
* 会员管理