This commit is contained in:
邱贞招 2025-03-18 09:34:10 +08:00
parent 06281c14b2
commit 3b3f4e1eb8
14 changed files with 155 additions and 16 deletions

View File

@ -170,10 +170,10 @@ public class AppController extends BaseController
Long cityId = query.getCityId();
if(ObjectUtil.isNull(cityId)){
if(StrUtil.isBlank(query.getPhoneLon())){
ServiceUtil.assertion(false, "经度[phoneLon]未传");
ServiceUtil.assertion(true, "经度[phoneLon]未传");
}
if(StrUtil.isBlank(query.getPhoneLat())){
ServiceUtil.assertion(false, "纬度[phoneLat]未传");
ServiceUtil.assertion(true, "纬度[phoneLat]未传");
}
query.setCityId(cityService.getCityIdByLocation(query.getPhoneLon(), query.getPhoneLat()));
}

View File

@ -108,7 +108,7 @@ public class AppDeviceAdminController extends BaseController {
@PostMapping("/adminAll/{roomId}/switch")
@DeviceAdminRequired
public AjaxResult adminGet(@PathVariable @ApiParam("房间id") Long roomId ,@RequestParam @ApiParam("是否开启") Boolean open) {
return toAjax(deviceService.roomAllSwitchDevice(roomId, open,"小程序房间开关"));
return toAjax(deviceService.roomAllSwitchDevice(roomId, open,"管理员房间开关"));
}
}

View File

@ -170,6 +170,9 @@ public class User extends BaseEntity
@ApiModelProperty(value = "多店权限1-单店N-多店")
private String multiStore;
@ApiModelProperty(value = "到期提醒时间")
private Integer reminder;
public User() {
}

View File

@ -34,7 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectUserBalance" parameterType="UserBalanceQuery" resultType="java.math.BigDecimal">
SELECT SUM(amount) AS totalAmount
SELECT SUM(CASE WHEN type = '1' THEN amount ELSE 0 END) -
SUM(CASE WHEN type = '2' THEN amount ELSE 0 END) AS netBalance
FROM ss_change_balance
WHERE 1=1
<if test="startTime != null">

View File

@ -15,6 +15,7 @@ import com.ruoyi.ss.callback.service.ICallbackService;
import com.ruoyi.ss.changeBalance.service.IChangeBalanceService;
import com.ruoyi.ss.channel.domain.ChannelVO;
import com.ruoyi.ss.channel.service.IChannelService;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.dividendDetail.domain.DividendDetail;
import com.ruoyi.ss.dividendDetail.domain.DividendDetailVO;
import com.ruoyi.ss.dividendDetail.service.IDividendDetailService;
@ -58,6 +59,7 @@ import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -123,6 +125,8 @@ public class CallbackServiceImpl implements ICallbackService {
@Value("${ruoyi.privateKeyPath}")
private String path;
@Autowired
private DeviceService deviceService;
/**
* 微信支付回调
@ -171,10 +175,10 @@ public class CallbackServiceImpl implements ICallbackService {
/**
* 1. 更新支付订单表pay_bill
2. 更新订单表的状态
3. 更新分账表 分账金额状态实际支付金额
4. 更新用户账变
5. 订单履历
2. 更新订单表的状态
3. 更新分账表 分账金额状态实际支付金额
4. 更新用户账变
5. 订单履历
*/
Boolean execute = transactionTemplate.execute(e -> {
updateOrder(orderVO,payTime,payBillVO);
@ -365,6 +369,13 @@ public class CallbackServiceImpl implements ICallbackService {
status = ServiceConstants.ORDER_STATUS_PAYMENT_SUCCESS;
}else{
status = ServiceConstants.ORDER_STATUS_IN_USE;
// 发送一次房间的全开 用time 门打开
deviceService.roomAllDeviceSetTime(orderVO, "(回调时)下单成功后房间全开");
}
UserVO userVO = userService.selectUserById(orderVO.getMerchantId());
if(ObjectUtil.isNotNull(userVO)){
Date timeAfterXMinutes = DateUtils.getTimeAfterXMinutes(orderVO.getReserveEndTime(), -userVO.getReminder());
updateOrder.setReminderTime(timeAfterXMinutes);
}
updateOrder.setStatus(status);
updateOrder.setPayTime(payTime);

View File

@ -456,6 +456,11 @@ public interface DeviceService
*/
int roomAllDeviceSetTime(OrderVO orderVO, String reason);
/**
* 时间快到时房间设备提醒
*/
int roomAllDeviceSerVoice(OrderVO orderVO, long seconds);
/**
* 大厅开关
*/

View File

@ -1011,7 +1011,7 @@ public class DeviceServiceImpl implements DeviceService
}
} catch (Exception e) {
log.error("【房间开关】失败", e);
return 1;
return 0;
}
return 1;
}
@ -1038,6 +1038,23 @@ public class DeviceServiceImpl implements DeviceService
return 1;
}
/**
* 时间快到时房间设备提醒
*/
@Override
public int roomAllDeviceSerVoice(OrderVO orderVO, long seconds) {
// 通过房间id查询所有设备id
List<Long> deviceIds = roomService.selectAllDeviceIdsByRoomId(orderVO.getRoomId());
for (Long deviceId : deviceIds) {
DeviceVO deviceVO = selectById(deviceId);
ServiceUtil.assertion(deviceVO == null, "设备不存在");
iotService.setVoice(deviceVO, seconds);
}
return 1;
}
/**
* 大厅开关
*/

