| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.activity.entity.Coupon; |
| | | import com.dsh.activity.entity.CouponCity; |
| | | import com.dsh.activity.entity.CouponStore; |
| | | import com.dsh.activity.entity.UserCoupon; |
| | | import com.dsh.activity.entity.*; |
| | | import com.dsh.activity.feignclient.account.AppUserClient; |
| | | import com.dsh.activity.feignclient.account.CityClient; |
| | | import com.dsh.activity.feignclient.account.StoreStaffClient; |
| | |
| | | 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 com.dsh.activity.model.request.CouponDataVo; |
| | | import com.dsh.activity.model.request.CouponPackageReq; |
| | | import com.dsh.activity.model.VipDetailVO; |
| | | import com.dsh.activity.model.VipPaymentVO; |
| | | import com.dsh.activity.model.request.*; |
| | | import com.dsh.activity.model.response.CouponPackageResp; |
| | | import com.dsh.activity.service.CouponCityService; |
| | | import com.dsh.activity.service.CouponStoreService; |
| | | import com.dsh.activity.service.ICouponService; |
| | | import com.dsh.activity.service.UserCouponService; |
| | | import com.dsh.activity.service.*; |
| | | import com.dsh.activity.util.GDMapGeocodingUtil; |
| | | import com.dsh.activity.util.ResultUtil; |
| | | import com.dsh.activity.util.TokenUtil; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | @Autowired |
| | | private VipDetailService vipDetailService; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | |
| | | @Resource |
| | | private CouponCityService cityService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | @Autowired |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/coupon/vipDetail") |
| | | @ResponseBody |
| | | List<VipDetailVO> vipDetail(@RequestBody VipDetailDto vipDetailDto){ |
| | | List<VipDetailVO> vipDetailVOS = new ArrayList<>(); |
| | | List<VipDetail> list = vipDetailService.lambdaQuery() |
| | | .in(!vipDetailDto.getVipIds().isEmpty(), VipDetail::getVipId, vipDetailDto.getVipIds()) |
| | | .in(!vipDetailDto.getUserIds().isEmpty(), VipDetail::getAppUserId, vipDetailDto.getUserIds()) |
| | | .in(!vipDetailDto.getStoreIds().isEmpty(), VipDetail::getUseStoreId, vipDetailDto.getStoreIds()) |
| | | .ge(StringUtils.hasLength(vipDetailDto.getStartTime()), VipDetail::getInsertTime, vipDetailDto.getStartTime()) |
| | | .le(StringUtils.hasLength(vipDetailDto.getEndTime()), VipDetail::getInsertTime, vipDetailDto.getEndTime()) |
| | | .ge(StringUtils.hasLength(vipDetailDto.getUseStartTime()), VipDetail::getUseTime, vipDetailDto.getUseStartTime()) |
| | | .le(StringUtils.hasLength(vipDetailDto.getUseEndTime()), VipDetail::getUseTime, vipDetailDto.getUseEndTime()) |
| | | .eq(vipDetailDto.getOperatorId() != null, VipDetail::getOperatorId, vipDetailDto.getOperatorId()) |
| | | .eq(vipDetailDto.getType() != null, VipDetail::getType, vipDetailDto.getType()) |
| | | .eq(vipDetailDto.getStatus() != null, VipDetail::getStatus, vipDetailDto.getStatus()).list(); |
| | | |
| | | // 使用 Stream + 手动拷贝提升性能和可读性(或使用 MapStruct) |
| | | vipDetailVOS = list.stream().map(vipDetail -> { |
| | | VipDetailVO vo = new VipDetailVO(); |
| | | BeanUtils.copyProperties(vo, vipDetail); // 注意参数顺序是否正确 |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | List<Coupon> coupons = couponService.list(); |
| | | for (VipDetailVO vipDetailVO : vipDetailVOS) { |
| | | if (vipDetailVO.getType()==1){ |
| | | Coupon coupon = coupons.stream().filter(coupon1 -> coupon1.getId().equals(vipDetailVO.getCouponId())).findFirst().orElse(null); |
| | | if (coupon!=null){ |
| | | vipDetailVO.setTicketName(coupon.getName()); |
| | | vipDetailVO.setGoodsName(coupon.getName()); |
| | | } |
| | | } |
| | | } |
| | | return vipDetailVOS; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询注册赠送优惠券 判断当前优惠券限领数量 |
| | |
| | | // 优惠券已领取数量 |
| | | int couponId = ucService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId())); |
| | | // 用户已领取该优惠券数量 |
| | | int count = ucService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId() |
| | | ).eq("userId", userId)); |
| | | int count = ucService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId()).eq("userId", userId)); |
| | | if (couponId >= quantityIssued) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/coupon/queryCouponAll") |
| | | public List<Coupon> queryCouponAll() { |
| | | try { |
| | | |
| | | return couponService.lambdaQuery().eq(Coupon::getState,1) |
| | | .eq(Coupon::getAuditStatus,2).list(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/coupon/queryCouponList") |
| | | public List<Coupon> queryCouponList() { |
| | | try { |
| | | |
| | | return couponService.lambdaQuery().ne(Coupon::getState,3) |
| | | .eq(Coupon::getAuditStatus,2).list(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/coupon/queryUserCouponById") |
| | | public Integer queryUserCouponById(@RequestBody Long id) { |
| | | try { |
| | | Integer couponId = userCouponService.getById(id).getCouponId(); |
| | | return couponId; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private UserCouponService userCouponService; |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<CouponPackageResp>> queryAppuserCouponList(CouponPackageReq req) { |
| | | public ResultUtil<List<CouponPackageResp>> queryCouponPackage(CouponPackageReq req) { |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if (null == uid) { |
| | |
| | | } |
| | | if (ofSearch.getStoreId() != null || ofSearch.getStoreIds().size() != 0) { |
| | | for (Map<String, Object> map : mapList1) { |
| | | if (map.get("cityManagerId").equals(ofSearch.getOperatorId())){ |
| | | mapList.add(map); |
| | | continue; |
| | | } |
| | | // 如果当前登陆人是运营商 只能查看平台添加的优惠券应只展示使用范围为全国通用、 |
| | | // 指定城市有运营商管辖的、指定门店有运营商旗下门店 |
| | | if (ofSearch.getObjType() == 2) { |
| | | if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 1) { |
| | | mapList.add(map); |
| | | continue; |
| | | } |
| | | if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 2) { |
| | | // 获取到优惠券id 查询这个优惠券指定了哪些城市 |
| | |
| | | int count = ucService.count(new LambdaQueryWrapper<UserCoupon>() |
| | | .eq(UserCoupon::getCouponId, o)); |
| | | stringObjectMap.put("hasPickQty", count); |
| | | } |
| | | } |
| | | return mapList; |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/coupon/getCouponListAllOfSearch") |
| | | public List<Map<String, Object>> getCouponListAllOfSearch(@RequestBody CouponListOfSearch ofSearch) { |
| | | List<Map<String, Object>> mapList1 = couponService.queryCouponListOfSearch(ofSearch); |
| | | |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | if (ofSearch.getStoreIds() == null) { |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | ofSearch.setStoreIds(list); |
| | | } |
| | | mapList = mapList1; |
| | | if (mapList.size() > 0) { |
| | | for (Map<String, Object> stringObjectMap : mapList) { |
| | | Object startTime = stringObjectMap.get("startTime"); |
| | | Object endTime = stringObjectMap.get("endTime"); |
| | | stringObjectMap.put("timeValue", startTime + "至" + endTime); |
| | | } |
| | | } |
| | | return mapList; |
| | |
| | | stringObjectHashMap.put("experienceName", dataVo.getExperience()); |
| | | coupon.setContent(gson.toJson(stringObjectHashMap)); |
| | | break; |
| | | case 4: |
| | | coupon.setGoodsId(dataVo.getGoodsId()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | List<CouponCity> list = cityService.list(new LambdaQueryWrapper<CouponCity>().eq(CouponCity::getCouponId, id)); |
| | | return list; |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/coupon/queryAllCity") |
| | | public List<CouponCity> queryAllCity() { |
| | | List<CouponCity> list = cityService.list(new LambdaQueryWrapper<CouponCity>()); |
| | | return list; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/coupon/queryStore") |
| | | public List<Integer> queryStore(@RequestBody Integer id) { |
| | | return couStoreService.list(new LambdaQueryWrapper<CouponStore>().eq(CouponStore::getCouponId, id)).stream().map(CouponStore::getStoreId).collect(Collectors.toList()); |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/coupon/queryAllStore") |
| | | public List<CouponStore> queryAllStore() { |
| | | return couStoreService.list(new LambdaQueryWrapper<CouponStore>()); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/coupon/listRecord") |
| | | @ResponseBody |
| | | public List<Map<String, Object>> listRecord(@RequestBody CouponRecordQuery ofSearch) { |
| | | Page<Object> objectPage = new Page<>(ofSearch.getOffset(), ofSearch.getLimit()); |
| | | return couponService.listRecord(objectPage, ofSearch.getId(), ofSearch.getIds(), ofSearch.getType()); |
| | | return couponService.listRecord(ofSearch.getId(), ofSearch.getIds(), ofSearch.getType()); |
| | | } |
| | | |
| | | |