原记录表作废

This commit is contained in:
2025-09-13 15:57:51 +08:00
parent 77ac277856
commit dca94cc848
15 changed files with 183 additions and 336 deletions

View File

@@ -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);
}

View File

@@ -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<>();

View File

@@ -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 &gt; #{param.startTime}
</if>
<if test="param.endTime != null ">
and record.create_time &lt; #{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 &lt; now()
and inRecord.use_end_time &gt; now()
order by inRecord.use_end_time
</select>
</mapper>