View File

@ -420,4 +420,11 @@ public class Order extends BaseEntity {
@ApiModelProperty("房间/设施图片")
private String picture;
@Excel(name = "到期时间")
@ApiModelProperty("到期时间")
private Date reminderTime;
@Excel(name = "是否已发送过提醒")
@ApiModelProperty("是否已发送过提醒")
private Boolean isReminded;
}

View File

@ -170,6 +170,11 @@ public interface OrderMapper
*/
List<OrderVO> selectNotRefundedOrderList();
/**
* 查询需要到期提醒的订单
*/
List<OrderVO> selectExpirationReminderOrderList();
/**
* 统计数量
*/

View File

@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
paid, pay_id, type, re_type, total_fee, pay_fee, deposit, deposit_refund, refund, refund_time, is_refund, platform_service_fee, mark, duration, status, create_time,
change_reason, pay_channel, channel_name, channel_cost, store_name, lng,lat, store_id, merchant_id, original_order_no, price, `explain`, auto_cancel_time,
is_send_msg, room_id,equipment_id, equipment_type,equipment_name, room_name, room_type, room_type2, mode, hours, reserve_start_time, reserve_end_time,
wifi, wifi_password, manager_phone, deposit_refund_desc, product_id, product_name from ss_order
wifi, wifi_password, manager_phone, deposit_refund_desc, product_id, product_name, reminder_time, is_reminded from ss_order
</sql>
<sql id="selectRlOrderDetail">
@ -84,7 +84,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
o.product_name,
o.product_id,
o.deposit_refund_desc,
o.refund_duration
o.refund_duration,
o.reminder_time,
o.is_reminded
FROM
ss_order o
left join ss_user u on o.user_id = u.user_id
@ -360,6 +362,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND p.status = '3'
</select>
<select id="selectExpirationReminderOrderList" resultMap="RlOrderResult">
SELECT
o.order_no,
o.merchant_id,
o.reminder_time,
o.room_id,
o.is_reminded
FROM
ss_order o
WHERE
o.paid = '3'
AND o.is_reminded = '0'
AND o.status = '3'
</select>
<select id="getCount" parameterType="OrderQuery" resultType="java.lang.Integer">
select count(1) from ss_order o
<where>
@ -476,6 +493,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="managerPhone != null">manager_phone,</if>
<if test="productId != null">product_id,</if>
<if test="productName != null">product_name,</if>
<if test="reminderTime != null">reminder_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
@ -538,6 +556,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="managerPhone != null">#{managerPhone},</if>
<if test="productId != null">#{productId},</if>
<if test="productName != null">#{productName},</if>
<if test="reminderTime != null">#{reminderTime},</if>
</trim>
</insert>
@ -611,6 +630,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productId != null">product_id = #{productId},</if>
<if test="productName != null">product_name = #{productName},</if>
<if test="depositRefundDesc != null">deposit_refund_desc = #{depositRefundDesc},</if>
<if test="reminderTime != null">reminder_time = #{reminderTime},</if>
<if test="isReminded != null">is_reminded = #{isReminded},</if>
</trim>
where order_id = #{orderId}
</update>
@ -679,6 +700,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productId != null">product_id = #{productId},</if>
<if test="productName != null">product_name = #{productName},</if>
<if test="depositRefundDesc != null">deposit_refund_desc = #{depositRefundDesc},</if>
<if test="reminderTime != null">reminder_time = #{reminderTime},</if>
<if test="isReminded != null">is_reminded = #{isReminded},</if>
</trim>
where order_no = #{orderNo}
</update>

