Commit 9b4257b8 by 吕明尚

领取记录表增加套餐ID

parent ae624c7a
......@@ -128,7 +128,7 @@ public class DeviceController extends BaseController
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo);
int result = deviceLogService.addDeviceLog(mqttxVo, SecurityUtils.getUsername());
return toAjax(result);
}
......
......@@ -16,6 +16,7 @@ import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.common.utils.SecurityUtils;
import share.system.domain.DeviceGateway;
import share.system.service.DeviceGatewayService;
import share.common.utils.poi.ExcelUtil;
......@@ -113,7 +114,7 @@ public class DeviceGatewayController extends BaseController
@PostMapping(value = "/clearGatewayDevice")
public AjaxResult clearGatewayDevice(@RequestBody DeviceGateway deviceGateway)
{
deviceOpService.clearGatewayDevice(deviceGateway.getDevId());
deviceOpService.clearGatewayDevice(deviceGateway.getDevId(), SecurityUtils.getUsername());
return toAjax(true);
}
......@@ -125,7 +126,7 @@ public class DeviceGatewayController extends BaseController
@PostMapping(value = "/addGatewayDevice")
public AjaxResult addGatewayDevice(@RequestBody DeviceGateway deviceGateway)
{
deviceOpService.addGatewayDevice(deviceGateway.getDevId());
deviceOpService.addGatewayDevice(deviceGateway.getDevId(), SecurityUtils.getUsername());
return toAjax(true);
}
......
......@@ -84,8 +84,8 @@ public class SOrderController extends BaseController
* 开门
*/
@ApiOperation(value = "开门")
@RequestMapping(value = "/open/door", method = RequestMethod.POST)
public R<String> openDoor(@RequestBody String orderNo) {
@RequestMapping(value = "/open/door", method = RequestMethod.GET)
public R<String> openDoor(@RequestParam("orderNo") String orderNo) {
return R.ok(sOrderService.openDoor(orderNo));
}
......
......@@ -32,6 +32,12 @@ public class SConsumerCoupon extends BaseEntity
@Excel(name = "优惠券ID")
private Long couponId;
/**
* 优惠券ID
*/
@Excel(name = "套餐ID")
private Long dealId;
/** 优惠券编码 */
@Excel(name = "优惠券编码")
private String couponCode;
......
......@@ -81,4 +81,6 @@ public interface DeviceMapper extends BaseMapper<Device>
List<Device> notRoomIdList(Device device);
int clearDeviceRoomId(Device device);
Device selectDeviceByRoomId(Long roomId);
}
......@@ -67,6 +67,6 @@ public interface DeviceLogService extends IService<DeviceLog>
* @param mqttxVo 设备操作信息
* @return 结果
*/
int addDeviceLog(MqttxVo mqttxVo);
int addDeviceLog(MqttxVo mqttxVo, String userNme);
}
......@@ -14,27 +14,27 @@ public interface DeviceOpService {
* 小程序订单开门
* @param deviceParam
*/
void openDoor(DeviceParamVo deviceParam);
void openDoor(DeviceParamVo deviceParam, String userName);
/**
* 小程序订单开门
* @param roomId 房间id
* @param phone 操作用户
*/
void openDoor(Long roomId, String phone);
void openDoor(Long roomId, String phone, String userName);
/**
* 清除网关锁id列表
* @param devId 网关设备dev_id
* @return
*/
void clearGatewayDevice(String devId);
void clearGatewayDevice(String devId, String userName);
/**
* 下发组号、锁id/取电开关id列表
* @param devId 网关设备dev_id
* @return
*/
void addGatewayDevice(String devId);
void addGatewayDevice(String devId, String userName);
}
......@@ -70,4 +70,6 @@ public interface DeviceService extends IService<Device>
List<Device> notRoomIdList(Device device);
List<Device> selectDeviceListByIds(List<Long> collect);
Device selectDeviceByRoomId(Long roomId);
}
......@@ -98,7 +98,7 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
}
@Override
public int addDeviceLog(MqttxVo mqttxVo) {
public int addDeviceLog(MqttxVo mqttxVo, String userNmae) {
DeviceLog deviceLog = new DeviceLog();
deviceLog.setDevId(mqttxVo.getDevId());
deviceLog.setDevMac(mqttxVo.getDevMac());
......@@ -108,7 +108,7 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
deviceLog.setMqttType(mqttxVo.getMqttType());
deviceLog.setMqttDescribe(mqttxVo.getMqttDescribe());
deviceLog.setCreateTime(DateUtils.getNowDate());
deviceLog.setCreateBy(SecurityUtils.getUsername());
deviceLog.setCreateBy(userNmae);
return deviceLogMapper.insertDeviceLog(deviceLog);
}
}
......@@ -40,7 +40,7 @@ public class DeviceOpServiceImpl implements DeviceOpService {
* 小程序订单开门
* @param deviceParam
*/
public void openDoor(DeviceParamVo deviceParam) {
public void openDoor(DeviceParamVo deviceParam, String userName) {
SRoom room = roomMapper.selectSRoomById(deviceParam.getRoomId());
if (room != null) {
Device param = new Device();
......@@ -49,11 +49,11 @@ public class DeviceOpServiceImpl implements DeviceOpService {
for (Device device : list) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "10");
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "10", userName);
}
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "20");
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "20", userName);
}
}
......@@ -65,7 +65,7 @@ public class DeviceOpServiceImpl implements DeviceOpService {
* @param roomId 房间id
* @param phone 操作用户
*/
public void openDoor(Long roomId, String phone) {
public void openDoor(Long roomId, String phone, String userName) {
SRoom room = roomMapper.selectSRoomById(roomId);
if (room != null) {
Device param = new Device();
......@@ -74,24 +74,24 @@ public class DeviceOpServiceImpl implements DeviceOpService {
for (Device device : list) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁
this.deviceOpInit(device.getDevId(), phone, "10");
this.deviceOpInit(device.getDevId(), phone, "10", userName);
}
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关
this.deviceOpInit(device.getDevId(), phone, "20");
this.deviceOpInit(device.getDevId(), phone, "20", userName);
}
}
}
}
private void deviceOpInit(String devId, String phone, String opType) {
private void deviceOpInit(String devId, String phone, String opType, String userName) {
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(devId, phone, opType);
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
deviceLogService.addDeviceLog(mqttxVo);
deviceLogService.addDeviceLog(mqttxVo, userName);
}
/**
......@@ -100,13 +100,13 @@ public class DeviceOpServiceImpl implements DeviceOpService {
* @return
*/
@Override
public void clearGatewayDevice(String devId) {
public void clearGatewayDevice(String devId, String userName) {
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.clearGatewayDevice(devId);
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
deviceLogService.addDeviceLog(mqttxVo);
deviceLogService.addDeviceLog(mqttxVo, userName);
}
/**
......@@ -115,13 +115,13 @@ public class DeviceOpServiceImpl implements DeviceOpService {
* @return
*/
@Override
public void addGatewayDevice(String devId) {
public void addGatewayDevice(String devId, String userName) {
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.addGatewayDevice(devId);
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
deviceLogService.addDeviceLog(mqttxVo);
deviceLogService.addDeviceLog(mqttxVo, userName);
}
......
......@@ -123,6 +123,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
@Override
public Device selectDeviceByRoomId(Long roomId) {
return deviceMapper.selectDeviceByRoomId(roomId);
}
@Override
public List<Device> notRoomIdList(Device device) {
SRoom room = roomMapper.selectSRoomById(device.getRoomId());
if (room != null) {
......
......@@ -463,7 +463,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
@Override
public String openDoor(String orderNo) {
SOrder sOrder = sOrderMapper.selectSOrderByNo(orderNo);
LambdaQueryWrapper<SOrder> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
orderLambdaQueryWrapper.eq(SOrder::getOrderNo, orderNo);
SOrder sOrder = sOrderMapper.selectOne(orderLambdaQueryWrapper);
if (Objects.isNull(sOrder)) {
throw new BaseException("订单不存在!");
}
......@@ -471,9 +473,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
if (Objects.isNull(sRoomVo)) {
throw new BaseException("房间不存在!");
}
LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Device::getRoomId, sOrder.getRoomId());
Device one = deviceService.getOne(queryWrapper);
Device one = deviceService.selectDeviceByRoomId(sOrder.getRoomId());
if (Objects.isNull(one)) {
throw new BaseException("设备不存在!");
}
......@@ -492,7 +492,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
}
}
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
deviceOpService.openDoor(sRoomVo.getId(), user.getNickName());
deviceOpService.openDoor(sRoomVo.getId(), user.getPhone(), user.getNickName());
return "开锁成功";
}
......@@ -513,7 +513,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
add(RefundStatusEnum.REFUNDED.getCode());
}});
queryWrapper.apply("IFNULL(start_date,pre_start_date) >= '"+DateUtils.getTime()+"' " +
" AND IFNULL(start_date,pre_start_date) <= '"+DateUtils.getTime()+"')");
" AND IFNULL(start_date,pre_start_date) <= '" + DateUtils.getTime() + "'");
return count(queryWrapper)==0;
}
......
......@@ -234,7 +234,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
if (Objects.isNull(one)) {
throw new BaseException("设备不存在!");
}
deviceOpService.openDoor(id, user.getNickName());
deviceOpService.openDoor(id, user.getPhone(), user.getNickName());
return "开锁成功";
}
......
......@@ -84,6 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDeviceVo"/>
where dev_id = #{devId}
</select>
<select id="selectDeviceByRoomId" parameterType="Long" resultMap="DeviceResult">
<include refid="selectDeviceVo"/>
where room_id=#{roomId}
</select>
<insert id="insertDevice" parameterType="Device" useGeneratedKeys="true" keyProperty="id">
insert into s_device
......
......@@ -8,6 +8,7 @@
<result property="id" column="id" />
<result property="consumerId" column="consumer_id" />
<result property="couponId" column="coupon_id" />
<result property="dealId" column="deal_id"/>
<result property="couponCode" column="coupon_code" />
<result property="name" column="name" />
<result property="couponType" column="coupon_type" />
......@@ -37,7 +38,37 @@
</resultMap>
<sql id="selectSConsumerCouponVo">
select id, consumer_id, coupon_id, coupon_code, name, coupon_type,coupon_time_start,coupon_time_end, max_duration,min_duration, duration, min_price, sub_price, source_type, platform_type, start_date, end_date, use_date, use_status, is_delete, create_by, create_time, update_by, update_time, delete_by, delete_time, remark,room_type,store_type from s_consumer_coupon
select id,
consumer_id,
coupon_id,
deal_id,
coupon_code,
name,
coupon_type,
coupon_time_start,
coupon_time_end,
max_duration,
min_duration,
duration,
min_price,
sub_price,
source_type,
platform_type,
start_date,
end_date,
use_date,
use_status,
is_delete,
create_by,
create_time,
update_by,
update_time,
delete_by,
delete_time,
remark,
room_type,
store_type
from s_consumer_coupon
</sql>
<select id="selectSConsumerCouponList" parameterType="SConsumerCoupon" resultMap="SConsumerCouponResult">
......@@ -45,6 +76,7 @@
<where>
<if test="consumerId != null "> and consumer_id = #{consumerId}</if>
<if test="couponId != null "> and coupon_id = #{couponId}</if>
<if test="dealId !=null">and deal_id=#{dealId}</if>
<if test="couponCode != null and couponCode != ''"> and coupon_code = #{couponCode}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="couponType != null and couponType != ''"> and coupon_type = #{couponType}</if>
......@@ -90,6 +122,7 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="consumerId != null">consumer_id,</if>
<if test="couponId != null">coupon_id,</if>
<if test="dealId != null">deal_id,</if>
<if test="couponCode != null and couponCode != ''">coupon_code,</if>
<if test="name != null and name != ''">name,</if>
<if test="couponType != null">coupon_type,</if>
......@@ -120,6 +153,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consumerId != null">#{consumerId},</if>
<if test="couponId != null">#{couponId},</if>
<if test="dealId != null">#{dealId}</if>
<if test="couponCode != null and couponCode != ''">#{couponCode},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="couponType != null">#{couponType},</if>
......@@ -154,6 +188,7 @@
<trim prefix="SET" suffixOverrides=",">
<if test="consumerId != null">consumer_id = #{consumerId},</if>
<if test="couponId != null">coupon_id = #{couponId},</if>
<if test="dealId != null">deal_id = #{dealId}</if>
<if test="couponCode != null and couponCode != ''">coupon_code = #{couponCode},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="couponType != null">coupon_type = #{couponType},</if>
......
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