fix:移动端智能柜上架接口修改
This commit is contained in:
1 parent
a255c59dfa
commit
8cf5bc717a
9 files changed
+58
-20
No files matched your search
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.bsd.pjcloud.hard.api.constant;
|
||||
package com.bsd.pjcloud.hard.api.constant.flow;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -14,7 +14,7 @@ import java.util.Arrays;
|
||||
public enum HardDoorFlowBizEnum {
|
||||
PAY_OPEN("10", "购买开门"),
|
||||
REPERTORY_OPEN("20", "上架开门"),
|
||||
ACCESS_OPEN("20", "检修开门"),
|
||||
ACCESS_OPEN("30", "检修开门"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.bsd.pjcloud.hard.api.dto;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.constant.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.flow.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardDoorOpenTypeEnum;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
+10
-2
@@ -10,7 +10,7 @@ import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.flow.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardDoorOpenTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto;
|
||||
@@ -89,7 +89,7 @@ public class HardDoorFlowController {
|
||||
/* ************************************* start app start ************************************* */
|
||||
|
||||
@Operation(summary = "上架开门", description = "上架开门")
|
||||
@PostMapping("/open-repertory")
|
||||
@PostMapping("/app/open-repertory")
|
||||
public R<Long> openRepertory(@Validated @RequestBody HardDoorFlowOpenDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
dto.setFlowType(HardDoorFlowBizEnum.REPERTORY_OPEN);
|
||||
@@ -137,6 +137,14 @@ public class HardDoorFlowController {
|
||||
return R.ok(hardDoorFlowService.join(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过订单id查询流程", description = "通过订单id查询流程")
|
||||
@GetMapping("/get-by-order-id")
|
||||
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_view')")
|
||||
public R<HardDoorFlowVo> getByOrderId(@RequestParam Long orderId) {
|
||||
return R.ok(hardDoorFlowService.getByOrderId(orderId));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "新增智能柜流程", description = "新增智能柜流程")
|
||||
@SysLog("新增智能柜流程")
|
||||
@PostMapping
|
||||
|
||||
+3
-1
@@ -23,7 +23,9 @@ public interface HardDoorFlowMapper extends PjcloudBaseMapper<HardDoorFlowEntity
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getHardDoorId()), HardDoorFlowEntity::getHardDoorId, dto.getHardDoorId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getCabinetNo()), HardDoorFlowEntity::getCabinetNo, dto.getCabinetNo())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getOrderId()), HardDoorFlowEntity::getOrderId, dto.getOrderId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getIsOpen()), HardDoorFlowEntity::getIsOpen, dto.getIsOpen());
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getIsOpen()), HardDoorFlowEntity::getIsOpen, dto.getIsOpen())
|
||||
.orderByDesc(HardDoorFlowEntity::getCreateTime)
|
||||
.orderByDesc(HardDoorFlowEntity::getId);
|
||||
return selectJoinPage(page, HardDoorFlowVo.class, wrapper);
|
||||
}
|
||||
}
|
||||
+5
@@ -22,6 +22,11 @@ public interface HardDoorFlowService extends IService<HardDoorFlowEntity> {
|
||||
|
||||
HardDoorFlowVo join(Long id);
|
||||
|
||||
/**
|
||||
* 通过订单id查询流程
|
||||
*/
|
||||
HardDoorFlowVo getByOrderId(Long orderId);
|
||||
|
||||
/**
|
||||
* 检修开门
|
||||
*/
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardAuthTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.flow.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardDoorOpenTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardAuthAppDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardAuthDto;
|
||||
|
||||
+32
-10
@@ -8,7 +8,6 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.admin.api.vo.UserVO;
|
||||
@@ -16,7 +15,7 @@ import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.flow.HardDoorFlowBizEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.flow.HardDoorFlowEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto;
|
||||
@@ -91,14 +90,19 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
HardDoorFlowEntity detail = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(detail)) return null;
|
||||
HardDoorFlowVo result = BeanUtil.toBean(detail, HardDoorFlowVo.class);
|
||||
// 用户
|
||||
List<UserVO> usrList = remoteUserService.getUserDeptByIds(List.of(result.getUserId())).getData();
|
||||
if (ObjectUtil.isNotEmpty(usrList)) {
|
||||
DataUtil.convertUserDept(result, usrList.get(0));
|
||||
}
|
||||
// 设备
|
||||
HardManagerEntity hardManager = hardManagerMapper.selectById(result.getHardDoorId());
|
||||
if (ObjectUtil.isNotEmpty(hardManager)) HardUtil.convertHard(result, hardManager);
|
||||
disposeList(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过订单id查询流程
|
||||
*/
|
||||
@Override
|
||||
public HardDoorFlowVo getByOrderId(Long orderId) {
|
||||
HardDoorFlowEntity detail = baseMapper.selectOne(new LambdaQueryWrapper<HardDoorFlowEntity>().eq(HardDoorFlowEntity::getOrderId, orderId));
|
||||
if (ObjectUtil.isEmpty(detail)) return null;
|
||||
HardDoorFlowVo result = BeanUtil.toBean(detail, HardDoorFlowVo.class);
|
||||
disposeList(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -344,8 +348,10 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
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);
|
||||
}
|
||||
// 完成授权流程
|
||||
@@ -449,6 +455,9 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
}
|
||||
case FLOW_PAY_ORDER -> {
|
||||
updateObj.setPayTime(LocalDateTime.now());
|
||||
if (ObjectUtil.isNotEmpty(error)) {
|
||||
updateObj.setErrorDesc("商品识别响应错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -477,6 +486,19 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
}
|
||||
}
|
||||
|
||||
private void disposeList(HardDoorFlowVo detail) {
|
||||
// 用户
|
||||
List<UserVO> usrList = remoteUserService.getUserDeptByIds(List.of(detail.getUserId())).getData();
|
||||
if (ObjectUtil.isNotEmpty(usrList)) {
|
||||
DataUtil.convertUserDept(detail, usrList.get(0));
|
||||
}
|
||||
// 设备
|
||||
HardManagerEntity hardManager = hardManagerMapper.selectById(detail.getHardDoorId());
|
||||
if (ObjectUtil.isNotEmpty(hardManager)) {
|
||||
HardUtil.convertHard(detail, hardManager);
|
||||
}
|
||||
}
|
||||
|
||||
private HardDoorFlowServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ public class HardSpuJoinServiceImpl extends ServiceImpl<HardSpuJoinMapper, HardS
|
||||
// 查询商品
|
||||
if (ObjectUtil.isNotEmpty(spuIds)) {
|
||||
HardSpuDto spuDto = new HardSpuDto();
|
||||
spuDto.setSpuIdList(spuIds);
|
||||
List<HardSpuVo> spuList = hardSpuMapper.scopPageList(spuDto, null);
|
||||
for (HardSpuJoinVo v : joinList) {
|
||||
spuList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getSpuId())).findFirst().ifPresent(v::setSpuDetail);
|
||||
|
||||
+3
-3
@@ -166,6 +166,7 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
HardSpuJoinDto spuJoinDto = new HardSpuJoinDto();
|
||||
spuJoinDto.setHardDoorId(hardDoorId);
|
||||
spuJoinDto.setCabinetNo(cabinetNo);
|
||||
spuJoinDto.setIsSpu(true);
|
||||
return hardSpuJoinService.scopeList(spuJoinDto);
|
||||
}
|
||||
|
||||
@@ -261,7 +262,6 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
log.error("|{}|扣减商品库存失败查询到的智能柜商品为空dto|{}|", TAG, JSONUtil.toJsonStr(list));
|
||||
return false;
|
||||
}
|
||||
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())) {
|
||||
@@ -269,11 +269,11 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
entity.setId(hardSpu.getHardSpuId());
|
||||
entity.setSalesCount(i.getSalesCount() + hardSpu.getIncrCount());
|
||||
entity.setRepertoryCount(i.getRepertoryCount() - hardSpu.getIncrCount());
|
||||
updateList.add(entity);
|
||||
// 乐观锁循环扣减库存
|
||||
baseMapper.updateById(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
baseMapper.updateById(updateList);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user