View File

@ -300,4 +300,9 @@ public interface IOrderService
* 后台首页图表数据
*/
IndexChartDatas adminIndexChartData(IndexChartQuery query);
/**
* 查询需要到期提醒的订单
*/
List<OrderVO> selectExpirationReminderOrderList();
}

View File

@ -12,6 +12,7 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.YPMsgUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.common.utils.wx.vo.PrepayResponseVO;
import com.ruoyi.ss.balance.domain.UserBalanceQuery;
@ -49,7 +50,6 @@ import com.ruoyi.ss.payBill.service.PayBillService;
import com.ruoyi.ss.product.service.IProductService;
import com.ruoyi.ss.reconciliation.domain.ReconciliationQuery;
import com.ruoyi.ss.reconciliation.domain.ReconciliationVO;
import com.ruoyi.ss.reconciliation.domain.enums.ReconciliationDateChannelType;
import com.ruoyi.ss.reconciliation.service.IReconciliationService;
import com.ruoyi.ss.refund.domain.Refund;
import com.ruoyi.ss.refund.domain.RefundQuery;
@ -984,6 +984,9 @@ public class OrderServiceImpl implements IOrderService
int i1 = roomService.updateERoom(room);
ServiceUtil.assertion(i1 == 0,"【订单结束】更新房间状态失败");
/* 房间电源全关 */
int i2 = deviceService.roomAllSwitchDevice(order.getRoomId(), false, "订单结束房间电源全关");
ServiceUtil.assertion(i2 == 0,"【订单结束】更新房间电源全关失败");
return Boolean.TRUE;
});
if(Boolean.FALSE.equals(execute))throw new ServiceException("订单结束失败");
@ -1372,6 +1375,8 @@ public class OrderServiceImpl implements IOrderService
// 今日余额
UserBalanceQuery userBalanceQuery = new UserBalanceQuery();
userBalanceQuery.setStartTime(LocalDate.now());
userBalanceQuery.setEndTime(LocalDate.now());
BigDecimal todayUserBalance = userBalanceService.selectUserBalance(userBalanceQuery);
adminIndexDataVO.setTodayBalance(todayUserBalance);
@ -1501,6 +1506,14 @@ public class OrderServiceImpl implements IOrderService
return indexChartDatas;
}
/**
* 查询需要到期提醒的订单
*/
@Override
public List<OrderVO> selectExpirationReminderOrderList() {
return orderMapper.selectExpirationReminderOrderList();
}
private void setDeviceOverview(Long merchantId, IndexAdminVo indexAdminVo) {
RoomQuery query = new RoomQuery();

View File

@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar,u.user_type,u.channel_ids,u.merchant_id,u.dividend_proportion,u.app_menus,
u.phonenumber, u.password, u.sex, u.status,u.service_fee_proportion,u.clean_duration, u.clean_notice,u.ago_cancel,u.penalty, u.before_time,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid,u.is_authentication,u.store_id,u.device_admin,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.balance,multi_store
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.balance,u.multi_store,u.reminder
from ss_user u
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar,u.user_type,u.channel_ids,u.merchant_id,u.dividend_proportion,u.app_menus,
u.phonenumber, u.password, u.sex, u.status, u.service_fee_proportion,u.clean_duration, u.clean_notice,u.ago_cancel,u.penalty, u.before_time,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid,u.is_authentication,u.store_id,u.device_admin,
u.balance,u.multi_store
u.balance,u.multi_store,u.reminder
from ss_user u
</sql>
<sql id="searchCondition">
@ -100,6 +100,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
u.create_time,
u.remark,
u.is_authentication,
u.multi_store,
u.reminder,
u.balance,
u.wxopenid from ss_user u
left join ss_store s on u.store_id = s.store_id
@ -200,7 +202,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
u.is_authentication,
u.channel_ids,
u.dividend_proportion,
u.multi_store
u.multi_store,
u.reminder
from ss_user u
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
@ -355,6 +358,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="appMenus != null">app_menus,</if>
<if test="merchantId != null">merchant_id,</if>
<if test="storeId != null">store_id,</if>
<if test="reminder != null">reminder,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
@ -381,6 +385,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="appMenus != null">#{appMenus,typeHandler=com.ruoyi.system.mapper.typehandler.LongSplitListTypeHandler},</if>
<if test="merchantId != null">#{merchantId},</if>
<if test="storeId != null">#{storeId},</if>
<if test="reminder != null">#{reminder},</if>
sysdate()
)
</insert>
@ -418,6 +423,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="beforeTime != null">before_time = #{beforeTime},</if>
<if test="storeId != null">store_id = #{storeId},</if>
<if test="multiStore != null">multi_store = #{multiStore},</if>
<if test="reminder != null">reminder = #{reminder},</if>
update_time = sysdate()
</set>
where user_id = #{userId}

