Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松
2024-11-09 09:32:11 +08:00
15 changed files with 145 additions and 181 deletions

View File

@@ -45,7 +45,6 @@ public class LoginFilter implements Filter {
"cashierService/home",//首页
"cashierService/order/testMessage",//首页
"cashierService/common/**",//通用接口
"cashierService/tbShopShare/**",//通用接口
"cashierService/distirict/**",//首页其它接口
// "cashierService/login/**",//登录部分接口不校验

View File

@@ -34,6 +34,7 @@ public interface TbCouponProductMapper {
List<TbCouponProduct> queryAllByCouponId(Integer couponId);
List<String> queryProsByActivateId(@Param("couponId")Integer couponId,@Param("num")Integer num);
List<TbCouponProduct> queryProInfoByActivateId(@Param("couponId")Integer couponId,@Param("num")Integer num);
/**

View File

@@ -1,10 +1,12 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* (TbShopShareRecord)表数据库访问层
@@ -37,6 +39,10 @@ public interface TbShopShareRecordMapper {
* @return 对象列表
*/
List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord);
Map<String,Object> statisticsRecord(TbShopShareRecord tbShopShareRecord);
List<TbShopShareRecord> queryIsSuccess(TbShopShareRecord tbShopShareRecord);
List<TbShopShareRecord> queryIsNoSuccess(TbShopShareRecord tbShopShareRecord);
/**

View File

@@ -1,5 +1,7 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
@@ -9,6 +11,7 @@ import java.io.Serializable;
* @author ww
* @since 2024-10-23 14:35:49
*/
@Data
public class TbCouponProduct implements Serializable {
private static final long serialVersionUID = 619724621133545616L;
@@ -21,6 +24,8 @@ public class TbCouponProduct implements Serializable {
* 商品id
*/
private Integer productId;
private String proName;
private String proImg;
/**
* 数量
*/
@@ -30,54 +35,5 @@ public class TbCouponProduct implements Serializable {
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;
}
}

View File

@@ -125,7 +125,7 @@ public class TbShopShare implements Serializable {
//使用描述
private String useDetail;
//商品描述
private List<String> gives;
private List<TbCouponProduct> gives;
}
}

View File

@@ -1,7 +1,11 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.chaozhanggui.system.cashierservice.entity.dto.BasePageDto;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
import java.util.List;
/**
* (TbShopShareRecord)实体类
@@ -9,7 +13,8 @@ import java.io.Serializable;
* @author ww
* @since 2024-11-07 15:50:04
*/
public class TbShopShareRecord implements Serializable {
@Data
public class TbShopShareRecord extends BasePageDto implements Serializable {
private static final long serialVersionUID = -41620929736900271L;
private Integer id;
@@ -41,10 +46,12 @@ public class TbShopShareRecord implements Serializable {
* 奖励券获得方式 get/use 领取获得/使用获得
*/
private String method;
private List<TbShopShare.ShareCoupons> newCoupons;
/**
* 1 未领取 2 已领取 3 已使用
*/
private Integer status;
private boolean success = true;
/**
* 生效时间/获得奖励的时间
*/
@@ -54,103 +61,5 @@ public class TbShopShareRecord implements Serializable {
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getShareId() {
return shareId;
}
public void setShareId(Integer shareId) {
this.shareId = shareId;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getInvitedId() {
return invitedId;
}
public void setInvitedId(Integer invitedId) {
this.invitedId = invitedId;
}
public String getInvitedName() {
return invitedName;
}
public void setInvitedName(String invitedName) {
this.invitedName = invitedName;
}
public Integer getBeInvitedId() {
return beInvitedId;
}
public void setBeInvitedId(Integer beInvitedId) {
this.beInvitedId = beInvitedId;
}
public String getBeInvitedName() {
return beInvitedName;
}
public void setBeInvitedName(String beInvitedName) {
this.beInvitedName = beInvitedName;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getRewardTime() {
return rewardTime;
}
public void setRewardTime(Date rewardTime) {
this.rewardTime = rewardTime;
}
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;
}
}

View File

@@ -1,11 +0,0 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
@Data
public class UserCouponDto extends BasePageDto{
private Integer userId;
private Integer status;
private Integer shopId;
}

View File

@@ -12,6 +12,7 @@ public class TbUserCouponVo {
private BigDecimal fullAmount;
private BigDecimal discountAmount;
private Integer couponId;
private Integer shopId;
private Integer proId;
//优惠券名称
private String name;

View File

@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import java.util.List;
import java.util.Map;
/**
* (TbShopShareRecord)表服务接口
@@ -29,7 +30,7 @@ public interface TbShopShareRecordService {
* @param tbShopShareRecord 筛选条件
* @return 查询结果
*/
List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord);
Map query(TbShopShareRecord tbShopShareRecord);
Result receive(TbShopShareRecord tbShopShareRecord);

View File

@@ -7,7 +7,11 @@ import cn.hutool.core.util.RandomUtil;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@@ -17,9 +21,8 @@ import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* (TbShopShareRecord)表服务实现类
@@ -63,12 +66,26 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
* @return 查询结果
*/
@Override
public List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord) {
List<TbShopShareRecord> records = tbShopShareRecordMapper.query(tbShopShareRecord);
public Map query(TbShopShareRecord tbShopShareRecord) {
Map<String, Object> result = tbShopShareRecordMapper.statisticsRecord(tbShopShareRecord);
if(CollectionUtil.isEmpty(result)){
result=new HashMap<>();
result.put("isSuccess",0);
result.put("isFail",0);
}
PageHelper.startPage(tbShopShareRecord.getPage(), tbShopShareRecord.getSize());
List<TbShopShareRecord> records;
if(tbShopShareRecord.isSuccess()){
records = tbShopShareRecordMapper.queryIsSuccess(tbShopShareRecord);
}else {
records = tbShopShareRecordMapper.queryIsNoSuccess(tbShopShareRecord);
}
for (TbShopShareRecord shareRecord : records) {
shareRecord.setBeInvitedName(userInfoMapper.selectNameByPrimaryKey(shareRecord.getBeInvitedId()));
}
return records;
result.put("records",new PageInfo<>());
return result;
}
@Override
@@ -103,11 +120,11 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
@Override
public Result insert(TbShopShareRecord tbShopShareRecord) {
TbShopUser shopUserInfo = getShopUserInfo(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
TbShopShare tbShopShare = tbShopShareMapper.queryById(tbShopShareRecord.getShareId());
TbShopShareRecord query = tbShopShareRecordMapper.queryByData(
tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(),
tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId());
if (query == null) {
TbShopShare tbShopShare = tbShopShareMapper.queryById(tbShopShareRecord.getShareId());
tbShopShareRecord.setMethod(tbShopShare.getGetMethod());
tbShopShareRecord.setShopId(tbShopShareRecord.getShopId());
tbShopShareRecord.setCreateTime(new Date());
@@ -116,19 +133,13 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
query.setUpdateTime(new Date());
}
if (shopUserInfo == null) {
if (query != null) {
query.setStatus(1);
tbShopShareRecordMapper.update(query);
} else {
if (query == null) {
tbShopShareRecord.setStatus(1);
tbShopShareRecordMapper.insert(tbShopShareRecord);
}
saveShopUser(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
} else {
if (query != null) {
query.setStatus(0);
tbShopShareRecordMapper.update(query);
} else {
if (query == null){
tbShopShareRecord.setStatus(0);
tbShopShareRecordMapper.insert(tbShopShareRecord);
}
@@ -136,6 +147,24 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
if (query == null) {
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);
}
@@ -229,6 +258,7 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
record.setNum(newCoupon.getCouponNum());
record.setOverNum(newCoupon.getCouponNum());
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
record.setCreateTime(new Date());
record.setSourceActId(shopShare.getId());
record.setUseStartTime(start);
record.setUseEndTime(end);
@@ -250,6 +280,7 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
record.setSourceActId(shopShare.getId());
record.setUseStartTime(start);
record.setUseEndTime(end);
record.setCreateTime(new Date());
record.setSource("invited");
actGiveRecords.add(record);
}
@@ -259,4 +290,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();
}
}

View File

@@ -50,7 +50,7 @@ public class TbShopShareServiceImpl implements TbShopShareService {
//商品
newCoupon.setType(2);
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.setUseDetail(setCouponInfo(coupon));
rewardCoupon.setGives(couProductMapper.queryProsByActivateId(coupon.getId(), rewardCoupon.getCouponNum()));
rewardCoupon.setGives(couProductMapper.queryProInfoByActivateId(coupon.getId(), rewardCoupon.getCouponNum()));
}
}
}

View File

@@ -43,6 +43,7 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu
inRecord.full_amount as fullAmount,
inRecord.discount_amount as discountAmount,
inRecord.coupon_id as couponId,
inRecord.shop_id as shopId,
pro.id as proId,
CASE
WHEN inRecord.type = 1 THEN inRecord.NAME

View File

@@ -41,8 +41,8 @@
from tb_activate
where shop_id = #{shopId}
and amount = #{amount}
order by id desc
and amount &lt;= #{amount}
order by amount desc
limit 1
</select>

View File

@@ -68,6 +68,14 @@
group by tb_coupon_product.product_id
</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 into tb_coupon_product(coupon_id, product_id, num, create_time, update_time)

View File

@@ -92,6 +92,45 @@
</where>
</select>
<select id="statisticsRecord" resultType="java.util.HashMap">
SELECT
SUM(CASE WHEN (`method` = 'get' AND `status`= 2 ) OR ( `method` = 'use' AND `status`= 3 ) THEN 1 ELSE 0 END) AS isSuccess,
SUM(CASE WHEN (`method` = 'get' AND `status`!= 2 ) OR ( `method` = 'use' AND `status`!= 3 ) THEN 1 ELSE 0 END) AS isFail
FROM
tb_shop_share_record
WHERE
share_id = #{shareId}
AND invited_id = #{invitedId}
ORDER BY
create_time DESC;
</select>
<select id="queryIsSuccess" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where
share_id = #{shareId}
and invited_id = #{invitedId}
and (`method` = 'get' and status = 2 )
or (`method` = 'use' and status = 3 )
order by create_time desc
</select>
<select id="queryIsNoSuccess" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where
share_id = #{shareId}
and invited_id = #{invitedId}
and (`method` = 'get' and status != 2 )
or (`method` = 'use' and status != 3 )
order by create_time desc
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">