后台日志管理,优惠卷列表以及增加优惠卷

This commit is contained in:
liuyingfang
2024-03-21 09:20:09 +08:00
parent 42f401469a
commit 1981baeb94
15 changed files with 795 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
/*
* 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.shopimpl;
import cn.ysk.cashier.pojo.shop.TbMerchantCoupon;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.repository.shop.TbMerchantCouponRepository;
import cn.ysk.cashier.service.shop.TbMerchantCouponService;
import cn.ysk.cashier.dto.shop.TbMerchantCouponDto;
import cn.ysk.cashier.dto.shop.TbMerchantCouponQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbMerchantCouponMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.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-03-20
**/
@Service
@RequiredArgsConstructor
public class TbMerchantCouponServiceImpl implements TbMerchantCouponService {
private final TbMerchantCouponRepository tbMerchantCouponRepository;
private final TbMerchantCouponMapper tbMerchantCouponMapper;
@Override
public Map<String,Object> queryAll(TbMerchantCouponQueryCriteria criteria, Pageable pageable){
Page<TbMerchantCoupon> page = tbMerchantCouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbMerchantCouponMapper::toDto));
}
@Override
public List<TbMerchantCouponDto> queryAll(TbMerchantCouponQueryCriteria criteria){
return tbMerchantCouponMapper.toDto(tbMerchantCouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public TbMerchantCouponDto findById(Integer id) {
TbMerchantCoupon tbMerchantCoupon = tbMerchantCouponRepository.findById(id).orElseGet(TbMerchantCoupon::new);
ValidationUtil.isNull(tbMerchantCoupon.getId(),"TbMerchantCoupon","id",id);
return tbMerchantCouponMapper.toDto(tbMerchantCoupon);
}
@Override
@Transactional(rollbackFor = Exception.class)
public TbMerchantCouponDto create(TbMerchantCoupon resources) {
return tbMerchantCouponMapper.toDto(tbMerchantCouponRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbMerchantCoupon resources) {
TbMerchantCoupon tbMerchantCoupon = tbMerchantCouponRepository.findById(resources.getId()).orElseGet(TbMerchantCoupon::new);
ValidationUtil.isNull( tbMerchantCoupon.getId(),"TbMerchantCoupon","id",resources.getId());
tbMerchantCoupon.copy(resources);
tbMerchantCouponRepository.save(tbMerchantCoupon);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
tbMerchantCouponRepository.deleteById(id);
}
}
@Override
public void download(List<TbMerchantCouponDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbMerchantCouponDto tbMerchantCoupon : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("状态0-关闭 1 正常", tbMerchantCoupon.getStatus());
map.put(" 优惠券名称", tbMerchantCoupon.getTitle());
map.put(" templateId", tbMerchantCoupon.getTemplateId());
map.put(" shopId", tbMerchantCoupon.getShopId());
map.put(" shopSnap", tbMerchantCoupon.getShopSnap());
map.put("开始时间", tbMerchantCoupon.getFromTime());
map.put("到期时间", tbMerchantCoupon.getToTime());
map.put("限领数量", tbMerchantCoupon.getLimitNumber());
map.put("发放数量", tbMerchantCoupon.getNumber());
map.put("剩余数量", tbMerchantCoupon.getLeftNumber());
map.put("优惠金额", tbMerchantCoupon.getAmount());
map.put("订单满赠金额", tbMerchantCoupon.getLimitAmount());
map.put("是否显示0-不显示 1显示", tbMerchantCoupon.getIsShow());
map.put("图标", tbMerchantCoupon.getPic());
map.put("0-满减 1-折扣", tbMerchantCoupon.getType());
map.put("折扣 ,一位小数", tbMerchantCoupon.getRatio());
map.put("最大折扣金额", tbMerchantCoupon.getMaxRatioAmount());
map.put("优惠券途径,首充|分销", tbMerchantCoupon.getTrack());
map.put("品类product 商品券 ---cateogry 品类券common -通 用券", tbMerchantCoupon.getClassType());
map.put("有效期类型0-toTime有效 1-effectDays有效", tbMerchantCoupon.getEffectType());
map.put("领取之日有效天数", tbMerchantCoupon.getEffectDays());
map.put("关联商品Id", tbMerchantCoupon.getRelationIds());
map.put(" relationList", tbMerchantCoupon.getRelationList());
map.put("发放人", tbMerchantCoupon.getEditor());
map.put("说明", tbMerchantCoupon.getNote());
map.put(" createdAt", tbMerchantCoupon.getCreatedAt());
map.put(" updatedAt", tbMerchantCoupon.getUpdatedAt());
map.put("支持堂食", tbMerchantCoupon.getFurnishMeal());
map.put("支持配送", tbMerchantCoupon.getFurnishExpress());
map.put("支持自提", tbMerchantCoupon.getFurnishDraw());
map.put("支持虚拟", tbMerchantCoupon.getFurnishVir());
map.put(" disableDistribute", tbMerchantCoupon.getDisableDistribute());
map.put("商户Id", tbMerchantCoupon.getMerchantId());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@@ -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 cn.ysk.cashier.service.shop;
import cn.ysk.cashier.pojo.shop.TbMerchantCoupon;
import cn.ysk.cashier.dto.shop.TbMerchantCouponDto;
import cn.ysk.cashier.dto.shop.TbMerchantCouponQueryCriteria;
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-03-20
**/
public interface TbMerchantCouponService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TbMerchantCouponQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbMerchantCouponDto>
*/
List<TbMerchantCouponDto> queryAll(TbMerchantCouponQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TbMerchantCouponDto
*/
TbMerchantCouponDto findById(Integer id);
/**
* 创建
* @param resources /
* @return TbMerchantCouponDto
*/
TbMerchantCouponDto create(TbMerchantCoupon resources);
/**
* 编辑
* @param resources /
*/
void update(TbMerchantCoupon resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<TbMerchantCouponDto> all, HttpServletResponse response) throws IOException;
}