debug 蓝牙充值
This commit is contained in:
parent
6dcb9f123e
commit
8a1ad7c929
|
@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
|
@ -271,7 +272,9 @@ public class SmDeviceServiceImpl implements ISmDeviceService
|
|||
ServiceUtil.assertion(!StringUtils.hasText(device.getMac()), "设备MAC号为空");
|
||||
ServiceUtil.assertion(DeviceStatus.FIXING.getStatus().equals(device.getStatus()), "设备正在维修中,无法使用");
|
||||
|
||||
Boolean result = transactionTemplate.execute(status -> {
|
||||
// 开启一个新的事务
|
||||
TransactionTemplate newTransaction = new TransactionTemplate();
|
||||
Boolean result = newTransaction.execute(status -> {
|
||||
// 更新数据库时长
|
||||
int updateCount = smDeviceMapper.addTime(deviceId, num);
|
||||
ServiceUtil.assertion(updateCount != 1, "增加时长失败,请刷新后重试");
|
||||
|
@ -317,19 +320,18 @@ public class SmDeviceServiceImpl implements ISmDeviceService
|
|||
return;
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Duration between = Duration.between(now, device.getExpireTime());
|
||||
|
||||
// 如果已过期,则调整设备为正常状态
|
||||
if (device.getExpireTime().isBefore(now) || device.getExpireTime().isEqual(now)) {
|
||||
int i = smDeviceMapper.changeTimeoutStatus(device.getDeviceId());
|
||||
if (i == 1) {
|
||||
return;
|
||||
}
|
||||
int i = smDeviceMapper.changeTimeoutStatus(device.getDeviceId());
|
||||
if (i == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果没有过期,则延迟至过期时间继续查询
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
freshStatus(device.getDeviceId());
|
||||
}, device.getExpireTime().until(LocalDateTime.now(), ChronoUnit.MINUTES), TimeUnit.MINUTES);
|
||||
}, between.getSeconds() , TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private int changeStatus(Long deviceId, DeviceStatus status) {
|
||||
|
|
|
@ -157,4 +157,8 @@ public class TransactionBill extends BaseEntity
|
|||
@JsonView(JsonViewProfile.App.class)
|
||||
private String suitName;
|
||||
|
||||
@ApiModelProperty("设备MAC")
|
||||
@JsonView(JsonViewProfile.App.class)
|
||||
private String deviceMac;
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
stb.device_name,
|
||||
stb.device_no,
|
||||
stb.suit_name,
|
||||
stb.device_mac,
|
||||
su.user_name user_name,
|
||||
su1.user_name mch_name
|
||||
from sm_transaction_bill stb
|
||||
|
@ -70,6 +71,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deviceRechargeStatus != null"> and stb.device_recharge_status = #{deviceRechargeStatus} </if>
|
||||
<if test="suitId != null"> and stb.suit_id = #{suitId} </if>
|
||||
<if test="storeId != null"> and stb.store_id = #{storeId} </if>
|
||||
<if test="billIds != null and billIds.size() > 0">
|
||||
and stb.bill_id in
|
||||
<foreach item="item" collection="billIds" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="deviceRechargeStatusList != null and deviceRechargeStatusList.size() > 0">
|
||||
and stb.device_recharge_status in
|
||||
<foreach item="item" collection="deviceRechargeStatusList" open="(" separator="," close=")">
|
||||
|
@ -206,6 +213,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deviceName != null ">device_name,</if>
|
||||
<if test="deviceNo != null ">device_no,</if>
|
||||
<if test="suitName != null ">suit_name,</if>
|
||||
<if test="deviceMac != null ">device_mac,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="billNo != null">#{billNo},</if>
|
||||
|
@ -239,6 +247,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deviceName != null ">#{deviceName},</if>
|
||||
<if test="deviceNo != null ">#{deviceNo},</if>
|
||||
<if test="suitName != null ">#{suitName},</if>
|
||||
<if test="deviceMac != null ">#{deviceMac},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -274,6 +283,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deviceName != null ">device_name = #{deviceName},</if>
|
||||
<if test="deviceNo != null ">device_no = #{deviceNo},</if>
|
||||
<if test="suitName != null ">suit_name = #{suitName},</if>
|
||||
<if test="deviceMac != null ">device_mac = #{deviceMac},</if>
|
||||
</trim>
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
@ -371,6 +381,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="bluetoothRechargeSuccess">
|
||||
update sm_transaction_bill
|
||||
set device_recharge_status = '1'
|
||||
where bill_no = #{billNo} and type = '1' and device_recharge_status = '3'
|
||||
where bill_no = #{billNo} and type = '1' and device_recharge_status = '3' and status = '2'
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
@ -103,6 +104,8 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
|
||||
@Value("${sm.withdraw.password.enable}")
|
||||
private Boolean smWithdrawPasswordEnable; // 是否开启提现密码
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
/**
|
||||
* 查询充值记录
|
||||
|
@ -225,6 +228,7 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
order.setDeviceId(device.getDeviceId());
|
||||
order.setMchId(device.getUserId()); // 到账人ID
|
||||
order.setDeviceName(device.getDeviceName());
|
||||
order.setDeviceMac(device.getMac());
|
||||
|
||||
// 店铺信息
|
||||
order.setStoreId(device.getStoreId());
|
||||
|
@ -796,6 +800,15 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
*/
|
||||
@Override
|
||||
public boolean bluetoothRechargeSuccess(String billNo) {
|
||||
return transactionBillMapper.bluetoothRechargeSuccess(billNo) == 1;
|
||||
Boolean execute = transactionTemplate.execute(status -> {
|
||||
TransactionBill bill = selectSmTransactionBillByBillNo(billNo);
|
||||
ServiceUtil.assertion(bill == null, "订单不存在", 10001);
|
||||
ServiceUtil.assertion(!TransactionBillType.RECHARGE.getType().equals(bill.getType()), "该订单不是充值订单", 10002);
|
||||
ServiceUtil.assertion(TransactionBillDeviceRechargeStatus.SUCCESS.getStatus().equals(bill.getDeviceRechargeStatus()), "设备已充值成功,请勿重复充值", 10003);
|
||||
ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(bill.getStatus()), "订单尚未充值成功", 10004);
|
||||
return transactionBillMapper.bluetoothRechargeSuccess(billNo) == 1;
|
||||
});
|
||||
|
||||
return execute != null && execute;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ public class DeviceTask {
|
|||
private ISmMeterReadingRecordService smMeterReadingRecordService;
|
||||
|
||||
// 定时拉取设备信息
|
||||
public void pullDeviceInfo() throws InterruptedException {
|
||||
smDeviceService.pullDeviceInfo(null);
|
||||
Thread.sleep(3000); // 睡眠3秒,防止quartz重复调度
|
||||
}
|
||||
// public void pullDeviceInfo() throws InterruptedException {
|
||||
// smDeviceService.pullDeviceInfo(null);
|
||||
// Thread.sleep(3000); // 睡眠3秒,防止quartz重复调度
|
||||
// }
|
||||
|
||||
// 定时抄表
|
||||
public void recordElectriQuantity() throws InterruptedException {
|
||||
|
|
Loading…
Reference in New Issue
Block a user