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

This commit is contained in:
张松
2025-09-25 14:41:16 +08:00
6 changed files with 132 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ package com.czg.service.market.mapper;
import com.czg.account.dto.QueryReceiveDto;
import com.czg.account.vo.CouponReceiveVo;
import com.czg.account.vo.ShopInfoCouponVO;
import com.czg.account.vo.UserCouponVo;
import com.czg.market.vo.UserCouponVO;
import com.mybatisflex.core.BaseMapper;
@@ -24,4 +25,5 @@ public interface MkShopCouponRecordMapper extends BaseMapper<MkShopCouponRecord>
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
List<ShopInfoCouponVO> getShopByCouponRecord(Long userId);
}

View File

@@ -13,6 +13,7 @@ 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.ShopInfoCouponVO;
import com.czg.account.vo.UserCouponFoodVo;
import com.czg.account.vo.UserCouponVo;
import com.czg.market.dto.ShopCouponDTO;
@@ -24,6 +25,7 @@ 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.MkShopCouponRecordMapper;
import com.czg.service.market.mapper.ShopCouponMapper;
import com.czg.utils.AssertUtil;
import com.czg.utils.PageUtil;
@@ -56,6 +58,8 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
private MkCouponGiftService couponGiftService;
@Resource
private MkShopCouponRecordService recordService;
@Resource
private MkShopCouponRecordMapper recordMapper;
@DubboReference
private ShopInfoService shopInfoService;
@DubboReference
@@ -149,15 +153,15 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
}
coupon.setFoods(result.toString());
}
}else {
} else {
coupon.setFoods("全部商品");
}
if ("only".equals(coupon.getUseShopType())) {
coupon.setUseShops("仅本店");
}else if ("all".equals(coupon.getUseShopType())) {
} else if ("all".equals(coupon.getUseShopType())) {
coupon.setUseShops("所有门店");
}else if ("custom".equals(coupon.getUseShopType())) {
if(StrUtil.isNotBlank(coupon.getUseShops())){
} 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);
@@ -265,6 +269,42 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
.update();
}
@Override
public List<ShopInfoCouponVO> getShopByCouponRecord(Long shopId, Long shopUserId) {
List<ShopInfoCouponVO> originalList = recordMapper.getShopByCouponRecord(shopUserId);
// 2. 若shopId为空直接返回原集合
if (shopId == null) {
return originalList;
}
// 3. 若shopId不为空筛选目标元素并重组列表
List<ShopInfoCouponVO> resultList = new ArrayList<>();
ShopInfoCouponVO targetShop = null;
// 遍历原始集合,找到目标元素
for (ShopInfoCouponVO shopVO : originalList) {
if (Objects.equals(shopVO.getShopId(), shopId)) {
targetShop = shopVO;
break;
}
}
if (targetShop != null) {
resultList.add(targetShop);
// 再添加其余非目标元素
for (ShopInfoCouponVO shopVO : originalList) {
if (!Objects.equals(shopVO.getShopId(), shopId)) {
resultList.add(shopVO);
}
}
} else {
resultList = originalList;
}
return resultList;
}
private void setCouponInfo(Map<Long, JSONObject> coupons, UserCouponVo tbUserCouponVo, BigDecimal amount, String week, DateTimeFormatter formatter) {
JSONObject json = new JSONObject();
boolean isUse = true;

View File

@@ -106,4 +106,16 @@
and inRecord.is_del = 0
order by inRecord.use_end_time
</select>
<select id="getShopByCouponRecord" resultType="com.czg.account.vo.ShopInfoCouponVO">
SELECT inRecord.shop_id AS shopId,
shop.shop_name AS shopName,
shop.address AS shopAddress,
shop.chain_name AS chainName,
COUNT(inRecord.coupon_id) AS couponCount
FROM mk_shop_coupon_record inRecord
LEFT JOIN tb_shop_info shop ON inRecord.shop_id = shop.id
WHERE inRecord.user_id = #{userId}
AND inRecord.is_del = 0
GROUP BY inRecord.shop_id
</select>
</mapper>