订单短信发送

This commit is contained in:
syruan 2025-02-25 13:54:46 +08:00
parent 249cc4553c
commit 94c04684dc
3 changed files with 27 additions and 7 deletions

View File

@ -19,8 +19,8 @@ public class ToDoServiceImpl implements ToDoService {
@Resource
private ToDoMapper toDoMapper;
@Resource
private RemoteUserService remoteUserService;
// @Resource
// private RemoteUserService remoteUserService;
@Override
public List<ToDoBean> getToDoList(ToDoBean bean) {

View File

@ -89,15 +89,20 @@ public class OrderServiceImpl implements OrderService {
if (orderDetailDtos.isEmpty()) {
throw new RuntimeException("请正确添加设备");
}
//生成订单信息
String code = "D" + System.currentTimeMillis();
orderInfoDto.setCode(code);
DevInfo maInfo;
for (OrderDetailDto orderDetailDto : orderDetailDtos) {
// 先判断要租赁的设备状态是否正常
DevInfo maInfo = devInfoMapper.getMaStatusByMaId(Long.valueOf(orderDetailDto.getMaId()));
maInfo = devInfoMapper.getMaStatusByMaId(Long.valueOf(orderDetailDto.getMaId()));
if (maInfo == null || maInfo.getMaStatus() == null) {
throw new RuntimeException("设备信息异常");
}
if (!maInfo.getMaStatus().equals(MaStatusEnum.LISTING.getCode())) {
throw new RuntimeException("设备非上架状态,无法下单!");
}
String devPersonPhone = maInfo.getPersonPhone();
//如果是编码设备改设备状态为在租
orderDetailDto.setMaStatus(MaStatusEnum.UNDER_RENT.getCode().toString());
@ -107,10 +112,20 @@ public class OrderServiceImpl implements OrderService {
}
// 更改购物车状态为已下单
orderMapper.updateMaStatus(orderDetailDto);
if (devPersonPhone != null) {
if (devPersonPhone.length() == 11) {
String sendResult = SmsUtils.smsToken(devPersonPhone, "订单编号:" + code + "已下单,请尽快处理。", "");
System.out.println("短信发送结果:" + sendResult);
} else if (devPersonPhone.length() > 11) {
SmsUtils.smsToken(Sm4Utils.decrypt(devPersonPhone), "订单编号:" + code + "已下单,请尽快处理。", "");
} else {
System.err.println("-----------用户绑定手机号,格式异常!!!---------------");
}
//生成订单信息
String code = "D" + System.currentTimeMillis();
orderInfoDto.setCode(code);
} else {
System.err.println("-----------设备联系人手机号为空!!!---------------");
}
}
Long userid = SecurityUtils.getLoginUser().getUserid();
orderInfoDto.setBuyerId(userid.intValue());
orderInfoDto.setBuyerCompany(SecurityUtils.getLoginUser().getSysUser().getCompanyId().intValue());

View File

@ -693,7 +693,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="getMaStatusByMaId" resultType="com.bonus.material.device.domain.DevInfo">
select ma_status,device_count from ma_dev_info where ma_id = #{maId}
select
mdi.ma_status,mdi.device_count,mdi.person_phone
from
ma_dev_info mdi
where
mdi.ma_id = #{maId}
</select>
<select id="selectCompany" resultType="java.lang.Integer">