|
|
@@ -67,6 +67,8 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
|
|
|
private final StoreInfoMapper storeInfoMapper;
|
|
|
|
|
|
+ private final StoreUserMapper storeUserMapper;
|
|
|
+
|
|
|
private final LifeDiscountCouponQuantumRulesService lifeDiscountCouponQuantumRulesService;
|
|
|
|
|
|
private final LifeDiscountCouponUserService lifeDiscountCouponUserService;
|
|
|
@@ -430,6 +432,53 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
|
|
|
return lifeDiscountCouponVo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public LifeDiscountCouponVo getCouponDetailWithFriendOwnedQty(String couponId, String storeId) {
|
|
|
+ if (StringUtils.isEmpty(couponId) || StringUtils.isEmpty(storeId)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ int couponIdInt;
|
|
|
+ int storeIdInt;
|
|
|
+ try {
|
|
|
+ couponIdInt = Integer.parseInt(couponId.trim());
|
|
|
+ storeIdInt = Integer.parseInt(storeId.trim());
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (lifeDiscountCouponMapper.selectById(couponIdInt) == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ LifeDiscountCouponVo vo = getCounponDetailById(String.valueOf(couponIdInt), null);
|
|
|
+
|
|
|
+ int owned = 0;
|
|
|
+ List<StoreUser> storeUsers = storeUserMapper.selectList(new LambdaQueryWrapper<StoreUser>()
|
|
|
+ .eq(StoreUser::getStoreId, storeIdInt)
|
|
|
+ .eq(StoreUser::getDeleteFlag, 0));
|
|
|
+ if (CollectionUtils.isNotEmpty(storeUsers)) {
|
|
|
+ List<Integer> userIds = storeUsers.stream()
|
|
|
+ .map(StoreUser::getId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(userIds)) {
|
|
|
+ List<LifeDiscountCouponStoreFriend> rows = lifeDiscountCouponStoreFriendMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<LifeDiscountCouponStoreFriend>()
|
|
|
+ .eq(LifeDiscountCouponStoreFriend::getCouponId, couponIdInt)
|
|
|
+ .in(LifeDiscountCouponStoreFriend::getStoreUserId, userIds)
|
|
|
+ .eq(LifeDiscountCouponStoreFriend::getReleaseType, 1));
|
|
|
+ for (LifeDiscountCouponStoreFriend row : rows) {
|
|
|
+ if (row.getSingleQty() != null) {
|
|
|
+ owned += row.getSingleQty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setOwnedQuantity(owned);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
public static Date addDaysToDateJava8(Date date, int days) {
|
|
|
// 将Date转换为Instant
|
|
|
Instant instant = date.toInstant();
|