Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c067a48980
10 files changed
+87
-166
No files matched your search
+10
-10
@@ -111,31 +111,31 @@ CREATE TABLE hard_door_flow
|
||||
order_id bigint DEFAULT NULL COMMENT '订单编号',
|
||||
auth_id bigint DEFAULT NULL COMMENT '授权编号',
|
||||
# 请求开门
|
||||
request_open_dto varchar(512) DEFAULT NULL COMMENT '请求开门参数',
|
||||
request_open_vo varchar(512) DEFAULT NULL COMMENT '请求开门返回',
|
||||
request_open_dto text DEFAULT NULL COMMENT '请求开门参数',
|
||||
request_open_vo text DEFAULT NULL COMMENT '请求开门返回',
|
||||
request_open_time datetime DEFAULT NULL COMMENT '请求开门时间',
|
||||
# 请求开门回调
|
||||
is_open varchar(32) DEFAULT NULL COMMENT '是否开门',
|
||||
open_callback_time datetime DEFAULT NULL COMMENT '开门回调时间',
|
||||
open_callback_vo varchar(512) DEFAULT NULL COMMENT '开门回调结果',
|
||||
open_callback_vo text DEFAULT NULL COMMENT '开门回调结果',
|
||||
# 视频回调
|
||||
video_callback_vo varchar(512) DEFAULT NULL COMMENT '视频回调结果',
|
||||
video_callback_vo text DEFAULT NULL COMMENT '视频回调结果',
|
||||
video_callback_time datetime DEFAULT NULL COMMENT '视频回调时间',
|
||||
# sku识别
|
||||
sku_submit_dto varchar(512) DEFAULT NULL COMMENT 'sku识别提交参数',
|
||||
sku_submit_vo varchar(512) DEFAULT NULL COMMENT 'sku识别提交结果',
|
||||
sku_submit_dto text DEFAULT NULL COMMENT 'sku识别提交参数',
|
||||
sku_submit_vo text DEFAULT NULL COMMENT 'sku识别提交结果',
|
||||
sku_submit_recog_id varchar(32) DEFAULT NULL COMMENT 'sku识别提交id(用于查询)',
|
||||
sku_submit_time datetime DEFAULT NULL COMMENT 'sku识别提交时间',
|
||||
# sku识别回调
|
||||
sku_callback_vo varchar(512) DEFAULT NULL COMMENT 'sku识别回调结果',
|
||||
sku_callback_vo text DEFAULT NULL COMMENT 'sku识别回调结果',
|
||||
sku_callback_time datetime DEFAULT NULL COMMENT 'sku识别回调时间',
|
||||
# sku主动获取
|
||||
sku_driving_dto varchar(512) DEFAULT NULL COMMENT 'sku识别主动获取参数',
|
||||
sku_driving_vo varchar(512) DEFAULT NULL COMMENT 'sku识别主动获取结果',
|
||||
sku_driving_dto text DEFAULT NULL COMMENT 'sku识别主动获取参数',
|
||||
sku_driving_vo text DEFAULT NULL COMMENT 'sku识别主动获取结果',
|
||||
sku_driving_time datetime DEFAULT NULL COMMENT 'sku识别主动获取时间',
|
||||
# 流程相关
|
||||
flow_status varchar(32) DEFAULT NULL COMMENT '流程状态',
|
||||
error varchar(512) DEFAULT NULL COMMENT '流程错误信息',
|
||||
error text DEFAULT NULL COMMENT '流程错误信息',
|
||||
error_desc varchar(64) DEFAULT NULL COMMENT '流程错误描述(展示)',
|
||||
# 购买成功
|
||||
pay_time datetime DEFAULT NULL COMMENT '购买成功时间',
|
||||
|
||||
+5
-3
@@ -106,7 +106,7 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
}
|
||||
HardBroadcastEntity saveObj = HardBroadcastEntity.builder()
|
||||
.userId(orderdetail.getUserId())
|
||||
.hardId(orderdetail.getHardId())
|
||||
.hardId(hardDetail.getId())
|
||||
.topic(hardDetail.getMainTopic())
|
||||
.bizType(HardBroadcastEnum.OFFLINE_CANTEEN_RESERVE.getType())
|
||||
.bizId(String.valueOf(orderdetail.getId()))
|
||||
@@ -118,12 +118,13 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
.isDone(YesNoEnum.NO.getCode())
|
||||
.build();
|
||||
baseMapper.insert(saveObj);
|
||||
String topic = saveObj.getTopic().replaceAll("/#", "");
|
||||
// 发送mq
|
||||
HardTakeFoodBroadcastMsg msg = new HardTakeFoodBroadcastMsg();
|
||||
msg.setTopic(saveObj.getTopic());
|
||||
msg.setTopic(topic);
|
||||
msg.setAction(MqttActionEnum.TAKE_FOOD_BROADCAST);
|
||||
msg.setUserId(String.valueOf(userInfo.getSysUser().getUserId()));
|
||||
msg.setUserName(userInfo.getSysUser().getName());
|
||||
msg.setUsername(userInfo.getSysUser().getName());
|
||||
msg.setUserMobile(userInfo.getSysUser().getPhone());
|
||||
msg.setId(String.valueOf(saveObj.getId()));
|
||||
msg.setTitle(saveObj.getTitle());
|
||||
@@ -131,6 +132,7 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
msg.setBroadcastMaxCount(saveObj.getBroadcastMaxCount());
|
||||
msg.setProductDesc(orderdetail.getProductDesc());
|
||||
msg.setPayPrice(orderdetail.getPayPrice());
|
||||
msg.setHourType(orderdetail.getHourType());
|
||||
remoteMqttEventService.sendTakeFoodBroadcast(msg);
|
||||
}
|
||||
|
||||
|
||||
+50
-138
@@ -29,7 +29,9 @@ import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardDoorFlowVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuJoinVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardAuthMapper;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import com.bsd.pjcloud.hard.mapper.HardDoorFlowMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
|
||||
import com.bsd.pjcloud.hard.service.*;
|
||||
@@ -72,7 +74,6 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
@Lazy
|
||||
private final HardAuthService hardAuthService;
|
||||
|
||||
private final HardAuthMapper hardAuthMapper;
|
||||
private final HardManagerMapper hardManagerMapper;
|
||||
|
||||
private final RemoterThirdDoorApiService thirdDoorApiService;
|
||||
@@ -127,10 +128,10 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
public Long openDoor(HardDoorFlowOpenDto dto, HardDoorManagerVo hardDoorVo) {
|
||||
HardDoorFlowEntity saveObj = HardDoorFlowEntity.builder().flowStatus(HardDoorFlowEnum.FLOW_AUTH.getType()).userId(dto.getUserId()).bizType(dto.getFlowType().getType()).isOpen(YesNoEnum.NO.getCode()).build();
|
||||
baseMapper.insert(saveObj);
|
||||
HardDoorManagerEntity hardDoorStatus = hardDoorManagerService.refresh(hardDoorVo.getDeviceCode());
|
||||
hardDoorManagerService.refresh(hardDoorVo.getDeviceCode());
|
||||
// 校验设备和货柜编号
|
||||
hardDoorStatus = hardDoorManagerService.checkDeviceAndCabinet(dto.getHardDoorId(), dto.getCabinetNo());
|
||||
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(saveObj.getId()).flowStatus(saveObj.getFlowStatus()).hardId(hardDoorStatus.getHardId()).hardDoorId(dto.getHardDoorId()).cabinetNo(dto.getCabinetNo()).build();
|
||||
HardDoorManagerEntity hardDoorStatus = hardDoorManagerService.checkDeviceAndCabinet(dto.getHardDoorId(), dto.getCabinetNo());
|
||||
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(saveObj.getId()).flowStatus(saveObj.getFlowStatus()).hardId(hardDoorStatus.getHardId()).hardDoorId(dto.getHardDoorId()).cabinetNo(dto.getCabinetNo()).flowStatus(HardDoorFlowEnum.FLOW_APPLY_OPEN.getType()).requestOpenTime(LocalDateTime.now()).build();
|
||||
// 请求开门
|
||||
DoorOpenDto openDto = BeanUtil.toBean(dto, DoorOpenDto.class);
|
||||
openDto.setDeviceCode(hardDoorVo.getDeviceCode());
|
||||
@@ -138,15 +139,16 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
openDto.setOutOpenNo(String.valueOf(saveObj.getId()));
|
||||
openDto.setEventType(Integer.valueOf(dto.getOpenType().getType()));
|
||||
DoorOpenVo openVo = thirdDoorApiService.open(openDto).getData();
|
||||
updateObj.setRequestOpenDto(JSONUtil.toJsonStr(openDto));
|
||||
updateObj.setRequestOpenVo(JSONUtil.toJsonStr(openVo));
|
||||
if (ObjectUtil.isEmpty(openVo) || !openVo.isSuccess()) {
|
||||
String errorMsg = "智能柜申请开门错误," + openVo.getMessage();
|
||||
flowStatusControl(updateObj, openDto, openVo, errorMsg);
|
||||
updateObj.setError(errorMsg);
|
||||
baseMapper.updateById(updateObj);
|
||||
throw new RuntimeException(errorMsg);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto.getAuthId())) {
|
||||
updateObj.setAuthId(dto.getAuthId());
|
||||
}
|
||||
flowStatusControl(updateObj, openDto, openVo, null);
|
||||
if (ObjectUtil.isNotEmpty(dto.getAuthId())) updateObj.setAuthId(dto.getAuthId());
|
||||
baseMapper.updateById(updateObj);
|
||||
return updateObj.getId();
|
||||
}
|
||||
|
||||
@@ -200,6 +202,14 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
if (!userCredit) {
|
||||
throw new RuntimeException("用户信誉不足,请联系管理员");
|
||||
}
|
||||
// 查看当前用户是否有正在进行购买的动作
|
||||
Long isHaveFlowCount = baseMapper.selectCount(new LambdaQueryWrapper<HardDoorFlowEntity>()
|
||||
.eq(HardDoorFlowEntity::getUserId, dto.getUserId())
|
||||
.eq(HardDoorFlowEntity::getIsOpen, YesNoEnum.NO.getCode())
|
||||
.eq(HardDoorFlowEntity::getBizType, HardDoorFlowBizEnum.PAY_OPEN.getType())
|
||||
.between(HardDoorFlowEntity::getCreateTime, LocalDateTime.now().minus(1, ChronoUnit.HOURS), LocalDateTime.now())
|
||||
);
|
||||
if (isHaveFlowCount > 0) throw new RuntimeException("正在购买中请勿重复操作,请稍后再试");
|
||||
// 查询货柜是否配置spu信息
|
||||
List<HardSpuJoinVo> spuList = hardSpuJoinService.getSpuList(hardDoorDetail.getId(), dto.getCabinetNo());
|
||||
if (ObjectUtil.isEmpty(spuList) || spuList.isEmpty()) throw new RuntimeException("货柜商品信息为空,请上架");
|
||||
@@ -221,25 +231,19 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
*/
|
||||
@Override
|
||||
public void disposeLocakCallback(DoorOpenCallbackDto dto) {
|
||||
if (ObjectUtil.isEmpty(dto) || ObjectUtil.isEmpty(dto.getType()) || ObjectUtil.equals(dto.getResultCode(), "FAIL")) {
|
||||
log.info("|{}|disposeLocakCallback 意外的错误,参数错误dto|{}|", TAG, JSONUtil.toJsonStr(dto));
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(dto.getType()) || ObjectUtil.equals(dto.getResultCode(), "FAIL")) return;
|
||||
// 查询流程
|
||||
HardDoorFlowEntity flowDetail = baseMapper.selectById(dto.getOutOpenNo());
|
||||
if (ObjectUtil.isEmpty(flowDetail) || ObjectUtil.isNotEmpty(flowDetail.getOpenCallbackTime())) {
|
||||
log.info("|{}|disposeLocakCallback 意外的错误,流程不存在或者重复dto|{}|", TAG, JSONUtil.toJsonStr(dto));
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(flowDetail) || ObjectUtil.isNotEmpty(flowDetail.getOpenCallbackTime())) return;
|
||||
boolean isOpenDoor = ObjectUtil.equals(dto.getType(), "OPEN");
|
||||
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).flowStatus(flowDetail.getFlowStatus()).isOpen(isOpenDoor ? YesNoEnum.YES.getCode() : YesNoEnum.NO.getCode()).build();
|
||||
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).isOpen(isOpenDoor ? YesNoEnum.YES.getCode() : YesNoEnum.NO.getCode()).flowStatus(HardDoorFlowEnum.FLOW_CALLBACK_OPEN.getType()).openCallbackVo(JSONUtil.toJsonStr(dto)).openCallbackTime(LocalDateTime.now()).build();
|
||||
// 如果是购买的话
|
||||
if (ObjectUtil.equals(flowDetail.getBizType(), HardDoorFlowBizEnum.PAY_OPEN.getType())) {
|
||||
// 创建订单
|
||||
Long orderId = hardOrderService.createHardDoorOrder(flowDetail.getUserId(), flowDetail.getHardId());
|
||||
updateObj.setOrderId(orderId);
|
||||
}
|
||||
getSelf().flowStatusControl(updateObj, null, dto, null);
|
||||
baseMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,6 +282,9 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
log.info("|{}|disposeVideoCallback 意外的错误,流程不存在或重复dto|{}|", TAG, JSONUtil.toJsonStr(dto));
|
||||
return;
|
||||
}
|
||||
// 更新视频回调流程
|
||||
HardDoorFlowEntity callbackUpdateObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).flowStatus(HardDoorFlowEnum.FLOW_CALLBACK_VIDEO.getType()).videoCallbackVo(JSONUtil.toJsonStr(dto)).videoCallbackTime(LocalDateTime.now()).build();
|
||||
baseMapper.updateById(callbackUpdateObj);
|
||||
// 提交视频
|
||||
List<String> videoList = dto.getVideoList().stream().map(DoorVideoCallbackDto.Video::getVideoUrl).toList();
|
||||
// 提交柜子商品信息
|
||||
@@ -293,8 +300,6 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
}
|
||||
ksMap.put("origin_time", System.currentTimeMillis());
|
||||
ksMap.put("sku_scope", ksSpuMap);
|
||||
// 更新流程
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, null);
|
||||
// 提交识别
|
||||
KsRecognitionDto ksRecognitionDto = new KsRecognitionDto();
|
||||
ksRecognitionDto.setRecog_id(String.valueOf(flowDetail.getId()));
|
||||
@@ -305,16 +310,19 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
// third服务生成
|
||||
ksRecognitionDto.setNotify_url("");
|
||||
ksRecognitionDto.setSub_mch_id(String.valueOf(flowDetail.getOrderId()));
|
||||
// 更新sku提交流程
|
||||
HardDoorFlowEntity submitUploadObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).flowStatus(HardDoorFlowEnum.FLOW_SUBMIT_RECOGNITION.getType()).skuSubmitTime(LocalDateTime.now()).build();
|
||||
KsRecognitionVo ksRecognitionVo = thirdKsService.recognition(ksRecognitionDto).getData();
|
||||
if (ObjectUtil.isEmpty(ksRecognitionVo) || !ksRecognitionVo.isSuccess()) {
|
||||
submitUploadObj.setSkuSubmitDto(JSONUtil.toJsonStr(ksRecognitionDto));
|
||||
submitUploadObj.setSkuSubmitVo(JSONUtil.toJsonStr(ksRecognitionVo));
|
||||
submitUploadObj.setSkuSubmitRecogId(ksRecognitionVo.getKs_recog_id());
|
||||
if (ObjectUtil.isEmpty(ksRecognitionVo) || !ksRecognitionVo.isSuccess() || ObjectUtil.isEmpty(ksRecognitionVo.getKs_recog_id())) {
|
||||
String errorMsg = String.format("|%s|disposeVideoCallback 提交识别错误dto|%s|vo|%s|", TAG, JSONUtil.toJsonStr(ksRecognitionDto), JSONUtil.toJsonStr(ksRecognitionVo));
|
||||
log.error(errorMsg);
|
||||
getSelf().flowStatusControl(flowDetail, ksRecognitionDto, ksRecognitionVo, errorMsg);
|
||||
return;
|
||||
submitUploadObj.setErrorDesc(errorMsg);
|
||||
}
|
||||
// 更新流程
|
||||
flowDetail.setSkuSubmitRecogId(ksRecognitionVo.getKs_recog_id());
|
||||
getSelf().flowStatusControl(flowDetail, ksRecognitionDto, ksRecognitionVo, null);
|
||||
baseMapper.updateById(submitUploadObj);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,23 +341,25 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
return;
|
||||
}
|
||||
// 查询授权流程
|
||||
HardAuthEntity authDetail = hardAuthMapper.selectById(flowDetail.getAuthId());
|
||||
HardAuthEntity authDetail = hardAuthService.getById(flowDetail.getAuthId());
|
||||
if (ObjectUtil.isEmpty(authDetail)) {
|
||||
log.error("|{}|disposeRecognitionCallback 意外的错误,授权流程不存在dto|{}|", TAG, JSONUtil.toJsonStr(dto));
|
||||
return;
|
||||
}
|
||||
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).flowStatus(HardDoorFlowEnum.FLOW_CALLBACK_RECOGNITION.getType()).skuCallbackVo(JSONUtil.toJsonStr(dto)).skuCallbackTime(LocalDateTime.now()).build();
|
||||
String ksFlowCode = dto.getState().getCode();
|
||||
String ksRecognitionCode = dto.getResult().getStatus().getCode();
|
||||
if (ObjectUtil.notEqual(ksFlowCode, "2") || ObjectUtil.notEqual(ksRecognitionCode, "2")) {
|
||||
if (ObjectUtil.equals(ksFlowCode, "2") && ObjectUtil.equals(ksRecognitionCode, "3")) {
|
||||
// 未拿商品取消订单
|
||||
hardOrderService.cancelHardDoorOrder(flowDetail.getOrderId());
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, "");
|
||||
baseMapper.updateById(updateObj);
|
||||
return;
|
||||
}
|
||||
String ksErrorMsg = String.format("商品识别响应错误:ksFlowCode:%s;ksRecognitionCode:%s;", ksFlowCode, ksRecognitionCode);
|
||||
log.error(ksErrorMsg);
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, ksErrorMsg);
|
||||
updateObj.setError(ksErrorMsg);
|
||||
baseMapper.updateById(updateObj);
|
||||
return;
|
||||
}
|
||||
KsRecognitionCallbackDto.Result result = dto.getResult();
|
||||
@@ -357,135 +367,37 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
if (ObjectUtil.isEmpty(resultSkuList)) {
|
||||
String ksErrorMsg = "商品识别响应错误,识别的商品列表为空";
|
||||
log.error(ksErrorMsg);
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, ksErrorMsg);
|
||||
updateObj.setError(ksErrorMsg);
|
||||
baseMapper.updateById(updateObj);
|
||||
return;
|
||||
}
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, null);
|
||||
// 查询订单
|
||||
HardOrderEntity orderDetail = hardOrderService.getById(flowDetail.getOrderId());
|
||||
if (ObjectUtil.isEmpty(orderDetail)) {
|
||||
String ksErrorMsg = String.format("订单结算错误,订单不存在orderId%s", flowDetail.getOrderId());
|
||||
log.error(ksErrorMsg);
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, ksErrorMsg);
|
||||
updateObj.setError(ksErrorMsg);
|
||||
baseMapper.updateById(updateObj);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getSelf().flowStatusControl(flowDetail, null, null, null);
|
||||
Long orderId = hardOrderService.payHardDoorOrder(orderDetail, resultSkuList);
|
||||
if (ObjectUtil.isNotEmpty(orderId)) {
|
||||
flowDetail.setFlowStatus(HardDoorFlowEnum.FLOW_CALLBACK_RECOGNITION.getType());
|
||||
getSelf().flowStatusControl(flowDetail, null, null, null);
|
||||
updateObj.setPayTime(LocalDateTime.now());
|
||||
updateObj.setFlowStatus(HardDoorFlowEnum.FLOW_PAY_ORDER.getType());
|
||||
baseMapper.updateById(updateObj);
|
||||
}
|
||||
// 完成授权流程
|
||||
HardAuthEntity updateAuthObj = HardAuthEntity.builder().id(authDetail.getId()).isDone(YesNoEnum.YES.getCode()).isDoneTime(LocalDateTime.now()).build();
|
||||
hardAuthMapper.updateById(updateAuthObj);
|
||||
hardAuthService.updateById(updateAuthObj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String ksErrorMsg = String.format("订单结算错误,订单支付失败error%s;", e.getMessage());
|
||||
log.error(ksErrorMsg);
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, ksErrorMsg);
|
||||
updateObj.setError(ksErrorMsg);
|
||||
baseMapper.updateById(updateObj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程状态控制(发起流程需要手动)
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void flowStatusControl(HardDoorFlowEntity flow, Object dto, Object vo, String error) {
|
||||
if (!ObjectUtil.isAllNotEmpty(flow.getId(), flow.getFlowStatus())) {
|
||||
log.error("|{}|flowStatusControl 意外的错误,流程id或者flowstatus为空", TAG);
|
||||
return;
|
||||
}
|
||||
HardDoorFlowEnum flowStatus = HardDoorFlowEnum.valueOfByType(flow.getFlowStatus());
|
||||
HardDoorFlowEnum nextType = HardDoorFlowEnum.getNextType(flowStatus);
|
||||
if (ObjectUtil.isEmpty(nextType)) {
|
||||
log.error("|{}|flowStatusControl 意外的错误,流程状态控制错误该流程已结束", TAG);
|
||||
return;
|
||||
}
|
||||
HardDoorFlowEntity updateObj = new HardDoorFlowEntity();
|
||||
updateObj.setId(flow.getId());
|
||||
updateObj.setError(error);
|
||||
updateObj.setFlowStatus(nextType.getType());
|
||||
switch (nextType) {
|
||||
// 智能柜申请开门
|
||||
case FLOW_APPLY_OPEN -> {
|
||||
updateObj.setRequestOpenDto(JSONUtil.toJsonStr(dto));
|
||||
updateObj.setRequestOpenVo(JSONUtil.toJsonStr(vo));
|
||||
updateObj.setRequestOpenTime(LocalDateTime.now());
|
||||
if (ObjectUtil.isNotEmpty(flow.getAuthId())) {
|
||||
updateObj.setAuthId(flow.getAuthId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(flow.getHardId())) {
|
||||
updateObj.setHardId(flow.getHardId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(flow.getHardDoorId())) {
|
||||
updateObj.setHardDoorId(flow.getHardDoorId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(flow.getCabinetNo())) {
|
||||
updateObj.setCabinetNo(flow.getCabinetNo());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(error)) {
|
||||
updateObj.setErrorDesc("智能柜申请开门错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 智能柜开门响应
|
||||
case FLOW_CALLBACK_OPEN -> {
|
||||
updateObj.setOpenCallbackVo(JSONUtil.toJsonStr(vo));
|
||||
updateObj.setOpenCallbackTime(LocalDateTime.now());
|
||||
if (ObjectUtil.isNotEmpty(flow.getIsOpen())) {
|
||||
updateObj.setIsOpen(flow.getIsOpen());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(flow.getOrderId())) {
|
||||
updateObj.setOrderId(flow.getOrderId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(error)) {
|
||||
updateObj.setErrorDesc("智能柜开门响应错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 智能柜视频回调
|
||||
case FLOW_CALLBACK_VIDEO -> {
|
||||
updateObj.setVideoCallbackVo(JSONUtil.toJsonStr(vo));
|
||||
updateObj.setVideoCallbackTime(LocalDateTime.now());
|
||||
if (ObjectUtil.isNotEmpty(error)) {
|
||||
updateObj.setErrorDesc("智能柜视频回调错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 商品提交识别提交
|
||||
case FLOW_SUBMIT_RECOGNITION -> {
|
||||
updateObj.setSkuSubmitDto(JSONUtil.toJsonStr(dto));
|
||||
updateObj.setSkuSubmitVo(JSONUtil.toJsonStr(vo));
|
||||
updateObj.setSkuSubmitTime(LocalDateTime.now());
|
||||
if (ObjectUtil.isNotEmpty(flow.getSkuSubmitRecogId())) {
|
||||
updateObj.setSkuSubmitRecogId(flow.getSkuSubmitRecogId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(error)) {
|
||||
updateObj.setErrorDesc("商品提交识别提交错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 商品识别响应
|
||||
case FLOW_CALLBACK_RECOGNITION -> {
|
||||
updateObj.setSkuCallbackVo(JSONUtil.toJsonStr(vo));
|
||||
updateObj.setSkuCallbackTime(LocalDateTime.now());
|
||||
if (ObjectUtil.isNotEmpty(error)) {
|
||||
updateObj.setErrorDesc("商品识别响应错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLOW_PAY_ORDER -> {
|
||||
updateObj.setPayTime(LocalDateTime.now());
|
||||
if (ObjectUtil.isNotEmpty(error)) {
|
||||
updateObj.setErrorDesc("商品识别响应错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private void disposeList(List<HardDoorFlowVo> list, HardDoorFlowDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 设备
|
||||
|
||||
+1
-1
@@ -97,7 +97,6 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||
.parentCarId(null)
|
||||
.sysType(null)
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.merchantId(null)
|
||||
.orderType(HardOrderTypeEnum.ZY.getType())
|
||||
.payType(HardPayTypeEnum.WALLET_CARD.getType())
|
||||
.orderSourceTypeId(null)
|
||||
@@ -108,6 +107,7 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||
.productDesc(subject)
|
||||
.walletId(wallet.getId())
|
||||
.build();
|
||||
log.info("|{}| 正元支付创建订单参数|{}", TAG, JSONUtil.toJsonStr(orderObj));
|
||||
boolean isCreateOrder = hardOrderService.save(orderObj);
|
||||
if (!isCreateOrder) throw new RuntimeException("创建订单失败");
|
||||
hardOrderService.fastReduceBalance(orderObj);
|
||||
|
||||
+4
-2
@@ -15,6 +15,7 @@ import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteOnlineCanteenSpuService;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
@@ -303,7 +304,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
|
||||
// 判断是否有重复的预约订单
|
||||
Long reserveCount = isHaveCanteenReserve(dto.getUserId());
|
||||
if (reserveCount > 0) throw new RuntimeException("您有" + reserveCount + "笔未核销的预约订单,请先核销");
|
||||
if (reserveCount > 100) throw new RuntimeException("您有" + reserveCount + "笔未核销的预约订单,请先核销");
|
||||
// 钱包
|
||||
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), dto.getWalletType()).getData();
|
||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
|
||||
@@ -831,9 +832,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
private Long isHaveCanteenReserve(Long userId) {
|
||||
return baseMapper.selectCount(new LambdaQueryWrapper<HardOrderEntity>()
|
||||
.eq(HardOrderEntity::getUserId, userId)
|
||||
.eq(HardOrderEntity::getMerchantType, MerchantTypeEnum.CANTEEN.getType())
|
||||
.eq(HardOrderEntity::getSysType, HardTypeEnum.CANTEEN.getType())
|
||||
.eq(HardOrderEntity::getOrderType, HardOrderTypeEnum.RESERVE.getType())
|
||||
.ne(HardOrderEntity::getOrderStatus, HardOrderStatusEnum.CANCEL.getType())
|
||||
.eq(HardOrderEntity::getOrderStatus, HardOrderStatusEnum.PAY.getType())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -19,7 +19,7 @@ public class HardTakeFoodBroadcastMsg extends MqttHardBaseMsg {
|
||||
/**
|
||||
* 预定用户名
|
||||
*/
|
||||
private String userName;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 预定用户手机号
|
||||
@@ -56,4 +56,9 @@ public class HardTakeFoodBroadcastMsg extends MqttHardBaseMsg {
|
||||
*/
|
||||
private Integer payPrice;
|
||||
|
||||
/**
|
||||
* 预定时间类型
|
||||
*/
|
||||
private String hourType;
|
||||
|
||||
}
|
||||
+2
-1
@@ -10,6 +10,7 @@ import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
@Validated
|
||||
@@ -96,7 +97,7 @@ public class MqttService {
|
||||
MqttMessage message = new MqttMessage();
|
||||
message.setQos(qos);
|
||||
message.setRetained(retained);
|
||||
message.setPayload(pushMessage.getBytes());
|
||||
message.setPayload(pushMessage.getBytes(StandardCharsets.UTF_8));
|
||||
MqttTopic mTopic = MqttService.getClient().getTopic(topic);
|
||||
MqttDeliveryToken token;
|
||||
try {
|
||||
|
||||
@@ -42,10 +42,6 @@
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-common-data</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId></artifactId>
|
||||
</dependency>
|
||||
<!--必备:pigx安全模块-->
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
|
||||
+8
-5
@@ -387,11 +387,14 @@ public class ThirdDoorApiServiceImpl implements ThirdDoorApiService {
|
||||
log.error("|{}|apiParseSign 接口解签错误headers为空dto|{}|headers|{}|", TAG, json, JSONUtil.toJsonStr(headers));
|
||||
return false;
|
||||
}
|
||||
String appid = headers.get("appId");
|
||||
String noncestr = headers.get("nonceStr");
|
||||
String timestamp = headers.get("timestamp");
|
||||
String sign = headers.get("sign");
|
||||
|
||||
Map<String, String> transitionHeader = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
transitionHeader.put(entry.getKey().toUpperCase(), entry.getValue());
|
||||
}
|
||||
String appid = transitionHeader.get("APPID");
|
||||
String noncestr = transitionHeader.get("NONCESTR");
|
||||
String timestamp = transitionHeader.get("TIMESTAMP");
|
||||
String sign = transitionHeader.get("SIGN");
|
||||
if (ObjectUtil.notEqual(doorConfig.getAppId(), appid)) {
|
||||
log.error("|{}|apiParseSign 接口解签错误appId错误dto|{}|headers|{}|appid|{}|nonceStr|{}|timestamp|{}|sign|{}|", TAG, json, JSONUtil.toJsonStr(headers), appid, noncestr, timestamp, sign);
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class WalletRechargeApplyController {
|
||||
/* ************************************* start callback start ************************************* */
|
||||
@Inner(value = false)
|
||||
@PostMapping("/apply-callback")
|
||||
public void applyCallback(@RequestBody ProcessNodeRecordAssignUserParamDto dto, @RequestParam Long tenantId) {
|
||||
public void applyCallback(@RequestBody ProcessNodeRecordAssignUserParamDto dto, @RequestParam(required = false) Long tenantId) {
|
||||
walletRechargeApplyService.applyCallback(dto, tenantId);
|
||||
}
|
||||
/* ************************************* start callback start ************************************* */
|
||||
|
||||
Reference in new issue
Block a user