From b21fb4c288c98971f9859cf5d85cef4c86e131bb Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期五, 08 十二月 2023 14:46:21 +0800
Subject: [PATCH] 12.8
---
cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java | 328 +++++++++++++++++++++++++++---------------------------
1 files changed, 164 insertions(+), 164 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 e0804f2..db0d613 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
@@ -1,4 +1,5 @@
package com.dsh.activity.controller;
+
import java.util.Date;
import com.alibaba.fastjson.JSON;
@@ -87,7 +88,6 @@
private StoreClient stoClient;
-
@Resource
private RegionClient regionClient;
@@ -107,8 +107,10 @@
*/
@ResponseBody
@PostMapping("/coupon/queryCouponByUser/{userId}")
- public List<Integer> queryCouponByUser(@PathVariable("userId") Integer userId){
- List<Coupon> list = couponService.list(new QueryWrapper<Coupon>().eq("distributionMethod", 2).eq("userPopulation",2)
+ public List<Long> queryCouponByUser(@PathVariable("userId") Integer userId) {
+ List<Long> ids = new ArrayList<>();
+ System.err.println("到达了赠送优惠价");
+ List<Coupon> list = couponService.list(new QueryWrapper<Coupon>().eq("distributionMethod", 2)
.le("startTime", new Date()).ge("endTime", new Date()).eq("auditStatus", 2)
.eq("state", 1));
@@ -122,10 +124,10 @@
// 用户已领取该优惠券数量
int count = ucService.count(new QueryWrapper<UserCoupon>().eq("couponId", coupon.getId()
).eq("userId", userId));
- if (couponId>=quantityIssued){
+ if (couponId >= quantityIssued) {
continue;
}
- if (count>=pickUpQuantity){
+ if (count >= pickUpQuantity) {
continue;
}
// 条件满足 将优惠券送给用户
@@ -135,8 +137,9 @@
userCoupon.setStatus(1);
userCoupon.setInsertTime(new Date());
ucService.save(userCoupon);
+ ids.add(userCoupon.getId());
}
- return null;
+ return ids;
}
@ResponseBody
@@ -146,18 +149,18 @@
@ApiImplicitParam(value = "1=积分购买,2=注册赠送", name = "distributionMethod", dataType = "int", required = true),
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
- public ResultUtil<List<CouponListVo>> queryCouponList(Integer distributionMethod){
- if(null == distributionMethod){
+ public ResultUtil<List<CouponListVo>> queryCouponList(Integer distributionMethod) {
+ if (null == distributionMethod) {
return ResultUtil.paranErr("distributionMethod");
}
try {
Integer uid = tokenUtil.getUserIdFormRedis();
- if(null == uid){
+ if (null == uid) {
return ResultUtil.tokenErr();
}
List<CouponListVo> listVos = couponService.queryCouponList(uid, distributionMethod);
return ResultUtil.success(listVos);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.success();
}
@@ -166,16 +169,17 @@
/**
* 根据id获取优惠券信息
+ *
* @param id
* @return
*/
@ResponseBody
@PostMapping("/coupon/queryCouponById")
- public Coupon queryCouponById(@RequestBody Integer id){
+ public Coupon queryCouponById(@RequestBody Integer id) {
try {
Coupon coupon = couponService.getById(id);
return coupon;
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
@@ -184,9 +188,10 @@
@Autowired
private UserCouponService userCouponService;
+
@ResponseBody
@PostMapping("/coupon/queryCouponByUid")
- public List<Coupon> queryCouponByUid(@RequestBody Integer uid){
+ public List<Coupon> queryCouponByUid(@RequestBody Integer uid) {
try {
LocalDateTime currentTime = LocalDateTime.now();
LocalDateTime oneMinuteAgo = currentTime.minusSeconds(20);
@@ -197,14 +202,14 @@
ids.add(userCoupon.getCouponId());
}
- if (ids.size()>0){
- List<Coupon> userId = couponService.list(new QueryWrapper<Coupon>().in("id",ids));
+ if (ids.size() > 0) {
+ List<Coupon> userId = couponService.list(new QueryWrapper<Coupon>().in("id", ids));
return userId;
}
return null;
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
@@ -212,7 +217,8 @@
/**
- * 我的券包列表
+ * 我的券包列表
+ *
* @param req
* @return
*/
@@ -222,14 +228,14 @@
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
- public ResultUtil<List<CouponPackageResp>> queryAppuserCouponList( CouponPackageReq req){
+ public ResultUtil<List<CouponPackageResp>> queryAppuserCouponList(CouponPackageReq req) {
try {
Integer uid = tokenUtil.getUserIdFormRedis();
- if(null == uid){
+ if (null == uid) {
return ResultUtil.tokenErr();
}
return ResultUtil.success(ucService.queryCouponPackagesList(uid, req));
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.success();
}
@@ -237,39 +243,39 @@
@PostMapping("/base/coupon/getAllCoupons")
- public List<Coupon> getAllCoupons(@RequestBody CommodityRequest request){
+ public List<Coupon> getAllCoupons(@RequestBody CommodityRequest request) {
List<Coupon> couponList = new ArrayList<>();
String provinceCode = "";
String cityCode = "";
- if (ToolUtil.isEmpty(request.getLat()) && ToolUtil.isEmpty(request.getLon())){
+ if (ToolUtil.isEmpty(request.getLat()) && ToolUtil.isEmpty(request.getLon())) {
return couponList;
}
try {
Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat());
provinceCode = geocode.get("provinceCode");
cityCode = geocode.get("cityCode");
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
try {
LocalDateTime currentDate = LocalDateTime.now();
couponList = couponService.list(new QueryWrapper<Coupon>()
- .eq("distributionMethod",1)
- .eq("state",1)
- .eq("status",1)
- .le("startTime", currentDate)
+ .eq("distributionMethod", 1)
+ .eq("state", 1)
+ .eq("status", 1)
+ .le("startTime", currentDate)
.ge("endTime", currentDate));
- if (couponList.size() > 0 ){
+ if (couponList.size() > 0) {
Iterator<Coupon> iterator = couponList.iterator();
while (iterator.hasNext()) {
Coupon merchandise = iterator.next();
- if (merchandise.getUseScope() == 2){
+ if (merchandise.getUseScope() == 2) {
List<CouponCity> couponCities = cityService.list(new LambdaQueryWrapper<CouponCity>()
- .eq(CouponCity::getCouponId,merchandise.getId()));
- if (couponCities.size() > 0){
+ .eq(CouponCity::getCouponId, merchandise.getId()));
+ if (couponCities.size() > 0) {
for (CouponCity couponCity : couponCities) {
- if (!Objects.equals(couponCity.getCityCode(), cityCode) && !Objects.equals(couponCity.getProvinceCode(), provinceCode)){
+ if (!Objects.equals(couponCity.getCityCode(), cityCode) && !Objects.equals(couponCity.getProvinceCode(), provinceCode)) {
iterator.remove(); // 移除符合条件的商品
break;
}
@@ -286,14 +292,14 @@
}
@PostMapping("/base/coupon/getRedeemedNums")
- public int getRedeemedQuantity(@RequestBody Integer id){
+ public int getRedeemedQuantity(@RequestBody Integer id) {
return ucService.count(new QueryWrapper<UserCoupon>()
- .eq("couponId",id));
+ .eq("couponId", id));
}
@PostMapping("/base/coupon/insertToAppuserCoupon")
- public void insertToAppuserCoupon(@RequestBody UserCoupon coupon){
+ public void insertToAppuserCoupon(@RequestBody UserCoupon coupon) {
coupon.setInsertTime(new Date());
ucService.save(coupon);
}
@@ -301,28 +307,30 @@
@Autowired
private OperatorClient operatorClient;
+
@ResponseBody
@PostMapping("/base/coupon/queryCouponListSearch")
- public List<Map<String,Object>> getCouponListOfSearch(@RequestBody CouponListOfSearch ofSearch){
+ public List<Map<String, Object>> getCouponListOfSearch(@RequestBody CouponListOfSearch ofSearch) {
List<Map<String, Object>> mapList1 = couponService.queryCouponListOfSearch(ofSearch);
+
List<Map<String, Object>> mapList = new ArrayList<>();
- if (ofSearch.getStoreIds()==null){
+ if (ofSearch.getStoreIds() == null) {
ArrayList<Integer> list = new ArrayList<>();
ofSearch.setStoreIds(list);
}
- if(ofSearch.getStoreId()!=null || ofSearch.getStoreIds().size()!=0){
+ if (ofSearch.getStoreId() != null || ofSearch.getStoreIds().size() != 0) {
for (Map<String, Object> map : mapList1) {
// 如果当前登陆人是运营商 只能查看平台添加的优惠券应只展示使用范围为全国通用、
// 指定城市有运营商管辖的、指定门店有运营商旗下门店
- if (ofSearch.getObjType()== 2){
- if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 1){
+ if (ofSearch.getObjType() == 2) {
+ if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 1) {
mapList.add(map);
}
- if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 2){
+ if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 2) {
// 获取到优惠券id 查询这个优惠券指定了哪些城市
Integer id = Integer.parseInt(String.valueOf(map.get("id")));
// 获取到运营商管理的省和市
- List<TOperatorCity> cityByOperatorId = operatorClient.getCityByOperatorId(ofSearch.getOperatorId());
+ List<TOperatorCity> cityByOperatorId = ofSearch.getOperatorCities();
// 拿到运营商市的code集合
List<String> collect = cityByOperatorId.stream().filter(t -> t.getPid() != 0)
.map(tOperatorCity -> Integer.toString(tOperatorCity.getCode()))
@@ -334,59 +342,59 @@
// 优惠券指定的省
List<String> collect2 = couponId.stream().map(CouponCity::getCityCode)
.collect(Collectors.toList());
- if (!Collections.disjoint(collect, collect1)){
+ if (!Collections.disjoint(collect, collect1)) {
mapList.add(map);
- }else{
+ } else {
// 如果没有交集 那么还需要判断运营商是否管理了整个省
}
}
- if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 3){
+ if (Integer.parseInt(String.valueOf(map.get("useScope"))) == 3) {
// 获取到优惠券id 查询这个优惠券指定了哪些门店
Integer id = Integer.parseInt(String.valueOf(map.get("id")));
// 当前运营商管理的门店ids
List<Integer> storeIds = ofSearch.getStoreIds();
// 优惠券指定的门店
- List<Integer> collect = couStoreService.list(new QueryWrapper<CouponStore>().eq("couponId",id)
+ List<Integer> collect = couStoreService.list(new QueryWrapper<CouponStore>().eq("couponId", id)
.in("storeId", storeIds)).stream().map(CouponStore::getStoreId)
.collect(Collectors.toList());
// 判断两个集合是否相交
// 比较两个集合中是否有相同的元素;当两个集合中没有相同元素时返回true,
// 当有相同元素时返回false。
- if (!Collections.disjoint(collect, storeIds)){
+ if (!Collections.disjoint(collect, storeIds)) {
mapList.add(map);
}
}
- }else{
+ } else {
List<CouponStore> id = couStoreService.list(new LambdaQueryWrapper<CouponStore>()
.eq(CouponStore::getCouponId, map.get("id").toString()));
List<Integer> collect = id.stream().map(CouponStore::getStoreId).collect(Collectors.toList());
- if(collect.size()==0){
+ if (collect.size() == 0) {
collect.add(-1);
}
- if(collect.contains(ofSearch.getStoreId())){
- if(collect.size()>1){
- map.put("size",1);
- }else {
- map.put("size",0);
+ if (collect.contains(ofSearch.getStoreId())) {
+ if (collect.size() > 1) {
+ map.put("size", 1);
+ } else {
+ map.put("size", 0);
}
mapList.add(map);
}
}
}
- }else {
+ } else {
mapList = mapList1;
}
- if (mapList.size() > 0){
+ 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);
+ stringObjectMap.put("timeValue", startTime + "至" + endTime);
int count = ucService.count(new LambdaQueryWrapper<UserCoupon>()
.eq(UserCoupon::getCouponId, o));
- stringObjectMap.put("hasPickQty",count);
+ stringObjectMap.put("hasPickQty", count);
}
}
return mapList;
@@ -395,13 +403,12 @@
@ResponseBody
@PostMapping("/base/coupon/queryCouponListSearch1")
- public List<Map<String,Object>> getCouponListOfSearch1(@RequestBody CouponListOfSearch ofSearch){
+ public List<Map<String, Object>> getCouponListOfSearch1(@RequestBody CouponListOfSearch ofSearch) {
+ // 查询全国通用的优惠券和包含指定门店的优惠券
List<Map<String, Object>> mapList = couponService.queryCouponListOfSearch1(ofSearch);
-
Date currentDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String currentDateStr = sdf.format(currentDate);
-
// Iterate over the mapList and remove entries where endTime is less than the current date
Iterator<Map<String, Object>> iterator = mapList.iterator();
while (iterator.hasNext()) {
@@ -413,36 +420,33 @@
}
- if (mapList.size() > 0){
+ 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);
+ stringObjectMap.put("timeValue", startTime + "至" + endTime);
int count = ucService.count(new LambdaQueryWrapper<UserCoupon>()
.eq(UserCoupon::getCouponId, o));
- stringObjectMap.put("hasPickQty",count);
+ stringObjectMap.put("hasPickQty", count);
}
}
return mapList;
}
+
@ResponseBody
@PostMapping("/base/coupon/couponExamineListSearch")
- public List<Map<String,Object>> getCouponExamineListOfSearch(@RequestBody CouponExamineListSearch ofSearch){
+ public List<Map<String, Object>> getCouponExamineListOfSearch(@RequestBody CouponExamineListSearch ofSearch) {
List<Map<String, Object>> mapList = couponService.queryCouponExamineList(ofSearch);
- if (mapList.size() > 0){
+ if (mapList.size() > 0) {
for (Map<String, Object> stringObjectMap : mapList) {
Object startTime = stringObjectMap.get("startTime");
Object endTime = stringObjectMap.get("endTime");
- stringObjectMap.put("timeValue",startTime + "至"+endTime);
+ stringObjectMap.put("timeValue", startTime + "至" + endTime);
Integer publisherType = (Integer) stringObjectMap.get("publisherType");
- if (publisherType!=null) {
+ if (publisherType != null) {
if (publisherType == 1) {
- Integer cityManagerId = (Integer) stringObjectMap.get("cityManagerId");
- TCityManager byId = citClient.getById(cityManagerId);
- stringObjectMap.put("province", byId.getProvince());
- stringObjectMap.put("city", byId.getCity());
}
}
}
@@ -453,102 +457,102 @@
@ResponseBody
@PostMapping("/base/coupon/couponExamineDetail")
- Map<String, Object> queryCouponExamineDetail(@RequestBody Integer id){
+ Map<String, Object> queryCouponExamineDetail(@RequestBody Integer id) {
Map<String, Object> couponInfo = new HashMap<>();
Coupon coupon = couponService.getById(id);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- if (ToolUtil.isNotEmpty(coupon)){
- couponInfo.put("id",coupon.getId());
- couponInfo.put("auditStatus",coupon.getAuditStatus());
- couponInfo.put("publisherType",coupon.getPublisherType());
+ if (ToolUtil.isNotEmpty(coupon)) {
+ couponInfo.put("id", coupon.getId());
+ couponInfo.put("auditStatus", coupon.getAuditStatus());
+ couponInfo.put("publisherType", coupon.getPublisherType());
- couponInfo.put("name",coupon.getName());
- couponInfo.put("type",coupon.getType());
+ couponInfo.put("name", coupon.getName());
+ couponInfo.put("type", coupon.getType());
JSONObject jsonObject = JSON.parseObject(coupon.getContent());
- switch (coupon.getType()){
+ switch (coupon.getType()) {
case 1:
// {"conditionalAmount":50,"deductionAmount":10,"experienceName":""}
- couponInfo.put("num1",jsonObject.getDouble("conditionalAmount"));
- couponInfo.put("num2",jsonObject.getDouble("deductionAmount"));
+ couponInfo.put("num1", jsonObject.getDouble("conditionalAmount"));
+ couponInfo.put("num2", jsonObject.getDouble("deductionAmount"));
break;
case 2:
- couponInfo.put("num1",jsonObject.getDouble("conditionalAmount"));
+ couponInfo.put("num1", jsonObject.getDouble("conditionalAmount"));
break;
case 3:
- couponInfo.put("num1",jsonObject.getString("experienceName"));
+ couponInfo.put("num1", jsonObject.getString("experienceName"));
break;
default:
break;
}
- couponInfo.put("illustrate",coupon.getIllustrate());
- switch (coupon.getDistributionMethod()){
+ couponInfo.put("illustrate", coupon.getIllustrate());
+ switch (coupon.getDistributionMethod()) {
case 1:
- couponInfo.put("distributionMethod","积分注册");
+ couponInfo.put("distributionMethod", "积分注册");
break;
case 2:
- couponInfo.put("distributionMethod","注册赠送");
+ couponInfo.put("distributionMethod", "注册赠送");
break;
case 3:
- couponInfo.put("distributionMethod","自动发券");
+ couponInfo.put("distributionMethod", "自动发券");
break;
default:
break;
}
- couponInfo.put("redemptionMethod",coupon.getRedemptionMethod());
- couponInfo.put("integral",coupon.getIntegral());
- couponInfo.put("cash",coupon.getCash());
- switch (coupon.getUserPopulation()){
+ couponInfo.put("redemptionMethod", coupon.getRedemptionMethod());
+ couponInfo.put("integral", coupon.getIntegral());
+ couponInfo.put("cash", coupon.getCash());
+ switch (coupon.getUserPopulation()) {
case 1:
- couponInfo.put("userPopulation","全部用户");
+ couponInfo.put("userPopulation", "全部用户");
break;
case 2:
- couponInfo.put("userPopulation","年度会员");
+ couponInfo.put("userPopulation", "年度会员");
break;
case 3:
- couponInfo.put("userPopulation","已有学员用户");
+ couponInfo.put("userPopulation", "已有学员用户");
break;
default:
break;
}
- couponInfo.put("quantityIssued",coupon.getQuantityIssued());
- couponInfo.put("pickUpQuantity",coupon.getPickUpQuantity());
+ couponInfo.put("quantityIssued", coupon.getQuantityIssued());
+ couponInfo.put("pickUpQuantity", coupon.getPickUpQuantity());
String startTime = simpleDateFormat.format(coupon.getStartTime());
String endTime = simpleDateFormat.format(coupon.getEndTime());
- couponInfo.put("timeValue",startTime + "至"+endTime);
- couponInfo.put("useScope",coupon.getUseScope());
+ couponInfo.put("timeValue", startTime + "至" + endTime);
+ couponInfo.put("useScope", coupon.getUseScope());
ArrayList<Map<String, Object>> maps = new ArrayList<>();
- switch (coupon.getUseScope()){
+ switch (coupon.getUseScope()) {
case 2:
List<CouponCity> couponCities = cityService.list(new LambdaQueryWrapper<CouponCity>()
- .eq(CouponCity::getCouponId,coupon.getId()));
- if (couponCities.size() > 0){
+ .eq(CouponCity::getCouponId, coupon.getId()));
+ if (couponCities.size() > 0) {
for (CouponCity couponCity : couponCities) {
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
- stringObjectHashMap.put("province",couponCity.getProvince());
- stringObjectHashMap.put("city",couponCity.getCity());
+ stringObjectHashMap.put("province", couponCity.getProvince());
+ stringObjectHashMap.put("city", couponCity.getCity());
maps.add(stringObjectHashMap);
}
- couponInfo.put("rangeData",maps);
+ couponInfo.put("rangeData", maps);
}
break;
case 3:
List<CouponStore> list = couStoreService.list(new LambdaQueryWrapper<CouponStore>()
- .eq(CouponStore::getCouponId,coupon.getId()));
- if (list.size() > 0){
+ .eq(CouponStore::getCouponId, coupon.getId()));
+ if (list.size() > 0) {
// 获取门店ids
List<Integer> collect = list.stream().map(CouponStore::getStoreId).collect(Collectors.toList());
List<Store> storeList = stoClient.queryStoreByIds(collect);
- if (storeList.size() > 0){
+ if (storeList.size() > 0) {
for (Store store : storeList) {
StoreInfoDto storeInfo = stoClient.getStoreInfo(store.getStoreStaffId());
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
- stringObjectHashMap.put("procity",store.getProvince()+store.getCity());
- stringObjectHashMap.put("storeAccount",storeInfo.getInfo());
- stringObjectHashMap.put("storeName",store.getName());
+ stringObjectHashMap.put("procity", store.getProvince() + store.getCity());
+ stringObjectHashMap.put("storeAccount", storeInfo.getInfo());
+ stringObjectHashMap.put("storeName", store.getName());
maps.add(stringObjectHashMap);
}
- couponInfo.put("rangeData",maps);
+ couponInfo.put("rangeData", maps);
}
}
@@ -561,20 +565,19 @@
}
-
@ResponseBody
@PostMapping("/base/coupon/updateCouponExamine")
- public boolean updateCouponData(@RequestBody Coupon coupon){
+ public boolean updateCouponData(@RequestBody Coupon coupon) {
try {
return couponService.updateById(coupon);
- }catch (Exception e){
+ } catch (Exception e) {
return false;
}
}
@ResponseBody
@PostMapping("/base/coupon/insertIntoCouponData")
- public boolean saveCouponData(@RequestBody CouponDataVo dataVo){
+ public boolean saveCouponData(@RequestBody CouponDataVo dataVo) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
System.out.println(dataVo);
@@ -583,19 +586,19 @@
coupon.setType(dataVo.getPrescription());
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
Gson gson = new Gson();
- switch (dataVo.getPrescription()){
+ switch (dataVo.getPrescription()) {
// {"conditionalAmount":50,"deductionAmount":10,"experienceName":""}
case 1:
- stringObjectHashMap.put("conditionalAmount",dataVo.getCondition());
- stringObjectHashMap.put("deductionAmount",dataVo.getSubtraction());
+ stringObjectHashMap.put("conditionalAmount", dataVo.getCondition());
+ stringObjectHashMap.put("deductionAmount", dataVo.getSubtraction());
coupon.setContent(gson.toJson(stringObjectHashMap));
break;
case 2:
- stringObjectHashMap.put("conditionalAmount",dataVo.getDiscount());
+ stringObjectHashMap.put("conditionalAmount", dataVo.getDiscount());
coupon.setContent(gson.toJson(stringObjectHashMap));
break;
case 3:
- stringObjectHashMap.put("experienceName",dataVo.getExperience());
+ stringObjectHashMap.put("experienceName", dataVo.getExperience());
coupon.setContent(gson.toJson(stringObjectHashMap));
break;
default:
@@ -604,14 +607,14 @@
coupon.setIllustrate(dataVo.getIllustrate());
coupon.setDistributionMethod(dataVo.getDistributionMethod());
coupon.setRedemptionMethod(dataVo.getExchangeMethod());
- if (dataVo.getExchangeMethod()!=null){
- switch (dataVo.getExchangeMethod()){
+ if (dataVo.getExchangeMethod() != null&&dataVo.getDistributionMethod()!=4) {
+ switch (dataVo.getExchangeMethod()) {
case 1:
coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints()));
break;
case 2:
- coupon.setCash(dataVo.getRequiredCash());
coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints()));
+ coupon.setCash(dataVo.getRequiredCash());
break;
case 3:
coupon.setCash(dataVo.getRequiredCash());
@@ -626,7 +629,7 @@
coupon.setUseScope(dataVo.getCompany());
coupon.setUserPopulation(dataVo.getUserGroup());
String timeDeal = dataVo.getPeriodOfValidity();
- if (ToolUtil.isNotEmpty(timeDeal)){
+ if (ToolUtil.isNotEmpty(timeDeal)) {
String[] split = timeDeal.split(" - ");
coupon.setStartTime(simpleDateFormat.parse(split[0]));
coupon.setEndTime(simpleDateFormat.parse(split[1]));
@@ -638,30 +641,27 @@
coupon.setCover(dataVo.getGoodImg());
String goodImgs = dataVo.getGoodImgs();
String[] imgsSplit = goodImgs.split(",");
- if (imgsSplit.length > 0){
- if (imgsSplit.length == 1){
+ if (imgsSplit.length > 0) {
+ if (imgsSplit.length == 1) {
coupon.setProductImages(imgsSplit[0]);
- }else {
+ } else {
coupon.setProductImages(goodImgs);
}
}
- if (dataVo.getUserType() == 1){
+ if (dataVo.getUserType() == 1) {
coupon.setPublisherType(2);
- }
- if (dataVo.getUserType() == 2){
- coupon.setPublisherType(1);
+ coupon.setAuditStatus(2);
coupon.setCityManagerId(dataVo.getCityManagerId());
}
- if(dataVo.getObjType()!=1){
+ if (dataVo.getUserType() == 2) {
+ coupon.setPublisherType(1);
coupon.setAuditStatus(1);
+ coupon.setCityManagerId(dataVo.getCityManagerId());
}
- if (dataVo.getUserType()==1){
- coupon.setAuditStatus(2);
- }else{
+ if (dataVo.getUserType() == 3) {
+ coupon.setPublisherType(3);
coupon.setAuditStatus(1);
- }
- if(dataVo.getObjType()!=1){
- coupon.setAuditStatus(1);
+ coupon.setCityManagerId(dataVo.getCityManagerId());
}
boolean save = couponService.save(coupon);
@@ -674,25 +674,25 @@
// 赠送用户数量
int count = quantityIssued / pickUpQuantity;
// 自动发券
- if (dataVo.getDistributionMethod() == 3){
+ if (dataVo.getDistributionMethod() == 3) {
// 判断用户人群 再判断限领数量
- switch (dataVo.getUserGroup()){
+ switch (dataVo.getUserGroup()) {
case 1:
// 给全部用户发券
// 全部用户ids
List<Integer> collect = tAppUsers.stream()
.map(TAppUser::getId).collect(Collectors.toList());
for (int i = 0; i < count; i++) {
- for (int j = 0; j < pickUpQuantity; j++) {
- UserCoupon u1 = new UserCoupon();
- u1.setCouponId(coupon.getId());
- u1.setUserId(collect.get(i));
- u1.setStatus(1);
- u1.setVerificationUserId(null);
- u1.setVerificationTime(null);
- u1.setInsertTime(new Date());
- ucService.save(u1);
- }
+ for (int j = 0; j < pickUpQuantity; j++) {
+ UserCoupon u1 = new UserCoupon();
+ u1.setCouponId(coupon.getId());
+ u1.setUserId(collect.get(i));
+ u1.setStatus(1);
+ u1.setVerificationUserId(null);
+ u1.setVerificationTime(null);
+ u1.setInsertTime(new Date());
+ ucService.save(u1);
+ }
}
break;
case 2:
@@ -731,8 +731,8 @@
break;
}
}
- if (save){
- if (dataVo.getCompany() == 3){
+ if (save) {
+ if (dataVo.getCompany() == 3) {
String[] split = dataVo.getStoreIds().split(",");
for (String storeId : split) {
CouponStore couponStore = new CouponStore();
@@ -741,10 +741,10 @@
couStoreService.save(couponStore);
}
}
- String cityIds = dataVo.getCityIds();
+ String cityIds = dataVo.getCityIds();
String[] split = cityIds.split(",");
List<Integer> cityIdss = new ArrayList<>();
- if (dataVo.getCompany() == 2 && split.length > 0 ){
+ if (dataVo.getCompany() == 2 && split.length > 0) {
for (String s : split) {
int intValue = Integer.parseInt(s);
cityIdss.add(intValue);
@@ -763,36 +763,36 @@
}
}
return true;
- }catch (Exception e){
+ } catch (Exception e) {
+ e.printStackTrace();
return false;
}
}
@ResponseBody
@PostMapping("/base/coupon/queryCity")
- public List<CouponCity> queryCity(@RequestBody Integer id){
+ 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());
+ 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){
+ 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());
+ return couponService.listRecord(objectPage, ofSearch.getId(), ofSearch.getIds(), ofSearch.getType());
}
-
@PostMapping("/base/coupon/updateType")
- public void updateType(@RequestBody Long id){
+ public void updateType(@RequestBody Long id) {
couponService.updateType(id);
}
}
--
Gitblit v1.7.1