商品券
This commit is contained in:
@@ -34,6 +34,7 @@ public interface TbCouponProductMapper {
|
|||||||
|
|
||||||
List<TbCouponProduct> queryAllByCouponId(Integer couponId);
|
List<TbCouponProduct> queryAllByCouponId(Integer couponId);
|
||||||
List<String> queryProsByActivateId(@Param("couponId")Integer couponId,@Param("num")Integer num);
|
List<String> queryProsByActivateId(@Param("couponId")Integer couponId,@Param("num")Integer num);
|
||||||
|
List<TbCouponProduct> queryProInfoByActivateId(@Param("couponId")Integer couponId,@Param("num")Integer num);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.entity;
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@@ -9,6 +11,7 @@ import java.io.Serializable;
|
|||||||
* @author ww
|
* @author ww
|
||||||
* @since 2024-10-23 14:35:49
|
* @since 2024-10-23 14:35:49
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class TbCouponProduct implements Serializable {
|
public class TbCouponProduct implements Serializable {
|
||||||
private static final long serialVersionUID = 619724621133545616L;
|
private static final long serialVersionUID = 619724621133545616L;
|
||||||
|
|
||||||
@@ -21,6 +24,8 @@ public class TbCouponProduct implements Serializable {
|
|||||||
* 商品id
|
* 商品id
|
||||||
*/
|
*/
|
||||||
private Integer productId;
|
private Integer productId;
|
||||||
|
private String proName;
|
||||||
|
private String proImg;
|
||||||
/**
|
/**
|
||||||
* 数量
|
* 数量
|
||||||
*/
|
*/
|
||||||
@@ -30,54 +35,5 @@ public class TbCouponProduct implements Serializable {
|
|||||||
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCouponId() {
|
|
||||||
return couponId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCouponId(Integer couponId) {
|
|
||||||
this.couponId = couponId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getProductId() {
|
|
||||||
return productId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProductId(Integer productId) {
|
|
||||||
this.productId = productId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getNum() {
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNum(Integer num) {
|
|
||||||
this.num = num;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreateTime() {
|
|
||||||
return createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateTime(Date createTime) {
|
|
||||||
this.createTime = createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getUpdateTime() {
|
|
||||||
return updateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdateTime(Date updateTime) {
|
|
||||||
this.updateTime = updateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class TbShopShare implements Serializable {
|
|||||||
//使用描述
|
//使用描述
|
||||||
private String useDetail;
|
private String useDetail;
|
||||||
//商品描述
|
//商品描述
|
||||||
private List<String> gives;
|
private List<TbCouponProduct> gives;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (TbShopShareRecord)实体类
|
* (TbShopShareRecord)实体类
|
||||||
@@ -45,6 +46,7 @@ public class TbShopShareRecord extends BasePageDto implements Serializable {
|
|||||||
* 奖励券获得方式 get/use 领取获得/使用获得
|
* 奖励券获得方式 get/use 领取获得/使用获得
|
||||||
*/
|
*/
|
||||||
private String method;
|
private String method;
|
||||||
|
private List<TbShopShare.ShareCoupons> newCoupons;
|
||||||
/**
|
/**
|
||||||
* 1 未领取 2 已领取 3 已使用
|
* 1 未领取 2 已领取 3 已使用
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
|||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -20,6 +21,7 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,11 +115,11 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
|||||||
@Override
|
@Override
|
||||||
public Result insert(TbShopShareRecord tbShopShareRecord) {
|
public Result insert(TbShopShareRecord tbShopShareRecord) {
|
||||||
TbShopUser shopUserInfo = getShopUserInfo(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
|
TbShopUser shopUserInfo = getShopUserInfo(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
|
||||||
|
TbShopShare tbShopShare = tbShopShareMapper.queryById(tbShopShareRecord.getShareId());
|
||||||
TbShopShareRecord query = tbShopShareRecordMapper.queryByData(
|
TbShopShareRecord query = tbShopShareRecordMapper.queryByData(
|
||||||
tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(),
|
tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(),
|
||||||
tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId());
|
tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId());
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
TbShopShare tbShopShare = tbShopShareMapper.queryById(tbShopShareRecord.getShareId());
|
|
||||||
tbShopShareRecord.setMethod(tbShopShare.getGetMethod());
|
tbShopShareRecord.setMethod(tbShopShare.getGetMethod());
|
||||||
tbShopShareRecord.setShopId(tbShopShareRecord.getShopId());
|
tbShopShareRecord.setShopId(tbShopShareRecord.getShopId());
|
||||||
tbShopShareRecord.setCreateTime(new Date());
|
tbShopShareRecord.setCreateTime(new Date());
|
||||||
@@ -146,6 +148,24 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
|||||||
if (query == null) {
|
if (query == null) {
|
||||||
query = tbShopShareRecord;
|
query = tbShopShareRecord;
|
||||||
}
|
}
|
||||||
|
for (TbShopShare.ShareCoupons newCoupon : tbShopShare.getNewCoupons()) {
|
||||||
|
TbShopCoupon coupon = couponMapper.queryById(newCoupon.getCouponId());
|
||||||
|
if (coupon != null) {
|
||||||
|
if (coupon.getType() == 1) {
|
||||||
|
//满减
|
||||||
|
newCoupon.setType(1);
|
||||||
|
newCoupon.setFullAmount(coupon.getFullAmount());
|
||||||
|
newCoupon.setDiscountAmount(coupon.getDiscountAmount());
|
||||||
|
newCoupon.setUseDetail(setCouponInfo(coupon));
|
||||||
|
} else if (coupon.getType() == 2) {
|
||||||
|
//商品
|
||||||
|
newCoupon.setType(2);
|
||||||
|
newCoupon.setUseDetail(setCouponInfo(coupon));
|
||||||
|
newCoupon.setGives(couProductMapper.queryProInfoByActivateId(coupon.getId(), newCoupon.getCouponNum()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.setNewCoupons(tbShopShare.getNewCoupons());
|
||||||
return Result.successWithData(query);
|
return Result.successWithData(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,4 +289,27 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String setCouponInfo(TbShopCoupon tbShopCoupon) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||||
|
StringBuilder useRestrictions = new StringBuilder("每天 ");
|
||||||
|
if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) {
|
||||||
|
String[] split = tbShopCoupon.getUserDays().split(",");
|
||||||
|
if (split.length != 7) {
|
||||||
|
useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(tbShopCoupon.getUseTimeType()) && tbShopCoupon.getUseTimeType().equals("custom")) {
|
||||||
|
useRestrictions.append(
|
||||||
|
tbShopCoupon.getUseStartTime().format(formatter)
|
||||||
|
+ "-"
|
||||||
|
+ tbShopCoupon.getUseEndTime().format(formatter));
|
||||||
|
} else {
|
||||||
|
useRestrictions.append("全时段");
|
||||||
|
}
|
||||||
|
useRestrictions.append(" 可用");
|
||||||
|
|
||||||
|
return useRestrictions.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class TbShopShareServiceImpl implements TbShopShareService {
|
|||||||
//商品
|
//商品
|
||||||
newCoupon.setType(2);
|
newCoupon.setType(2);
|
||||||
newCoupon.setUseDetail(setCouponInfo(coupon));
|
newCoupon.setUseDetail(setCouponInfo(coupon));
|
||||||
newCoupon.setGives(couProductMapper.queryProsByActivateId(coupon.getId(), newCoupon.getCouponNum()));
|
newCoupon.setGives(couProductMapper.queryProInfoByActivateId(coupon.getId(), newCoupon.getCouponNum()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class TbShopShareServiceImpl implements TbShopShareService {
|
|||||||
//商品
|
//商品
|
||||||
rewardCoupon.setType(2);
|
rewardCoupon.setType(2);
|
||||||
rewardCoupon.setUseDetail(setCouponInfo(coupon));
|
rewardCoupon.setUseDetail(setCouponInfo(coupon));
|
||||||
rewardCoupon.setGives(couProductMapper.queryProsByActivateId(coupon.getId(), rewardCoupon.getCouponNum()));
|
rewardCoupon.setGives(couProductMapper.queryProInfoByActivateId(coupon.getId(), rewardCoupon.getCouponNum()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,14 @@
|
|||||||
group by tb_coupon_product.product_id
|
group by tb_coupon_product.product_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryProInfoByActivateId" resultType="com.chaozhanggui.system.cashierservice.entity.TbCouponProduct" >
|
||||||
|
select tb_coupon_product.*,tb_product name as proName,tb_product.cover_img as proImg SUM(tb_coupon_product.num)*#{num} as num
|
||||||
|
from tb_coupon_product
|
||||||
|
LEFT JOIN tb_product ON tb_coupon_product.product_id = tb_product.id
|
||||||
|
where coupon_id = #{couponId}
|
||||||
|
group by tb_coupon_product.product_id
|
||||||
|
</select>
|
||||||
|
|
||||||
<!--新增所有列-->
|
<!--新增所有列-->
|
||||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||||
insert into tb_coupon_product(coupon_id, product_id, num, create_time, update_time)
|
insert into tb_coupon_product(coupon_id, product_id, num, create_time, update_time)
|
||||||
|
|||||||
Reference in New Issue
Block a user