| | |
| | | import com.dsh.activity.feignclient.account.model.TStoreStaff; |
| | | import com.dsh.activity.feignclient.model.CouponExamineListSearch; |
| | | import com.dsh.activity.feignclient.model.CouponListOfSearch; |
| | | import com.dsh.activity.feignclient.other.OperatorClient; |
| | | import com.dsh.activity.feignclient.other.RegionClient; |
| | | import com.dsh.activity.feignclient.other.StoreClient; |
| | | import com.dsh.activity.feignclient.other.model.CityDataAndProvinceDataVo; |
| | | import com.dsh.activity.feignclient.other.model.Store; |
| | | import com.dsh.activity.feignclient.other.model.TOperatorCity; |
| | | import com.dsh.activity.model.CouponListVo; |
| | | import com.dsh.activity.model.CouponRecordQuery; |
| | | import com.dsh.activity.model.request.CommodityRequest; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | @ResponseBody |
| | | @PostMapping("/coupon/queryCouponByUser/{userId}") |
| | | public List<Integer> queryCouponByUser(@PathVariable("userId") Integer userId){ |
| | | List<Coupon> list = couponService.list(new QueryWrapper<Coupon>().eq("distributionMethod", 2) |
| | | List<Coupon> list = couponService.list(new QueryWrapper<Coupon>().eq("distributionMethod", 2).eq("userPopulation",2) |
| | | .le("startTime", new Date()).ge("endTime", new Date()).eq("auditStatus", 2) |
| | | .eq("state", 1)); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private OperatorClient operatorClient; |
| | | @ResponseBody |
| | | @PostMapping("/base/coupon/queryCouponListSearch") |
| | | public List<Map<String,Object>> getCouponListOfSearch(@RequestBody CouponListOfSearch ofSearch){ |
| | | List<Map<String, Object>> mapList1 = couponService.queryCouponListOfSearch(ofSearch); |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | |
| | | if(ofSearch.getStoreId()!=null){ |
| | | if (ofSearch.getStoreIds()==null){ |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | ofSearch.setStoreIds(list); |
| | | } |
| | | if(ofSearch.getStoreId()!=null || ofSearch.getStoreIds().size()!=0){ |
| | | for (Map<String, Object> map : mapList1) { |
| | | List<CouponStore> id = couStoreService.list(new LambdaQueryWrapper<CouponStore>().eq(CouponStore::getCouponId, map.get("id").toString())); |
| | | List<Integer> collect = id.stream().map(CouponStore::getStoreId).collect(Collectors.toList()); |
| | | if(collect.size()==0){ |
| | | collect.add(-1); |
| | | } |
| | | if(collect.contains(ofSearch.getStoreId())){ |
| | | if(collect.size()>1){ |
| | | map.put("size",1); |
| | | }else { |
| | | map.put("size",0); |
| | | // 如果当前登陆人是运营商 只能查看平台添加的优惠券应只展示使用范围为全国通用、 |
| | | // 指定城市有运营商管辖的、指定门店有运营商旗下门店 |
| | | if (ofSearch.getObjType()== 2){ |
| | | if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 1){ |
| | | mapList.add(map); |
| | | } |
| | | mapList.add(map); |
| | | if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 2){ |
| | | // 获取到优惠券id 查询这个优惠券指定了哪些城市 |
| | | Integer id = Integer.parseInt(String.valueOf(map.get("id"))); |
| | | // 获取到运营商管理的省和市 |
| | | List<TOperatorCity> cityByOperatorId = operatorClient.getCityByOperatorId(ofSearch.getOperatorId()); |
| | | // 拿到运营商市的code集合 |
| | | List<String> collect = cityByOperatorId.stream().filter(t -> t.getPid() != 0) |
| | | .map(tOperatorCity -> Integer.toString(tOperatorCity.getCode())) |
| | | .collect(Collectors.toList()); |
| | | List<CouponCity> couponId = cityService.list(new QueryWrapper<CouponCity>().eq("couponId", id)); |
| | | // 先判断优惠券管理的市 运营商是否有 |
| | | List<String> collect1 = couponId.stream().map(CouponCity::getCityCode) |
| | | .collect(Collectors.toList()); |
| | | // 优惠券指定的省 |
| | | List<String> collect2 = couponId.stream().map(CouponCity::getCityCode) |
| | | .collect(Collectors.toList()); |
| | | if (!Collections.disjoint(collect, collect1)){ |
| | | mapList.add(map); |
| | | }else{ |
| | | // 如果没有交集 那么还需要判断运营商是否管理了整个省 |
| | | |
| | | |
| | | } |
| | | } |
| | | if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 3){ |
| | | // 获取到优惠券id 查询这个优惠券指定了哪些门店 |
| | | Integer id = Integer.parseInt(String.valueOf(map.get("id"))); |
| | | // 当前运营商管理的门店ids |
| | | List<Integer> storeIds = ofSearch.getStoreIds(); |
| | | // 优惠券指定的门店 |
| | | List<Integer> collect = couStoreService.list(new QueryWrapper<CouponStore>().eq("couponId",id) |
| | | .in("storeId", storeIds)).stream().map(CouponStore::getStoreId) |
| | | .collect(Collectors.toList()); |
| | | // 判断两个集合是否相交 |
| | | // 比较两个集合中是否有相同的元素;当两个集合中没有相同元素时返回true, |
| | | // 当有相同元素时返回false。 |
| | | if (!Collections.disjoint(collect, storeIds)){ |
| | | mapList.add(map); |
| | | } |
| | | } |
| | | }else{ |
| | | List<CouponStore> id = couStoreService.list(new LambdaQueryWrapper<CouponStore>() |
| | | .eq(CouponStore::getCouponId, map.get("id").toString())); |
| | | List<Integer> collect = id.stream().map(CouponStore::getStoreId).collect(Collectors.toList()); |
| | | if(collect.size()==0){ |
| | | collect.add(-1); |
| | | } |
| | | if(collect.contains(ofSearch.getStoreId())){ |
| | | if(collect.size()>1){ |
| | | map.put("size",1); |
| | | }else { |
| | | map.put("size",0); |
| | | } |
| | | mapList.add(map); |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | |
| | | } |
| | | |
| | | boolean save = couponService.save(coupon); |
| | | // 自动发券 |
| | | if (dataVo.getDistributionMethod() == 3){ |
| | | // 判断用户人群 再判断限领数量 |
| | | switch (dataVo.getUserGroup()){ |
| | | case 1: |
| | | |
| | | break; |
| | | case 2: |
| | | |
| | | break; |
| | | case 3: |
| | | |
| | | break; |
| | | } |
| | | } |
| | | if (save){ |
| | | if (dataVo.getCompany() == 3){ |
| | | String[] split = dataVo.getStoreIds().split(","); |