餐盘解绑限时,超市订单
This commit is contained in:
@ -95,6 +95,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
ErrorCode DINING_PLATES_CANNOT_UNBIND = new ErrorCode(1_007_902_002, "餐盘已产生费用,无法解绑");
|
ErrorCode DINING_PLATES_CANNOT_UNBIND = new ErrorCode(1_007_902_002, "餐盘已产生费用,无法解绑");
|
||||||
ErrorCode DINING_PLATES_ALREADY = new ErrorCode(1_007_902_003, "餐盘已存在");
|
ErrorCode DINING_PLATES_ALREADY = new ErrorCode(1_007_902_003, "餐盘已存在");
|
||||||
|
ErrorCode DINING_PLATES_TIME = new ErrorCode(1_007_902_004, "3秒内餐盘不能解绑");
|
||||||
|
|
||||||
ErrorCode REFUND_NOT_EXISTS = new ErrorCode(1_007_903_001, "退款审核不存在");
|
ErrorCode REFUND_NOT_EXISTS = new ErrorCode(1_007_903_001, "退款审核不存在");
|
||||||
ErrorCode ORDER_ALREADY_APPLY = new ErrorCode(1_007_903_002, "订单已申请退款");
|
ErrorCode ORDER_ALREADY_APPLY = new ErrorCode(1_007_903_002, "订单已申请退款");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.storeorder.vo;
|
package cn.iocoder.yudao.module.member.controller.admin.storeorder.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.storeorderdetail.StoreOrderDetailDO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -45,4 +46,12 @@ public class StoreOrderRespVO {
|
|||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
@ExcelProperty("用户")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
@ExcelProperty("用户")
|
||||||
|
private List<StoreOrderDetailDO> detailDOS;
|
||||||
|
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -92,13 +93,11 @@ public class AppDiningPlatesController {
|
|||||||
@Operation(summary = "餐盘解绑")
|
@Operation(summary = "餐盘解绑")
|
||||||
public CommonResult<String> checkBindAndUnBind(String diningPlatesNum,Long storeId) {
|
public CommonResult<String> checkBindAndUnBind(String diningPlatesNum,Long storeId) {
|
||||||
storeId = getCarteen(storeId);
|
storeId = getCarteen(storeId);
|
||||||
String b = diningPlatesService.checkBindAndUnBind(diningPlatesNum, storeId);
|
Map<String, String> map = diningPlatesService.checkBindAndUnBind(diningPlatesNum, storeId);
|
||||||
CommonResult<String> result = new CommonResult<>();
|
CommonResult<String> result = new CommonResult<>();
|
||||||
result.setCode(200);
|
result.setCode(200);
|
||||||
result.setData(b);
|
result.setData(map.get("data"));
|
||||||
if ("bind".equals(b)) {
|
result.setMsg(map.get("msg"));
|
||||||
result.setMsg("餐盘已解绑");
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,4 +8,6 @@ public class StoreOrderDto extends StoreSaleGoodsDto{
|
|||||||
private String cardNumber;
|
private String cardNumber;
|
||||||
|
|
||||||
private String jwt;
|
private String jwt;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.app.storeorder;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.storeorder.StoreOrderDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.storeorder.StoreOrderService;
|
||||||
|
import cn.iocoder.yudao.module.member.service.storeorderdetail.StoreOrderDetailService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 商品订单")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/member/store-order")
|
||||||
|
@Validated
|
||||||
|
public class AppStoreOrderController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StoreOrderService storeOrderService;
|
||||||
|
@Resource
|
||||||
|
private StoreOrderDetailService orderDetailService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得商品订单分页")
|
||||||
|
public CommonResult<PageResult<StoreOrderRespVO>> getStoreOrderPage(@Valid StoreOrderPageReqVO pageReqVO) {
|
||||||
|
PageResult<StoreOrderDO> pageResult = storeOrderService.getStoreOrderPage(pageReqVO);
|
||||||
|
PageResult<StoreOrderRespVO> bean = BeanUtils.toBean(pageResult, StoreOrderRespVO.class);
|
||||||
|
//处理订单详情
|
||||||
|
for (StoreOrderRespVO vo: bean.getList()) {
|
||||||
|
vo.setDetailDOS(orderDetailService.getListByOrderNo(vo.getOrderId()));
|
||||||
|
}
|
||||||
|
return success(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -52,4 +52,6 @@ public class StoreOrderDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Double totalPrice;
|
private Double totalPrice;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 餐盘 Service 接口
|
* 餐盘 Service 接口
|
||||||
@ -106,5 +107,5 @@ public interface DiningPlatesService {
|
|||||||
*/
|
*/
|
||||||
List<String> getBindDiningPlatesList();
|
List<String> getBindDiningPlatesList();
|
||||||
|
|
||||||
String checkBindAndUnBind(String diningPlatesNum,Long storeId);
|
Map<String, String> checkBindAndUnBind(String diningPlatesNum, Long storeId);
|
||||||
}
|
}
|
@ -37,11 +37,14 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -480,18 +483,31 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String checkBindAndUnBind(String diningPlatesNum,Long storeId) {
|
public Map<String, String> checkBindAndUnBind(String diningPlatesNum,Long storeId) {
|
||||||
|
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
|
||||||
DiningPlatesDO diningPlatesDO = diningPlatesMapper.selectOne(Wrappers.<DiningPlatesDO>lambdaQuery()
|
DiningPlatesDO diningPlatesDO = diningPlatesMapper.selectOne(Wrappers.<DiningPlatesDO>lambdaQuery()
|
||||||
.eq(DiningPlatesDO::getDiningPlatesNum, diningPlatesNum)
|
.eq(DiningPlatesDO::getDiningPlatesNum, diningPlatesNum)
|
||||||
.eq(DiningPlatesDO::getStoreId, storeId));
|
.eq(DiningPlatesDO::getStoreId, storeId));
|
||||||
|
LocalDateTime bindingTime = diningPlatesDO.getBindingTime();
|
||||||
|
long seconds = Duration.between(bindingTime, LocalDateTime.now()).getSeconds();
|
||||||
if(diningPlatesDO == null ) {
|
if(diningPlatesDO == null ) {
|
||||||
return "absent";
|
map.put("data", "absent");
|
||||||
|
map.put("msg",null);
|
||||||
}else if (diningPlatesDO.getUserId() == null){
|
}else if (diningPlatesDO.getUserId() == null){
|
||||||
return "unbind";
|
map.put("data", "unbind");
|
||||||
}else {
|
map.put("msg",null);
|
||||||
unbind(diningPlatesNum,storeId);
|
}else if (seconds <= 3){
|
||||||
return "bind";
|
throw exception(DINING_PLATES_TIME);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
unbind(diningPlatesNum,storeId);
|
||||||
|
map.put("data", "bind");
|
||||||
|
map.put("msg","餐盘已解绑");
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -142,12 +142,15 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String cardPay(StoreOrderDto dto) {
|
public String cardPay(StoreOrderDto dto) {
|
||||||
Double totalPrice = createOrder(dto).getTotalPrice();
|
|
||||||
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
|
||||||
MemberUserDO userDO = userService.getByCardId(dto.getCardNumber());
|
MemberUserDO userDO = userService.getByCardId(dto.getCardNumber());
|
||||||
if (ObjectUtil.isEmpty(userDO)){
|
if (ObjectUtil.isEmpty(userDO)){
|
||||||
return "该卡未绑定用户";
|
return "该卡未绑定用户";
|
||||||
}
|
}
|
||||||
|
dto.setUserId(userDO.getId());
|
||||||
|
Double totalPrice = createOrder(dto).getTotalPrice();
|
||||||
|
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
BigDecimal compute = compute(total, userDO.getId());
|
BigDecimal compute = compute(total, userDO.getId());
|
||||||
if (compute.compareTo(BigDecimal.ZERO) < 0) {
|
if (compute.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
return "false";
|
return "false";
|
||||||
@ -157,12 +160,14 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String codePay(StoreOrderDto dto) {
|
public String codePay(StoreOrderDto dto) {
|
||||||
String s = validateJWT(dto.getJwt());
|
String s = validateJWT(dto.getJwt());
|
||||||
if (StrUtil.isBlank(s)) {
|
if (StrUtil.isBlank(s)) {
|
||||||
return "二维码过期";
|
return "二维码过期";
|
||||||
}
|
}
|
||||||
MemberUserDO user = userService.getUser(Long.valueOf(s));
|
MemberUserDO user = userService.getUser(Long.valueOf(s));
|
||||||
|
dto.setUserId(user.getId());
|
||||||
Double totalPrice = createOrder(dto).getTotalPrice();
|
Double totalPrice = createOrder(dto).getTotalPrice();
|
||||||
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
@ -53,4 +53,6 @@ public interface StoreOrderDetailService {
|
|||||||
PageResult<StoreOrderDetailDO> getStoreOrderDetailPage(StoreOrderDetailPageReqVO pageReqVO);
|
PageResult<StoreOrderDetailDO> getStoreOrderDetailPage(StoreOrderDetailPageReqVO pageReqVO);
|
||||||
|
|
||||||
void saveBatch(List<StoreOrderDetailDO> list);
|
void saveBatch(List<StoreOrderDetailDO> list);
|
||||||
|
|
||||||
|
List<StoreOrderDetailDO> getListByOrderNo(Integer orderId);
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.storeorderdetail;
|
package cn.iocoder.yudao.module.member.service.storeorderdetail;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -75,4 +76,9 @@ public class StoreOrderDetailServiceImpl implements StoreOrderDetailService {
|
|||||||
public void saveBatch(List<StoreOrderDetailDO> list) {
|
public void saveBatch(List<StoreOrderDetailDO> list) {
|
||||||
storeOrderDetailMapper.insertBatch(list);
|
storeOrderDetailMapper.insertBatch(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StoreOrderDetailDO> getListByOrderNo(Integer orderId) {
|
||||||
|
return storeOrderDetailMapper.selectList(Wrappers.<StoreOrderDetailDO>lambdaQuery().eq(StoreOrderDetailDO::getOrderId, orderId));
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user