原记录表作废
This commit is contained in:
parent
77ac277856
commit
dca94cc848
|
|
@ -1,118 +0,0 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
@Data
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_activate_coupon_record")
|
||||
public class ShopActivateCouponRecord implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id shopUserId
|
||||
*/
|
||||
private Long shopUserId;
|
||||
|
||||
/**
|
||||
* 卷Id (校验是否可用)
|
||||
*/
|
||||
private Long couponId;
|
||||
|
||||
/**
|
||||
* 卷描述 满10减2/商品卷
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 1-满减 2-商品
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long proId;
|
||||
|
||||
/**
|
||||
* 满多少金额
|
||||
*/
|
||||
private BigDecimal fullAmount;
|
||||
|
||||
/**
|
||||
* 减多少金额
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
@Column(ignore = true)
|
||||
private String shopName;
|
||||
|
||||
/**
|
||||
* 来源活动id
|
||||
*/
|
||||
private Long sourceActId;
|
||||
|
||||
private Long sourceFlowId;
|
||||
|
||||
/**
|
||||
* 可用开始时间
|
||||
*/
|
||||
private LocalDateTime useStartTime;
|
||||
|
||||
/**
|
||||
* 可用结束时间
|
||||
*/
|
||||
private LocalDateTime useEndTime;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
private String couponJson;
|
||||
|
||||
/**
|
||||
* invited 邀请
|
||||
* activate 活动
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 未使用 0
|
||||
* 已使用 1
|
||||
* 已过期 2
|
||||
*/
|
||||
private Integer status;
|
||||
private Long targetId;
|
||||
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.QueryReceiveDto;
|
||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
public interface ShopActivateCouponRecordService extends IService<ShopActivateCouponRecord> {
|
||||
|
||||
|
||||
List<CouponReceiveVo> queryReceive(QueryReceiveDto param);
|
||||
|
||||
List<ShopActivateCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
|
||||
|
||||
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
|
||||
}
|
||||
|
|
@ -98,7 +98,9 @@ public class MkShopCouponRecordDTO implements Serializable {
|
|||
* 过期时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime expiredTime;
|
||||
private LocalDateTime useEndTime;
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime useStartTime;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ public class MkShopCouponRecord implements Serializable {
|
|||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private LocalDateTime expiredTime;
|
||||
private LocalDateTime useEndTime;
|
||||
private LocalDateTime useStartTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
package com.czg.market.service;
|
||||
|
||||
import com.czg.account.dto.QueryReceiveDto;
|
||||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.czg.market.dto.MkShopCouponRecordDTO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券发放记录表 服务层。
|
||||
*
|
||||
|
|
@ -13,6 +18,13 @@ import com.czg.market.entity.MkShopCouponRecord;
|
|||
*/
|
||||
public interface MkShopCouponRecordService extends IService<MkShopCouponRecord> {
|
||||
|
||||
|
||||
List<CouponReceiveVo> queryReceive(QueryReceiveDto param);
|
||||
|
||||
List<MkShopCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
|
||||
|
||||
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
|
||||
|
||||
/**
|
||||
* 优惠券列表/已领取详情
|
||||
* @param search 用户Id/昵称/手机号
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.dto.QueryReceiveDto;
|
||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
public interface ShopActivateCouponRecordMapper extends BaseMapper<ShopActivateCouponRecord> {
|
||||
|
||||
List<CouponReceiveVo> queryReceive(@Param("param") QueryReceiveDto param);
|
||||
|
||||
List<ShopActivateCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
|
||||
|
||||
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.czg.account.dto.QueryReceiveDto;
|
||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||
import com.czg.account.service.ShopActivateCouponRecordService;
|
||||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.czg.service.account.mapper.ShopActivateCouponRecordMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
@DubboService
|
||||
public class ShopActivateCouponRecordServiceImpl extends ServiceImpl<ShopActivateCouponRecordMapper, ShopActivateCouponRecord> implements ShopActivateCouponRecordService {
|
||||
|
||||
@Override
|
||||
public List<CouponReceiveVo> queryReceive(QueryReceiveDto param) {
|
||||
return getMapper().queryReceive(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopActivateCouponRecord> findByUser(List<Long> shopUserIds, Integer status) {
|
||||
return getMapper().findByUser(shopUserIds, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type) {
|
||||
return getMapper().queryByVipIdAndShopId(shopId, shopUserId, type);
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,8 @@ import com.czg.config.RedisCst;
|
|||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.enums.YesNoEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.TbMemberConfigService;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderDetailService;
|
||||
|
|
@ -62,8 +64,8 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||
private UserInfoService userInfoService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private ShopActivateCouponRecordService shopActivateCouponRecordService;
|
||||
@DubboReference
|
||||
private MkShopCouponRecordService couponRecordService;
|
||||
@Resource
|
||||
private ShopInfoMapper shopInfoMapper;
|
||||
@Resource
|
||||
|
|
@ -337,7 +339,11 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||
save(shopUser);
|
||||
shopUser = getById(shopUser.getId());
|
||||
} else {
|
||||
couponNum = shopActivateCouponRecordService.count(new QueryWrapper().eq(ShopActivateCouponRecord::getShopUserId, shopUser.getId()).eq(ShopActivateCouponRecord::getStatus, 0));
|
||||
couponNum = couponRecordService.count(new QueryWrapper()
|
||||
.eq(MkShopCouponRecord::getShopUserId, shopUser.getId())
|
||||
.eq(MkShopCouponRecord::getStatus, 0)
|
||||
.eq(MkShopCouponRecord::getIsDel,0)
|
||||
);
|
||||
}
|
||||
ShopUserDetailDTO shopUserDetailDTO = BeanUtil.copyProperties(shopUser, ShopUserDetailDTO.class);
|
||||
shopUserDetailDTO.setCouponNum(couponNum);
|
||||
|
|
@ -364,7 +370,11 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||
@Override
|
||||
public ShopUser getDetail(Integer id, Integer userId) {
|
||||
ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getUsableShopId()).eq(ShopUser::getId, id).eq(ShopUser::getUserId, userId));
|
||||
long count = shopActivateCouponRecordService.count(new QueryWrapper().eq(ShopActivateCouponRecord::getShopUserId, shopUser.getId()).eq(ShopActivateCouponRecord::getStatus, 0));
|
||||
long count = couponRecordService.count(new QueryWrapper()
|
||||
.eq(MkShopCouponRecord::getShopUserId, shopUser.getId())
|
||||
.eq(MkShopCouponRecord::getStatus, 0)
|
||||
.eq(MkShopCouponRecord::getIsDel,0)
|
||||
);
|
||||
ShopUserDTO shopUserDTO = BeanUtil.copyProperties(shopUser, ShopUserDTO.class);
|
||||
shopUserDTO.setCouponNum(count);
|
||||
shopUserDTO.setOrderNumber(orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, userId).eq(OrderInfo::getShopId, StpKit.USER.getShopId(0L)).eq(OrderInfo::getStatus, "done")));
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopActivateCouponRecordMapper">
|
||||
|
||||
<select id="queryReceive" resultType="com.czg.account.vo.CouponReceiveVo">
|
||||
SELECT
|
||||
record.id,
|
||||
vip.id as userId ,
|
||||
vip.`nick_name`,
|
||||
vip.phone as phone,
|
||||
record.create_time as receiveTime,
|
||||
record.update_time as useTime,
|
||||
record.source as source
|
||||
FROM
|
||||
tb_shop_activate_coupon_record record
|
||||
LEFT JOIN tb_shop_user vip
|
||||
ON record.shop_user_id = vip.id AND vip.shop_id = #{param.shopId}
|
||||
WHERE
|
||||
record.coupon_id = #{param.couponId}
|
||||
and record.shop_id = #{param.shopId}
|
||||
<if test="param.value != null and param.value != '' ">
|
||||
and (vip.name like concat('%', #{param.value}, '%') or vip.telephone like concat('%', #{param.value}, '%'))
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
and record.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.startTime != null ">
|
||||
and record.create_time > #{param.startTime}
|
||||
</if>
|
||||
<if test="param.endTime != null ">
|
||||
and record.create_time < #{param.endTime}
|
||||
</if>
|
||||
order by record.create_time desc
|
||||
</select>
|
||||
<select id="findByUser" resultType="com.czg.account.entity.ShopActivateCouponRecord">
|
||||
select tb_shop_activate_coupon_record.*,tb_shop_info.shop_name
|
||||
from tb_shop_activate_coupon_record
|
||||
left join tb_shop_info on tb_shop_activate_coupon_record.shop_id = tb_shop_info.id
|
||||
where tb_shop_activate_coupon_record.shop_user_id in
|
||||
<foreach collection="shopUserIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<if test="status != null">
|
||||
and tb_shop_activate_coupon_record.status = #{status}
|
||||
</if>
|
||||
order by tb_shop_activate_coupon_record.status , tb_shop_activate_coupon_record.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryByVipIdAndShopId" resultType="com.czg.account.vo.UserCouponVo">
|
||||
SELECT
|
||||
inRecord.id as id,
|
||||
inRecord.shop_id as shopId,
|
||||
shop.shop_name as shopName,
|
||||
inRecord.full_amount as fullAmount,
|
||||
inRecord.discount_amount as discountAmount,
|
||||
inRecord.coupon_id as couponId,
|
||||
pro.id as proId,
|
||||
pro.name as productName,
|
||||
inRecord.name as name,
|
||||
inRecord.type,
|
||||
inRecord.use_end_time as endTime
|
||||
FROM
|
||||
tb_shop_activate_coupon_record inRecord
|
||||
LEFT JOIN tb_shop_info shop ON inRecord.shop_id = shop.id
|
||||
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
|
||||
WHERE
|
||||
inRecord.shop_user_id = #{shopUserId}
|
||||
<if test="shopId != null and shopId != ''">
|
||||
and inRecord.shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="type != null ">
|
||||
and inRecord.type = #{type}
|
||||
</if>
|
||||
and inRecord.status = 0
|
||||
and inRecord.use_start_time < now()
|
||||
and inRecord.use_end_time > now()
|
||||
order by inRecord.use_end_time
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -39,17 +39,17 @@
|
|||
</select>
|
||||
|
||||
<select id="selectAssetsSummary" resultType="com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO">
|
||||
SELECT
|
||||
IFNULL(SUM(b.amount), 0) AS amount,
|
||||
IFNULL(SUM(b.account_points), 0) AS accountPoints,
|
||||
COUNT(DISTINCT c.id) AS couponNum
|
||||
SELECT IFNULL(SUM(b.amount), 0) AS amount,
|
||||
IFNULL(SUM(b.account_points), 0) AS accountPoints,
|
||||
COUNT(DISTINCT c.id) AS couponNum
|
||||
FROM tb_shop_user AS b
|
||||
LEFT JOIN tb_shop_activate_coupon_record AS c
|
||||
ON c.shop_id = b.shop_id
|
||||
AND c.shop_user_id = b.id
|
||||
AND c.`status` = 1
|
||||
AND c.use_start_time < NOW()
|
||||
AND c.use_end_time > NOW()
|
||||
LEFT JOIN mk_shop_coupon_record AS c
|
||||
ON c.shop_id = b.shop_id
|
||||
AND c.shop_user_id = b.id
|
||||
AND c.`status` = 1
|
||||
AND c.use_start_time < NOW()
|
||||
AND c.use_end_time > NOW()
|
||||
AND c.is_del = 0
|
||||
WHERE b.user_id = #{userId};
|
||||
|
||||
|
||||
|
|
@ -66,10 +66,11 @@
|
|||
-- 预计算优惠券数量
|
||||
LEFT JOIN (
|
||||
SELECT shop_user_id, COUNT(*) AS couponNum
|
||||
FROM tb_shop_activate_coupon_record
|
||||
FROM mk_shop_coupon_record
|
||||
WHERE status = 0
|
||||
AND use_start_time < NOW()
|
||||
AND use_end_time > NOW()
|
||||
AND is_del = 0
|
||||
GROUP BY shop_user_id
|
||||
) c ON c.shop_user_id = a.id
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.czg.account.dto.QueryReceiveDto;
|
||||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券发放记录表 映射层。
|
||||
|
|
@ -11,4 +17,10 @@ import com.czg.market.entity.MkShopCouponRecord;
|
|||
*/
|
||||
public interface MkShopCouponRecordMapper extends BaseMapper<MkShopCouponRecord> {
|
||||
|
||||
List<CouponReceiveVo> queryReceive(@Param("param") QueryReceiveDto param);
|
||||
|
||||
List<MkShopCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
|
||||
|
||||
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@ package com.czg.service.market.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.QueryReceiveDto;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkShopCouponRecordDTO;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
|
|
@ -15,6 +18,7 @@ import com.mybatisflex.core.paginate.Page;
|
|||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
@ -28,13 +32,31 @@ import java.util.stream.Collectors;
|
|||
* @author ww
|
||||
* @since 2025-09-13
|
||||
*/
|
||||
@Service
|
||||
@DubboService
|
||||
public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecordMapper, MkShopCouponRecord> implements MkShopCouponRecordService {
|
||||
|
||||
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Override
|
||||
public List<CouponReceiveVo> queryReceive(QueryReceiveDto param) {
|
||||
return getMapper().queryReceive(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MkShopCouponRecord> findByUser(List<Long> shopUserIds, Integer status) {
|
||||
return getMapper().findByUser(shopUserIds, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type) {
|
||||
return getMapper().queryByVipIdAndShopId(shopId, shopUserId, type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Page<MkShopCouponRecordDTO> getRecord(String search, MkShopCouponRecordDTO mkShopCouponRecordDTO) {
|
||||
Map<Long, UserInfo> userInfoMap = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -4,4 +4,80 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.market.mapper.MkShopCouponRecordMapper">
|
||||
|
||||
|
||||
<select id="queryReceive" resultType="com.czg.account.vo.CouponReceiveVo">
|
||||
SELECT
|
||||
record.id,
|
||||
vip.id as userId ,
|
||||
vip.`nick_name`,
|
||||
vip.phone as phone,
|
||||
record.create_time as receiveTime,
|
||||
record.update_time as useTime,
|
||||
record.source as source
|
||||
FROM
|
||||
mk_shop_coupon_record record
|
||||
LEFT JOIN tb_shop_user vip
|
||||
ON record.shop_user_id = vip.id AND vip.shop_id = #{param.shopId}
|
||||
WHERE
|
||||
record.coupon_id = #{param.couponId}
|
||||
and record.shop_id = #{param.shopId}
|
||||
<if test="param.value != null and param.value != '' ">
|
||||
and (vip.name like concat('%', #{param.value}, '%') or vip.telephone like concat('%', #{param.value}, '%'))
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
and record.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.startTime != null ">
|
||||
and record.create_time > #{param.startTime}
|
||||
</if>
|
||||
<if test="param.endTime != null ">
|
||||
and record.create_time < #{param.endTime}
|
||||
</if>
|
||||
order by record.create_time desc
|
||||
</select>
|
||||
<select id="findByUser" resultType="com.czg.market.entity.MkShopCouponRecord">
|
||||
select mk_shop_coupon_record.*,tb_shop_info.shop_name
|
||||
from mk_shop_coupon_record
|
||||
left join tb_shop_info on mk_shop_coupon_record.shop_id = tb_shop_info.id
|
||||
where mk_shop_coupon_record.shop_user_id in
|
||||
<foreach collection="shopUserIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<if test="status != null">
|
||||
and mk_shop_coupon_record.status = #{status}
|
||||
</if>
|
||||
order by mk_shop_coupon_record.status , mk_shop_coupon_record.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryByVipIdAndShopId" resultType="com.czg.account.vo.UserCouponVo">
|
||||
SELECT
|
||||
inRecord.id as id,
|
||||
inRecord.shop_id as shopId,
|
||||
shop.shop_name as shopName,
|
||||
inRecord.full_amount as fullAmount,
|
||||
inRecord.discount_amount as discountAmount,
|
||||
inRecord.coupon_id as couponId,
|
||||
pro.id as proId,
|
||||
pro.name as productName,
|
||||
inRecord.name as name,
|
||||
inRecord.type,
|
||||
inRecord.use_end_time as endTime
|
||||
FROM
|
||||
mk_shop_coupon_record inRecord
|
||||
LEFT JOIN tb_shop_info shop ON inRecord.shop_id = shop.id
|
||||
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
|
||||
WHERE
|
||||
inRecord.shop_user_id = #{shopUserId}
|
||||
<if test="shopId != null and shopId != ''">
|
||||
and inRecord.shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="type != null ">
|
||||
and inRecord.type = #{type}
|
||||
</if>
|
||||
and inRecord.status = 0
|
||||
and inRecord.use_start_time < now()
|
||||
and inRecord.use_end_time > now()
|
||||
order by inRecord.use_end_time
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -107,8 +107,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
private PointsBasicSettingService pointsBasicService;
|
||||
// @DubboReference
|
||||
// private ShopCouponService couponService;
|
||||
@DubboReference
|
||||
private ShopActivateCouponRecordService couponRecordService;
|
||||
@DubboReference
|
||||
private TbMemberConfigService memberConfigService;
|
||||
@Resource
|
||||
|
|
@ -590,29 +588,30 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
*/
|
||||
private void checkCoupon(Map<Long, Integer> prodCouponMap, BigDecimalDTO fullAmount, BigDecimalDTO discountAmount, CheckOrderPay param) {
|
||||
if (CollUtil.isNotEmpty(param.getCouponList())) {
|
||||
//校验优惠券
|
||||
List<ShopActivateCouponRecord> records = couponRecordService.listAs(
|
||||
QueryWrapper.create()
|
||||
.where(ShopActivateCouponRecord::getId).in(param.getCouponList())
|
||||
.and(ShopActivateCouponRecord::getStatus).eq(0), ShopActivateCouponRecord.class);
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
throw new ValidateException("生成支付订单失败,优惠券信息不存在");
|
||||
} else if (records.size() != param.getCouponList().size()) {
|
||||
throw new ValidateException("生成支付订单失败,优惠券信息不正确");
|
||||
}
|
||||
boolean isFullMinus = false;
|
||||
for (ShopActivateCouponRecord record : records) {
|
||||
if (record.getType().equals(1)) {
|
||||
if (isFullMinus) {
|
||||
throw new ValidateException("生成支付订单失败,满减券仅可使用一张");
|
||||
}
|
||||
fullAmount.setPrice(record.getFullAmount());
|
||||
discountAmount.setPrice(record.getDiscountAmount());
|
||||
isFullMinus = true;
|
||||
} else if (record.getType().equals(2)) {
|
||||
prodCouponMap.compute(record.getProId(), (key, oldValue) -> oldValue == null ? 1 : oldValue + 1);
|
||||
}
|
||||
}
|
||||
//TODO 校验优惠券
|
||||
// //校验优惠券
|
||||
// List<ShopActivateCouponRecord> records = couponRecordService.listAs(
|
||||
// QueryWrapper.create()
|
||||
// .where(ShopActivateCouponRecord::getId).in(param.getCouponList())
|
||||
// .and(ShopActivateCouponRecord::getStatus).eq(0), ShopActivateCouponRecord.class);
|
||||
// if (CollUtil.isEmpty(records)) {
|
||||
// throw new ValidateException("生成支付订单失败,优惠券信息不存在");
|
||||
// } else if (records.size() != param.getCouponList().size()) {
|
||||
// throw new ValidateException("生成支付订单失败,优惠券信息不正确");
|
||||
// }
|
||||
// boolean isFullMinus = false;
|
||||
// for (ShopActivateCouponRecord record : records) {
|
||||
// if (record.getType().equals(1)) {
|
||||
// if (isFullMinus) {
|
||||
// throw new ValidateException("生成支付订单失败,满减券仅可使用一张");
|
||||
// }
|
||||
// fullAmount.setPrice(record.getFullAmount());
|
||||
// discountAmount.setPrice(record.getDiscountAmount());
|
||||
// isFullMinus = true;
|
||||
// } else if (record.getType().equals(2)) {
|
||||
// prodCouponMap.compute(record.getProId(), (key, oldValue) -> oldValue == null ? 1 : oldValue + 1);
|
||||
// }
|
||||
// }
|
||||
if (discountAmount.getPrice().compareTo(param.getFullCouponDiscountAmount()) != 0) {
|
||||
throw new ValidateException("生成支付订单失败,满减券减免金额不正确");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,8 +79,6 @@ public class PayServiceImpl implements PayService {
|
|||
// private ShopActivateService shopActivateService;
|
||||
@DubboReference
|
||||
private ShopUserFlowService userFlowService;
|
||||
@DubboReference
|
||||
private ShopActivateCouponRecordService inRecordService;
|
||||
// @DubboReference
|
||||
// private ShopCouponService couponService;
|
||||
@DubboReference
|
||||
|
|
@ -551,11 +549,12 @@ public class PayServiceImpl implements PayService {
|
|||
shopUserService.updateMoney(shopUser.getShopId(), giftFlowEdit);
|
||||
userFlowService.updateRefund(giftFlow.getId(), giftFlow.getAmount());
|
||||
}
|
||||
//TODO 移除优惠券
|
||||
//移除优惠券
|
||||
inRecordService.remove(QueryWrapper.create()
|
||||
.eq(ShopActivateCouponRecord::getSourceFlowId, inFlow.getId())
|
||||
.eq(ShopActivateCouponRecord::getSource, "activate")
|
||||
.eq(ShopActivateCouponRecord::getStatus, 0));
|
||||
// inRecordService.remove(QueryWrapper.create()
|
||||
// .eq(ShopActivateCouponRecord::getSourceFlowId, inFlow.getId())
|
||||
// .eq(ShopActivateCouponRecord::getSource, "activate")
|
||||
// .eq(ShopActivateCouponRecord::getStatus, 0));
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue