From b79d17d163a1f162190cb46d881ab1fd5957c602 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 06 三月 2024 17:02:07 +0800
Subject: [PATCH] Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/PlayPai into 2.0

---
 cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java |   97 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 65 insertions(+), 32 deletions(-)

diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
index de2ce98..98b3825 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
@@ -10,11 +10,9 @@
 import com.dsh.activity.feignclient.course.model.CoursePackagePaymentConfig;
 import com.dsh.activity.feignclient.model.*;
 import com.dsh.activity.feignclient.other.OperatorClient;
+import com.dsh.activity.feignclient.other.SiteClient;
 import com.dsh.activity.feignclient.other.StoreClient;
-import com.dsh.activity.feignclient.other.model.Store;
-import com.dsh.activity.feignclient.other.model.StoreDetailOfCourse;
-import com.dsh.activity.feignclient.other.model.StoreInfoDto;
-import com.dsh.activity.feignclient.other.model.TOperatorCity;
+import com.dsh.activity.feignclient.other.model.*;
 import com.dsh.activity.model.CoachChangeStateVO;
 import com.dsh.activity.model.PointMerchandiseIncomeVo;
 import com.dsh.activity.model.PointMerchandiseVo;
@@ -27,6 +25,7 @@
 import com.dsh.activity.util.*;
 import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -78,6 +77,8 @@
 
     @Resource
     private CouponCityService ccityService;
+    @Autowired
+    private SiteClient siteClient;
 
 
     @Resource
@@ -297,12 +298,11 @@
         List<IntegralCommodity> commodity = new ArrayList<>();
 
         Map<String, String> geocode = gdMapGeocodingUtil.geocode(location.getLon(), location.getLat());
+        if(null == geocode){
+            return new ArrayList<>();
+        }
         String provinceCode = geocode.get("provinceCode");
         String cityCode = geocode.get("cityCode");
-
-
-//        if(null != geocode) {
-
         List<Store> stores = storeClient.queryStoreList(new QueryStoreList(provinceCode, cityCode));
         Store s = null;
         Double d = 0D;
@@ -314,25 +314,21 @@
                 d = wgs84;
             }
         }
-//        }
-
-//        List<PointsMerchandiseCity> cityCode1 = pmdsCityService.list(new QueryWrapper<PointsMerchandiseCity>().eq("cityCode", cityCode));
         List<Integer> cIds = new ArrayList<>();
-//        for (PointsMerchandiseCity pointsMerchandiseCity : cityCode1) {
-//            cIds.add(pointsMerchandiseCity.getPointsMerchandiseId());
-//        }
-
         List<PointsMerchandiseStore> storesids = pointsMerchandiseStoreService.list(new QueryWrapper<PointsMerchandiseStore>().eq("storeId", s.getId()));
         for (PointsMerchandiseStore storesid : storesids) {
             cIds.add(storesid.getPointsMerchandiseId());
         }
 
 
-
-        List<PointsMerchandise> merchandises = pmdsService.list(new QueryWrapper<PointsMerchandise>().in("id", cIds)
+        QueryWrapper<PointsMerchandise> wrapper = new QueryWrapper<PointsMerchandise>()
                 .eq("state", 1)
                 .eq("shelves", 1)
-                .gt("endTime", new Date()).last("ORDER BY sort desc,insertTime desc"));
+                .gt("endTime", new Date());
+        if(cIds.size() > 0){
+            wrapper.in("id", cIds);
+        }
+        List<PointsMerchandise> merchandises = pmdsService.list(wrapper.last("ORDER BY sort desc,insertTime desc"));
         if (merchandises.size() > 0) {
             for (PointsMerchandise merchandise : merchandises) {
                 IntegralCommodity integralCommodity = new IntegralCommodity();
@@ -351,7 +347,12 @@
         for (CouponStore couponStore : storeId) {
             storeCoupons.add(couponStore.getCouponId());
         }
-        List<Coupon> list = couponService.list(new QueryWrapper<Coupon>().in("id", storeCoupons).eq("state", 1).gt("endTime", new Date()).last("ORDER BY insertTime desc"));
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        QueryWrapper<Coupon> queryWrapper = new QueryWrapper<Coupon>().eq("state", 1).gt("endTime", sdf.format(new Date()));
+        if(storeCoupons.size() > 0){
+            queryWrapper.in("id", storeCoupons);
+        }
+        List<Coupon> list = couponService.list(queryWrapper.last(" ORDER BY insertTime desc"));
         if (!list.isEmpty()){
             for (Coupon coupon : list) {
             IntegralCommodity integralCommodity = new IntegralCommodity();
@@ -441,7 +442,7 @@
                 detailsVo.setGoodName(coursePackage.getName());
                 detailsVo.setBelongsScope(merchandise.getUserPopulation());
                 int coursePackageNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
-                        .eq("pointsMerchandiseId", merchandise.getId()));
+                        .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
                 detailsVo.setRedeemedNum(coursePackageNums);
                 detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - coursePackageNums, 0));
                 detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -504,7 +505,7 @@
                 detailsVo.setGoodName(merchandise.getName());
                 detailsVo.setBelongsScope(merchandise.getUserPopulation());
                 int count = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
-                        .eq("pointsMerchandiseId", merchandise.getId()));
+                        .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
                 detailsVo.setRedeemedNum(count);
                 detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - count, 0));
                 detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -559,7 +560,7 @@
                 detailsVo.setGoodName(coupon.getName());
                 detailsVo.setBelongsScope(coupon.getUserPopulation());
                 int couponNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
-                        .eq("pointsMerchandiseId", merchandise.getId()));
+                        .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
                 detailsVo.setRedeemedNum(couponNums);
                 detailsVo.setResidueNum(Math.max(coupon.getQuantityIssued() - couponNums, 0));
                 detailsVo.setPerLimit(coupon.getPickUpQuantity());
@@ -639,7 +640,7 @@
                 detailsVo.setGoodName(coursePackage.getName());
                 detailsVo.setBelongsScope(merchandise.getUserPopulation());
                 int coursePackageNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
-                        .eq("pointsMerchandiseId", merchandise.getId()));
+                        .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
                 detailsVo.setRedeemedNum(coursePackageNums);
                 detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - coursePackageNums, 0));
                 detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -702,7 +703,7 @@
                 detailsVo.setGoodName(merchandise.getName());
                 detailsVo.setBelongsScope(merchandise.getUserPopulation());
                 int count = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
-                        .eq("pointsMerchandiseId", merchandise.getId()));
+                        .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
                 detailsVo.setRedeemedNum(count);
                 detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - count, 0));
                 detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -889,7 +890,7 @@
                             //detailsResponse.setRid(rid);
                             // todo 修改区域id 临时
                             // 根据门店id 写死区域id 后续调整为门票指定多个区域
-                            // 以下代码均为临时代码
+                            // 以下代码均为临时代码===============================
                             for (Integer integer : collect) {
                                 ArrayList<Integer> list2 = new ArrayList<>();
                                 if (integer==2024){
@@ -903,13 +904,15 @@
                                         ArrayList<Integer> list3 = new ArrayList<>();
                                         list3.add(44);
                                         detailsResponse.setRid(list3);
-                                    }else {
+                                    }else if(pointsMerchandise.getPointsMerchandiseId()==197) {
                                         ArrayList<Integer> list4 = new ArrayList<>();
                                         list4.add(43);
                                         detailsResponse.setRid(list4);
                                     }
+
                                 }
                             }
+                            //======================================================
                         }
                     }
 
@@ -924,14 +927,11 @@
                         String endDate = dateFormat.format(end);
                         detailsResponse.setStartTime(startDate);
                         detailsResponse.setEndTime(startDate);
-
                         Date now = new Date();
                         Calendar cal1 = Calendar.getInstance();
                         cal1.setTime(pointsMerchandise.getInsertTime());
-
                         Calendar cal2 = Calendar.getInstance();
                         cal2.setTime(now);
-
                         // Compare the year, month, and day of the two Calendar instances
                         boolean isSameDate = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
                                 cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) &&
@@ -1382,7 +1382,8 @@
     public int queryUserHasGoodsNums(@RequestBody AppUserGoodResp goodResp) {
         int count = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
                 .eq(UserPointsMerchandise::getUserId, goodResp.getAppUserId())
-                .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId()));
+                .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId())
+                .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
         System.out.println(count);
         return count;
     }
@@ -1391,7 +1392,8 @@
     @PostMapping("/base/pointMerchars/queryUserHasGoodsNums1")
     public int queryUserHasGoodsNums1(@RequestBody AppUserGoodResp goodResp) {
         int count = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
-                .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId()));
+                .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId())
+                .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
         System.out.println(count);
         return count;
     }
@@ -1623,6 +1625,9 @@
                 case 3:
                     infoOneVo.setExchangeArea("指定门店");
                     break;
+                case 4:
+                    infoOneVo.setExchangeArea("指定场地");
+                    break;
                 default:
                     break;
             }
@@ -1662,12 +1667,16 @@
                 .eq("pointsMerchandiseId", id));
         if (list.size() > 0) {
             List<Integer> collect = list.stream().map(PointsMerchandiseStore::getStoreId).collect(Collectors.toList());
+            List<Integer> collect1 = list.stream().map(PointsMerchandiseStore::getSiteId).collect(Collectors.toList());
             List<Store> stores = stoClient.queryStoreByIds(collect);
             if (stores.size() > 0) {
+                int a = 0;
                 for (Store store : stores) {
                     StoreVos storeVos1 = new StoreVos();
                     storeVos1.setNum1(store.getProvince() + "省" + store.getCity() + "市");
-                    if (store.getOperatorId() == 0) {
+                    if (store.getOperatorId()==null){
+                        storeVos1.setNum2("平台");
+                    }else if (store.getOperatorId() == 0) {
                         storeVos1.setNum2("平台");
                     } else {
 
@@ -1675,12 +1684,18 @@
                     }
                     storeVos1.setNum3(store.getName());
                     storeVos1.setNum4(store.getIds());
+                    if (collect1.get(a)!=null){
+                        Site site = siteClient.querySiteById(collect1.get(a));
+                        storeVos1.setNum5(site.getName());
+                    }
+                    storeVos1.setNum4(store.getIds());
                     storeVos.add(storeVos1);
                 }
             }
         }
         return storeVos;
     }
+
 
 
     @ResponseBody
@@ -1721,6 +1736,7 @@
     public Integer add(@RequestBody PointsMerchandise pointsMerchandise) {
         Integer storeId = pointsMerchandise.getShelves();
         pointsMerchandise.setShelves(1);
+        pointsMerchandise.setInsertTime(new Date());
         boolean save = pmdsService.save(pointsMerchandise);
         if (save && ToolUtil.isNotEmpty(storeId) && pointsMerchandise.getType() == 2) {
             PointsMerchandiseStore pointsMerchandiseStore = new PointsMerchandiseStore();
@@ -1742,6 +1758,20 @@
     public Boolean addOther(@RequestBody String pam) {
         Boolean save = false;
         String[] split = pam.split("_");
+        if (split.length>2){
+        if (StringUtils.hasLength(split[2])){
+            for (String s : split[2].split(",")) {
+                PointsMerchandiseStore pointsMerchandiseStore = new PointsMerchandiseStore();
+                pointsMerchandiseStore.setPointsMerchandiseId(Integer.valueOf(split[0]));
+                pointsMerchandiseStore.setSiteId(Integer.valueOf(s));
+                Site site = siteClient.querySiteById(Integer.valueOf(s));
+                pointsMerchandiseStore.setStoreId(site.getStoreId());
+                save = pmdstoService.save(pointsMerchandiseStore);
+            }
+            // 这个门票是选择的场地
+            return save;
+        }
+        }
         for (String s : split[1].split(",")) {
             PointsMerchandiseStore pointsMerchandiseStore = new PointsMerchandiseStore();
             pointsMerchandiseStore.setPointsMerchandiseId(Integer.valueOf(split[0]));
@@ -1750,6 +1780,7 @@
         }
         return save;
     }
+
 
     @PostMapping("/base/pointMerchars/addCitys")
     public Boolean addCitys(@RequestBody ArrayList<Map<String, String>> objects) {
@@ -1843,6 +1874,8 @@
         List<Integer> ids = queryDataFee.getIds();
         if (ids.size() == 0) {
             ids.add(-1);
+        }else{
+
         }
         List<PointsMerchandise> list1 = pmdsService.list(new LambdaQueryWrapper<PointsMerchandise>().eq(PointsMerchandise::getRedemptionMethod, 3));
         LambdaQueryWrapper<UserPointsMerchandise> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>();

--
Gitblit v1.7.1