优化
This commit is contained in:
@ -60,6 +60,7 @@ public interface ErrorCodeConstants {
|
||||
//========== 用户余额明细 1-004-013-000 =============
|
||||
ErrorCode CARD_NOT_EXISTS = new ErrorCode(1_004_013_000, "余额明细不存在");
|
||||
ErrorCode ORDER_NOT_EXISTS = new ErrorCode(1_004_013_001, "订单不存在");
|
||||
ErrorCode ORDER_STATUS_NOT_ALLOW = new ErrorCode(1_004_013_001, "未完成订单或异常订单不支持减免");
|
||||
ErrorCode ORDER_DETAIL_NOT_EXISTS = new ErrorCode(1_004_013_002, "订单明细不存在");
|
||||
ErrorCode RECHARGE_AMOUNT_NOT_EXISTS = new ErrorCode(1_004_013_003, "订单明细不存在");
|
||||
ErrorCode RECHARGE_AMOUNT_ALREADY_EXISTS = new ErrorCode(1_004_013_004, "该金额已存在");
|
||||
|
@ -10,6 +10,8 @@ import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageR
|
||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessRespVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||
import cn.iocoder.yudao.module.member.service.business.BusinessService;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -24,6 +26,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
@ -37,6 +41,8 @@ public class BusinessController {
|
||||
|
||||
@Resource
|
||||
private BusinessService businessService;
|
||||
@Resource
|
||||
private CarteenApi carteenApi;
|
||||
|
||||
// @PostMapping("/create")
|
||||
// @Operation(summary = "创建营业统计")
|
||||
@ -87,9 +93,15 @@ public class BusinessController {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<BusinessDO> list = businessService.getBusinessPage(pageReqVO).getList();
|
||||
List<CarteenRespDto> carteenList = carteenApi.getCarteenList();
|
||||
Map<Long, String> stroreMap = carteenList.stream().collect(Collectors.toMap(CarteenRespDto::getId, CarteenRespDto::getStoresName));
|
||||
// 导出 Excel
|
||||
List<BusinessRespVO> bean = BeanUtils.toBean(list, BusinessRespVO.class);
|
||||
for (BusinessRespVO businessRespVO : bean) {
|
||||
businessRespVO.setStoreName(stroreMap.get(businessRespVO.getCarteenId()));
|
||||
}
|
||||
ExcelUtils.write(response, "营业统计.xls", "数据", BusinessRespVO.class,
|
||||
BeanUtils.toBean(list, BusinessRespVO.class));
|
||||
bean);
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.business.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@ -16,6 +18,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class BusinessPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "门店名")
|
||||
private String storeName;
|
||||
|
||||
@Schema(description = "营业额")
|
||||
private BigDecimal turnover;
|
||||
|
||||
|
@ -17,6 +17,9 @@ public class BusinessRespVO {
|
||||
@ExcelProperty("营业统计编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "门店名")
|
||||
private String storeName;
|
||||
|
||||
@Schema(description = "营业额")
|
||||
@ExcelProperty("营业额")
|
||||
private BigDecimal turnover;
|
||||
@ -87,4 +90,5 @@ public class BusinessRespVO {
|
||||
private Integer lunchNum;
|
||||
|
||||
private Integer dinnerNum;
|
||||
|
||||
}
|
@ -1,17 +1,11 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.customizeExcel;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.iocoder.yudao.framework.excel.core.handler.SelectSheetWriteHandler;
|
||||
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.customizeExcel.vo.*;
|
||||
import cn.iocoder.yudao.module.member.service.customizeExcel.CustomizeExcelService;
|
||||
import cn.iocoder.yudao.module.member.util.CustomMergeStrategy;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.converters.longconverter.LongStringConverter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
@ -45,6 +39,8 @@ public class CustomizeExcelController {
|
||||
|
||||
@Resource
|
||||
private CustomizeExcelService excelService;
|
||||
@Resource
|
||||
private CarteenApi carteenApi;
|
||||
|
||||
@GetMapping("/orderExcel")
|
||||
@Operation(summary = "导出订单详情")
|
||||
@ -53,6 +49,9 @@ public class CustomizeExcelController {
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
||||
List<OrderExcelVO> orderExcelVOS = excelService.exportOrderExcel(startTime, endTime,carteenId);
|
||||
for(OrderExcelVO vo : orderExcelVOS){
|
||||
vo.setStoreName(carteenApi.getCarteenById(carteenId).getStoresName());
|
||||
}
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "订单详情统计.xlsx", "数据", OrderExcelVO.class,
|
||||
orderExcelVOS);
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.NumberFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -9,6 +10,10 @@ import java.math.BigDecimal;
|
||||
@Data
|
||||
public class OrderExcelVO {
|
||||
|
||||
|
||||
@Schema(description = "门店名")
|
||||
private String storeName;
|
||||
|
||||
@ExcelProperty("用户名")
|
||||
private String nickname;
|
||||
|
||||
|
@ -9,8 +9,8 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
import cn.iocoder.yudao.module.member.service.devicewarn.DeviceWarnService;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnNumDO;
|
||||
import cn.iocoder.yudao.module.member.service.devicewarn.DeviceWarnNumService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -38,10 +38,10 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E
|
||||
@RestController
|
||||
@RequestMapping("/member/device-warn")
|
||||
@Validated
|
||||
public class DeviceWarnController {
|
||||
public class DeviceWarnNumController {
|
||||
|
||||
@Resource
|
||||
private DeviceWarnService deviceWarnService;
|
||||
private DeviceWarnNumService deviceWarnService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备告警次数")
|
||||
@ -72,7 +72,7 @@ public class DeviceWarnController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('member:device-warn:query')")
|
||||
public CommonResult<DeviceWarnRespVO> getDeviceWarn(@RequestParam("id") Long id) {
|
||||
DeviceWarnDO deviceWarn = deviceWarnService.getDeviceWarn(id);
|
||||
DeviceWarnNumDO deviceWarn = deviceWarnService.getDeviceWarn(id);
|
||||
return success(BeanUtils.toBean(deviceWarn, DeviceWarnRespVO.class));
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class DeviceWarnController {
|
||||
@Operation(summary = "获得设备告警次数分页")
|
||||
@PreAuthorize("@ss.hasPermission('member:device-warn:query')")
|
||||
public CommonResult<PageResult<DeviceWarnRespVO>> getDeviceWarnPage(@Valid DeviceWarnPageReqVO pageReqVO) {
|
||||
PageResult<DeviceWarnDO> pageResult = deviceWarnService.getDeviceWarnPage(pageReqVO);
|
||||
PageResult<DeviceWarnNumDO> pageResult = deviceWarnService.getDeviceWarnPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DeviceWarnRespVO.class));
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class DeviceWarnController {
|
||||
public void exportDeviceWarnExcel(@Valid DeviceWarnPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DeviceWarnDO> list = deviceWarnService.getDeviceWarnPage(pageReqVO).getList();
|
||||
List<DeviceWarnNumDO> list = deviceWarnService.getDeviceWarnPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "设备告警次数.xls", "数据", DeviceWarnRespVO.class,
|
||||
BeanUtils.toBean(list, DeviceWarnRespVO.class));
|
@ -140,4 +140,11 @@ public class OrderController {
|
||||
orderService.customize(mobile,money,carteenId,type,date);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/abnormalHandle")
|
||||
@Operation(summary = "异常订单指定用户扣款")
|
||||
public CommonResult<Boolean> abnormalHandle(Long orderId,String mobile){
|
||||
orderService.abnormalHandle(orderId,mobile);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,29 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.orderdetail;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO;
|
||||
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 订单明细")
|
||||
@RestController
|
||||
@RequestMapping("/member/order-detail")
|
||||
@Validated
|
||||
public class OrderDetailController {
|
||||
|
||||
//@Resource
|
||||
//private OrderDetailService orderDetailService;
|
||||
@Resource
|
||||
private OrderDetailService orderDetailService;
|
||||
//
|
||||
//@PostMapping("/create")
|
||||
//@Operation(summary = "创建订单明细")
|
||||
@ -21,13 +32,12 @@ public class OrderDetailController {
|
||||
// return success(orderDetailService.createOrderDetail(createReqVO));
|
||||
//}
|
||||
//
|
||||
//@PutMapping("/update")
|
||||
//@Operation(summary = "更新订单明细")
|
||||
//@PreAuthorize("@ss.hasPermission('member:order-detail:update')")
|
||||
//public CommonResult<Boolean> updateOrderDetail(@Valid @RequestBody OrderDetailSaveReqVO updateReqVO) {
|
||||
// orderDetailService.updateOrderDetail(updateReqVO);
|
||||
// return success(true);
|
||||
//}
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新订单明细")
|
||||
public CommonResult<Boolean> updateOrderDetail(@Valid @RequestBody OrderDetailDO updateReqVO) {
|
||||
orderDetailService.updateOrderDetailNew(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
//
|
||||
//@DeleteMapping("/delete")
|
||||
//@Operation(summary = "删除订单明细")
|
||||
|
@ -14,7 +14,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTra
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDetailDO;
|
||||
import cn.iocoder.yudao.module.member.service.business.BusinessService;
|
||||
import cn.iocoder.yudao.module.member.service.customertraffic.CustomerTrafficService;
|
||||
import cn.iocoder.yudao.module.member.service.devicewarn.DeviceWarnService;
|
||||
import cn.iocoder.yudao.module.member.service.devicewarn.DeviceWarnNumService;
|
||||
import cn.iocoder.yudao.module.member.service.order.OrderService;
|
||||
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
||||
import cn.iocoder.yudao.module.member.service.storebusiness.StoreBusinessService;
|
||||
@ -57,7 +57,7 @@ public class ScreenController {
|
||||
@Resource
|
||||
private OrderDetailService orderDetailService;
|
||||
@Resource
|
||||
private DeviceWarnService deviceWarnService;
|
||||
private DeviceWarnNumService deviceWarnService;
|
||||
@Resource
|
||||
private UserPreferenceService preferenceService;
|
||||
@Resource
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.diningplates.vo.AppUserInfo;
|
||||
import cn.iocoder.yudao.module.member.controller.app.diningplates.vo.BindVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService;
|
||||
@ -12,11 +13,7 @@ import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -55,12 +52,21 @@ public class AppDiningPlatesController {
|
||||
return success(diningPlatesService.bind(diningPlatesNum,cardId,storeId));
|
||||
}
|
||||
|
||||
@GetMapping("/bindByFace")
|
||||
@PostMapping("/bindByFace")
|
||||
@Operation(summary = "人脸绑定餐盘")
|
||||
public CommonResult<AppUserInfoCardVO> bindByFace(String diningPlatesNum, Long faceId,Long storeId,String mobile) {
|
||||
return success(diningPlatesService.bindByFace(diningPlatesNum,faceId,storeId,mobile));
|
||||
public CommonResult<AppUserInfoCardVO> bindByFace(@RequestBody BindVO vo) {
|
||||
return success(diningPlatesService.bindByFace(vo.getDiningPlatesNum(), vo.getFaceId(), vo.getStoreId(), vo.getMobile(),vo.getFaceData()));
|
||||
}
|
||||
|
||||
|
||||
// @GetMapping("/bindByFace")
|
||||
// @Operation(summary = "人脸绑定餐盘")
|
||||
// public CommonResult<AppUserInfoCardVO> bindByFace(String diningPlatesNum, Long faceId,Long storeId,String mobile) {
|
||||
// return success(diningPlatesService.bindByFace(diningPlatesNum,faceId,storeId,mobile));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@GetMapping("/checkBind")
|
||||
@Operation(summary = "验证餐盘绑定")
|
||||
public CommonResult<AppUserInfoCardVO> checkBind(String diningPlatesNum, Long storeId) {
|
||||
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.diningplates.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BindVO {
|
||||
private String diningPlatesNum;
|
||||
private Long faceId;
|
||||
private Long storeId;
|
||||
private String mobile;
|
||||
private String faceData;
|
||||
}
|
@ -81,8 +81,14 @@ public class AppOrderRespVO {
|
||||
|
||||
private String faceData;
|
||||
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 补贴金额
|
||||
*/
|
||||
private BigDecimal subsidyAmount;
|
||||
|
||||
private String nickname;
|
||||
|
||||
private String diningPlatesNum;
|
||||
}
|
@ -12,7 +12,7 @@ import lombok.Data;
|
||||
public class AppPageVo extends PageParam {
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long storeId;
|
||||
private String mobile;
|
||||
private String orderStatus;
|
||||
private Boolean billingExist;
|
||||
|
@ -63,7 +63,6 @@ public class AppOrderDetailController {
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新订单明细")
|
||||
@PreAuthorize("@ss.hasPermission('member:order-detail:update')")
|
||||
public CommonResult<Boolean> updateOrderDetail(@Valid @RequestBody AppOrderDetailSaveReqVO updateReqVO) {
|
||||
orderDetailService.updateOrderDetail(updateReqVO);
|
||||
return success(true);
|
||||
|
@ -1,9 +1,6 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.devicewarn;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
@ -20,7 +17,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceWarnDO extends BaseDO {
|
||||
public class DeviceWarnNumDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
@ -30,8 +30,8 @@ public class DishOrderDO extends BaseDO {
|
||||
|
||||
public final static String COMPLETE = "1"; //完成
|
||||
public final static String INCOMPLETE = "0"; //未完成
|
||||
public final static String TOCOMPLETE = "2"; //未支付
|
||||
public final static String LOSE_EFFICACY = "3"; //已失效
|
||||
public final static String TOCOMPLETE = "2"; //未完全支付
|
||||
public final static String ABNORMAL = "3"; //异常
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,32 +1,32 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.devicewarn;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.screen.vo.DeviceInfo;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnNumDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备告警次数 Mapper
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceWarnMapper extends BaseMapperX<DeviceWarnDO> {
|
||||
public interface DeviceWarnNumMapper extends BaseMapperX<DeviceWarnNumDO> {
|
||||
|
||||
default PageResult<DeviceWarnDO> selectPage(DeviceWarnPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceWarnDO>()
|
||||
.eqIfPresent(DeviceWarnDO::getDeviceSn, reqVO.getDeviceSn())
|
||||
.eqIfPresent(DeviceWarnDO::getStoreId, reqVO.getStoreId())
|
||||
.eqIfPresent(DeviceWarnDO::getWarnNum, reqVO.getWarnNum())
|
||||
.betweenIfPresent(DeviceWarnDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(DeviceWarnDO::getId));
|
||||
default PageResult<DeviceWarnNumDO> selectPage(DeviceWarnPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceWarnNumDO>()
|
||||
.eqIfPresent(DeviceWarnNumDO::getDeviceSn, reqVO.getDeviceSn())
|
||||
.eqIfPresent(DeviceWarnNumDO::getStoreId, reqVO.getStoreId())
|
||||
.eqIfPresent(DeviceWarnNumDO::getWarnNum, reqVO.getWarnNum())
|
||||
.betweenIfPresent(DeviceWarnNumDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(DeviceWarnNumDO::getId));
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,10 @@
|
||||
package cn.iocoder.yudao.module.member.job;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.StatisticsVo;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
||||
import cn.iocoder.yudao.module.member.service.amount.DeductionService;
|
||||
import cn.iocoder.yudao.module.member.service.business.BusinessService;
|
||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||
@ -21,11 +17,9 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -58,33 +52,55 @@ public class BalanceDeductionJob implements JobHandler {
|
||||
*/
|
||||
private static final Integer EXPIRATION_TIME = 30;
|
||||
|
||||
/**
|
||||
* 30分钟之后自动解绑并扣款
|
||||
*/
|
||||
private static final Integer ABNORMAL_EXPIRATION_TIME = 60;
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String execute(String param) {
|
||||
//查询扣费用户
|
||||
List<DiningPlatesDO> diningPlatesToCharging = platesService.getDiningPlatesToCharging(EXPIRATION_TIME);
|
||||
Map<String, List<DiningPlatesDO>> map = platesService.getDiningPlatesToCharging(EXPIRATION_TIME, ABNORMAL_EXPIRATION_TIME);
|
||||
List<DiningPlatesDO> normal = map.get("normal");
|
||||
List<DiningPlatesDO> abnormal = map.get("abnormal");
|
||||
int size = 0;
|
||||
|
||||
if (CollectionUtil.isNotEmpty(diningPlatesToCharging)) {
|
||||
List<Long> ids = diningPlatesToCharging.stream().map(DiningPlatesDO::getId).collect(Collectors.toList());
|
||||
List<Long> orderIds = diningPlatesToCharging.stream().map(DiningPlatesDO::getOrderId).collect(Collectors.toList());
|
||||
//先更改状态防止重复消费
|
||||
//platesService.updatePayFlag(ids,DiningPlatesDO.PAY);
|
||||
//获取用户订单
|
||||
List<Long> unbindIds = new ArrayList<>();
|
||||
List<DishOrderDO> updateList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(normal)) {
|
||||
List<Long> ids = normal.stream().map(DiningPlatesDO::getId).collect(Collectors.toList());
|
||||
List<Long> orderIds = normal.stream().map(DiningPlatesDO::getOrderId).collect(Collectors.toList());
|
||||
//获取正常用户订单
|
||||
List<DishOrderDO> toPay = orderService.getToPayByOrder(orderIds);
|
||||
|
||||
toPay.forEach(dishOrderDO -> {
|
||||
deductionService.deduction(dishOrderDO);
|
||||
});
|
||||
//取消批量,防止同一人订餐少扣款
|
||||
//cardService.insertBatch(list);
|
||||
size = toPay.size();
|
||||
//餐盘解绑
|
||||
platesService.updateBind(ids);
|
||||
//更新订单状态和总价
|
||||
orderService.updateBatch(toPay);
|
||||
updateList.addAll(toPay);
|
||||
unbindIds.addAll(ids);
|
||||
}
|
||||
|
||||
if(CollectionUtil.isNotEmpty(abnormal)){
|
||||
List<Long> ids = abnormal.stream().map(DiningPlatesDO::getId).collect(Collectors.toList());
|
||||
List<Long> orderIds = abnormal.stream().map(DiningPlatesDO::getOrderId).collect(Collectors.toList());
|
||||
//获取异常用户订单
|
||||
List<DishOrderDO> toPay = orderService.getToPayByOrder(orderIds);
|
||||
toPay.forEach(dishOrderDO -> {
|
||||
deductionService.abnormalOrderHandle(dishOrderDO);
|
||||
});
|
||||
updateList.addAll(toPay);
|
||||
unbindIds.addAll(ids);
|
||||
}
|
||||
//餐盘解绑
|
||||
if(CollectionUtil.isNotEmpty(unbindIds)){
|
||||
platesService.updateBind(unbindIds);
|
||||
}
|
||||
//更新订单状态和总价
|
||||
if(CollectionUtil.isNotEmpty(updateList)){
|
||||
orderService.updateBatch(updateList);
|
||||
}
|
||||
|
||||
log.info("[execute][扣款定时任务扣款数量 ({}) 个]", size);
|
||||
|
@ -11,6 +11,16 @@ public interface DeductionService {
|
||||
*/
|
||||
void deduction(DishOrderDO dishOrderDO);
|
||||
|
||||
/**
|
||||
* 异常订单处理
|
||||
*/
|
||||
void abnormalOrderHandle(DishOrderDO dishOrderDO);
|
||||
|
||||
/**
|
||||
* 异常订单扣费
|
||||
*/
|
||||
void abnormalOrderDeduct(DishOrderDO dishOrderDO);
|
||||
|
||||
/**
|
||||
* 现金提现
|
||||
*/
|
||||
|
@ -202,6 +202,151 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
updateRedis(userId, name, newMoney);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abnormalOrderHandle(DishOrderDO dishOrderDO) {
|
||||
String s = deductionRedisTemplate.opsForValue().get(dishOrderDO.getDiningPlatesNum() + "-" + dishOrderDO.getStoreId());
|
||||
dishOrderDO.setTotalMoney(new BigDecimal(StrUtil.isBlank(s) ? "0" : s));
|
||||
dishOrderDO.setUpdateTime(LocalDateTime.now());
|
||||
dishOrderDO.setOrderStatus(DishOrderDO.ABNORMAL);
|
||||
deductionRedisTemplate.delete(dishOrderDO.getDiningPlatesNum() + "-" + dishOrderDO.getStoreId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abnormalOrderDeduct(DishOrderDO dishOrderDO) {
|
||||
Long userId = dishOrderDO.getUserId();
|
||||
|
||||
BigDecimal changeMoney;
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal cashNewMoney;
|
||||
BigDecimal newMoney;
|
||||
|
||||
String name;
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
//新的总价
|
||||
BigDecimal total = dishOrderDO.getTotalMoney();
|
||||
|
||||
//计算减免价格
|
||||
BigDecimal reductionAmount = BigDecimal.ZERO;
|
||||
//补贴
|
||||
BigDecimal subsidyAmount = BigDecimal.ZERO;
|
||||
if (total.compareTo(BigDecimal.ZERO) > 0) {
|
||||
subsidyAmount = userService.getReductionAmount(userId, total, dishOrderDO.getCreateTime());
|
||||
}
|
||||
dishOrderDO.setSubsidyAmount(subsidyAmount);
|
||||
if (dishOrderDO.getReductionAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
reductionAmount = reductionAmount.add(dishOrderDO.getReductionAmount());
|
||||
dishOrderDO.setReductionAmount(reductionAmount);
|
||||
} else {
|
||||
dishOrderDO.setReductionAmount(reductionAmount);
|
||||
}
|
||||
dishOrderDO.setReductionState(reductionAmount.compareTo(BigDecimal.ZERO) > 0 ? "1" : "0");
|
||||
//计算减免后的总价
|
||||
reductionAmount = reductionAmount.add(subsidyAmount);
|
||||
if (total.compareTo(reductionAmount) < 0) {
|
||||
total = BigDecimal.ZERO;
|
||||
} else {
|
||||
total = total.subtract(reductionAmount);
|
||||
}
|
||||
|
||||
//微信
|
||||
BigDecimal wxAmount = user.getWxAmount();
|
||||
//现金
|
||||
BigDecimal cashAmount = user.getCashAmount();
|
||||
//当前金额
|
||||
BigDecimal money = user.getMoney();
|
||||
|
||||
//待支付金额 最大退款金额
|
||||
dishOrderDO.setRefundAmount(total);
|
||||
if (money.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
dishOrderDO.setPayAmount(total);
|
||||
dishOrderDO.setRefundAmount(BigDecimal.ZERO);
|
||||
} else {
|
||||
if (total.compareTo(money) > 0) {
|
||||
dishOrderDO.setPayAmount(total.subtract(money));
|
||||
dishOrderDO.setRefundAmount(money);
|
||||
}
|
||||
}
|
||||
//扣除金额
|
||||
user.setMoney(money.subtract(total));
|
||||
if (total.compareTo(money) > 0) {
|
||||
dishOrderDO.setOrderStatus(DishOrderDO.TOCOMPLETE);
|
||||
dishOrderDO.setWxAmount(wxAmount);
|
||||
dishOrderDO.setCashAmount(cashAmount);
|
||||
|
||||
user.setWxAmount(BigDecimal.ZERO);
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
} else {
|
||||
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
||||
//扣除具体金额
|
||||
if (judge(userId)) { //微信->现金
|
||||
if (total.compareTo(wxAmount) <= 0) {
|
||||
user.setWxAmount(wxAmount.subtract(total));
|
||||
dishOrderDO.setWxAmount(total);
|
||||
} else {
|
||||
user.setWxAmount(BigDecimal.ZERO);
|
||||
dishOrderDO.setWxAmount(wxAmount);
|
||||
BigDecimal total1 = total.subtract(wxAmount);
|
||||
user.setCashAmount(cashAmount.subtract(total1));
|
||||
dishOrderDO.setCashAmount(total1);
|
||||
}
|
||||
|
||||
} else { //现金->微信
|
||||
if (total.compareTo(cashAmount) <= 0) {
|
||||
user.setCashAmount(cashAmount.subtract(total));
|
||||
dishOrderDO.setCashAmount(total);
|
||||
} else {
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
dishOrderDO.setCashAmount(cashAmount);
|
||||
BigDecimal total1 = total.subtract(cashAmount);
|
||||
user.setWxAmount(wxAmount.subtract(total1));
|
||||
dishOrderDO.setWxAmount(total1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//修改
|
||||
userService.updateById(user);
|
||||
|
||||
wxNewMoney = user.getWxAmount();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
changeMoney = total;
|
||||
newMoney = user.getMoney();
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
//记录消费记录
|
||||
CardDO cardDO = new CardDO();
|
||||
cardDO.setType(TimePeriodEnum.getTimePeriod(dishOrderDO.getCreateTime()));
|
||||
cardDO.setUserId(userId);
|
||||
cardDO.setChangeMoney(changeMoney);
|
||||
cardDO.setFlag(CardDO.MINUS);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCarteenId(dishOrderDO.getStoreId());
|
||||
cardDO.setMoney(newMoney);
|
||||
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
dishOrderDO.setTotalMoney(changeMoney);
|
||||
dishOrderDO.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
//更新营业数据
|
||||
if (dishOrderDO.getOrderStatus().equals(DishOrderDO.COMPLETE)) {
|
||||
StatisticsVo statisticsVo = new StatisticsVo();
|
||||
statisticsVo.setCarteenId(dishOrderDO.getStoreId());
|
||||
statisticsVo.setTotalMoney(dishOrderDO.getTotalMoney());
|
||||
statisticsVo.setOrderSum(1);
|
||||
statisticsVo.setReduceMoney(dishOrderDO.getReductionAmount());
|
||||
statisticsVo.setTime(dishOrderDO.getCreateTime());
|
||||
statisticsVo.setOrderId(dishOrderDO.getId());
|
||||
statisticsVo.setSubsidyPurse(dishOrderDO.getSubsidyAmount());
|
||||
businessService.updateStatistics(statisticsVo);
|
||||
}
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId, name, newMoney);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cashDraw(Long userId, BigDecimal money, String type, Long storeId) {
|
||||
|
@ -18,4 +18,6 @@ public interface MemberAsyncService {
|
||||
void createOrderDetail(AppOrderDetailSaveReqVO createReqVO, OtherVO otherVO);
|
||||
|
||||
void batchRecord(AddReqVO addReqVO);
|
||||
|
||||
void saveFace(String faceData,String path);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storegoodsinventoryrecord.StoreGoodsInventoryRecordDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.diningplates.DiningPlatesMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.orderdetail.OrderDetailMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.storegoodsinventory.StoreGoodsInventoryMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.storegoodsinventoryrecord.StoreGoodsInventoryRecordMapper;
|
||||
import cn.iocoder.yudao.module.member.service.storegoods.StoreGoodsService;
|
||||
import cn.iocoder.yudao.module.system.api.dishesnutrition.DishesNutritionApi;
|
||||
@ -23,10 +22,13 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@ -107,6 +109,34 @@ public class MemberAsyncServiceImpl implements MemberAsyncService{
|
||||
storeGoodsInventoryRecordMapper.insertBatch(addList);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void saveFace(String faceData, String path) {
|
||||
try {
|
||||
// 解码 Base64 字符串
|
||||
// 过滤非法字符
|
||||
String s = faceData.replaceAll("\n", "");
|
||||
byte[] decodedBytes = Base64.getDecoder().decode(s);
|
||||
|
||||
// 指定保存文件的路径// 根据实际情况修改文件路径和文件名
|
||||
String uploadDirPath= "orderFaceData/";
|
||||
|
||||
// 创建上传文件目录
|
||||
File uploadDir = new File(uploadDirPath);
|
||||
if (!uploadDir.exists()) {
|
||||
uploadDir.mkdir();
|
||||
}
|
||||
// 创建文件输出流
|
||||
try (FileOutputStream fos = new FileOutputStream(path)) {
|
||||
// 将解码后的数据写入文件
|
||||
fos.write(decodedBytes);
|
||||
System.out.println("文件保存成功!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void discard(){
|
||||
//DishesNutritionRespDTO dishEnergy = dishesNutritionApi.getDishEnergy(createReqVO.getDishesId());
|
||||
//
|
||||
|
@ -2,12 +2,9 @@ package cn.iocoder.yudao.module.member.service.customizeExcel;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.customizeExcel.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.customizeExcel.CustomizeExcelMapper;
|
||||
import cn.iocoder.yudao.module.member.service.devicewarn.DeviceWarnService;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@Service
|
||||
public class CustomizeExcelServiceImpl implements CustomizeExcelService {
|
||||
|
@ -4,8 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.screen.vo.DeviceInfo;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnNumDO;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
@ -16,7 +15,7 @@ import java.util.List;
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
public interface DeviceWarnService {
|
||||
public interface DeviceWarnNumService {
|
||||
|
||||
/**
|
||||
* 创建设备告警次数
|
||||
@ -46,7 +45,7 @@ public interface DeviceWarnService {
|
||||
* @param id 编号
|
||||
* @return 设备告警次数
|
||||
*/
|
||||
DeviceWarnDO getDeviceWarn(Long id);
|
||||
DeviceWarnNumDO getDeviceWarn(Long id);
|
||||
|
||||
/**
|
||||
* 获得设备告警次数分页
|
||||
@ -54,7 +53,7 @@ public interface DeviceWarnService {
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 设备告警次数分页
|
||||
*/
|
||||
PageResult<DeviceWarnDO> getDeviceWarnPage(DeviceWarnPageReqVO pageReqVO);
|
||||
PageResult<DeviceWarnNumDO> getDeviceWarnPage(DeviceWarnPageReqVO pageReqVO);
|
||||
|
||||
|
||||
void addDeviceWarn(HttpServletRequest request);
|
@ -7,13 +7,12 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.devicewarn.vo.DeviceWarnSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.screen.vo.DeviceInfo;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.devicewarn.DeviceWarnMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.devicewarn.DeviceWarnNumDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.devicewarn.DeviceWarnNumMapper;
|
||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.dto.DeviceInfoDto;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -21,7 +20,6 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -35,10 +33,10 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.DEVICE_WAR
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DeviceWarnServiceImpl implements DeviceWarnService {
|
||||
public class DeviceWarnNumServiceImpl implements DeviceWarnNumService {
|
||||
|
||||
@Resource
|
||||
private DeviceWarnMapper deviceWarnMapper;
|
||||
private DeviceWarnNumMapper deviceWarnNumMapper;
|
||||
@Resource
|
||||
private DeviceInfoApi deviceInfoApi;
|
||||
|
||||
@ -46,8 +44,8 @@ public class DeviceWarnServiceImpl implements DeviceWarnService {
|
||||
@Override
|
||||
public Long createDeviceWarn(DeviceWarnSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DeviceWarnDO deviceWarn = BeanUtils.toBean(createReqVO, DeviceWarnDO.class);
|
||||
deviceWarnMapper.insert(deviceWarn);
|
||||
DeviceWarnNumDO deviceWarn = BeanUtils.toBean(createReqVO, DeviceWarnNumDO.class);
|
||||
deviceWarnNumMapper.insert(deviceWarn);
|
||||
// 返回
|
||||
return deviceWarn.getId();
|
||||
}
|
||||
@ -57,8 +55,8 @@ public class DeviceWarnServiceImpl implements DeviceWarnService {
|
||||
// 校验存在
|
||||
validateDeviceWarnExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DeviceWarnDO updateObj = BeanUtils.toBean(updateReqVO, DeviceWarnDO.class);
|
||||
deviceWarnMapper.updateById(updateObj);
|
||||
DeviceWarnNumDO updateObj = BeanUtils.toBean(updateReqVO, DeviceWarnNumDO.class);
|
||||
deviceWarnNumMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,23 +64,23 @@ public class DeviceWarnServiceImpl implements DeviceWarnService {
|
||||
// 校验存在
|
||||
validateDeviceWarnExists(id);
|
||||
// 删除
|
||||
deviceWarnMapper.deleteById(id);
|
||||
deviceWarnNumMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDeviceWarnExists(Long id) {
|
||||
if (deviceWarnMapper.selectById(id) == null) {
|
||||
if (deviceWarnNumMapper.selectById(id) == null) {
|
||||
throw exception(DEVICE_WARN_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceWarnDO getDeviceWarn(Long id) {
|
||||
return deviceWarnMapper.selectById(id);
|
||||
public DeviceWarnNumDO getDeviceWarn(Long id) {
|
||||
return deviceWarnNumMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DeviceWarnDO> getDeviceWarnPage(DeviceWarnPageReqVO pageReqVO) {
|
||||
return deviceWarnMapper.selectPage(pageReqVO);
|
||||
public PageResult<DeviceWarnNumDO> getDeviceWarnPage(DeviceWarnPageReqVO pageReqVO) {
|
||||
return deviceWarnNumMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,29 +88,29 @@ public class DeviceWarnServiceImpl implements DeviceWarnService {
|
||||
String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern(MemberConstants.DATE_FORMAT));
|
||||
String deviceIp = request.getHeader("Authorization");
|
||||
DeviceInfoDto device = deviceInfoApi.getDevice(deviceIp);
|
||||
QueryWrapper<DeviceWarnDO> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<DeviceWarnNumDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("date_format(create_time,'%Y-%m-%d')", format)
|
||||
.eq("device_sn", deviceIp)
|
||||
.last(MemberConstants.LIMIT_ONE);
|
||||
DeviceWarnDO old = deviceWarnMapper.selectOne(queryWrapper);
|
||||
DeviceWarnNumDO old = deviceWarnNumMapper.selectOne(queryWrapper);
|
||||
if (ObjUtil.isNotEmpty(old)) {
|
||||
old.setWarnNum(old.getWarnNum() + 1);
|
||||
deviceWarnMapper.updateById(old);
|
||||
deviceWarnNumMapper.updateById(old);
|
||||
} else {
|
||||
DeviceWarnDO deviceWarnDO = new DeviceWarnDO();
|
||||
DeviceWarnNumDO deviceWarnDO = new DeviceWarnNumDO();
|
||||
deviceWarnDO.setDeviceSn(deviceIp).setWarnNum(1).setStoreId(device.getCarteenId());
|
||||
deviceWarnMapper.insert(deviceWarnDO);
|
||||
deviceWarnNumMapper.insert(deviceWarnDO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getWarn(Long storeId) {
|
||||
String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern(MemberConstants.DATE_FORMAT));
|
||||
QueryWrapper<DeviceWarnDO> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<DeviceWarnNumDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("sum(warn_num) as warnNum")
|
||||
.eq("date_format(create_time,'%Y-%m-%d')", format)
|
||||
.eq(storeId!=null,"store_id", storeId);
|
||||
List<Map<String, Object>> maps = deviceWarnMapper.selectMaps(queryWrapper);
|
||||
List<Map<String, Object>> maps = deviceWarnNumMapper.selectMaps(queryWrapper);
|
||||
if(CollectionUtil.isNotEmpty(maps) && maps.get(0)!=null){
|
||||
return Long.valueOf(maps.get(0).get("warnNum").toString());
|
||||
}
|
||||
@ -121,6 +119,6 @@ public class DeviceWarnServiceImpl implements DeviceWarnService {
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> getDeviceInfo(Long carteenId) {
|
||||
return deviceWarnMapper.getDeviceInfo(carteenId);
|
||||
return deviceWarnNumMapper.getDeviceInfo(carteenId);
|
||||
}
|
||||
}
|
@ -29,6 +29,8 @@ public interface DiningPlatesService {
|
||||
*/
|
||||
Long createDiningPlates(@Valid DiningPlatesSaveReqVO createReqVO);
|
||||
|
||||
void insertDiningPlates(DiningPlatesDO diningPlatesDO);
|
||||
|
||||
/**
|
||||
* 更新餐盘
|
||||
*
|
||||
@ -65,8 +67,9 @@ public interface DiningPlatesService {
|
||||
* 获取扣费餐盘
|
||||
*
|
||||
* @param time
|
||||
* @param abnormalTime
|
||||
*/
|
||||
List<DiningPlatesDO> getDiningPlatesToCharging(Integer time);
|
||||
Map<String,List<DiningPlatesDO>> getDiningPlatesToCharging(Integer time,Integer abnormalTime);
|
||||
|
||||
/**
|
||||
* 修改付费状态
|
||||
@ -90,7 +93,7 @@ public interface DiningPlatesService {
|
||||
*/
|
||||
AppUserInfoCardVO bind(String diningPlatesNum,String cardId,Long storeId);
|
||||
|
||||
AppUserInfoCardVO bindByFace(String diningPlatesNum, Long faceId, Long storeId,String mobile);
|
||||
AppUserInfoCardVO bindByFace(String diningPlatesNum, Long faceId, Long storeId,String mobile,String faceData);
|
||||
|
||||
Boolean checkBind(String diningPlatesNum,Long storeId);
|
||||
|
||||
@ -111,4 +114,6 @@ public interface DiningPlatesService {
|
||||
Map<String, String> checkBindAndUnBind(String diningPlatesNum, Long storeId);
|
||||
|
||||
BigDecimal getOrderMoney(Long orderId);
|
||||
|
||||
void updateById(DiningPlatesDO diningPlatesDO);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.service.diningplates;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
@ -16,7 +16,6 @@ import cn.iocoder.yudao.module.member.controller.app.diningplates.vo.AppUserInfo
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.admincard.AdminCardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.diningplates.DiningPlatesMapper;
|
||||
@ -26,15 +25,12 @@ import cn.iocoder.yudao.module.member.enums.GroupTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.service.admincard.AdminCardService;
|
||||
import cn.iocoder.yudao.module.member.service.amount.DeductionService;
|
||||
import cn.iocoder.yudao.module.member.service.async.MemberAsyncService;
|
||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||
import cn.iocoder.yudao.module.member.service.group.MemberGroupService;
|
||||
import cn.iocoder.yudao.module.member.service.holiday.HolidayService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
|
||||
import cn.iocoder.yudao.module.system.api.dish.DishesApi;
|
||||
import cn.iocoder.yudao.module.system.api.dish.dto.DishesRespDto;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -104,6 +100,11 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
return diningPlates.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertDiningPlates(DiningPlatesDO diningPlatesDO) {
|
||||
diningPlatesMapper.insert(diningPlatesDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDiningPlates(DiningPlatesSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
@ -157,20 +158,27 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DiningPlatesDO> getDiningPlatesToCharging(Integer time) {
|
||||
public Map<String, List<DiningPlatesDO>> getDiningPlatesToCharging(Integer time, Integer abnormalTime) {
|
||||
// 获取当前时间
|
||||
LocalDateTime currentTime = LocalDateTime.now();
|
||||
|
||||
// 计算指定分钟之前的时间
|
||||
LocalDateTime timeMinutesAgo = currentTime.minusMinutes(time);
|
||||
LocalDateTime normalTimeAgo = currentTime.minusMinutes(time);
|
||||
|
||||
LocalDateTime abnormalTimeAgo = currentTime.minusMinutes(abnormalTime);
|
||||
|
||||
LambdaQueryWrapper<DiningPlatesDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(DiningPlatesDO::getStatus, DiningPlatesDO.USE)
|
||||
.eq(DiningPlatesDO::getPayFlag, DiningPlatesDO.TO_PAY)
|
||||
.le(DiningPlatesDO::getBindingTime, timeMinutesAgo);
|
||||
|
||||
.le(DiningPlatesDO::getBindingTime, normalTimeAgo);
|
||||
List<DiningPlatesDO> diningPlatesDOS = diningPlatesMapper.selectList(wrapper);
|
||||
return diningPlatesDOS;
|
||||
Map<String, List<DiningPlatesDO>> map = new HashMap<>();
|
||||
// 筛选正常结算的订单
|
||||
List<DiningPlatesDO> normalList = diningPlatesDOS.stream().filter(dp -> dp.getUserId() != null).collect(Collectors.toList());
|
||||
map.put("normal",normalList);
|
||||
List<DiningPlatesDO> abnormalList = diningPlatesDOS.stream().filter(dp -> dp.getUserId() == null && !dp.getBindingTime().isAfter(abnormalTimeAgo)).collect(Collectors.toList());
|
||||
map.put("abnormal",abnormalList);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -215,34 +223,37 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
BigDecimal money = checkMoney(memberUserDO, storeId);
|
||||
|
||||
diningPlatesDO.setUserId(memberUserDO.getId());
|
||||
diningPlatesDO.setStatus(DiningPlatesDO.USE);
|
||||
diningPlatesDO.setBindingTime(LocalDateTime.now());
|
||||
|
||||
|
||||
//创建初始订单
|
||||
DishOrderDO dishOrderDO = new DishOrderDO();
|
||||
dishOrderDO.setDiningPlatesNum(diningPlatesNum)
|
||||
.setOrderStatus(DishOrderDO.INCOMPLETE)
|
||||
.setUserId(memberUserDO.getId())
|
||||
.setStoreId(storeId)
|
||||
.setStoreName(carteenApi.getCarteenById(storeId).getStoresName());
|
||||
dishOrderMapper.insert(dishOrderDO);
|
||||
if(diningPlatesDO.getOrderId()==null){
|
||||
diningPlatesDO.setStatus(DiningPlatesDO.USE);
|
||||
diningPlatesDO.setBindingTime(LocalDateTime.now());
|
||||
|
||||
diningPlatesDO.setOrderId(dishOrderDO.getId());
|
||||
dishOrderDO.setDiningPlatesNum(diningPlatesNum)
|
||||
.setOrderStatus(DishOrderDO.INCOMPLETE)
|
||||
.setUserId(memberUserDO.getId())
|
||||
.setStoreId(storeId);
|
||||
dishOrderMapper.insert(dishOrderDO);
|
||||
diningPlatesDO.setOrderId(dishOrderDO.getId());
|
||||
//设置总价
|
||||
stringRedisTemplate.opsForValue().set(diningPlatesNum+"-"+storeId, "0");
|
||||
}else{
|
||||
dishOrderDO.setId(diningPlatesDO.getOrderId());
|
||||
dishOrderDO.setUserId(memberUserDO.getId());
|
||||
dishOrderMapper.updateById(dishOrderDO);
|
||||
}
|
||||
diningPlatesMapper.updateById(diningPlatesDO);
|
||||
//设置总价
|
||||
stringRedisTemplate.opsForValue().set(diningPlatesNum+"-"+storeId, "0");
|
||||
AppUserInfoCardVO data = new AppUserInfoCardVO();
|
||||
data.setName(StrUtil.isNotBlank(memberUserDO.getName())?memberUserDO.getName():memberUserDO.getNickname());
|
||||
data.setMoney(money);
|
||||
|
||||
//afterBind(memberUserDO.getId());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AppUserInfoCardVO bindByFace(String diningPlatesNum, Long faceId,Long storeId,String mobile) {
|
||||
public AppUserInfoCardVO bindByFace(String diningPlatesNum, Long faceId, Long storeId, String mobile,String faceData) {
|
||||
DiningPlatesDO diningPlatesDO = diningPlatesMapper.selectOne(Wrappers.<DiningPlatesDO>lambdaQuery()
|
||||
.eq(DiningPlatesDO::getDiningPlatesNum, diningPlatesNum)
|
||||
.eq(DiningPlatesDO::getStoreId,storeId)
|
||||
@ -265,27 +276,35 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
BigDecimal money = checkMoney(memberUserDO,storeId);
|
||||
|
||||
diningPlatesDO.setUserId(memberUserDO.getId());
|
||||
diningPlatesDO.setStatus(DiningPlatesDO.USE);
|
||||
diningPlatesDO.setBindingTime(LocalDateTime.now());
|
||||
|
||||
//创建初始订单
|
||||
String faceUrl = "facedata/orderFaceData/"+ IdUtil.getSnowflakeNextIdStr() +".jpg";
|
||||
DishOrderDO dishOrderDO = new DishOrderDO();
|
||||
dishOrderDO.setDiningPlatesNum(diningPlatesNum)
|
||||
.setOrderStatus(DishOrderDO.INCOMPLETE)
|
||||
.setUserId(memberUserDO.getId())
|
||||
.setStoreId(storeId)
|
||||
.setStoreName(carteenApi.getCarteenById(storeId).getStoresName());
|
||||
dishOrderMapper.insert(dishOrderDO);
|
||||
if(diningPlatesDO.getOrderId()==null){
|
||||
diningPlatesDO.setStatus(DiningPlatesDO.USE);
|
||||
diningPlatesDO.setBindingTime(LocalDateTime.now());
|
||||
dishOrderDO.setDiningPlatesNum(diningPlatesNum)
|
||||
.setOrderStatus(DishOrderDO.INCOMPLETE)
|
||||
.setUserId(memberUserDO.getId())
|
||||
.setStoreId(storeId)
|
||||
.setFaceData(faceUrl)
|
||||
;
|
||||
dishOrderMapper.insert(dishOrderDO);
|
||||
diningPlatesDO.setOrderId(dishOrderDO.getId());
|
||||
//设置总价
|
||||
stringRedisTemplate.opsForValue().set(diningPlatesNum+"-"+storeId, "0");
|
||||
}else{
|
||||
dishOrderDO.setId(diningPlatesDO.getOrderId());
|
||||
dishOrderDO.setUserId(memberUserDO.getId());
|
||||
dishOrderDO.setFaceData(faceUrl);
|
||||
dishOrderMapper.updateById(dishOrderDO);
|
||||
}
|
||||
asyncService.saveFace(faceData,faceUrl);
|
||||
|
||||
diningPlatesDO.setOrderId(dishOrderDO.getId());
|
||||
diningPlatesMapper.updateById(diningPlatesDO);
|
||||
//设置总价
|
||||
stringRedisTemplate.opsForValue().set(diningPlatesNum+"-"+storeId, "0");
|
||||
AppUserInfoCardVO data = new AppUserInfoCardVO();
|
||||
data.setName(StrUtil.isNotBlank(memberUserDO.getName())?memberUserDO.getName():memberUserDO.getNickname());
|
||||
data.setMoney(money);
|
||||
|
||||
//afterBind(memberUserDO.getId());
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -306,13 +325,22 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
|
||||
@Override
|
||||
public AppUserInfoCardVO appCheckBind(String diningPlatesNum, Long storeId) {
|
||||
|
||||
DiningPlatesDO diningPlatesDO = diningPlatesMapper.selectOne(Wrappers.<DiningPlatesDO>lambdaQuery()
|
||||
.eq(DiningPlatesDO::getDiningPlatesNum, diningPlatesNum)
|
||||
.eq(DiningPlatesDO::getStoreId,storeId)
|
||||
.last(MemberConstants.LIMIT_ONE));
|
||||
if (diningPlatesDO == null || diningPlatesDO.getUserId() == null) {
|
||||
|
||||
if (diningPlatesDO == null) {
|
||||
throw exception(DINING_PLATES_NOT_EXISTS);
|
||||
}
|
||||
//刷新绑定时间
|
||||
asyncService.flashTime(diningPlatesDO);
|
||||
|
||||
if ( diningPlatesDO.getUserId() == null ) {
|
||||
throw exception(DINING_PLATES_NOT_BIND);
|
||||
}
|
||||
|
||||
AppUserInfoCardVO appUserInfoCardVO = new AppUserInfoCardVO();
|
||||
|
||||
String redisKey = "USER_"+diningPlatesDO.getUserId();
|
||||
@ -326,8 +354,6 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
appUserInfoCardVO.setMoney(memberUserDO.getMoney());
|
||||
stringRedisTemplate.opsForValue().set(redisKey, JSONUtil.toJsonStr(appUserInfoCardVO));
|
||||
}
|
||||
//刷新绑定时间
|
||||
asyncService.flashTime(diningPlatesDO);
|
||||
return appUserInfoCardVO;
|
||||
}
|
||||
|
||||
@ -374,10 +400,9 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
cashAmount = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal money = memberUserDO.getWxAmount().add(cashAmount);
|
||||
BigDecimal compareMoney = MemberConstants.ALARM_BALANCE;
|
||||
if(storeId .equals(MemberConstants.SANXIA_ROAD_COMMUNITY)){
|
||||
compareMoney = MemberConstants.SANXIA_ROAD_COMMUNITY_BALANCE;
|
||||
}
|
||||
|
||||
|
||||
BigDecimal compareMoney = carteenApi.getCarteenById(storeId).getBindMoney();
|
||||
if (money.compareTo(compareMoney) < 0) {
|
||||
if(typeHoliday){
|
||||
throw exception(INSUFFICIENT_BALANCE_NEW);
|
||||
@ -548,4 +573,9 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
String s = stringRedisTemplate.opsForValue().get(diningPlatesDO.getDiningPlatesNum() + "-" + diningPlatesDO.getStoreId());
|
||||
return StrUtil.isNotBlank(s)?new BigDecimal(s):null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateById(DiningPlatesDO diningPlatesDO) {
|
||||
diningPlatesMapper.updateById(diningPlatesDO);
|
||||
}
|
||||
}
|
@ -127,4 +127,8 @@ public interface OrderService {
|
||||
void reduction(Long orderId,BigDecimal money);
|
||||
|
||||
void customize(String mobile, BigDecimal money,Long carteenId,String type,String date);
|
||||
|
||||
void abnormalHandle(Long orderId,String mobile);
|
||||
|
||||
|
||||
}
|
@ -20,7 +20,7 @@ import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.order.vo.AppPageVo;
|
||||
import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDetailRespVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
@ -181,20 +181,36 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
PageResult<DishOrderDO> dishOrderDOPageResult = dishOrderMapper.selectPage(vo, Wrappers.<DishOrderDO>lambdaQuery()
|
||||
.in(CollectionUtil.isNotEmpty(ids), DishOrderDO::getUserId, ids)
|
||||
.eq(vo.getStoreId()!=null,DishOrderDO::getStoreId,vo.getStoreId())
|
||||
.eq(StrUtil.isNotBlank(vo.getOrderStatus()),DishOrderDO::getOrderStatus,vo.getOrderStatus())
|
||||
.eq(ObjUtil.isNotEmpty(vo.getBillingExist()),DishOrderDO::getBillingExist,vo.getBillingExist())
|
||||
.orderByDesc(DishOrderDO::getCreateTime));
|
||||
PageResult<AppOrderRespVO> appOrderRespVOPageResult = BeanUtils.toBean(dishOrderDOPageResult, AppOrderRespVO.class);
|
||||
List<AppOrderRespVO> list = appOrderRespVOPageResult.getList();
|
||||
|
||||
List<Long> collect = list.stream().map(AppOrderRespVO::getUserId).collect(Collectors.toList());
|
||||
Map<Long, MemberUserDO> userMap = new HashMap<>();
|
||||
if(CollectionUtil.isNotEmpty(collect)){
|
||||
List<MemberUserDO> memberUserDOS = memberUserMapper.selectList(Wrappers.<MemberUserDO>lambdaQuery().in(MemberUserDO::getId, collect));
|
||||
userMap = memberUserDOS.stream().collect(Collectors.toMap(MemberUserDO::getId, userDO -> userDO));
|
||||
}
|
||||
|
||||
List<CarteenRespDto> carteenList = carteenApi.getCarteenList();
|
||||
Map<Long, String> stroreMap = carteenList.stream().collect(Collectors.toMap(CarteenRespDto::getId, CarteenRespDto::getStoresName));
|
||||
for (AppOrderRespVO dishOrderDO : list) {
|
||||
List<AppOrderDetailRespVO> appOrderDetailRespVOS = orderDetailService.selectListByOrderId(dishOrderDO.getId());
|
||||
|
||||
for (AppOrderDetailRespVO respVo : appOrderDetailRespVOS) {
|
||||
respVo.setDishesSumPrice(respVo.getUnitPrice());
|
||||
}
|
||||
//
|
||||
// for (AppOrderDetailRespVO respVo : appOrderDetailRespVOS) {
|
||||
// respVo.setDishesSumPrice(respVo.getUnitPrice());
|
||||
// }
|
||||
dishOrderDO.setStoreName(stroreMap.get(dishOrderDO.getStoreId()));
|
||||
dishOrderDO.setRefundStatus(refundService.getRefundStatus(dishOrderDO.getId()));
|
||||
dishOrderDO.setDetailList(appOrderDetailRespVOS);
|
||||
// dishOrderDO.setMoney(cardMapper.getMoneyByUsr(dishOrderDO.getUserId()));
|
||||
MemberUserDO memberUserDO = userMap.get(dishOrderDO.getUserId());
|
||||
if(memberUserDO!=null){
|
||||
dishOrderDO.setMobile(memberUserDO.getMobile());
|
||||
dishOrderDO.setNickname(memberUserDO.getNickname());
|
||||
}
|
||||
|
||||
}
|
||||
return appOrderRespVOPageResult;
|
||||
@ -238,11 +254,14 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
Map<Long, String> groupName = groupMapper.selectAllUserGroupName();
|
||||
|
||||
List<CarteenRespDto> carteenList = carteenApi.getCarteenList();
|
||||
Map<Long, String> stroreMap = carteenList.stream().collect(Collectors.toMap(CarteenRespDto::getId, CarteenRespDto::getStoresName));
|
||||
//进行分页查询
|
||||
PageResult<DishOrderDO> pageResult = dishOrderMapper.selectPageList(reqVO, userIds, startTime, endTime);
|
||||
List<OrderDetailsRespVO> list = new ArrayList<>();
|
||||
for (DishOrderDO dishOrderDO : pageResult.getList()) {
|
||||
OrderDetailsRespVO bean = BeanUtils.toBean(dishOrderDO, OrderDetailsRespVO.class);
|
||||
bean.setStoreName(stroreMap.get(bean.getStoreId()));
|
||||
userDetails(bean, userMap, groupName);
|
||||
list.add(bean);
|
||||
}
|
||||
@ -257,22 +276,23 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
private void userDetails(OrderDetailsRespVO bean) {
|
||||
MemberUserDO userDO = memberUserMapper.selectById(bean.getUserId());
|
||||
bean.setGroupName(groupMapper.getGroupName(bean.getUserId()));
|
||||
bean.setUserName(userDO.getNickname());
|
||||
bean.setUserJob(userDO.getMobile());
|
||||
bean.setAvatar(userDO.getAvatar());
|
||||
bean.setPayMethods("钱包");
|
||||
bean.setUserAccount(userDO.getMobile());
|
||||
bean.setTimePeriod(TimePeriodEnum.getTimeName(bean.getCreateTime()));
|
||||
BigDecimal moneyByUsr = cardMapper.getMoneyByUsr(bean.getUserId());
|
||||
bean.setMoney(moneyByUsr);
|
||||
|
||||
|
||||
if(bean.getUserId()!=null){
|
||||
MemberUserDO userDO = memberUserMapper.selectById(bean.getUserId());
|
||||
bean.setGroupName(groupMapper.getGroupName(bean.getUserId()));
|
||||
bean.setUserName(userDO.getNickname());
|
||||
bean.setUserJob(userDO.getMobile());
|
||||
bean.setAvatar(userDO.getAvatar());
|
||||
bean.setPayMethods("钱包");
|
||||
bean.setUserAccount(userDO.getMobile());
|
||||
bean.setTimePeriod(TimePeriodEnum.getTimeName(bean.getCreateTime()));
|
||||
BigDecimal moneyByUsr = cardMapper.getMoneyByUsr(bean.getUserId());
|
||||
bean.setMoney(moneyByUsr);
|
||||
}
|
||||
}
|
||||
|
||||
private void userDetails(OrderDetailsRespVO bean, HashMap<Long, MemberUserDO> userMap, Map<Long, String> groupName) {
|
||||
MemberUserDO userDO = userMap.get(bean.getUserId());
|
||||
bean.setTimePeriod(TimePeriodEnum.getTimeName(bean.getCreateTime()));
|
||||
if (ObjectUtil.isNotEmpty(userDO)) {
|
||||
bean.setGroupName(groupName.get(bean.getUserId()));
|
||||
bean.setUserName(userDO.getNickname());
|
||||
@ -280,7 +300,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
bean.setAvatar(userDO.getAvatar());
|
||||
bean.setPayMethods("钱包");
|
||||
bean.setUserAccount(userDO.getMobile());
|
||||
bean.setTimePeriod(TimePeriodEnum.getTimeName(bean.getCreateTime()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -473,13 +492,15 @@ public class OrderServiceImpl implements OrderService {
|
||||
businessService.updateStatistics(statisticsVo);
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if(dishOrderDO.getOrderStatus().equals("0")){
|
||||
BigDecimal orderMoney = diningPlatesService.getOrderMoney(orderId);
|
||||
BigDecimal add = dishOrderDO.getReductionAmount().add(money);
|
||||
if (orderMoney != null && orderMoney.compareTo(add) < 0) {
|
||||
add = orderMoney;
|
||||
}
|
||||
dishOrderDO.setReductionAmount(add);
|
||||
}else {
|
||||
throw exception(ORDER_STATUS_NOT_ALLOW);
|
||||
}
|
||||
dishOrderMapper.updateById(dishOrderDO);
|
||||
|
||||
@ -537,4 +558,29 @@ public class OrderServiceImpl implements OrderService {
|
||||
businessService.updateStatistics(statisticsVo);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abnormalHandle(Long orderId, String mobile) {
|
||||
DishOrderDO dishOrderDO = dishOrderMapper.selectById(orderId);
|
||||
if(dishOrderDO == null){
|
||||
throw exception(ORDER_NOT_EXISTS);
|
||||
}
|
||||
List<MemberUserDO> memberUserDOS = memberUserMapper.selectList(new LambdaQueryWrapperX<MemberUserDO>()
|
||||
.eq(MemberUserDO::getMobile, mobile));
|
||||
if(CollectionUtil.isEmpty(memberUserDOS)){
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
dishOrderDO.setUserId(memberUserDOS.get(0).getId());
|
||||
DiningPlatesDO diningPlatesDO = diningPlatesService.getDiningPlatesByNum(dishOrderDO.getDiningPlatesNum(), dishOrderDO.getStoreId());
|
||||
|
||||
if(dishOrderDO.getOrderStatus().equals("3")){
|
||||
//扣费处理
|
||||
deductionService.abnormalOrderDeduct(dishOrderDO);
|
||||
diningPlatesService.updateBind(Collections.singletonList(diningPlatesDO.getId()));
|
||||
}else {
|
||||
diningPlatesDO.setUserId(dishOrderDO.getUserId());
|
||||
diningPlatesService.updateById(diningPlatesDO);
|
||||
}
|
||||
dishOrderMapper.updateById(dishOrderDO);
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单明细 Service 接口
|
||||
@ -33,6 +32,7 @@ public interface OrderDetailService {
|
||||
*/
|
||||
void updateOrderDetail(@Valid AppOrderDetailSaveReqVO updateReqVO);
|
||||
|
||||
void updateOrderDetailNew(OrderDetailDO orderDetailDO);
|
||||
/**
|
||||
* 删除订单明细
|
||||
*
|
||||
|
@ -9,17 +9,17 @@ import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDeta
|
||||
import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDetailSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.OtherVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.diningplates.DiningPlatesMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.order.DishOrderMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.orderdetail.OrderDetailMapper;
|
||||
import cn.iocoder.yudao.module.member.service.async.MemberAsyncService;
|
||||
import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService;
|
||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||
import cn.iocoder.yudao.module.member.util.MemberTimeUtils;
|
||||
import cn.iocoder.yudao.module.system.api.dish.DishesApi;
|
||||
import cn.iocoder.yudao.module.system.api.dish.dto.DishesRespDto;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -29,15 +29,10 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.ORDER_ALREADY_COMPLETE;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.ORDER_DETAIL_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
@ -55,6 +50,9 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
||||
@Resource
|
||||
private DishOrderMapper dishOrderMapper;
|
||||
|
||||
@Resource
|
||||
private DiningPlatesMapper diningPlatesMapper;
|
||||
|
||||
@Resource
|
||||
private DishesApi dishesApi;
|
||||
|
||||
@ -75,13 +73,28 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
||||
public Long createOrderDetail(AppOrderDetailSaveReqVO createReqVO) {
|
||||
|
||||
DiningPlatesDO diningPlatesDO = diningPlatesService.getDiningPlatesByNum(createReqVO.getDiningPlatesNum(), createReqVO.getStoreId());
|
||||
if (diningPlatesDO == null || diningPlatesDO.getOrderId() ==null) {
|
||||
throw exception(ORDER_ALREADY_COMPLETE);
|
||||
if (diningPlatesDO == null ){
|
||||
diningPlatesDO = new DiningPlatesDO();
|
||||
}
|
||||
if (diningPlatesDO.getId() == null) {
|
||||
diningPlatesDO.setStoreId(createReqVO.getStoreId());
|
||||
diningPlatesDO.setDiningPlatesNum(createReqVO.getDiningPlatesNum());
|
||||
diningPlatesService.insertDiningPlates(diningPlatesDO);
|
||||
}
|
||||
|
||||
if(diningPlatesDO.getOrderId() == null){
|
||||
//创建初始订单
|
||||
DishOrderDO dishOrderDO = new DishOrderDO();
|
||||
dishOrderDO.setDiningPlatesNum(diningPlatesDO.getDiningPlatesNum())
|
||||
.setOrderStatus(DishOrderDO.ABNORMAL)
|
||||
.setStoreId(diningPlatesDO.getStoreId());
|
||||
dishOrderMapper.insert(dishOrderDO);
|
||||
diningPlatesDO.setOrderId(dishOrderDO.getId());
|
||||
diningPlatesDO.setStatus(DiningPlatesDO.USE);
|
||||
diningPlatesMapper.updateById(diningPlatesDO);
|
||||
}
|
||||
//计算新总价
|
||||
DishesRespDto dish = dishesApi.getDish(createReqVO.getDishesId());
|
||||
|
||||
String old = stringRedisTemplate.opsForValue().get(createReqVO.getDiningPlatesNum()+"-" +createReqVO.getStoreId());
|
||||
BigDecimal oldBigDecimal = new BigDecimal(StrUtil.isBlank(old)?"0":old);
|
||||
//计算每个菜品的价格
|
||||
@ -90,6 +103,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
||||
BigDecimal newPrice = bigDecimal1.add(oldBigDecimal).setScale(2, RoundingMode.HALF_UP);
|
||||
stringRedisTemplate.opsForValue().set(createReqVO.getDiningPlatesNum() + "-" +createReqVO.getStoreId(), newPrice.toString());
|
||||
|
||||
|
||||
OtherVO otherVO = new OtherVO();
|
||||
otherVO.setSn(getHearder());
|
||||
otherVO.setOrderId(diningPlatesDO.getOrderId());
|
||||
@ -108,7 +122,21 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
||||
validateOrderDetailExists(updateReqVO.getId());
|
||||
// 更新
|
||||
OrderDetailDO updateObj = BeanUtils.toBean(updateReqVO, OrderDetailDO.class);
|
||||
orderDetailMapper.updateById(updateObj);
|
||||
if(updateReqVO.getWeight().compareTo(BigDecimal.ZERO) == 0){
|
||||
orderDetailMapper.deleteById(updateObj);
|
||||
}else {
|
||||
orderDetailMapper.updateById(updateObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrderDetailNew(OrderDetailDO orderDetailDO) {
|
||||
// 更新
|
||||
if(orderDetailDO.getWeight().compareTo(BigDecimal.ZERO) == 0){
|
||||
orderDetailMapper.deleteById(orderDetailDO);
|
||||
}else {
|
||||
orderDetailMapper.updateById(orderDetailDO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,16 +14,11 @@ import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderP
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderPageVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storerefund.vo.StoreRefundSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.dto.FacePayDto;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreGoodsDto;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreLocalOrderDto;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreOrderDto;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreOrderUploadDto;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.dto.*;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.vo.UserInfoVo;
|
||||
import cn.iocoder.yudao.module.member.controller.app.storeorder.vo.AppStoreGoodsDetail;
|
||||
import cn.iocoder.yudao.module.member.controller.app.storeorder.vo.AppStoreOrderVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.storeorder.vo.CardDto;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storeorder.StoreOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storeorderdetail.StoreOrderDetailDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
@ -32,7 +27,7 @@ import cn.iocoder.yudao.module.member.enums.*;
|
||||
import cn.iocoder.yudao.module.member.service.amount.AmountService;
|
||||
import cn.iocoder.yudao.module.member.service.amount.DeductionService;
|
||||
import cn.iocoder.yudao.module.member.service.amount.LockManager;
|
||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||
import cn.iocoder.yudao.module.member.service.group.MemberGroupService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import cn.iocoder.yudao.module.member.service.storebusiness.StoreBusinessService;
|
||||
import cn.iocoder.yudao.module.member.service.storegoodsinventory.StoreGoodsInventoryService;
|
||||
@ -100,6 +95,9 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
@Resource
|
||||
private StoreShoppingCartService storeShoppingCartService;
|
||||
|
||||
@Resource
|
||||
private MemberGroupService memberGroupService;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate storeOrderRedisTemplate;
|
||||
|
||||
@ -236,9 +234,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
MemberUserDO user = userService.getUser(Long.valueOf(s));
|
||||
|
||||
dto.setUserId(user.getId());
|
||||
if(user.getMoney().compareTo(totalMoney) < 0){
|
||||
throw exception(AMOUNT_NOT_ENOUGH);
|
||||
}
|
||||
checkMoney(user,totalMoney);
|
||||
|
||||
//库存处理,扣除库存
|
||||
AddReqVO addReqVO = new AddReqVO();
|
||||
@ -350,11 +346,9 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AddReqVO appCreate(CardDto dto) {
|
||||
BigDecimal amount = amountService.getAmount(dto.getUserId(),dto.getCarteenId());
|
||||
MemberUserDO user = userService.getUser(dto.getUserId());
|
||||
BigDecimal total = BigDecimal.valueOf(dto.getTotalPrice());
|
||||
if(amount.compareTo(total) < 0){
|
||||
throw exception(AMOUNT_NOT_ENOUGH);
|
||||
}
|
||||
checkMoney(user,total);
|
||||
//扣除库存
|
||||
AddReqVO addReqVO = new AddReqVO();
|
||||
addReqVO.setType(InventoryTypeEnum.OUT.getCode());
|
||||
@ -418,11 +412,8 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
.mapToDouble(StoreGoodsDto::getTotalPrice)
|
||||
.sum();
|
||||
BigDecimal totalMoney = BigDecimal.valueOf(sum);
|
||||
|
||||
dto.setUserId(user.getId());
|
||||
if(user.getMoney().compareTo(totalMoney) < 0){
|
||||
throw exception(AMOUNT_NOT_ENOUGH);
|
||||
}
|
||||
checkMoney(user,totalMoney);
|
||||
|
||||
//创建订单
|
||||
StoreOrderDO storeOrderDO = new StoreOrderDO();
|
||||
@ -674,20 +665,17 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
public void test() {
|
||||
//计算金额
|
||||
//if (total.compareTo(wxAmount) <= 0) {
|
||||
// cardDO.setWxAmount(wxAmount.subtract(total).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
//} else {
|
||||
// cardDO.setWxAmount(BigDecimal.ZERO);
|
||||
// BigDecimal total1 = total.subtract(wxAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
// if (total1.compareTo(cashAmount) <= 0) {
|
||||
// cardDO.setCashAmount(cashAmount.subtract(total1).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
// } else {
|
||||
// cardDO.setCashAmount(BigDecimal.ZERO);
|
||||
// BigDecimal total2 = total1.subtract(cashAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
// cardDO.setGiftAmount(giftAmount.subtract(total2).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
// }
|
||||
//}
|
||||
public void checkMoney(MemberUserDO user,BigDecimal totalMoney){
|
||||
//获取用户所在组分类
|
||||
List<Integer> types = memberGroupService.getGroupTypeListByUserId(user.getId());
|
||||
BigDecimal computeMoney = user.getMoney();
|
||||
if (types.contains(GroupTypeEnum.YCLH.getCode()) || types.contains(GroupTypeEnum.DISTRICT.getCode())){
|
||||
computeMoney = user.getWxAmount();
|
||||
}
|
||||
if(computeMoney.compareTo(totalMoney) < 0){
|
||||
throw exception(AMOUNT_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.system.api.carteen.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 门店管理 DO
|
||||
*
|
||||
@ -48,4 +50,6 @@ public class CarteenRespDto{
|
||||
*/
|
||||
private String serialNumber;
|
||||
|
||||
private BigDecimal bindMoney;
|
||||
|
||||
}
|
@ -201,4 +201,5 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode CASH_REGISTER_INFO_NOT_EXISTS = new ErrorCode(1_002_040_005, "收银机信息关联门店不存在");
|
||||
ErrorCode CASH_REGISTER_INFO_EXISTS = new ErrorCode(1_002_040_006, "收银机已存在");
|
||||
ErrorCode DEVICE_WARN_NOT_EXISTS = new ErrorCode(1_002_040_007, "设备报警不存在");
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@ -45,4 +46,5 @@ public class CarteenPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
private BigDecimal bindMoney;
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.carteen.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.BoolenConvert;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 门店管理 Response VO")
|
||||
@Data
|
||||
@ -44,4 +44,5 @@ public class CarteenRespVO {
|
||||
// @ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private BigDecimal bindMoney;
|
||||
}
|
@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.system.controller.admin.carteen.vo;
|
||||
|
||||
import cn.hutool.core.lang.RegexPool;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 门店管理新增/修改 Request VO")
|
||||
@Data
|
||||
@ -38,4 +41,5 @@ public class CarteenSaveReqVO {
|
||||
@Pattern(regexp = RegexPool.MOBILE, message = "联系电话格式不正确")
|
||||
private String phone;
|
||||
|
||||
private BigDecimal bindMoney;
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.devicewarn;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
import cn.iocoder.yudao.module.system.service.devicewarn.DeviceWarnService;
|
||||
|
||||
@Tag(name = "管理后台 - 设备报警")
|
||||
@RestController
|
||||
@RequestMapping("/system/device-warn")
|
||||
@Validated
|
||||
public class DeviceWarnController {
|
||||
|
||||
@Resource
|
||||
private DeviceWarnService deviceWarnService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备报警")
|
||||
@PreAuthorize("@ss.hasPermission('system:device-warn:create')")
|
||||
public CommonResult<Long> createDeviceWarn(@Valid @RequestBody DeviceWarnSaveReqVO createReqVO) {
|
||||
return success(deviceWarnService.createDeviceWarn(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新设备报警")
|
||||
@PreAuthorize("@ss.hasPermission('system:device-warn:update')")
|
||||
public CommonResult<Boolean> updateDeviceWarn(@Valid @RequestBody DeviceWarnSaveReqVO updateReqVO) {
|
||||
deviceWarnService.updateDeviceWarn(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除设备报警")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('system:device-warn:delete')")
|
||||
public CommonResult<Boolean> deleteDeviceWarn(@RequestParam("id") Long id) {
|
||||
deviceWarnService.deleteDeviceWarn(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得设备报警")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:device-warn:query')")
|
||||
public CommonResult<DeviceWarnRespVO> getDeviceWarn(@RequestParam("id") Long id) {
|
||||
DeviceWarnDO deviceWarn = deviceWarnService.getDeviceWarn(id);
|
||||
return success(BeanUtils.toBean(deviceWarn, DeviceWarnRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得设备报警分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:device-warn:query')")
|
||||
public CommonResult<PageResult<DeviceWarnRespVO>> getDeviceWarnPage(@Valid DeviceWarnPageReqVO pageReqVO) {
|
||||
PageResult<DeviceWarnDO> pageResult = deviceWarnService.getDeviceWarnPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DeviceWarnRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出设备报警 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('system:device-warn:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportDeviceWarnExcel(@Valid DeviceWarnPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DeviceWarnDO> list = deviceWarnService.getDeviceWarnPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "设备报警.xls", "数据", DeviceWarnRespVO.class,
|
||||
BeanUtils.toBean(list, DeviceWarnRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 设备报警分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DeviceWarnPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备安卓码")
|
||||
private String deviceSn;
|
||||
|
||||
@Schema(description = "设备名", example = "王五")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "门店id", example = "26723")
|
||||
private Long storeId;
|
||||
|
||||
@Schema(description = "报警前重量")
|
||||
private BigDecimal beforeWeight;
|
||||
|
||||
@Schema(description = "报警后重量")
|
||||
private BigDecimal afterWeight;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 设备报警 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DeviceWarnRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10059")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备安卓码")
|
||||
@ExcelProperty("设备安卓码")
|
||||
private String deviceSn;
|
||||
|
||||
@Schema(description = "设备名", example = "王五")
|
||||
@ExcelProperty("设备名")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "门店id", example = "26723")
|
||||
@ExcelProperty("门店id")
|
||||
private Long storeId;
|
||||
|
||||
@Schema(description = "报警前重量")
|
||||
@ExcelProperty("报警前重量")
|
||||
private BigDecimal beforeWeight;
|
||||
|
||||
@Schema(description = "报警后重量")
|
||||
@ExcelProperty("报警后重量")
|
||||
private BigDecimal afterWeight;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 设备报警新增/修改 Request VO")
|
||||
@Data
|
||||
public class DeviceWarnSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10059")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备安卓码")
|
||||
private String deviceSn;
|
||||
|
||||
@Schema(description = "设备名", example = "王五")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "门店id", example = "26723")
|
||||
private Long storeId;
|
||||
|
||||
@Schema(description = "报警前重量")
|
||||
private BigDecimal beforeWeight;
|
||||
|
||||
@Schema(description = "报警后重量")
|
||||
private BigDecimal afterWeight;
|
||||
|
||||
}
|
@ -62,4 +62,5 @@ public class DishesPageReqVO extends PageParam {
|
||||
|
||||
private Integer dailySigns;
|
||||
|
||||
private Integer errorNum;
|
||||
}
|
@ -84,4 +84,6 @@ public class DishesRespVO {
|
||||
private String timeSlot;
|
||||
|
||||
private Integer dailySigns;
|
||||
|
||||
private Integer errorNum;
|
||||
}
|
@ -69,4 +69,6 @@ public class DishesSaveReqVO {
|
||||
private String timeSlot;
|
||||
|
||||
private Integer dailySigns;
|
||||
|
||||
private Integer errorNum;
|
||||
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.controller.app.carteen.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@ -24,4 +25,6 @@ public class CarteenRespVO {
|
||||
|
||||
private String phone;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private BigDecimal bindMoney;
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.devicewarn;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo.DeviceWarnSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.service.devicewarn.DeviceWarnService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
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 javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 设备报警")
|
||||
@RestController
|
||||
@RequestMapping("/system/device-warn")
|
||||
@Validated
|
||||
public class AppDeviceWarnController {
|
||||
|
||||
@Resource
|
||||
private DeviceWarnService deviceWarnService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备报警")
|
||||
public CommonResult<Long> createDeviceWarn(@Valid @RequestBody DeviceWarnSaveReqVO createReqVO) {
|
||||
return success(deviceWarnService.createDeviceWarn(createReqVO));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.carteen;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 门店管理 DO
|
||||
@ -60,4 +61,6 @@ public class CarteenDO extends BaseDO {
|
||||
*/
|
||||
private String serialNumber;
|
||||
|
||||
private BigDecimal bindMoney;
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.devicewarn;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 设备报警 DO
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@TableName("t_device_warn")
|
||||
@KeySequence("t_device_warn_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceWarnDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 设备安卓码
|
||||
*/
|
||||
private String deviceSn;
|
||||
/**
|
||||
* 设备名
|
||||
*/
|
||||
private String deviceName;
|
||||
/**
|
||||
* 门店id
|
||||
*/
|
||||
private Long storeId;
|
||||
/**
|
||||
* 报警前重量
|
||||
*/
|
||||
private BigDecimal beforeWeight;
|
||||
/**
|
||||
* 报警后重量
|
||||
*/
|
||||
private BigDecimal afterWeight;
|
||||
|
||||
}
|
@ -82,4 +82,6 @@ public class DishesDO extends BaseDO {
|
||||
private String timeSlot;
|
||||
|
||||
private Integer dailySigns;
|
||||
|
||||
private Integer errorNum;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.devicewarn;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo.*;
|
||||
|
||||
/**
|
||||
* 设备报警 Mapper
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceWarnMapper extends BaseMapperX<DeviceWarnDO> {
|
||||
|
||||
default PageResult<DeviceWarnDO> selectPage(DeviceWarnPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceWarnDO>()
|
||||
.likeIfPresent(DeviceWarnDO::getDeviceSn, reqVO.getDeviceSn())
|
||||
.likeIfPresent(DeviceWarnDO::getDeviceName, reqVO.getDeviceName())
|
||||
.eqIfPresent(DeviceWarnDO::getStoreId, reqVO.getStoreId())
|
||||
.eqIfPresent(DeviceWarnDO::getBeforeWeight, reqVO.getBeforeWeight())
|
||||
.eqIfPresent(DeviceWarnDO::getAfterWeight, reqVO.getAfterWeight())
|
||||
.betweenIfPresent(DeviceWarnDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(DeviceWarnDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.service.devicewarn;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo.DeviceWarnPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo.DeviceWarnSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 设备报警 Service 接口
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
public interface DeviceWarnService {
|
||||
|
||||
/**
|
||||
* 创建设备报警
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDeviceWarn(@Valid DeviceWarnSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新设备报警
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDeviceWarn(@Valid DeviceWarnSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除设备报警
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDeviceWarn(Long id);
|
||||
|
||||
/**
|
||||
* 获得设备报警
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 设备报警
|
||||
*/
|
||||
DeviceWarnDO getDeviceWarn(Long id);
|
||||
|
||||
/**
|
||||
* 获得设备报警分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 设备报警分页
|
||||
*/
|
||||
PageResult<DeviceWarnDO> getDeviceWarnPage(DeviceWarnPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package cn.iocoder.yudao.module.system.service.devicewarn;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo.DeviceWarnPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.devicewarn.vo.DeviceWarnSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.deviceInfo.DeviceInfoDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.devicewarn.DeviceWarnDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.deviceInfo.DeviceInfoMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.devicewarn.DeviceWarnMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.DEVICE_WARN_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 设备报警 Service 实现类
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DeviceWarnServiceImpl implements DeviceWarnService {
|
||||
|
||||
@Resource
|
||||
private DeviceWarnMapper deviceWarnMapper;
|
||||
@Resource
|
||||
private DeviceInfoMapper deviceInfoMapper;
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Override
|
||||
public Long createDeviceWarn(DeviceWarnSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DeviceWarnDO deviceWarn = BeanUtils.toBean(createReqVO, DeviceWarnDO.class);
|
||||
String mac = this.getHearder();
|
||||
DeviceInfoDO deviceInfoDO = deviceInfoMapper.selectOne(new LambdaQueryWrapper<DeviceInfoDO>()
|
||||
.eq(DeviceInfoDO::getDeviceIp, mac)
|
||||
.last("limit 1"));
|
||||
deviceWarn.setDeviceSn(mac);
|
||||
deviceWarn.setStoreId(deviceInfoDO.getCarteenId());
|
||||
deviceWarn.setDeviceName(deviceInfoDO.getDeviceName());
|
||||
deviceWarnMapper.insert(deviceWarn);
|
||||
// 返回
|
||||
return deviceWarn.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceWarn(DeviceWarnSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDeviceWarnExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DeviceWarnDO updateObj = BeanUtils.toBean(updateReqVO, DeviceWarnDO.class);
|
||||
deviceWarnMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDeviceWarn(Long id) {
|
||||
// 校验存在
|
||||
validateDeviceWarnExists(id);
|
||||
// 删除
|
||||
deviceWarnMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDeviceWarnExists(Long id) {
|
||||
if (deviceWarnMapper.selectById(id) == null) {
|
||||
throw exception(DEVICE_WARN_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceWarnDO getDeviceWarn(Long id) {
|
||||
return deviceWarnMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DeviceWarnDO> getDeviceWarnPage(DeviceWarnPageReqVO pageReqVO) {
|
||||
return deviceWarnMapper.selectPage(pageReqVO);
|
||||
}
|
||||
public String getHearder(){
|
||||
try {
|
||||
return httpServletRequest.getHeader("Authorization");
|
||||
} catch (Exception e) {
|
||||
throw exception(2000_10_001,"无法获取设备编码");
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ spring:
|
||||
autoconfigure:
|
||||
exclude:
|
||||
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
|
||||
- org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
|
||||
# - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
|
||||
- de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
|
||||
- de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
|
||||
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
|
||||
|
Reference in New Issue
Block a user