更新了写真预约特殊产品处理

This commit is contained in:
chen-xin-zhi 2025-03-03 22:08:41 +08:00
parent 3fca0c6d09
commit c2d356864c
3 changed files with 85 additions and 7 deletions

View File

@ -38,16 +38,15 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/photoProducts")
@ -80,6 +79,11 @@ public class PhotoProductsController {
private AdvanceOrderService advanceOrderService;
@Resource
private RedisTemplate redisTemplate;
/**
* Web端管理员添加写真产品
* @param photoProductsAddRequest 写真产品添加请求体
@ -427,4 +431,80 @@ public class PhotoProductsController {
/**
* Web端管理员获取Map集合(编号从1开始 写真产品id
* @return map集合
*/
@PostMapping("/list/map")
@Operation(summary = "Web端管理员获取Map集合(键编号从1开始写真产品id", description = "参数:无,权限:管理员(admin, boss)方法名queryPhotoProductsMap")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Map<Integer, Long>> queryPhotoProductsMap() {
List<PhotoProducts> photoProductsList = photoProductsService.list();
Collections.reverse(photoProductsList);
Map<Integer, Long> map = new HashMap<>();
int cnt = 1;
for (PhotoProducts photoProducts : photoProductsList) {
Long id = photoProducts.getId();
Integer isShelves = photoProducts.getIsShelves();
if (isShelves == 1) {
map.put(cnt, id);
}
cnt ++;
}
return ResultUtils.success(map);
}
/**
* Web端管理员保存特殊写真产品指向的id
* @return 是否保存成功
*/
@PostMapping("/special/save")
@Operation(summary = "Web端管理员保存特殊写真产品指向的id", description = "参数:无,权限:管理员(admin, boss)方法名saveSpecialPhotoProductById")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> saveSpecialPhotoProductById(@RequestBody CommonBatchRequest commonBatchRequest) {
if (commonBatchRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
List<Long> idList = commonBatchRequest.getIdList();
redisTemplate.opsForValue().set("photoProductIds", idList);
return ResultUtils.success(true);
}
/**
* Web端小程序端管理员查询特殊写真产品指向的id
* @return 写真产品id列表
*/
@PostMapping("/special/get")
@Operation(summary = "Web端管理员小程序端查询特殊写真产品指向的id", description = "参数写真产品id列表权限管理员(admin, boss)方法名getSpecialPhotoProductIds")
public BaseResponse<List<Long>> getSpecialPhotoProductIds () {
Object valueObj = redisTemplate.opsForValue().get("photoProductIds");
List<Long> newIds = new ArrayList<>();
if (valueObj != null) {
List<Long> ids = ((List<?>) valueObj).stream()
.map(obj -> ((Number) obj).longValue())
.collect(Collectors.toList());
for (Long id: ids) {
PhotoProducts photoProducts = photoProductsService.getById(id);
if (photoProducts == null || photoProducts.getIsShelves() == 0) {
newIds.add(0L);
} else {
newIds.add(id);
}
}
} else {
newIds = Arrays.asList(0L, 0L);
}
redisTemplate.opsForValue().set("photoProductIds", newIds);
return ResultUtils.success(newIds);
}
}

View File

@ -229,6 +229,4 @@ public class AdvanceOrderController {
}
}

View File

@ -94,7 +94,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
throw new BusinessException(ErrorCode.PARAMS_ERROR, "满减价格不能超过标准价格");
}
if (ObjectUtils.isEmpty(requirePoints) || requirePoints <= 0) {
if (ObjectUtils.isEmpty(requirePoints) || requirePoints < 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "积分参数错误");
}
if (StringUtils.isAnyBlank(name, startTime, endTime, description, content, status)) {