feat:
1. add refill api
This commit is contained in:
@@ -7,6 +7,7 @@ import lombok.SneakyThrows;
|
|||||||
import org.springblade.core.secure.annotation.PreAuth;
|
import org.springblade.core.secure.annotation.PreAuth;
|
||||||
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.api.R;
|
||||||
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
||||||
|
import org.springblade.modules.kiosk.pojo.dto.RefillApiRequest;
|
||||||
import org.springblade.modules.kiosk.pojo.vo.*;
|
import org.springblade.modules.kiosk.pojo.vo.*;
|
||||||
import org.springblade.modules.kiosk.service.IKioskApiService;
|
import org.springblade.modules.kiosk.service.IKioskApiService;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
@@ -144,6 +145,17 @@ public class KioskApiController {
|
|||||||
return R.data(kioskApiService.submitOrder(request));
|
return R.data(kioskApiService.submitOrder(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单提交
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
@PostMapping("/refill")
|
||||||
|
@Operation(summary = "订单提交", description = "传入request")
|
||||||
|
public R refill(@Valid @RequestBody RefillApiRequest request) {
|
||||||
|
return R.status(kioskApiService.refillOrder(request));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件
|
* 上传文件
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.springblade.modules.kiosk.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RefillApiRequest implements Serializable {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ public class SubmitVO implements Serializable {
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
private String serialNumber;
|
private String serialNumber;
|
||||||
|
|
||||||
private String storeInfo;
|
private String storeInfo;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.springblade.modules.kiosk.service;
|
package org.springblade.modules.kiosk.service;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
||||||
|
import org.springblade.modules.kiosk.pojo.dto.RefillApiRequest;
|
||||||
import org.springblade.modules.kiosk.pojo.vo.*;
|
import org.springblade.modules.kiosk.pojo.vo.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -33,10 +35,11 @@ public interface IKioskApiService {
|
|||||||
|
|
||||||
Long upload(String fileName, InputStream stream);
|
Long upload(String fileName, InputStream stream);
|
||||||
|
|
||||||
List<PriceListApiVO> priceList(Long id);
|
List<PriceListApiVO> priceList(Long id);
|
||||||
|
|
||||||
Integer autoCleanSeconds();
|
Integer autoCleanSeconds();
|
||||||
|
|
||||||
boolean cleanPhotos();
|
boolean cleanPhotos();
|
||||||
|
|
||||||
|
boolean refillOrder(RefillApiRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.springblade.core.secure.BladeUser;
|
|||||||
import org.springblade.core.secure.utils.AuthUtil;
|
import org.springblade.core.secure.utils.AuthUtil;
|
||||||
import org.springblade.core.tool.utils.*;
|
import org.springblade.core.tool.utils.*;
|
||||||
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
||||||
|
import org.springblade.modules.kiosk.pojo.dto.RefillApiRequest;
|
||||||
import org.springblade.modules.kiosk.pojo.entity.*;
|
import org.springblade.modules.kiosk.pojo.entity.*;
|
||||||
import org.springblade.modules.kiosk.pojo.vo.*;
|
import org.springblade.modules.kiosk.pojo.vo.*;
|
||||||
import org.springblade.modules.kiosk.service.*;
|
import org.springblade.modules.kiosk.service.*;
|
||||||
@@ -288,6 +289,7 @@ public class KioskServiceImpl implements IKioskApiService {
|
|||||||
|
|
||||||
log.info("Order submitted successfully: {}", order.getSerialNumber());
|
log.info("Order submitted successfully: {}", order.getSerialNumber());
|
||||||
SubmitVO result = new SubmitVO();
|
SubmitVO result = new SubmitVO();
|
||||||
|
result.setId(order.getId());
|
||||||
result.setStoreInfo(deptService.getDeptNames(AuthUtil.getDeptId()).stream().findFirst().orElse(""));
|
result.setStoreInfo(deptService.getDeptNames(AuthUtil.getDeptId()).stream().findFirst().orElse(""));
|
||||||
result.setSubAmount(order.getTotalAmount());
|
result.setSubAmount(order.getTotalAmount());
|
||||||
result.setSerialNumber(order.getSerialNumber());
|
result.setSerialNumber(order.getSerialNumber());
|
||||||
@@ -400,4 +402,25 @@ public class KioskServiceImpl implements IKioskApiService {
|
|||||||
public boolean cleanPhotos() {
|
public boolean cleanPhotos() {
|
||||||
return photoAttachmentService.update(Wrappers.<PhotoAttachmentEntity>lambdaUpdate().eq(PhotoAttachmentEntity::getCreateUser, AuthUtil.getUserId()).set(PhotoAttachmentEntity::getStatus, 2));
|
return photoAttachmentService.update(Wrappers.<PhotoAttachmentEntity>lambdaUpdate().eq(PhotoAttachmentEntity::getCreateUser, AuthUtil.getUserId()).set(PhotoAttachmentEntity::getStatus, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean refillOrder(RefillApiRequest request) {
|
||||||
|
if (StringUtil.isBlank(request.getEmail()) && StringUtil.isBlank(request.getPhone())) {
|
||||||
|
throw new ServiceException("Invalid parameters.");
|
||||||
|
}
|
||||||
|
OrderEntity order = orderService.getById(request.getId());
|
||||||
|
if (order == null) {
|
||||||
|
throw new ServiceException("Invalid order.");
|
||||||
|
}
|
||||||
|
if (order.getStatus() != 1) {
|
||||||
|
throw new ServiceException("Invalid order status.");
|
||||||
|
}
|
||||||
|
if (StringUtil.isNotBlank(request.getEmail()) && StringUtil.isNotBlank(order.getUserEmail())) {
|
||||||
|
throw new ServiceException("Email already exists.");
|
||||||
|
}
|
||||||
|
order.setUserEmail(request.getEmail());
|
||||||
|
order.setUserPhone(request.getPhone());
|
||||||
|
//todo send email
|
||||||
|
return orderService.updateById(order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user