소스 검색

门店详情代金券列表

qxy 2 주 전
부모
커밋
c53152cdae

+ 10 - 0
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -369,6 +369,16 @@ public class StoreInfoController {
         return R.data(storeDetail);
     }
 
+    @ApiOperation(value = "获取门店代金券明细")
+    @ApiOperationSupport(order = 7)
+    @GetMapping("/getStoreCouponList")
+    @ResponseBody
+    public R getStoreCouponList(@RequestParam("storeId") String storeId) {
+        log.info("StoreInfoController.getStoreDetail?storeId={},userId={}", storeId);
+        List<LifeCouponVo> lifeCouponVos = storeInfoService.getStoreCouponList(storeId);
+        return R.data(lifeCouponVos);
+    }
+
     @ApiOperation(value = "web端审批店铺")
     @ApiOperationSupport(order = 6)
     @GetMapping("/approveStoreInfo")

+ 5 - 1
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.multipart.MultipartRequest;
-import shop.alien.entity.store.OcrImageUpload;
 import shop.alien.entity.store.StoreBusinessInfo;
 import shop.alien.entity.store.StoreImg;
 import shop.alien.entity.store.StoreInfo;
@@ -282,6 +281,11 @@ public interface StoreInfoService extends IService<StoreInfo> {
     int foodLicenceType(int id);
 
     /**
+     * 获取门店代金券
+     */
+    List<LifeCouponVo> getStoreCouponList(String storeId);
+
+    /**
      * web-分页查询店铺信息
      *
 

+ 36 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -2816,6 +2816,42 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         return resultPage;
     }
 
+    @Override
+    public List<LifeCouponVo> getStoreCouponList(String storeId) {
+        // 获取店铺代金券列表
+        LambdaUpdateWrapper<LifeCoupon> quanWrapper = new LambdaUpdateWrapper<>();
+        quanWrapper.eq(LifeCoupon::getStoreId, storeId).eq(LifeCoupon::getStatus, CouponStatusEnum.ONGOING.getCode()).eq(LifeCoupon::getType, 1);
+        List<LifeCoupon> quanList = lifeCouponMapper.selectList(quanWrapper);
+        List<LifeCouponVo> quanVoList = new ArrayList<>();
+        List<String> collect = quanList.stream().map(LifeCoupon::getId).collect(Collectors.toList());
+        // 设置已售数量
+        // 定义需要的订单状态集合
+        Set<Integer> excludeStatuses = new HashSet<>(Arrays.asList(
+                OrderStatusEnum.WAIT_PAY.getStatus(),
+                OrderStatusEnum.WAIT_USE.getStatus(),
+                OrderStatusEnum.USED.getStatus()
+        ));
+        if (!collect.isEmpty()) {
+            List<LifeUserOrderVo> quanCount = lifeUserOrderMapper.getQuanCount(new QueryWrapper<LifeUserOrderVo>()
+                    .eq("luo.store_id", storeId)
+                    .eq("luo.coupon_type", CouponTypeEnum.COUPON.getCode())
+                    .eq("luo.delete_flag", 0)
+                    .in("ocm.status", excludeStatuses)
+                    .groupBy("ocm.coupon_id"));
+            quanList.forEach(a -> {
+                LifeCouponVo lifeCouponVo = new LifeCouponVo();
+                BeanUtils.copyProperties(a, lifeCouponVo);
+                quanCount.forEach(item -> {
+                    if (a.getId().equals(item.getCouponId().toString())) {
+                        lifeCouponVo.setCount(item.getCount());
+                    }
+                });
+                quanVoList.add(lifeCouponVo);
+            });
+        }
+        return quanVoList;
+    }
+
     void verificationStoreInfoStatus(StoreInfoDto storeInfo) {
         //营业状态 0:正常营业, 1:暂停营业, 2:筹建中, 99:永久关门
         if (!Objects.isNull(storeInfo.getBusinessStatus()) && storeInfo.getBusinessStatus() == 99) {