| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.PointsMerchandise; |
| | | import com.dsh.activity.entity.UserPointsMerchandise; |
| | | import com.dsh.activity.entity.*; |
| | | import com.dsh.activity.feignclient.course.CoursePackageClient; |
| | | import com.dsh.activity.feignclient.course.model.CoursePackage; |
| | | import com.dsh.activity.feignclient.model.IntegralCommodity; |
| | | 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.PointsMerchandiseService; |
| | | import com.dsh.activity.service.UserPointsMerchandiseService; |
| | | 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.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | @Autowired |
| | | private UserPointsMerchandiseService upmseService; |
| | | |
| | | @Autowired |
| | | private ICouponService iCouponService; |
| | | |
| | | @Autowired |
| | | private CoursePackageClient cpClient; |
| | | |
| | | @Autowired |
| | | private StoreClient stoClient; |
| | | |
| | | @Autowired |
| | | private PointsMerchandiseStoreService pmdstoService; |
| | | |
| | | @Autowired |
| | | private UserCouponService uconService; |
| | | |
| | | @Autowired |
| | | private CouponStoreService cstoreService; |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/convertGoods") |
| | |
| | | .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()+"可用"); |
| | | } |
| | | // TODO: 2023/7/12 课包的课时 |
| | | // detailsVo.setCourseHours(); |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |