Commit 9a99cf75 by YG8999

Merge remote-tracking branch 'origin/main'

parents fafa968d a80302d0
...@@ -181,5 +181,9 @@ public class SStoreController extends BaseController ...@@ -181,5 +181,9 @@ public class SStoreController extends BaseController
return toAjax(sStoreService.insertStoreConsumers(storeId, consumerIds)); return toAjax(sStoreService.insertStoreConsumers(storeId, consumerIds));
} }
/**
* 数据同步
*/
} }
...@@ -13,11 +13,15 @@ import share.common.core.domain.AjaxResult; ...@@ -13,11 +13,15 @@ import share.common.core.domain.AjaxResult;
import share.common.core.domain.R; import share.common.core.domain.R;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.utils.JsonConvertUtil; import share.common.utils.JsonConvertUtil;
import share.framework.mqtt.MqttGatewayComponent;
import share.system.domain.SOrder; import share.system.domain.SOrder;
import share.system.domain.vo.SOrderVo;
import share.system.domain.vo.MqttxVo;
import share.system.request.CreateOrderRequest; import share.system.request.CreateOrderRequest;
import share.system.request.OrderComputedPriceRequest; import share.system.request.OrderComputedPriceRequest;
import share.system.response.ComputedOrderPriceResponse; import share.system.response.ComputedOrderPriceResponse;
import share.system.response.OrderPayResultResponse; import share.system.response.OrderPayResultResponse;
import share.system.service.DeviceLogService;
import share.system.service.ISOrderService; import share.system.service.ISOrderService;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
...@@ -40,6 +44,10 @@ public class SOrderController extends BaseController ...@@ -40,6 +44,10 @@ public class SOrderController extends BaseController
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private DeviceLogService deviceLogService;
/** /**
* 查询订单列表 * 查询订单列表
...@@ -71,12 +79,25 @@ public class SOrderController extends BaseController ...@@ -71,12 +79,25 @@ public class SOrderController extends BaseController
} }
/** /**
* 获取订单详细信息
*/
@ApiOperation(value = "通过订单编号查询订单")
@GetMapping(value = "/{orderNo}")
public R<SOrderVo> queryOrderInfoByNo(@PathVariable("orderNo") String orderNo) {
return R.ok(sOrderService.queryOrderInfoByNo(orderNo));
}
/**
* 开门 * 开门
*/ */
@ApiOperation(value = "开门") @ApiOperation(value = "开门")
@RequestMapping(value = "/open/door", method = RequestMethod.POST) @RequestMapping(value = "/open/door", method = RequestMethod.POST)
public R<String> openDoor(@RequestBody Long id){ public R<Integer> openDoor(@RequestBody String orderNo) {
return R.ok(sOrderService.openDoor(id)); MqttxVo mqttxVo = sOrderService.openDoor(orderNo);
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo);
return R.ok(result);
} }
/** /**
......
...@@ -9,10 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,10 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController; import share.common.core.controller.BaseController;
import share.common.core.domain.R; import share.common.core.domain.R;
import share.framework.mqtt.MqttGatewayComponent;
import share.system.domain.SPack; import share.system.domain.SPack;
import share.system.domain.SRoom; import share.system.domain.SRoom;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.RoomStatusVo; import share.system.domain.vo.RoomStatusVo;
import share.system.domain.vo.SRoomVo; import share.system.domain.vo.SRoomVo;
import share.system.service.DeviceLogService;
import share.system.service.IPackService; import share.system.service.IPackService;
import share.system.service.ISRoomService; import share.system.service.ISRoomService;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
...@@ -36,6 +39,10 @@ public class SRoomController extends BaseController { ...@@ -36,6 +39,10 @@ public class SRoomController extends BaseController {
@Autowired @Autowired
private IPackService packService; private IPackService packService;
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private DeviceLogService deviceLogService;
/** /**
* 查询房间列表 * 查询房间列表
...@@ -79,8 +86,12 @@ public class SRoomController extends BaseController { ...@@ -79,8 +86,12 @@ public class SRoomController extends BaseController {
*/ */
@ApiOperation(value = "专属保洁的开门操作") @ApiOperation(value = "专属保洁的开门操作")
@RequestMapping(value = "/open/door", method = RequestMethod.POST) @RequestMapping(value = "/open/door", method = RequestMethod.POST)
public R<String> openDoor(@RequestBody Long id) { public R<Integer> openDoor(@RequestBody Long id) {
return R.ok(sRoomService.openDoor(id)); MqttxVo mqttxVo = sRoomService.openDoor(id);
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo);
return R.ok(result);
} }
/** /**
......
...@@ -191,4 +191,4 @@ dianping: ...@@ -191,4 +191,4 @@ dianping:
appKey: a59ea57cd1eb4737 appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706 appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
authCode: abcdefghijklmnopqrstuvwxyz authCode: abcdefghijklmnopqrstuvwxyz
openShoopUuid: 5067d2db1311d32a0ff366c79a73df51 openShoopUuid: cf0eb0891f9e366bcda10cb7f6f23b25
...@@ -192,4 +192,4 @@ dianping: ...@@ -192,4 +192,4 @@ dianping:
appKey: a59ea57cd1eb4737 appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706 appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
authCode: abcdefghijklmnopqrstuvwxyz authCode: abcdefghijklmnopqrstuvwxyz
openShoopUuid: 5067d2db1311d32a0ff366c79a73df51 openShoopUuid: cf0eb0891f9e366bcda10cb7f6f23b25
\ No newline at end of file \ No newline at end of file
...@@ -192,4 +192,4 @@ dianping: ...@@ -192,4 +192,4 @@ dianping:
appKey: a59ea57cd1eb4737 appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706 appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
authCode: abcdefghijklmnopqrstuvwxyz authCode: abcdefghijklmnopqrstuvwxyz
openShoopUuid: 5067d2db1311d32a0ff366c79a73df51 openShoopUuid: cf0eb0891f9e366bcda10cb7f6f23b25
\ No newline at end of file \ No newline at end of file
package share.system.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* 订单对象 s_order
*
* @author ruoyi
* @date 2023-10-09
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="SOrderVo对象", description="订单对象")
public class SOrderVo
{
private static final long serialVersionUID = 1L;
/** 订单ID */
private Long id;
/** 订单流水号 */
@ApiModelProperty(value = "订单编号")
private String orderNo;
@ApiModelProperty(value = "商户订单号")
private String outTradeNo;
/** 订单类型(0:订房订单,1:续房订单,2:充值订单) */
@ApiModelProperty(value = "订单类型(1:订房订单,2:续房订单,3:充值订单)")
private Integer orderType;
@ApiModelProperty(value = "支付类型(1:微信,2:支付宝)")
private Integer payType;
@ApiModelProperty(value = "支付状态(0:未支付,1:已支付)")
private Integer payStatus;
@ApiModelProperty(value = "门店ID")
private Long storeId;
@ApiModelProperty(value = "房间ID")
private Long roomId;
/** 用户ID */
@ApiModelProperty(value = "用户ID")
private Long consumerId;
/** 用户名称 */
@ApiModelProperty(value = "用户名称")
private String consumerName;
/** 用户手机号 */
@ApiModelProperty(value = "用户手机号")
private String consumerPhone;
@ApiModelProperty(value = "套餐ID")
private Long packId;
@ApiModelProperty(value = "套餐金额")
private BigDecimal packPrice;
/** 优惠券id */
@ApiModelProperty(value = "优惠券id")
private Long couponId;
@ApiModelProperty(value = "优惠券金额")
private BigDecimal couponPrice;
@ApiModelProperty(value = "订单总价")
private BigDecimal totalPrice;
@ApiModelProperty(value = "实际支付金额")
private BigDecimal payPrice;
@ApiModelProperty(value = "支付时间")
private Date payTime;
@ApiModelProperty(value = "订单时长(H)")
private String timeLong;
/** 预约开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@ApiModelProperty(value = "预约开始时间")
private Date preStartDate;
/** 预约结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@ApiModelProperty(value = "预约结束时间")
private Date preEndDate;
/** 开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@ApiModelProperty(value = "开始时间")
private Date startDate;
/** 结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@ApiModelProperty(value = "结束时间")
private Date endDate;
/** 订单状态(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/退款中,4:审核中,5:已退费) */
@ApiModelProperty(value = "订单状态(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/申请退款,4:退款中,5:已退费)")
private Integer status;
@ApiModelProperty(value = "0 未退款 1 申请中 2 退款中 3 已退款 4 拒绝退款")
@TableField(value = "refund_status")
private Integer refundStatus;
@ApiModelProperty(value = "退款说明")
@TableField(value = "refund_reason")
private String refundReason;
@ApiModelProperty(value = "退款时间")
@TableField(value = "refund_reason_time")
private Date refundReasonTime;
@ApiModelProperty(value = "退款金额")
private BigDecimal refundPrice;
//逻辑删除注解(0 未删除 1 已删除)
private Integer isDelete;
private Integer buyType;
/** 创建者 */
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 备注 */
private String remark;
@ApiModelProperty(value = "门店名称")
private String storeName;
@ApiModelProperty(value = "房间名称")
private String roomName;
/** 门店地址 */
@ApiModelProperty(value = "门店地址")
private String address;
}
...@@ -60,4 +60,6 @@ public interface SOrderMapper extends BaseMapper<SOrder> ...@@ -60,4 +60,6 @@ public interface SOrderMapper extends BaseMapper<SOrder>
* @return 结果 * @return 结果
*/ */
public int deleteSOrderByIds(Long[] ids); public int deleteSOrderByIds(Long[] ids);
SOrder selectSOrderByNo(String orderNo);
} }
...@@ -5,6 +5,8 @@ import java.util.List; ...@@ -5,6 +5,8 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SOrder; import share.system.domain.SOrder;
import share.system.domain.vo.SOrderVo;
import share.system.domain.vo.MqttxVo;
import share.system.request.CreateOrderRequest; import share.system.request.CreateOrderRequest;
import share.system.request.OrderComputedPriceRequest; import share.system.request.OrderComputedPriceRequest;
import share.system.request.OrderRefundRequest; import share.system.request.OrderRefundRequest;
...@@ -97,7 +99,7 @@ public interface ISOrderService extends IService<SOrder> ...@@ -97,7 +99,7 @@ public interface ISOrderService extends IService<SOrder>
*/ */
SOrder getByOrderNo(String orderNo); SOrder getByOrderNo(String orderNo);
String openDoor(Long id); MqttxVo openDoor(String orderNo);
SOrder getInfoByEntity(SOrder orderParam); SOrder getInfoByEntity(SOrder orderParam);
...@@ -124,4 +126,6 @@ public interface ISOrderService extends IService<SOrder> ...@@ -124,4 +126,6 @@ public interface ISOrderService extends IService<SOrder>
boolean cancel(String orderNo); boolean cancel(String orderNo);
SOrder selectSOrderByOrderNo(String orderNo); SOrder selectSOrderByOrderNo(String orderNo);
SOrderVo queryOrderInfoByNo(String orderNo);
} }
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.Device; import share.system.domain.Device;
import share.system.domain.SPack; import share.system.domain.SPack;
import share.system.domain.SRoom; import share.system.domain.SRoom;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.SRoomVo; import share.system.domain.vo.SRoomVo;
/** /**
...@@ -84,7 +85,7 @@ public interface ISRoomService extends IService<SRoom> ...@@ -84,7 +85,7 @@ public interface ISRoomService extends IService<SRoom>
List<SRoom> selectSroomListByStroeId(Long storeId); List<SRoom> selectSroomListByStroeId(Long storeId);
String openDoor(Long id); MqttxVo openDoor(Long id);
List<SPack> getPackByRoomId(Long id); List<SPack> getPackByRoomId(Long id);
......
package share.system.service.impl; package share.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dianping.openapi.sdk.api.oauth.CustomerRefreshToken; import com.dianping.openapi.sdk.api.oauth.CustomerRefreshToken;
import com.dianping.openapi.sdk.api.oauth.DynamicToken; import com.dianping.openapi.sdk.api.oauth.DynamicToken;
import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse; import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse;
...@@ -11,6 +12,7 @@ import com.dianping.openapi.sdk.api.oauth.enums.GrantType; ...@@ -11,6 +12,7 @@ import com.dianping.openapi.sdk.api.oauth.enums.GrantType;
import com.dianping.openapi.sdk.api.tuangou.*; import com.dianping.openapi.sdk.api.tuangou.*;
import com.dianping.openapi.sdk.api.tuangou.entity.*; import com.dianping.openapi.sdk.api.tuangou.entity.*;
import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient; import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.enums.PlatformTypeEnum; import share.common.enums.PlatformTypeEnum;
import share.common.enums.SourceTypeEnum; import share.common.enums.SourceTypeEnum;
import share.system.domain.Device;
import share.system.domain.SConsumer; import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon; import share.system.domain.SConsumerCoupon;
import share.system.domain.SCoupon; import share.system.domain.SCoupon;
...@@ -57,6 +60,13 @@ public class QPServiceImpl implements QPService { ...@@ -57,6 +60,13 @@ public class QPServiceImpl implements QPService {
if (sCoupon == null) { if (sCoupon == null) {
throw new RuntimeException("未找到对应的优惠券"); throw new RuntimeException("未找到对应的优惠券");
} }
//查询领取记录表
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SConsumerCoupon::getCouponId, prepare.getDeal_title());
SConsumerCoupon one = isConsumerCouponService.getOne(queryWrapper);
if (ObjectUtils.isNotEmpty(one)) {
throw new RuntimeException("该优惠券以领取");
}
//执行验券 //执行验券
// List<TuangouReceiptConsumeResponseEntity> consume = consume(code, count); // List<TuangouReceiptConsumeResponseEntity> consume = consume(code, count);
// consume.forEach(item -> { // consume.forEach(item -> {
......
...@@ -22,9 +22,12 @@ import share.common.utils.DateUtil; ...@@ -22,9 +22,12 @@ import share.common.utils.DateUtil;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.utils.SecurityUtils;
import share.common.utils.bean.BeanUtils; import share.common.utils.bean.BeanUtils;
import share.system.domain.*; import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SOrderVo;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.SRoomVo; import share.system.domain.vo.SRoomVo;
import share.system.mapper.SOrderMapper; import share.system.mapper.SOrderMapper;
import share.system.request.CreateOrderRequest; import share.system.request.CreateOrderRequest;
...@@ -60,6 +63,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -60,6 +63,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
private OrderRefundService orderRefundService; private OrderRefundService orderRefundService;
@Autowired @Autowired
private ISStoreService storeService;
@Autowired
private ISRoomService roomService; private ISRoomService roomService;
@Autowired @Autowired
...@@ -71,6 +77,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -71,6 +77,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private MqttxService mqttxService;
@Autowired
private DeviceService deviceService;
/** /**
* 查询订单 * 查询订单
* *
...@@ -176,6 +188,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -176,6 +188,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
response.setStatus(YesNoEnum.yes.getFlag()); response.setStatus(YesNoEnum.yes.getFlag());
response.setOrderNo(sOrder.getOrderNo()); response.setOrderNo(sOrder.getOrderNo());
sOrder.setPayStatus(YesNoEnum.yes.getIndex()); sOrder.setPayStatus(YesNoEnum.yes.getIndex());
sOrder.setPayTime(DateUtils.getNowDate());
}else { }else {
response = orderPayService.payment(sOrder); response = orderPayService.payment(sOrder);
// 加入自动未支付自动取消队列 // 加入自动未支付自动取消队列
...@@ -250,6 +263,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -250,6 +263,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
SPack pack = packService.getById(sOrder.getPackId()); SPack pack = packService.getById(sOrder.getPackId());
sOrder.setPackPrice(pack.getPrice()); sOrder.setPackPrice(pack.getPrice());
} }
sOrder.setCreateTime(DateUtils.getNowDate());
return sOrder; return sOrder;
} }
...@@ -389,8 +403,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -389,8 +403,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
} }
@Override @Override
public String openDoor(Long id) { public SOrderVo queryOrderInfoByNo(String orderNo) {
SOrder sOrder = sOrderMapper.selectSOrderById(id); SOrder en = getByOrderNo(orderNo);
SOrderVo vo = new SOrderVo();
BeanUtils.copyProperties(en,vo);
SStore store = storeService.getById(vo.getStoreId());
SRoom room = roomService.getById(vo.getRoomId());
vo.setStoreName(store.getName());
vo.setAddress(store.getAddress());
vo.setRoomName(room.getName());
return vo;
}
@Override
public MqttxVo openDoor(String orderNo) {
SOrder sOrder = sOrderMapper.selectSOrderByNo(orderNo);
if (Objects.isNull(sOrder)) { if (Objects.isNull(sOrder)) {
throw new BaseException("订单不存在!"); throw new BaseException("订单不存在!");
} }
...@@ -398,12 +425,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -398,12 +425,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
if (Objects.isNull(sRoomVo)) { if (Objects.isNull(sRoomVo)) {
throw new BaseException("房间不存在!"); throw new BaseException("房间不存在!");
} }
//根据门锁编号,电机控制,密码进行开门 LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
String doorLockCode = sRoomVo.getDoorLockCode(); queryWrapper.eq(Device::getRoomId, sOrder.getRoomId());
String electricControlCode = sRoomVo.getElectricControlCode(); Device one = deviceService.getOne(queryWrapper);
String password = sRoomVo.getPassword(); if (Objects.isNull(one)) {
if(true){ throw new BaseException("设备不存在!");
//TODO 开门成功 }
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(one.getDevId(), user.getNickName(), "10");
if (sOrder.getStatus().equals(OrderStatusEnum.UNUSED.getCode())) {
//更改订单状态,房间状态,开始时间,结束时间 //更改订单状态,房间状态,开始时间,结束时间
sOrder.setStatus(1); sOrder.setStatus(1);
//计算预约开始和结束时间时长 //计算预约开始和结束时间时长
...@@ -412,11 +442,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -412,11 +442,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
//结束时间为开始时间+预约时长 //结束时间为开始时间+预约时长
sOrder.setEndDate(DateUtils.addHours(new Date(), bigDecimal.intValue())); sOrder.setEndDate(DateUtils.addHours(new Date(), bigDecimal.intValue()));
sOrderMapper.updateById(sOrder); sOrderMapper.updateById(sOrder);
return "开门成功";
}else{
//TODO 开门失败
return "开门失败";
} }
return mqttxVo;
} }
private BigDecimal computeTotalPrice(BigDecimal unitPrice, Date startTime, Date endTime){ private BigDecimal computeTotalPrice(BigDecimal unitPrice, Date startTime, Date endTime){
......
...@@ -8,11 +8,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -8,11 +8,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import share.common.enums.RoleTypeEnum; import share.common.enums.RoleTypeEnum;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.system.domain.*; import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.SRoomVo; import share.system.domain.vo.SRoomVo;
import share.system.mapper.DeviceMapper; import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper; import share.system.mapper.SRoomMapper;
...@@ -39,6 +41,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -39,6 +41,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
private IRoomPackService roomPackService; private IRoomPackService roomPackService;
@Autowired @Autowired
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
@Autowired
private DeviceService deviceService;
@Autowired
private MqttxService mqttxService;
/** /**
...@@ -211,7 +217,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -211,7 +217,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
} }
@Override @Override
public String openDoor(Long id) { public MqttxVo openDoor(Long id) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry(); SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) { if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是保洁人员"); throw new RuntimeException("当前用户不是保洁人员");
...@@ -220,12 +226,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -220,12 +226,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
if (Objects.isNull(room)) { if (Objects.isNull(room)) {
throw new RuntimeException("房间不存在"); throw new RuntimeException("房间不存在");
} }
//TODO 调用开门接口 LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
if (true) { queryWrapper.eq(Device::getRoomId, id);
return "开门成功"; Device one = deviceService.getOne(queryWrapper);
} else { if (Objects.isNull(one)) {
return "开门失败"; throw new BaseException("设备不存在!");
} }
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(one.getDevId(), user.getNickName(), "10");
return mqttxVo;
} }
@Override @Override
......
...@@ -125,6 +125,10 @@ ...@@ -125,6 +125,10 @@
<include refid="selectSOrderVo"/> <include refid="selectSOrderVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="selectSOrderByNo" resultMap="SOrderResult" parameterType="String">
<include refid="selectSOrderVo"/>
where order_no=#{orderNo}
</select>
<insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_order insert into s_order
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment