From 6dd3ce5d438e90e453bf3e44e287aa835ffda339 Mon Sep 17 00:00:00 2001 From: lisy <linlangsur163@163.com> Date: 星期二, 01 八月 2023 14:05:30 +0800 Subject: [PATCH] app端接口优化 --- cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java | 98 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 85 insertions(+), 13 deletions(-) diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java index 26c9023..8c2e9aa 100644 --- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java +++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java @@ -1,6 +1,7 @@ package com.dsh.activity.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.dsh.activity.entity.*; import com.dsh.activity.feignclient.course.CoursePackageClient; @@ -14,6 +15,7 @@ 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; @@ -21,8 +23,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; @RestController @RequestMapping("") @@ -58,6 +62,12 @@ @Autowired private CouponStoreService cstoreService; + + @Autowired + private TokenUtil tokenUtil; + + @Resource + private CouponCityService ccityService; @PostMapping("/base/pointMerchars/convertGoods") @@ -121,7 +131,7 @@ switch (detailRequest.getGoodsType()){ case 2: // 课包 - CoursePackage coursePackage = cpClient.queryCoursePackageById(detailRequest.getGoodId()); + CoursePackage coursePackage = cpClient.queryCoursePackageById(merchandise.getCoursePackageId()); detailsVo.setGoodId(coursePackage.getId()); List<String> list1 = Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ",")); @@ -144,16 +154,22 @@ detailsVo.setResidueNum(merchandise.getQuantityIssued() - coursePackageNums); detailsVo.setPerLimit(merchandise.getPickUpQuantity()); if (merchandise.getRedemptionMethod() == 1){ - detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); + detailsVo.setExchangeType(1); + detailsVo.setIntegral(merchandise.getIntegral()); }else { - detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); + detailsVo.setExchangeType(2); + detailsVo.setIntegral(merchandise.getIntegral()); + detailsVo.setCash(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); @@ -161,12 +177,13 @@ detailsVo.setBelongs(courseOfStore.getStoreName()+"可用"); } List<CoursePackagePaymentConfig> courseConfigList = cpcfigClient.getCourseConfigList(coursePackage.getId()); - int redul = 0; for (CoursePackagePaymentConfig coursePackagePaymentConfig : courseConfigList) { - redul = redul + coursePackagePaymentConfig.getClassHours(); + if (Objects.equals(coursePackagePaymentConfig.getId(), merchandise.getCoursePackageConfigId())){ + detailsVo.setCourseHours(coursePackagePaymentConfig.getClassHours()); + break; + } } - detailsVo.setCourseHours(redul); detailsVo.setStartTime(format.format(merchandise.getStartTime())); detailsVo.setEndTime(format.format(merchandise.getEndTime())); @@ -199,9 +216,10 @@ detailsVo.setResidueNum(merchandise.getQuantityIssued()-count); detailsVo.setPerLimit(merchandise.getPickUpQuantity()); if (merchandise.getRedemptionMethod() == 1){ - detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); + detailsVo.setIntegral(merchandise.getIntegral()); }else { - detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); + detailsVo.setIntegral(merchandise.getIntegral()); + detailsVo.setCash(merchandise.getCash()); } detailsVo.setCost(merchandise.getPrice()); if (merchandise.getUseScope() == 1){ @@ -246,14 +264,19 @@ detailsVo.setResidueNum(coupon.getQuantityIssued()-couponNums); detailsVo.setPerLimit(coupon.getPickUpQuantity()); if (merchandise.getRedemptionMethod() == 1){ - detailsVo.setRequiredType(merchandise.getIntegral() + "积分"); + detailsVo.setIntegral(merchandise.getIntegral()); }else { - detailsVo.setRequiredType(merchandise.getIntegral() + "积分+¥"+merchandise.getCash()); + detailsVo.setIntegral(merchandise.getIntegral()); + detailsVo.setCash(merchandise.getCash()); } if (coupon.getUseScope() == 1){ detailsVo.setBelongs("全国通用"); }else if (coupon.getUseScope() == 2){ - detailsVo.setBelongs(coupon.getProvince()+"|"+coupon.getCity() + "用户可用"); + List<CouponCity> list = ccityService.list(new LambdaQueryWrapper<CouponCity>() + .eq(CouponCity::getCouponId, coupon.getId())); + if (list.size() > 0){ + detailsVo.setBelongs(list.get(0).getProvince()+"|"+list.get(0).getCity() + "用户可用"); + } }else { List<CouponStore> list = cstoreService.list(new QueryWrapper<CouponStore>() .eq("couponId",coupon.getId() )); @@ -287,9 +310,12 @@ detailsResponse.setDetailsId(pointsMerchandise.getId()); detailsResponse.setGoodName(merchandise.getName()); if (merchandise.getRedemptionMethod() == 1){ - detailsResponse.setRequiredType(merchandise.getIntegral()+"积分"); + detailsResponse.setExchangeType(1); + detailsResponse.setIntegral(merchandise.getIntegral()); }else { - detailsResponse.setRequiredType(merchandise.getIntegral()+"积分 ¥"+merchandise.getCash()); + detailsResponse.setExchangeType(2); + detailsResponse.setIntegral(merchandise.getIntegral()); + detailsResponse.setCash(merchandise.getCash()); } detailsResponse.setStartTime(simpleDateFormat.format(merchandise.getStartTime())); detailsResponse.setEndTime(simpleDateFormat.format(merchandise.getEndTime())); @@ -310,6 +336,14 @@ UserPointsMerchandise byId = upmseService.getById(speMercharsId); if (ToolUtil.isNotEmpty(byId)){ PointsMerchandise pmdsServiceById = pmdsService.getById(byId.getPointsMerchandiseId()); + detailsVo.setExchangeType(pmdsServiceById.getRedemptionMethod()); + detailsVo.setGoodType(pmdsServiceById.getType()); + if (pmdsServiceById.getRedemptionMethod() == 1){ + detailsVo.setIntegral(pmdsServiceById.getIntegral()); + }else { + detailsVo.setCash(pmdsServiceById.getCash()); + detailsVo.setIntegral(pmdsServiceById.getIntegral()); + } detailsVo.setDetailsId(byId.getId()); switch (pmdsServiceById.getType()){ case 1: @@ -332,6 +366,8 @@ List<String> list1 = Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ",")); list1.add(coursePackage.getCoverDrawing()); detailsVo.setPics(list1); + CoursePackagePaymentConfig coursePackagePaymentConfig = cpClient.queryConfigCoursePackData(pmdsServiceById.getCoursePackageConfigId()); + detailsVo.setClassHours(coursePackagePaymentConfig.getClassHours()); Collections.sort(detailsVo.getPics(), (s1, s2) -> { if (s1.equals(coursePackage.getCoverDrawing())) { return -1; // s1排在前面 @@ -394,4 +430,40 @@ 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; + } + } -- Gitblit v1.7.1