From ef9a326f927e66835901cc9fa32536ed85cb97d6 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期一, 16 十月 2023 14:31:49 +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 | 92 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 70 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 1d2982e..e9a3473 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
@@ -34,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;
@@ -237,6 +238,24 @@
return mapList;
}
+
+ @ResponseBody
+ @PostMapping("/base/coupon/queryCouponListSearch1")
+ public List<Map<String,Object>> getCouponListOfSearch1(@RequestBody CouponListOfSearch ofSearch){
+ List<Map<String, Object>> mapList = couponService.queryCouponListOfSearch1(ofSearch);
+ if (mapList.size() > 0){
+ for (Map<String, Object> stringObjectMap : mapList) {
+ Integer o = (Integer) stringObjectMap.get("id");
+ Object startTime = stringObjectMap.get("startTime");
+ Object endTime = stringObjectMap.get("endTime");
+ stringObjectMap.put("timeValue",startTime + "至"+endTime);
+ int count = ucService.count(new LambdaQueryWrapper<UserCoupon>()
+ .eq(UserCoupon::getCouponId, o));
+ stringObjectMap.put("hasPickQty",count);
+ }
+ }
+ return mapList;
+ }
@ResponseBody
@PostMapping("/base/coupon/couponExamineListSearch")
public List<Map<String,Object>> getCouponExamineListOfSearch(@RequestBody CouponExamineListSearch ofSearch){
@@ -385,26 +404,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;
@@ -412,45 +433,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());
@@ -458,6 +505,7 @@
couponCity.setCity(cityId.getCityName());
couponCity.setProvinceCode(cityId.getProvinceCode());
couponCity.setProvince(cityId.getProvinceName());
+ System.out.println(couponCity);
cityService.save(couponCity);
}
}
--
Gitblit v1.7.1