From 7504753468ffbd0af41b07de66c0ccebf73680ea Mon Sep 17 00:00:00 2001
From: lisy <linlangsur163@163.com>
Date: 星期一, 14 八月 2023 15:47:20 +0800
Subject: [PATCH] 管理后台:添加优惠券的字段优化
---
cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/CouponDataVo.java | 2
cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java | 74 ++++++++++++++++++++++++++-----------
cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html | 2
cloud-server-activity/src/main/java/com/dsh/activity/model/request/CouponDataVo.java | 8 ++--
cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js | 8 ++--
5 files changed, 62 insertions(+), 32 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..3228d61 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;
@@ -385,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;
@@ -412,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(2);
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 +487,7 @@
couponCity.setCity(cityId.getCityName());
couponCity.setProvinceCode(cityId.getProvinceCode());
couponCity.setProvince(cityId.getProvinceName());
+ System.out.println(couponCity);
cityService.save(couponCity);
}
}
diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/model/request/CouponDataVo.java b/cloud-server-activity/src/main/java/com/dsh/activity/model/request/CouponDataVo.java
index e24adcf..ab4876c 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/model/request/CouponDataVo.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/model/request/CouponDataVo.java
@@ -9,7 +9,7 @@
@Data
public class CouponDataVo {
/**
- * 用户类型1=城市管理者 2=平台管理者
+ * 用户类型2=城市管理者 1=平台管理者
*/
Integer userType;
/**
@@ -83,7 +83,7 @@
/**
* 图片列表
*/
- List<String> goodImgs;
+ String goodImgs;
/**
* 适用范围
*/
@@ -91,9 +91,9 @@
/**
* 城市code
*/
- List<Integer> cityIds;
+ String cityIds;
/**
* 门店列表
*/
- List<Integer> storeIds;
+ String storeIds;
}
diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/CouponDataVo.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/CouponDataVo.java
index c0fc2f8..c3089f7 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/CouponDataVo.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/CouponDataVo.java
@@ -39,7 +39,7 @@
/**
* 体验券名称
*/
- BigDecimal experience;
+ String experience;
/**
* 说明
*/
diff --git a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html
index f1172fc..6834772 100644
--- a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html
+++ b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html
@@ -402,7 +402,7 @@
},
methods: {
handleAvatarSuccess(res, file) {
- couponInfoDlg.goodsPicArray.push(file);
+ couponInfoDlg.goodsPicArray.push(file.response);
},
beforeAvatarUpload(file) {
const isLt2M = file.size / 1024 / 1024 < 10;
diff --git a/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js b/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js
index 01e5dd4..7524448 100644
--- a/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js
+++ b/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js
@@ -349,15 +349,15 @@
}
// 兑换方式
let exchangeMethod = $(':radio[name="exchangeMethod"]:checked').val();
- if (distributionMethod === '' || distributionMethod === undefined || distributionMethod === null){
+ if (exchangeMethod === '' || exchangeMethod === undefined || exchangeMethod === null){
return Feng.error('兑换方式不能为空');
}
- if (distributionMethod === '1'){
+ if (exchangeMethod === '1'){
if (requiredPoints === undefined || requiredPoints === '' || requiredPoints === null){
return Feng.error('所需积分不能为空');
}
}
- if (distributionMethod === '2'){
+ if (exchangeMethod === '2'){
if (requiredPoints === undefined || requiredPoints === '' || requiredPoints === null){
return Feng.error('所需积分不能为空');
}
@@ -365,7 +365,7 @@
return Feng.error('所需现金不能为空');
}
}
- if (distributionMethod === '3'){
+ if (exchangeMethod === '3'){
if (requiredCash === undefined || requiredCash === '' || requiredCash === null){
return Feng.error('所需现金不能为空');
}
--
Gitblit v1.7.1