优惠卷相关
This commit is contained in:
@@ -51,6 +51,12 @@ public class TbProductController {
|
||||
return new ResponseEntity<>(tbProductService.queryAll(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/isHot")
|
||||
public ResponseEntity<Object> updateIsHot(@RequestParam String shopId, @RequestParam Integer id){
|
||||
tbProductService.updateIsHot(id,shopId);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@GetMapping("/{product}")
|
||||
@Log("查询/product")
|
||||
@ApiOperation("查询/product")
|
||||
|
||||
@@ -18,6 +18,7 @@ package cn.ysk.cashier.dto.shop;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -44,10 +45,10 @@ public class TbMerchantCouponDto implements Serializable {
|
||||
private String shopSnap;
|
||||
|
||||
/** 开始时间 */
|
||||
private Long fromTime;
|
||||
private Timestamp fromTime;
|
||||
|
||||
/** 到期时间 */
|
||||
private Long toTime;
|
||||
private Timestamp toTime;
|
||||
|
||||
/** 限领数量 */
|
||||
private Integer limitNumber;
|
||||
|
||||
@@ -169,4 +169,6 @@ public class TbShopInfoDto implements Serializable {
|
||||
private String password;
|
||||
|
||||
private String profiles;
|
||||
|
||||
private String isOpenYhq;
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -31,7 +32,6 @@ import java.io.Serializable;
|
||||
* @date 2024-03-20
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_merchant_coupon")
|
||||
public class TbMerchantCoupon implements Serializable {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TbMerchantCoupon implements Serializable {
|
||||
@Column(name = "`template_id`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "templateId")
|
||||
private String templateId;
|
||||
private String templateId = "0";
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "shopId")
|
||||
@@ -62,15 +62,13 @@ public class TbMerchantCoupon implements Serializable {
|
||||
@ApiModelProperty(value = "shopSnap")
|
||||
private String shopSnap;
|
||||
|
||||
@Column(name = "`from_time`",nullable = false)
|
||||
@NotNull
|
||||
@Column(name = "`from_time`")
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Long fromTime;
|
||||
private Timestamp fromTime;
|
||||
|
||||
@Column(name = "`to_time`",nullable = false)
|
||||
@NotNull
|
||||
@Column(name = "`to_time`")
|
||||
@ApiModelProperty(value = "到期时间")
|
||||
private Long toTime;
|
||||
private Timestamp toTime;
|
||||
|
||||
@Column(name = "`limit_number`")
|
||||
@ApiModelProperty(value = "限领数量")
|
||||
@@ -81,7 +79,6 @@ public class TbMerchantCoupon implements Serializable {
|
||||
private Integer number;
|
||||
|
||||
@Column(name = "`left_number`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "剩余数量")
|
||||
private Integer leftNumber;
|
||||
|
||||
@@ -118,11 +115,13 @@ public class TbMerchantCoupon implements Serializable {
|
||||
private String track;
|
||||
|
||||
@Column(name = "`class_type`")
|
||||
@ApiModelProperty(value = "品类product 商品券 ---cateogry 品类券common -通 用券")
|
||||
@ApiModelProperty(value = "品类product 商品券 ---cateogry 品类券common -通用券")
|
||||
@NotNull
|
||||
private String classType;
|
||||
|
||||
@Column(name = "`effect_type`")
|
||||
@ApiModelProperty(value = "有效期类型:0-toTime有效 1-effectDays有效")
|
||||
@NotNull
|
||||
private Integer effectType;
|
||||
|
||||
@Column(name = "`effect_days`")
|
||||
@@ -182,4 +181,276 @@ public class TbMerchantCoupon implements Serializable {
|
||||
public void copy(TbMerchantCoupon source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(String shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getShopSnap() {
|
||||
return shopSnap;
|
||||
}
|
||||
|
||||
public void setShopSnap(String shopSnap) {
|
||||
this.shopSnap = shopSnap;
|
||||
}
|
||||
|
||||
public Timestamp getFromTime() {
|
||||
return fromTime;
|
||||
}
|
||||
|
||||
public void setFromTime(Timestamp fromTime) {
|
||||
this.fromTime = fromTime;
|
||||
}
|
||||
|
||||
public Timestamp getToTime() {
|
||||
return toTime;
|
||||
}
|
||||
|
||||
public void setToTime(Timestamp toTime) {
|
||||
this.toTime = toTime;
|
||||
}
|
||||
|
||||
public Integer getLimitNumber() {
|
||||
return limitNumber;
|
||||
}
|
||||
|
||||
public void setLimitNumber(Integer limitNumber) {
|
||||
this.limitNumber = limitNumber;
|
||||
}
|
||||
|
||||
public Integer getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Integer number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public Integer getLeftNumber() {
|
||||
return leftNumber;
|
||||
}
|
||||
|
||||
public void setLeftNumber(Integer leftNumber) {
|
||||
this.leftNumber = leftNumber;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public BigDecimal getLimitAmount() {
|
||||
return limitAmount;
|
||||
}
|
||||
|
||||
public void setLimitAmount(BigDecimal limitAmount) {
|
||||
this.limitAmount = limitAmount;
|
||||
}
|
||||
|
||||
public Integer getIsShow() {
|
||||
return isShow;
|
||||
}
|
||||
|
||||
public void setIsShow(Integer isShow) {
|
||||
this.isShow = isShow;
|
||||
}
|
||||
|
||||
public String getPic() {
|
||||
return pic;
|
||||
}
|
||||
|
||||
public void setPic(String pic) {
|
||||
this.pic = pic;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Float getRatio() {
|
||||
return ratio;
|
||||
}
|
||||
|
||||
public void setRatio(Float ratio) {
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
public BigDecimal getMaxRatioAmount() {
|
||||
return maxRatioAmount;
|
||||
}
|
||||
|
||||
public void setMaxRatioAmount(BigDecimal maxRatioAmount) {
|
||||
this.maxRatioAmount = maxRatioAmount;
|
||||
}
|
||||
|
||||
public String getTrack() {
|
||||
return track;
|
||||
}
|
||||
|
||||
public void setTrack(String track) {
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
public String getClassType() {
|
||||
return classType;
|
||||
}
|
||||
|
||||
public void setClassType(String classType) {
|
||||
this.classType = classType;
|
||||
}
|
||||
|
||||
public Integer getEffectType() {
|
||||
return effectType;
|
||||
}
|
||||
|
||||
public void setEffectType(Integer effectType) {
|
||||
this.effectType = effectType;
|
||||
}
|
||||
|
||||
public Integer getEffectDays() {
|
||||
return effectDays;
|
||||
}
|
||||
|
||||
public void setEffectDays(Integer effectDays) {
|
||||
this.effectDays = effectDays;
|
||||
}
|
||||
|
||||
public String getRelationIds() {
|
||||
return relationIds;
|
||||
}
|
||||
|
||||
public void setRelationIds(String relationIds) {
|
||||
this.relationIds = relationIds;
|
||||
}
|
||||
|
||||
public String getRelationList() {
|
||||
return relationList;
|
||||
}
|
||||
|
||||
public void setRelationList(String relationList) {
|
||||
this.relationList = relationList;
|
||||
}
|
||||
|
||||
public String getEditor() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void setEditor(String editor) {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Integer getFurnishMeal() {
|
||||
return furnishMeal;
|
||||
}
|
||||
|
||||
public void setFurnishMeal(Integer furnishMeal) {
|
||||
this.furnishMeal = furnishMeal;
|
||||
}
|
||||
|
||||
public Integer getFurnishExpress() {
|
||||
return furnishExpress;
|
||||
}
|
||||
|
||||
public void setFurnishExpress(Integer furnishExpress) {
|
||||
this.furnishExpress = furnishExpress;
|
||||
}
|
||||
|
||||
public Integer getFurnishDraw() {
|
||||
return furnishDraw;
|
||||
}
|
||||
|
||||
public void setFurnishDraw(Integer furnishDraw) {
|
||||
this.furnishDraw = furnishDraw;
|
||||
}
|
||||
|
||||
public Integer getFurnishVir() {
|
||||
return furnishVir;
|
||||
}
|
||||
|
||||
public void setFurnishVir(Integer furnishVir) {
|
||||
this.furnishVir = furnishVir;
|
||||
}
|
||||
|
||||
public Integer getDisableDistribute() {
|
||||
return disableDistribute;
|
||||
}
|
||||
|
||||
public void setDisableDistribute(Integer disableDistribute) {
|
||||
this.disableDistribute = disableDistribute;
|
||||
}
|
||||
|
||||
public String getMerchantId() {
|
||||
return merchantId;
|
||||
}
|
||||
|
||||
public void setMerchantId(String merchantId) {
|
||||
this.merchantId = merchantId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +217,10 @@ public class TbShopInfo implements Serializable {
|
||||
@Column(name = "profiles")
|
||||
@ApiModelProperty(value = "未激活 no 试用probation 正式release")
|
||||
private String profiles="";
|
||||
// @Column(name = "is_open_yhq")
|
||||
// @ApiModelProperty(value = "是否参与优惠券活动 0否 1是")
|
||||
@Transient
|
||||
private String isOpenYhq;
|
||||
|
||||
public void copy(TbShopInfo source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package cn.ysk.cashier.repository.product;
|
||||
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
@@ -37,4 +38,11 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
|
||||
@Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true)
|
||||
@Modifying
|
||||
void updateByStatus(List<Integer> productIds);
|
||||
@Query(value = "update tb_product set is_hot=1 where id = :id",nativeQuery = true)
|
||||
@Modifying
|
||||
void updateIsHot(@Param("id") Integer id);
|
||||
|
||||
@Query(value = "update tb_product set is_hot=0 where shop_id = :shopId and is_hot = 1",nativeQuery = true)
|
||||
@Modifying
|
||||
void updateNullHot(@Param("shopId")String shopId);
|
||||
}
|
||||
@@ -386,6 +386,13 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateIsHot(Integer id, String shopId) {
|
||||
tbProductRepository.updateNullHot(shopId);
|
||||
tbProductRepository.updateIsHot(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteAll(Integer[] ids) {
|
||||
|
||||
@@ -15,27 +15,33 @@
|
||||
*/
|
||||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantCoupon;
|
||||
import cn.ysk.cashier.repository.product.TbProductRepository;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.vo.CouponVO;
|
||||
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.beans.BeanUtils;
|
||||
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.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -49,13 +55,30 @@ public class TbMerchantCouponServiceImpl implements TbMerchantCouponService {
|
||||
|
||||
private final TbMerchantCouponRepository tbMerchantCouponRepository;
|
||||
private final TbMerchantCouponMapper tbMerchantCouponMapper;
|
||||
private final TbProductRepository tbProductRepository;
|
||||
|
||||
@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));
|
||||
List<CouponVO> objects = new ArrayList<>();
|
||||
for (TbMerchantCoupon o :page.getContent()) {
|
||||
CouponVO couponVO = new CouponVO();
|
||||
BeanUtils.copyProperties(o,couponVO);
|
||||
if (!o.getRelationIds().isEmpty()) {
|
||||
List<Integer> integers = new ArrayList<>();
|
||||
integers.add(Integer.valueOf(o.getRelationIds()));
|
||||
List<TbProduct> byIds = tbProductRepository.findByIds(integers);
|
||||
couponVO.setName(byIds.get(0).getName());
|
||||
couponVO.setCoverImg(byIds.get(0).getCoverImg());
|
||||
}
|
||||
objects.add(couponVO);
|
||||
}
|
||||
HashMap<String, Object> couponvoMap = new HashMap<>();
|
||||
couponvoMap.put("content", objects);
|
||||
couponvoMap.put("totalElements", page.getTotalElements());
|
||||
return couponvoMap;
|
||||
// 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)));
|
||||
@@ -71,8 +94,29 @@ public class TbMerchantCouponServiceImpl implements TbMerchantCouponService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbMerchantCouponDto create(TbMerchantCoupon resources) {
|
||||
return tbMerchantCouponMapper.toDto(tbMerchantCouponRepository.save(resources));
|
||||
public TbMerchantCoupon create(TbMerchantCoupon resources) {
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
if (resources.getEffectType() == 1){
|
||||
if (resources.getToTime() == null && resources.getFromTime() == null){
|
||||
throw new BadRequestException("开始时间结束时间为空");
|
||||
}
|
||||
}else {
|
||||
resources.setToTime(null);
|
||||
resources.setFromTime(null);
|
||||
}
|
||||
|
||||
if ("product".equals(resources.getClassType())){
|
||||
if (resources.getRelationIds() == null){
|
||||
throw new BadRequestException("商品不能为空");
|
||||
}
|
||||
}
|
||||
if (resources.getNumber() == 0){
|
||||
resources.setLeftNumber(0);
|
||||
}else {
|
||||
resources.setLeftNumber(resources.getNumber());
|
||||
}
|
||||
return tbMerchantCouponRepository.save(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -142,6 +142,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
tbShopInfo.setCreatedAt(Instant.now().toEpochMilli());
|
||||
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
tbShopInfo.setOnSale(1);
|
||||
tbShopInfo.setIsOpenYhq(resources.getIsOpenYhq());
|
||||
//激活码
|
||||
TbMerchantRegister tbMerchantRegister = new TbMerchantRegister();
|
||||
if (resources.getRegisterCode() != null){
|
||||
|
||||
@@ -85,4 +85,6 @@ public interface TbProductService {
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbProductDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
void updateIsHot(Integer id, String shopId);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public interface TbMerchantCouponService {
|
||||
* @param resources /
|
||||
* @return TbMerchantCouponDto
|
||||
*/
|
||||
TbMerchantCouponDto create(TbMerchantCoupon resources);
|
||||
TbMerchantCoupon create(TbMerchantCoupon resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
|
||||
29
eladmin-system/src/main/java/cn/ysk/cashier/vo/CouponVO.java
Normal file
29
eladmin-system/src/main/java/cn/ysk/cashier/vo/CouponVO.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package cn.ysk.cashier.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class CouponVO {
|
||||
private BigDecimal amount;
|
||||
private String classType;
|
||||
private Integer effectDays;
|
||||
private Integer leftNumber;
|
||||
private BigDecimal limitAmount;
|
||||
private Integer limitNumber;
|
||||
private Integer number;
|
||||
private Float ratio;
|
||||
private Integer status;
|
||||
private String name;
|
||||
private String coverImg;
|
||||
private String title;
|
||||
private Integer type;
|
||||
private Integer effectType;
|
||||
private Timestamp fromTime;
|
||||
private Timestamp toTime;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#server:
|
||||
# port: 8000
|
||||
server:
|
||||
port: 8000
|
||||
|
||||
spring:
|
||||
freemarker:
|
||||
|
||||
Reference in New Issue
Block a user