| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.PointsMerchandise; |
| | | import com.dsh.activity.entity.UserPointsMerchandise; |
| | | import com.dsh.activity.feignclient.model.IntegralCommodity; |
| | | 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.*; |
| | | 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 com.dsh.activity.util.TokenUtil; |
| | | import com.dsh.activity.util.ToolUtil; |
| | | 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.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | |
| | | @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; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | |
| | | @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(merchandise.getCoursePackageId()); |
| | | |
| | | detailsVo.setGoodId(coursePackage.getId()); |
| | | List<String> list1 = Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ",")); |
| | | list1.add(coursePackage.getCoverDrawing()); |
| | | detailsVo.setPics(list1); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(coursePackage.getCoverDrawing())) { |
| | | return -1; // s1排在前面 |
| | | } else if (s2.equals(coursePackage.getCoverDrawing())) { |
| | | return 1; // s2排在前面 |
| | | } else { |
| | | return 0; // 保持原顺序 |
| | | } |
| | | }); |
| | | 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()); |
| | | if (merchandise.getRedemptionMethod() == 1){ |
| | | detailsVo.setExchangeType(1); |
| | | detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); |
| | | }else { |
| | | detailsVo.setExchangeType(2); |
| | | detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); |
| | | } |
| | | detailsVo.setCost(merchandise.getPrice()); |
| | | if (merchandise.getUseScope() == 1){ |
| | | detailsVo.setExchangeAddrType(1); |
| | | detailsVo.setBelongs("全国通用"); |
| | | }else if (merchandise.getUseScope() == 2){ |
| | | detailsVo.setExchangeAddrType(2); |
| | | detailsVo.setBelongs(merchandise.getProvince()+"|"+merchandise.getCity() + "用户可用"); |
| | | }else { |
| | | detailsVo.setExchangeAddrType(3); |
| | | 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()); |
| | | List<String> list2 = Arrays.asList(StrUtils.splitStr2StrArr(merchandise.getProductImages(), ",")); |
| | | list2.add(merchandise.getCover()); |
| | | detailsVo.setPics(list2); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(merchandise.getCover())) { |
| | | return -1; // s1排在前面 |
| | | } else if (s2.equals(merchandise.getCover())) { |
| | | return 1; // s2排在前面 |
| | | } else { |
| | | return 0; // 保持原顺序 |
| | | } |
| | | }); |
| | | detailsVo.setPics(list2); |
| | | 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()); |
| | | if (merchandise.getRedemptionMethod() == 1){ |
| | | detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); |
| | | }else { |
| | | detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); |
| | | } |
| | | 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()); |
| | | List<String> list3 = Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")); |
| | | list3.add(coupon.getCover()); |
| | | detailsVo.setPics(list3); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(coupon.getCover())) { |
| | | return -1; // s1排在前面 |
| | | } else if (s2.equals(coupon.getCover())) { |
| | | return 1; // s2排在前面 |
| | | } else { |
| | | return 0; // 保持原顺序 |
| | | } |
| | | }); |
| | | 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()); |
| | | if (merchandise.getRedemptionMethod() == 1){ |
| | | detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); |
| | | }else { |
| | | detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/getDetailsOfExchange") |
| | | public List<ExchangeDetailsResponse> getIntegralExchangeDetails(@RequestBody Integer appUserId){ |
| | | List<ExchangeDetailsResponse> responses = new ArrayList<>(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | List<UserPointsMerchandise> pointsMerchandises = upmseService.list(new QueryWrapper<UserPointsMerchandise>() |
| | | .eq("userId",appUserId )); |
| | | if (pointsMerchandises.size() > 0 ){ |
| | | for (UserPointsMerchandise pointsMerchandise : pointsMerchandises) { |
| | | PointsMerchandise merchandise = pmdsService.getById(pointsMerchandise.getPointsMerchandiseId()); |
| | | ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse(); |
| | | detailsResponse.setDetailsId(pointsMerchandise.getId()); |
| | | detailsResponse.setGoodName(merchandise.getName()); |
| | | if (merchandise.getRedemptionMethod() == 1){ |
| | | detailsResponse.setRequiredType(merchandise.getIntegral()+"积分"); |
| | | }else { |
| | | detailsResponse.setRequiredType(merchandise.getIntegral()+"积分 ¥"+merchandise.getCash()); |
| | | } |
| | | detailsResponse.setStartTime(simpleDateFormat.format(merchandise.getStartTime())); |
| | | detailsResponse.setEndTime(simpleDateFormat.format(merchandise.getEndTime())); |
| | | detailsResponse.setUseStatus(pointsMerchandise.getStatus()); |
| | | detailsResponse.setGoodType(merchandise.getType()); |
| | | responses.add(detailsResponse); |
| | | } |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/getSpecificsOfGoods") |
| | | public PointDetailsVo getSpecificsOfGoods(@RequestBody Integer speMercharsId){ |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | PointDetailsVo detailsVo = new PointDetailsVo(); |
| | | UserPointsMerchandise byId = upmseService.getById(speMercharsId); |
| | | if (ToolUtil.isNotEmpty(byId)){ |
| | | PointsMerchandise pmdsServiceById = pmdsService.getById(byId.getPointsMerchandiseId()); |
| | | detailsVo.setDetailsId(byId.getId()); |
| | | switch (pmdsServiceById.getType()){ |
| | | case 1: |
| | | case 3: |
| | | List<String> list2 = Arrays.asList(StrUtils.splitStr2StrArr(pmdsServiceById.getProductImages(), ",")); |
| | | list2.add(pmdsServiceById.getCover()); |
| | | detailsVo.setPics(list2); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(pmdsServiceById.getCover())) { |
| | | return -1; // s1排在前面 |
| | | } else if (s2.equals(pmdsServiceById.getCover())) { |
| | | return 1; // s2排在前面 |
| | | } else { |
| | | return 0; // 保持原顺序 |
| | | } |
| | | }); |
| | | break; |
| | | case 2: |
| | | CoursePackage coursePackage = cpClient.queryCoursePackageById(pmdsServiceById.getCoursePackageId()); |
| | | List<String> list1 = Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ",")); |
| | | list1.add(coursePackage.getCoverDrawing()); |
| | | detailsVo.setPics(list1); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(coursePackage.getCoverDrawing())) { |
| | | return -1; // s1排在前面 |
| | | } else if (s2.equals(coursePackage.getCoverDrawing())) { |
| | | return 1; // s2排在前面 |
| | | } else { |
| | | return 0; // 保持原顺序 |
| | | } |
| | | }); |
| | | break; |
| | | case 4: |
| | | Coupon coupon = iCouponService.getById(pmdsServiceById.getId()); |
| | | List<String> list3 = Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")); |
| | | list3.add(coupon.getCover()); |
| | | detailsVo.setPics(list3); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(coupon.getCover())) { |
| | | return -1; // s1排在前面 |
| | | } else if (s2.equals(coupon.getCover())) { |
| | | return 1; // s2排在前面 |
| | | } else { |
| | | return 0; // 保持原顺序 |
| | | } |
| | | }); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | detailsVo.setGoodName(pmdsServiceById.getName()); |
| | | detailsVo.setStartTime(simpleDateFormat.format(pmdsServiceById.getStartTime())); |
| | | detailsVo.setEndTime(simpleDateFormat.format(pmdsServiceById.getEndTime())); |
| | | detailsVo.setOrderTime(simpleDateFormat.format(byId.getInsertTime())); |
| | | if (byId.getStatus() == 1){ |
| | | detailsVo.setUseType(2); |
| | | }else { |
| | | detailsVo.setUseType(1); |
| | | detailsVo.setWriteOffTime(simpleDateFormat.format(byId.getVerificationTime())); |
| | | StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(byId.getVerifiStoreId()); |
| | | detailsVo.setWriteOffName(courseOfStore.getStoreName()); |
| | | } |
| | | switch (pmdsServiceById.getUseScope()){ |
| | | case 1: |
| | | detailsVo.setBelongs("全国通用"); |
| | | break; |
| | | case 2: |
| | | detailsVo.setBelongs(pmdsServiceById.getProvince()+pmdsServiceById.getCity()); |
| | | break; |
| | | case 3: |
| | | PointsMerchandiseStore one = pmdstoService.getOne(new QueryWrapper<PointsMerchandiseStore>() |
| | | .eq("pointsMerchandiseId",pmdsServiceById.getId() )); |
| | | StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(one.getStoreId()); |
| | | detailsVo.setBelongs(courseOfStore.getStoreName()+" "+courseOfStore.getStoreAddr()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | detailsVo.setContents(pmdsServiceById.getRedemptionInstructions()); |
| | | } |
| | | return detailsVo; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/selectPointsMerchandiseById") |
| | | public PointsMerchandise selectPointsMerchandiseById(@RequestBody Integer speMercharsId){ |
| | | return pmdsService.getById(speMercharsId); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/saveDetailsUserPointMercase") |
| | | public void saveDetailsUserPointMercase(@RequestBody UserPointsMerchandise merchandise){ |
| | | upmseService.save(merchandise); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/updateDetailsUserPointMercase") |
| | | public void updateDetailsUserPointMercase(@RequestBody UserPointsMerchandise merchandise){ |
| | | upmseService.updateById(merchandise); |
| | | } |
| | | |
| | | @PostMapping("/base/pointMerchars/queryUserPointMerchaseByCode") |
| | | public List<UserPointsMerchandise> queryUserPointMerchaseByCode(@RequestBody String code){ |
| | | return upmseService.list(new QueryWrapper<UserPointsMerchandise>() |
| | | .eq("code",code)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/queryStoreIdsOfMerchandise") |
| | | public List<Integer> queryPointMerStoreIds(@RequestBody Integer pointMerId){ |
| | | List<Integer> storeIds = new ArrayList<>(); |
| | | List<PointsMerchandiseStore> list = pmdstoService.list(new QueryWrapper<PointsMerchandiseStore>() |
| | | .eq("pointsMerchandiseId",pointMerId)); |
| | | if (list.size() > 0){ |
| | | storeIds = list.stream().map(PointsMerchandiseStore::getStoreId).collect(Collectors.toList()); |
| | | } |
| | | return storeIds; |
| | | } |
| | | |
| | | } |