新增“更新”接口
This commit is contained in:
parent
27fb3bdba1
commit
473bbdf809
|
@ -27,7 +27,7 @@ public enum ChannelApiType {
|
|||
WECHAT("WX", "微信支付",WxPayService.class, false, true),
|
||||
ALI("ALI", "支付宝", AliPayService.class, true, true),
|
||||
BANK("BANK", "银行卡", null, false, true),
|
||||
BALANCE("BALANCE", "余额支付", null, true, true),
|
||||
BALANCE("BALANCE", "余额支付", null, true, false),
|
||||
TM_WX("TM_WX", "太米微信支付", TmPayService.class, true, true),
|
||||
CREDIT("CREDIT", "挂账", CreditPayServiceImpl.class, true, false);
|
||||
|
||||
|
@ -35,7 +35,7 @@ public enum ChannelApiType {
|
|||
private final String name;
|
||||
private final Class<? extends PayApi> payApi;
|
||||
private final Boolean isRefundSync; // 退款是否同步通知
|
||||
private final Boolean needPay; // 是否需要前端调起支付
|
||||
private final Boolean needPay; // 是否需要前端调起支付,也可作为刷新支付结果是否为异步的凭据
|
||||
|
||||
public static ChannelApiType parse(String type) {
|
||||
for (ChannelApiType value : ChannelApiType.values()) {
|
||||
|
|
|
@ -182,4 +182,14 @@ public interface DeviceIotService {
|
|||
*/
|
||||
Map<String, Object> getIotInfo(String mac);
|
||||
|
||||
/**
|
||||
* 升级设备
|
||||
*
|
||||
* @param device 设备
|
||||
* @param reason 原因
|
||||
* @param requiredIot 是否IOT操作必须成功
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(DeviceVO device, String reason, boolean requiredIot);
|
||||
|
||||
}
|
||||
|
|
|
@ -449,4 +449,16 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
return redisCache.getCacheMap(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean update(DeviceVO device, String reason, boolean requiredIot) {
|
||||
if (device == null) {
|
||||
return false;
|
||||
}
|
||||
CommandResponse res = iotService.update(device, reason);
|
||||
boolean success = IotUtil.isSuccess(res);
|
||||
ServiceUtil.assertion(requiredIot && !success, IotUtil.getMsg(res), ServiceCode.IOT_FAILED);
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -344,10 +344,6 @@ public class PayServiceImpl implements PayService {
|
|||
// 若支付金额为0,则不调起支付
|
||||
if (pay.getAmount().compareTo(BigDecimal.ZERO) == 0) {
|
||||
vo.setNeedPay(false);
|
||||
// 异步处理支付成功
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
this.handleSuccess(pay.getNo(), LocalDateTime.now());
|
||||
}, 1L, TimeUnit.SECONDS);
|
||||
} else {
|
||||
// 获取渠道信息
|
||||
ChannelVO channel = channelService.selectChannelByChannelId(pay.getChannelId());
|
||||
|
@ -376,9 +372,19 @@ public class PayServiceImpl implements PayService {
|
|||
log.error("更新渠道订单号失败,支付单ID为{}", pay.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 根据是否需要前端调起支付来判断
|
||||
if (vo.getNeedPay()) {
|
||||
// 异步刷新支付结果
|
||||
scheduledExecutorService.execute( ()-> {
|
||||
scheduledExecutorService.schedule( ()-> {
|
||||
log.info("异步刷新支付结果:pay.getNo() = {}", pay.getNo());
|
||||
this.refreshPayResultBeforeExpire(pay.getNo());
|
||||
}, 10, TimeUnit.SECONDS);
|
||||
} else {
|
||||
// 异步处理支付成功
|
||||
scheduledExecutorService.execute(() -> {
|
||||
this.handleSuccess(pay.getNo(), LocalDateTime.now());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -394,6 +400,7 @@ public class PayServiceImpl implements PayService {
|
|||
this.refreshPayResult(no);
|
||||
// 获取刷新后的订单
|
||||
PayVO pay = this.selectByNo(no);
|
||||
log.info("异步刷新支付结果:pay = {}", pay);
|
||||
if (pay == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -427,6 +434,7 @@ public class PayServiceImpl implements PayService {
|
|||
}
|
||||
|
||||
PayVO pay = this.selectByNo(no);
|
||||
log.info("刷新支付结果 pay = {}", pay);
|
||||
if (pay == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -448,7 +456,6 @@ public class PayServiceImpl implements PayService {
|
|||
// 获取支付结果,若成功则处理支付成功
|
||||
Object result = this.queryPayInfo(payApi, pay, channel, app);
|
||||
boolean isPaySuccess = payApi.isPaySuccess(result);
|
||||
log.info("刷新支付结果:{}, {}, {}", pay.getNo(), isPaySuccess, result);
|
||||
if (isPaySuccess) {
|
||||
this.handleSuccess(pay, payApi.getPayTime(result));
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class IotConstants {
|
|||
public static final String COMMAND_PLAY = "play"; // 播放语音
|
||||
public static final String VOLTAGE_CHECK = "check"; // 电压校准
|
||||
public static final String COMMAND_REBOOT = "reboot"; // 重启设备
|
||||
public static final String COMMAND_UPDATE = "update"; // 升级设备
|
||||
|
||||
// 语音列表
|
||||
public static final String PLAY_WELCOME = "0";// 欢迎
|
||||
|
@ -64,5 +65,6 @@ public class IotConstants {
|
|||
public static final String DS_SYS_LON = "lon"; // 经度
|
||||
public static final String DS_SYS_LAT = "lat"; // 纬度
|
||||
public static final String DS_CSQ = "CSQ"; // 信号强度
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -122,4 +122,12 @@ public interface IotService {
|
|||
* @return 结果
|
||||
*/
|
||||
CommandResponse uploadData(IotDevice device, String reason);
|
||||
|
||||
/**
|
||||
* 升级设备
|
||||
* @param device 设备
|
||||
* @param reason 原因
|
||||
* @return 结果
|
||||
*/
|
||||
CommandResponse update(IotDevice device, String reason);
|
||||
}
|
||||
|
|
|
@ -118,10 +118,10 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
}
|
||||
|
||||
// 处理设备定位BUG,若出现BUG则重启设备
|
||||
int handle = this.handleDeviceLocationBug(device, at, lastLocationTime, oldLon, oldLat);
|
||||
if (handle == 1) {
|
||||
return;
|
||||
}
|
||||
// int handle = this.handleDeviceLocationBug(device, at, lastLocationTime, oldLon, oldLat);
|
||||
// if (handle == 1) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 处理运营区
|
||||
this.handleArea(device);
|
||||
|
|
|
@ -383,6 +383,11 @@ public class IotServiceImpl implements IotService {
|
|||
return sendCommand(device, IotConstants.COMMAND_PLAY + type, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResponse update(IotDevice device, String reason) {
|
||||
return sendCommand(device, IotConstants.COMMAND_UPDATE, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResponse reboot(IotDevice device, String reason) {
|
||||
return sendCommand(device, IotConstants.COMMAND_REBOOT, reason);
|
||||
|
|
|
@ -134,4 +134,12 @@ public class DeviceIotController extends BaseController {
|
|||
DeviceVO device = this.getDevice(id, sn);
|
||||
return executeWithLock(device, () -> success(deviceIotService.setMusic(device, music, "管理员设置声音", true)));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('bst:device:update')")
|
||||
@Log(title = "管理员升级设备", businessType = BusinessType.OTHER, bizIdName = "arg0", bizType = LogBizType.DEVICE)
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(@RequestParam(required = false) Long id, @RequestParam(required = false) String sn) {
|
||||
DeviceVO device = this.getDevice(id, sn);
|
||||
return executeWithLock(device, () -> success(deviceIotService.update(device, "管理员升级设备", true)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user