用户优惠券列表3
This commit is contained in:
@@ -3,6 +3,7 @@ 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.czg.market.vo.UserCouponVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -19,7 +20,7 @@ public interface MkShopCouponRecordMapper extends BaseMapper<MkShopCouponRecord>
|
||||
|
||||
List<CouponReceiveVo> queryReceive(@Param("param") QueryReceiveDto param);
|
||||
|
||||
List<MkShopCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
|
||||
List<UserCouponVO> findCouponVOByUser(String name, List<Long> shopUserIds, Integer status);
|
||||
|
||||
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.entity.ShopCoupon;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.ShopCouponService;
|
||||
import com.czg.market.vo.UserCouponVO;
|
||||
import com.czg.service.market.mapper.MkShopCouponRecordMapper;
|
||||
import com.czg.service.market.mapper.ShopCouponMapper;
|
||||
import com.czg.utils.AssertUtil;
|
||||
@@ -66,8 +67,8 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MkShopCouponRecord> findByUser(List<Long> shopUserIds, Integer status) {
|
||||
return getMapper().findByUser(shopUserIds, status);
|
||||
public List<UserCouponVO> findByUser(String name, List<Long> shopUserIds, Integer status) {
|
||||
return getMapper().findCouponVOByUser(name, shopUserIds, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,9 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.vo.UserCouponFoodVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
@@ -19,6 +21,7 @@ import com.czg.market.entity.ShopCoupon;
|
||||
import com.czg.market.service.MkCouponGiftService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.ShopCouponService;
|
||||
import com.czg.market.vo.UserCouponVO;
|
||||
import com.czg.product.entity.Product;
|
||||
import com.czg.product.service.ProductService;
|
||||
import com.czg.service.market.mapper.ShopCouponMapper;
|
||||
@@ -54,6 +57,8 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
@Resource
|
||||
private MkShopCouponRecordService recordService;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
private ProductService productService;
|
||||
@@ -115,7 +120,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MkShopCouponRecord> find(Long userId, Long shopId, Integer status) {
|
||||
public Page<UserCouponVO> find(Long userId, String name, Long shopId, Integer status) {
|
||||
Page<Object> page = PageUtil.buildPage();
|
||||
List<Long> shopUserIds = shopUserService.listAs(new QueryWrapper().eq(ShopUser::getUserId, userId)
|
||||
.eq(ShopUser::getSourceShopId, shopId)
|
||||
@@ -123,7 +128,57 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
|
||||
if (CollectionUtil.isNotEmpty(shopUserIds)) {
|
||||
PageHelper.startPage(Math.toIntExact(page.getPageNumber()), Math.toIntExact(page.getPageSize()));
|
||||
return PageUtil.convert(new PageInfo<>(recordService.findByUser(shopUserIds, status)));
|
||||
List<UserCouponVO> coupons = recordService.findByUser(name, shopUserIds, status);
|
||||
for (UserCouponVO coupon : coupons) {
|
||||
int maxShow = 5;
|
||||
if (StrUtil.isNotBlank(coupon.getFoods())) {
|
||||
List<String> productNames = productService.listAs(new QueryWrapper().select(Product::getName)
|
||||
.in(Product::getId, Arrays.stream(coupon.getFoods().split(",")).map(Long::parseLong).toList())
|
||||
.eq(Product::getIsDel, 0), String.class);
|
||||
if (CollUtil.isNotEmpty(productNames)) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < productNames.size(); i++) {
|
||||
if (i > 0) {
|
||||
result.append(",");
|
||||
}
|
||||
result.append(productNames.get(i));
|
||||
if (i == maxShow - 1 && i != productNames.size() - 1) {
|
||||
result.append("...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
coupon.setFoods(result.toString());
|
||||
}
|
||||
}else {
|
||||
coupon.setFoods("全部商品");
|
||||
}
|
||||
if ("only".equals(coupon.getUseShopType())) {
|
||||
coupon.setUseShops("仅本店");
|
||||
}else if ("all".equals(coupon.getUseShopType())) {
|
||||
coupon.setUseShops("所有门店");
|
||||
}else if ("custom".equals(coupon.getUseShopType())) {
|
||||
if(StrUtil.isNotBlank(coupon.getUseShops())){
|
||||
List<String> shopNames = shopInfoService.listAs(new QueryWrapper().select(ShopInfo::getShopName)
|
||||
.in(ShopInfo::getId, Arrays.stream(coupon.getUseShops().split(",")).map(Long::parseLong).toList())
|
||||
.eq(ShopInfo::getStatus, 1), String.class);
|
||||
if (CollUtil.isNotEmpty(shopNames)) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < shopNames.size(); i++) {
|
||||
if (i > 0) {
|
||||
result.append(",");
|
||||
}
|
||||
result.append(shopNames.get(i));
|
||||
if (i == maxShow - 1 && i != shopNames.size() - 1) {
|
||||
result.append("...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
coupon.setUseShops(result.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return PageUtil.convert(new PageInfo<>(coupons));
|
||||
}
|
||||
return new Page<>();
|
||||
}
|
||||
|
||||
@@ -35,14 +35,33 @@
|
||||
</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
|
||||
<select id="findCouponVOByUser" resultType="com.czg.market.vo.UserCouponVO">
|
||||
select mk_shop_coupon_record.*,
|
||||
mk_shop_coupon_record.use_start_time as effectStartTime,
|
||||
mk_shop_coupon_record.use_end_time as effectEndTime,
|
||||
coupon.use_shop_type as useShopType,
|
||||
coupon.foods as foods,
|
||||
coupon.use_shop as useShops,
|
||||
coupon.use_type as useType,
|
||||
coupon.use_days as useDays,
|
||||
coupon.use_time_type as useTimeType,
|
||||
coupon.use_start_time as useStartTime,
|
||||
coupon.use_end_time as useEndTime,
|
||||
coupon.get_limit as getLimit,
|
||||
coupon.use_limit as useLimit,
|
||||
coupon.discount_share as discountShare,
|
||||
coupon.vip_price_share as vipPriceShare,
|
||||
coupon.rule_details as ruleDetails,
|
||||
coupon.deduct_num as deductNum
|
||||
from mk_shop_coupon_record
|
||||
left join tb_shop_info on mk_shop_coupon_record.shop_id = tb_shop_info.id
|
||||
left join mk_shop_coupon coupon on mk_shop_coupon_record.coupon_id = coupon.id
|
||||
where mk_shop_coupon_record.shop_user_id in
|
||||
<foreach collection="shopUserIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<if test="name != null and name != ''">
|
||||
and mk_shop_coupon_record.name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and mk_shop_coupon_record.status = #{status}
|
||||
</if>
|
||||
@@ -58,6 +77,7 @@
|
||||
shop.shop_name as shopName,
|
||||
inRecord.full_amount as fullAmount,
|
||||
inRecord.discount_amount as discountAmount,
|
||||
inRecord.discount_rate as discountRate,
|
||||
inRecord.coupon_id as couponId,
|
||||
inRecord.name as name,
|
||||
inRecord.type,
|
||||
|
||||
Reference in New Issue
Block a user