View File

@ -23,9 +23,11 @@ import com.ruoyi.ss.payBill.service.PayBillService;
import com.ruoyi.ss.refund.domain.RefundDTO;
import com.ruoyi.ss.refund.service.IRefundService;
import com.ruoyi.ss.room.domain.Room;
import com.ruoyi.ss.room.domain.RoomVO;
import com.ruoyi.ss.room.service.IRoomService;
import com.ruoyi.ss.user.domain.UserVO;
import com.ruoyi.ss.user.service.IUserService;
import com.ruoyi.system.iot.service.IotService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -35,6 +37,7 @@ import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@ -82,6 +85,9 @@ public class SsTask {
@Autowired
private IRefundService refundService;
@Autowired
private IotService iotService;
/**
@ -138,7 +144,7 @@ public class SsTask {
updateRoomStatus(orderVO,ServiceConstants.ROOM_STATUS_INUSE);
// 发送一次房间的全开 用time 门打开 其他的用settime
smDeviceService.roomAllDeviceSetTime(orderVO, "下单成功后房间全开");
smDeviceService.roomAllDeviceSetTime(orderVO, "(到预约时间后)下单成功后房间全开");
return Boolean.TRUE;
});
}
@ -232,6 +238,43 @@ public class SsTask {
log.info("-------------------【定时任务】押金自动退还处理---结束----------------");
}
/**
* 到期提醒
*/
public void expirationReminder(){
log.info("-------------------【定时任务】到期提醒---开始----------------");
List<OrderVO> orderVOS = orderService.selectExpirationReminderOrderList();
if(orderVOS.isEmpty()){
return;
}
for (OrderVO order : orderVOS) {
Boolean execute = transactionTemplate.execute(e -> {
int i = DateUtils.timeDifferenceInMinutes(DateUtils.getNowDate(), order.getReminderTime());
if(i<=5){
// 发送提醒命令
log.info("【到期提醒】发送提醒命令");
// 发送一次房间的全开 用time 门打开 其他的用settime
UserVO userVO = userService.selectUserById(order.getMerchantId());
Integer reminder = userVO.getReminder();
long reminderSeconds = 5 * 60L;
if(reminder != null){
reminderSeconds = reminder * 60L;
}
log.info("【到期提醒】,开始发送命令:{}秒之后后关闭", reminderSeconds);
smDeviceService.roomAllDeviceSerVoice(order, reminderSeconds);
// 更新订单
Order updateOrder = new Order();
updateOrder.setOrderNo(order.getOrderNo());
updateOrder.setIsReminded(true);
int i1 = orderService.updateRlOrderByOrderNo(updateOrder);
log.info("【到期提醒】更新订单状态{}", i1==0? "失败" : "成功");
}
return Boolean.TRUE;
});
}
log.info("-------------------【定时任务】到期提醒---结束----------------");
}
private void updateRoomStatus(OrderVO orderVO,String status) {