feat:结束流程

This commit is contained in:
dzc committed 2025-04-17 10:31:09 +08:00
1 parent 56e85713c8
commit ee47db73ba
3 files changed
+36 -7

No files matched your search

@@ -12,6 +12,7 @@ import com.bsd.pjcloud.hard.api.constant.HardDoorFlowEnum;
import com.bsd.pjcloud.hard.api.constant.HardDoorOpenTypeEnum;
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.entity.HardAuthEntity;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorManagerEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
@@ -51,11 +52,9 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
private static final String TAG = "智能柜流程";
private final HardManagerService hardManagerService;
private final HardDoorManagerService hardDoorManagerService;
private final HardDoorCabinetService hardDoorCabinetService;
private final HardSpuJoinService hardSpuJoinService;
private final HardSpuService hardSpuService;
private final HardOrderService hardOrderService;
private final HardAuthMapper hardAuthMapper;
@@ -295,8 +294,14 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
log.error("|{}|disposeRecognitionCallback 意外的错误,流程不存在dto|{}|", TAG, JSONUtil.toJsonStr(dto));
return;
}
// 查询授权流程
HardAuthEntity authDetail = hardAuthMapper.selectById(flowDetail.getId());
if (ObjectUtil.isEmpty(authDetail)) {
log.error("|{}|disposeRecognitionCallback 意外的错误,授权流程不存在dto|{}|", TAG, JSONUtil.toJsonStr(dto));
return;
}
if (ObjectUtil.isNotEmpty(flowDetail.getSkuCallbackTime())) {
log.error("|{}|disposeRecognitionCallback 该流程已经提交识别dto|{}|", TAG, JSONUtil.toJsonStr(dto));
log.error("|{}|disposeRecognitionCallback 该流程识别已经回调dto|{}|", TAG, JSONUtil.toJsonStr(dto));
return;
}
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).skuCallbackVo(JSONUtil.toJsonStr(dto)).skuCallbackTime(LocalDateTime.now()).build();
@@ -312,7 +317,9 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
if (ObjectUtil.isNotEmpty(resultSkuList)) {
Long orderId = hardOrderService.payHardDoorOrder(orderDetail, resultSkuList);
if (ObjectUtil.isNotEmpty(orderId)) {
// 完成授权流程
HardAuthEntity updateAuthObj = HardAuthEntity.builder().id(authDetail.getId()).isDone(YesNoEnum.YES.getCode()).isDoneTime(LocalDateTime.now()).build();
hardAuthMapper.updateById(updateAuthObj);
}
}
}
@@ -31,6 +31,7 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
@@ -656,7 +657,22 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}
// 智能柜扣减库存
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.DOOR)) {
// 查询购物车
List<HardCarEntity> carList = hardCarService.getByParentCarId(order.getParentCarId());
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("扣减库存错误,购物车不存在");
List<DeductionSpuStockDto> list = carList.stream().map(v -> {
DeductionSpuStockDto entity = new DeductionSpuStockDto();
entity.setHardSpuId(v.getProductId());
entity.setIncrCount(v.getProductCount());
return entity;
}).toList();
Boolean isDeduction = hardSpuService.deductionSpuStock(list);
if (!isDeduction) {
log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(list));
throw new RuntimeException("扣减智能柜库存" + CarErrorMsg + "错误");
}
log.info("扣减智能柜库存成功|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(list));
return;
}
}
@@ -234,7 +234,11 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
return spuDetail;
}
/**
* 扣减库存
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deductionSpuStock(List<DeductionSpuStockDto> list) {
if (ObjectUtil.isEmpty(list)) {
log.error("|{}|扣减商品库存失败list为空", TAG);
@@ -249,14 +253,16 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
List<HardSpuEntity> updateList = new ArrayList<>();
for (HardSpuEntity i : hardSpuList) {
list.stream().filter(j -> ObjectUtil.equals(i.getId(), j.getHardSpuId())).findFirst().ifPresent(hardSpu -> {
if(ObjectUtil.isNotEmpty(hardSpu.getIncrCount())){
if (ObjectUtil.isNotEmpty(hardSpu.getIncrCount())) {
HardSpuEntity entity = new HardSpuEntity();
entity.setId(hardSpu.getHardSpuId());
entity.setRepertoryCount(i.getRepertoryCount() - hardSpu.getIncrCount());
updateList.add(entity);
}
});
}
return null;
baseMapper.updateById(updateList);
return true;
}
public boolean asyncAllGroup(KsBarcodeLikeDto likeDto) {