From 1d07f8271751880bdfbf3ea41e696f9ee719888b Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期四, 17 八月 2023 08:48:36 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai --- cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java | 107 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 85 insertions(+), 22 deletions(-) diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java index e83e1c8..4829342 100644 --- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java +++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java @@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONObject; 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.feignclient.account.AppUserClient; import com.dsh.activity.feignclient.account.CityClient; import com.dsh.activity.feignclient.account.StoreStaffClient; import com.dsh.activity.feignclient.account.model.TCityManager; @@ -19,6 +21,7 @@ import com.dsh.activity.feignclient.other.model.CityDataAndProvinceDataVo; import com.dsh.activity.feignclient.other.model.Store; 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; @@ -31,6 +34,7 @@ import com.dsh.activity.util.ResultUtil; import com.dsh.activity.util.TokenUtil; import com.dsh.activity.util.ToolUtil; +import com.google.gson.Gson; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -82,6 +86,9 @@ @Resource private CouponCityService cityService; + + @Autowired + private AppUserClient appUserClient; @@ -379,26 +386,28 @@ @ResponseBody @PostMapping("/base/coupon/insertIntoCouponData") public boolean saveCouponData(@RequestBody CouponDataVo dataVo){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { System.out.println(dataVo); Coupon coupon = new Coupon(); coupon.setName(dataVo.getCouponName()); coupon.setType(dataVo.getPrescription()); HashMap<String, Object> stringObjectHashMap = new HashMap<>(); + Gson gson = new Gson(); switch (dataVo.getPrescription()){ // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} case 1: stringObjectHashMap.put("conditionalAmount",dataVo.getCondition()); stringObjectHashMap.put("deductionAmount",dataVo.getSubtraction()); - coupon.setContent(stringObjectHashMap.toString()); + coupon.setContent(gson.toJson(stringObjectHashMap)); break; case 2: stringObjectHashMap.put("conditionalAmount",dataVo.getDiscount()); - coupon.setContent(stringObjectHashMap.toString()); + coupon.setContent(gson.toJson(stringObjectHashMap)); break; case 3: stringObjectHashMap.put("experienceName",dataVo.getExperience()); - coupon.setContent(stringObjectHashMap.toString()); + coupon.setContent(gson.toJson(stringObjectHashMap)); break; default: break; @@ -406,45 +415,71 @@ coupon.setIllustrate(dataVo.getIllustrate()); coupon.setDistributionMethod(dataVo.getDistributionMethod()); coupon.setRedemptionMethod(dataVo.getExchangeMethod()); - coupon.setCash(dataVo.getRequiredCash()); - coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints())); + switch (dataVo.getExchangeMethod()){ + case 1: + coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints())); + break; + case 2: + coupon.setCash(dataVo.getRequiredCash()); + coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints())); + break; + case 3: + coupon.setCash(dataVo.getRequiredCash()); + break; + default: + break; + } coupon.setQuantityIssued(dataVo.getQuantityIssued()); coupon.setPickUpQuantity(dataVo.getPickUpQuantity()); coupon.setUseScope(dataVo.getCompany()); + coupon.setUserPopulation(dataVo.getUserGroup()); + String timeDeal = dataVo.getPeriodOfValidity(); + if (ToolUtil.isNotEmpty(timeDeal)){ + String[] split = timeDeal.split(" - "); + coupon.setStartTime(simpleDateFormat.parse(split[0])); + coupon.setEndTime(simpleDateFormat.parse(split[1])); + } coupon.setAuditStatus(1); coupon.setStatus(1); + coupon.setState(1); coupon.setInsertTime(new Date()); coupon.setCover(dataVo.getGoodImg()); - List<String> goodImgs = dataVo.getGoodImgs(); - StringBuilder builder = new StringBuilder(); - if (goodImgs.size() > 0){ - if (goodImgs.size() == 1){ - coupon.setProductImages(goodImgs.get(0)); + String goodImgs = dataVo.getGoodImgs(); + String[] imgsSplit = goodImgs.split(","); + if (imgsSplit.length > 0){ + if (imgsSplit.length == 1){ + coupon.setProductImages(imgsSplit[0]); }else { - for (String goodImg : goodImgs) { - builder.append(goodImg).append(","); - } - builder.deleteCharAt(builder.lastIndexOf(",")); - coupon.setProductImages(builder.toString()); + coupon.setProductImages(goodImgs); } } - coupon.setPublisherType(dataVo.getUserType()); if (dataVo.getUserType() == 1){ + coupon.setPublisherType(2); + } + if (dataVo.getUserType() == 2){ + coupon.setPublisherType(1); coupon.setCityManagerId(dataVo.getCityManagerId()); } boolean save = couponService.save(coupon); if (save){ - if (dataVo.getCompany() == 2){ - for (Integer storeId : dataVo.getStoreIds()) { + if (dataVo.getCompany() == 3){ + String[] split = dataVo.getStoreIds().split(","); + for (String storeId : split) { CouponStore couponStore = new CouponStore(); couponStore.setCouponId(coupon.getId()); - couponStore.setStoreId(storeId); + couponStore.setStoreId(Integer.parseInt(storeId)); couStoreService.save(couponStore); } } - List<Integer> cityIds = dataVo.getCityIds(); - if (dataVo.getCompany() == 3 && cityIds.size() > 0 ){ - List<CityDataAndProvinceDataVo> cityAndProvince = regionClient.getCityAndProvince(cityIds); + String cityIds = dataVo.getCityIds(); + String[] split = cityIds.split(","); + List<Integer> cityIdss = new ArrayList<>(); + if (dataVo.getCompany() == 2 && split.length > 0 ){ + for (String s : split) { + int intValue = Integer.parseInt(s); + cityIdss.add(intValue); + } + List<CityDataAndProvinceDataVo> cityAndProvince = regionClient.getCityAndProvince(cityIdss); for (CityDataAndProvinceDataVo cityId : cityAndProvince) { CouponCity couponCity = new CouponCity(); couponCity.setCouponId(coupon.getId()); @@ -452,6 +487,7 @@ couponCity.setCity(cityId.getCityName()); couponCity.setProvinceCode(cityId.getProvinceCode()); couponCity.setProvince(cityId.getProvinceName()); + System.out.println(couponCity); cityService.save(couponCity); } } @@ -462,4 +498,31 @@ } } + @ResponseBody + @PostMapping("/base/coupon/queryCity") + public List<CouponCity> queryCity(@RequestBody Integer id){ + List<CouponCity> list = cityService.list(new LambdaQueryWrapper<CouponCity>().eq(CouponCity::getCouponId, id)); + 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()); + } + + + @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()); + } + + + + @PostMapping("/base/coupon/updateType") + public void updateType(@RequestBody Long id){ + couponService.updateType(id); + } } -- Gitblit v1.7.1