| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.PointsMerchandise; |
| | | import com.dsh.activity.entity.*; |
| | | import com.dsh.activity.feignclient.course.CoursePackageClient; |
| | | import com.dsh.activity.feignclient.course.CoursePackageConfigClient; |
| | | import com.dsh.activity.feignclient.course.model.CoursePackage; |
| | | import com.dsh.activity.feignclient.course.model.CoursePackagePaymentConfig; |
| | | import com.dsh.activity.feignclient.model.IntegralCommodity; |
| | | import com.dsh.activity.service.PointsMerchandiseService; |
| | | import com.dsh.activity.feignclient.model.ProductDetailRequest; |
| | | import com.dsh.activity.feignclient.model.ProductDetailsVo; |
| | | import com.dsh.activity.feignclient.other.StoreClient; |
| | | import com.dsh.activity.feignclient.other.model.StoreDetailOfCourse; |
| | | import com.dsh.activity.model.request.CommodityRequest; |
| | | import com.dsh.activity.service.*; |
| | | import com.dsh.activity.util.GDMapGeocodingUtil; |
| | | import com.dsh.activity.util.StrUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | |
| | | @Autowired |
| | | private PointsMerchandiseService pmdsService; |
| | | |
| | | @Autowired |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | |
| | | @Autowired |
| | | private UserPointsMerchandiseService upmseService; |
| | | |
| | | @Autowired |
| | | private ICouponService iCouponService; |
| | | |
| | | @Autowired |
| | | private CoursePackageClient cpClient; |
| | | |
| | | @Autowired |
| | | private StoreClient stoClient; |
| | | |
| | | @Autowired |
| | | private CoursePackageConfigClient cpcfigClient; |
| | | |
| | | @Autowired |
| | | private PointsMerchandiseStoreService pmdstoService; |
| | | |
| | | @Autowired |
| | | private UserCouponService uconService; |
| | | |
| | | @Autowired |
| | | private CouponStoreService cstoreService; |
| | | |
| | | |
| | | @PostMapping("/pointMerchars/convertGoods") |
| | | @PostMapping("/base/pointMerchars/convertGoods") |
| | | public List<IntegralCommodity> getConvertibleGoods(){ |
| | | List<IntegralCommodity> commodity = new ArrayList<>(); |
| | | List<PointsMerchandise> merchandises = pmdsService.list(new QueryWrapper<PointsMerchandise>() |
| | |
| | | return commodity; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/getCommoditys") |
| | | public List<PointsMerchandise> getVicinityGoods(@RequestBody CommodityRequest request){ |
| | | String provinceCode = ""; |
| | | String cityCode = ""; |
| | | try { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat()); |
| | | provinceCode = geocode.get("provinceCode"); |
| | | cityCode = geocode.get("cityCode"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | List<PointsMerchandise> list = pmdsService.list(new QueryWrapper<PointsMerchandise>() |
| | | .eq("state", 1)); |
| | | if (list.size() > 0 ){ |
| | | Iterator<PointsMerchandise> iterator = list.iterator(); |
| | | while (iterator.hasNext()) { |
| | | PointsMerchandise merchandise = iterator.next(); |
| | | if (merchandise.getUseScope() == 2 && (!Objects.equals(merchandise.getCityCode(), cityCode) && !Objects.equals(merchandise.getProvinceCode(), provinceCode))) { |
| | | iterator.remove(); // 移除符合条件的商品 |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @PostMapping("/base/pointMerchars/getRedeemedNums") |
| | | public int getRedeemedQuantity(@RequestBody Integer goodId){ |
| | | return upmseService.count(new QueryWrapper<UserPointsMerchandise>() |
| | | .eq("pointsMerchandiseId",goodId)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/getGoodDetails") |
| | | public ProductDetailsVo getGoodDetailsWithId(@RequestBody ProductDetailRequest detailRequest){ |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | ProductDetailsVo detailsVo = new ProductDetailsVo(); |
| | | PointsMerchandise merchandise = pmdsService.getById(detailRequest.getGoodId()); |
| | | switch (detailRequest.getGoodsType()){ |
| | | case 2: |
| | | // 课包 |
| | | CoursePackage coursePackage = cpClient.queryCoursePackageById(detailRequest.getGoodId()); |
| | | |
| | | detailsVo.setGoodId(coursePackage.getId()); |
| | | detailsVo.setPics(Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ","))); |
| | | detailsVo.setGoodName(coursePackage.getName()); |
| | | detailsVo.setBelongsScope(merchandise.getUserPopulation()); |
| | | int coursePackageNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>() |
| | | .eq("pointsMerchandiseId",merchandise.getId() )); |
| | | detailsVo.setRedeemedNum(coursePackageNums); |
| | | detailsVo.setResidueNum(merchandise.getQuantityIssued() - coursePackageNums); |
| | | detailsVo.setPerLimit(merchandise.getPickUpQuantity()); |
| | | detailsVo.setIntegral(merchandise.getIntegral()); |
| | | detailsVo.setCost(merchandise.getPrice()); |
| | | if (merchandise.getUseScope() == 1){ |
| | | detailsVo.setBelongs("全国通用"); |
| | | }else if (merchandise.getUseScope() == 2){ |
| | | detailsVo.setBelongs(merchandise.getProvince()+"|"+merchandise.getCity() + "用户可用"); |
| | | }else { |
| | | List<PointsMerchandiseStore> list = pmdstoService.list(new QueryWrapper<PointsMerchandiseStore>() |
| | | .eq("pointsMerchandiseId",merchandise.getId() )); |
| | | PointsMerchandiseStore pointsMerchandiseStore = list.get(0); |
| | | StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(pointsMerchandiseStore.getStoreId()); |
| | | detailsVo.setBelongs(courseOfStore.getStoreName()+"可用"); |
| | | } |
| | | List<CoursePackagePaymentConfig> courseConfigList = cpcfigClient.getCourseConfigList(coursePackage.getId()); |
| | | int redul = 0; |
| | | |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : courseConfigList) { |
| | | redul = redul + coursePackagePaymentConfig.getClassHours(); |
| | | } |
| | | detailsVo.setCourseHours(redul); |
| | | detailsVo.setStartTime(format.format(merchandise.getStartTime())); |
| | | detailsVo.setEndTime(format.format(merchandise.getEndTime())); |
| | | |
| | | detailsVo.setContents(merchandise.getRedemptionInstructions()); |
| | | detailsVo.setGoodType(merchandise.getType()); |
| | | |
| | | break; |
| | | case 1: |
| | | case 3: |
| | | |
| | | detailsVo.setGoodId(merchandise.getId()); |
| | | String[] strings = StrUtils.splitStr2StrArr(merchandise.getProductImages(), ","); |
| | | detailsVo.setPics(Arrays.asList(strings)); |
| | | detailsVo.setGoodName(merchandise.getName()); |
| | | detailsVo.setBelongsScope(merchandise.getUserPopulation()); |
| | | int count = upmseService.count(new QueryWrapper<UserPointsMerchandise>() |
| | | .eq("pointsMerchandiseId",merchandise.getId() )); |
| | | detailsVo.setRedeemedNum(count); |
| | | detailsVo.setResidueNum(merchandise.getQuantityIssued()-count); |
| | | detailsVo.setPerLimit(merchandise.getPickUpQuantity()); |
| | | detailsVo.setIntegral(merchandise.getIntegral()); |
| | | detailsVo.setCost(merchandise.getPrice()); |
| | | if (merchandise.getUseScope() == 1){ |
| | | detailsVo.setBelongs("全国通用"); |
| | | }else if (merchandise.getUseScope() == 2){ |
| | | detailsVo.setBelongs(merchandise.getProvince()+"|"+merchandise.getCity() + "用户可用"); |
| | | }else { |
| | | List<PointsMerchandiseStore> list = pmdstoService.list(new QueryWrapper<PointsMerchandiseStore>() |
| | | .eq("pointsMerchandiseId",merchandise.getId() )); |
| | | PointsMerchandiseStore pointsMerchandiseStore = list.get(0); |
| | | StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(pointsMerchandiseStore.getStoreId()); |
| | | detailsVo.setBelongs(courseOfStore.getStoreName()+"可用"); |
| | | } |
| | | |
| | | detailsVo.setStartTime(format.format(merchandise.getStartTime())); |
| | | detailsVo.setEndTime(format.format(merchandise.getEndTime())); |
| | | |
| | | detailsVo.setContents(merchandise.getRedemptionInstructions()); |
| | | detailsVo.setGoodType(merchandise.getType()); |
| | | break; |
| | | case 4: |
| | | // 优惠券 |
| | | Coupon coupon = iCouponService.getById(detailRequest.getGoodId()); |
| | | detailsVo.setGoodId(coupon.getId()); |
| | | detailsVo.setPics(Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ","))); |
| | | detailsVo.setGoodName(coupon.getName()); |
| | | detailsVo.setBelongsScope(coupon.getUserPopulation()); |
| | | int couponNums = uconService.count(new QueryWrapper<UserCoupon>() |
| | | .eq("couponId",coupon.getId() )); |
| | | detailsVo.setRedeemedNum(couponNums); |
| | | detailsVo.setResidueNum(coupon.getQuantityIssued()-couponNums); |
| | | detailsVo.setPerLimit(coupon.getPickUpQuantity()); |
| | | detailsVo.setIntegral(merchandise.getIntegral()); |
| | | if (coupon.getUseScope() == 1){ |
| | | detailsVo.setBelongs("全国通用"); |
| | | }else if (coupon.getUseScope() == 2){ |
| | | detailsVo.setBelongs(coupon.getProvince()+"|"+coupon.getCity() + "用户可用"); |
| | | }else { |
| | | List<CouponStore> list = cstoreService.list(new QueryWrapper<CouponStore>() |
| | | .eq("couponId",coupon.getId() )); |
| | | StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(list.get(0).getStoreId()); |
| | | detailsVo.setBelongs(courseOfStore.getStoreName()+"可用"); |
| | | } |
| | | detailsVo.setStartTime(format.format(merchandise.getStartTime())); |
| | | detailsVo.setEndTime(format.format(merchandise.getEndTime())); |
| | | |
| | | detailsVo.setContents(coupon.getIllustrate()); |
| | | detailsVo.setGoodType(4); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return detailsVo; |
| | | } |
| | | |
| | | |
| | | } |