11
This commit is contained in:
1 parent
9ae5f917ce
commit
56e85713c8
8 files changed
+82
-11
No files matched your search
@@ -414,6 +414,7 @@ CREATE TABLE hard_spu
|
||||
ks_status char(1) DEFAULT NULL COMMENT '旷世审核状态',
|
||||
ks_status_title varchar(64) DEFAULT NULL COMMENT '旷世审核状态标题',
|
||||
ks_comments varchar(512) DEFAULT NULL COMMENT '旷世审核状态描述',
|
||||
version int DEFAULT 0 NOT NULL COMMENT '乐观锁',
|
||||
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.spu;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DeductionSpuStockDto {
|
||||
|
||||
private Long hardSpuId;
|
||||
|
||||
private Integer incrCount;
|
||||
|
||||
}
|
||||
+6
@@ -165,6 +165,12 @@ public class HardSpuEntity extends Model<HardSpuEntity> {
|
||||
@Schema(description = "旷世审核状态标题")
|
||||
private String ksStatusTitle;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 旷世审核状态描述
|
||||
*/
|
||||
|
||||
+7
-1
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.hard.service;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.HardPutawayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
|
||||
@@ -60,7 +61,12 @@ public interface HardSpuService extends IService<HardSpuEntity> {
|
||||
void asyncAll();
|
||||
|
||||
/**
|
||||
* 拉取旷世商品
|
||||
* 检验商品
|
||||
*/
|
||||
HardSpuEntity validateSpu(Long hardSpuId);
|
||||
|
||||
/**
|
||||
* 扣减库存
|
||||
*/
|
||||
Boolean deductionSpuStock(List<DeductionSpuStockDto> list);
|
||||
}
|
||||
+1
-1
@@ -298,7 +298,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
if (ObjectUtil.isNotEmpty(flowDetail.getSkuCallbackTime())) {
|
||||
log.error("|{}|disposeRecognitionCallback 该流程已经提交识别dto|{}|", TAG, JSONUtil.toJsonStr(dto));
|
||||
return;
|
||||
}
|
||||
}
|
||||
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).skuCallbackVo(JSONUtil.toJsonStr(dto)).skuCallbackTime(LocalDateTime.now()).build();
|
||||
baseMapper.updateById(updateObj);
|
||||
// 查询订单
|
||||
|
||||
+11
-6
@@ -425,6 +425,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.merchantDeptId(mch.getDeptId())
|
||||
.userId(userDetail.getSysUser().getUserId())
|
||||
.userDeptId(userDetail.getSysUser().getDeptId())
|
||||
.sysType(HardTypeEnum.DOOR.getType())
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.orderType(HardOrderTypeEnum.BELOW.getType())
|
||||
.payType(HardPayTypeEnum.HARD_DOOR_FREE_PAY.getType())
|
||||
@@ -462,14 +463,14 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
carListDto.add(entity);
|
||||
});
|
||||
}
|
||||
HardTypeEnum hardType = HardTypeEnum.valueOfByType(dto.getSysType());
|
||||
HardTypeEnum sysType = HardTypeEnum.valueOfByType(dto.getSysType());
|
||||
HardOrderTypeEnum orderType = HardOrderTypeEnum.valueOfByType(dto.getOrderType());
|
||||
// 获取商品价格
|
||||
Integer totalPrice = hardCarService.computerCarTotalPrice(hardType, orderType, carListDto);
|
||||
Integer totalPrice = hardCarService.computerCarTotalPrice(sysType, orderType, carListDto);
|
||||
// 添加购物车
|
||||
Long parentCarId = hardCarService.createCard(dto.getUserId(), dto.getMerchantId(), hardType, orderType, carListDto);
|
||||
Long parentCarId = hardCarService.createCard(dto.getUserId(), dto.getMerchantId(), sysType, orderType, carListDto);
|
||||
// 获取商品描述
|
||||
String subject = hardCarService.computerCarSubject(hardType, orderType, carListDto);
|
||||
String subject = hardCarService.computerCarSubject(sysType, orderType, carListDto);
|
||||
// 更新订单信息
|
||||
HardOrderEntity updateObj = HardOrderEntity.builder()
|
||||
.id(dto.getId())
|
||||
@@ -603,7 +604,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (!ObjectUtil.isAllNotEmpty(hardTypeEnum, orderTypeEnum)) return;
|
||||
String CarErrorMsg = ObjectUtil.equals(isReduce, YesNoEnum.YES) ? "扣减库存" : "恢复库存";
|
||||
int base = ObjectUtil.equals(isReduce, YesNoEnum.YES) ? -1 : 1;
|
||||
// 食堂扣件库存
|
||||
// 食堂扣减库存
|
||||
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.CANTEEN) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) {
|
||||
// 查询购物车
|
||||
List<HardCarEntity> carList = hardCarService.getByParentCarId(order.getParentCarId());
|
||||
@@ -624,7 +625,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
log.info("|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
|
||||
return;
|
||||
}
|
||||
// 超市扣家库存
|
||||
// 超市扣减库存
|
||||
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.SUPERMARKET)) {
|
||||
// 查询购物车
|
||||
List<HardCarEntity> carList = hardCarService.getByParentCarId(order.getParentCarId());
|
||||
@@ -653,6 +654,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
log.info("|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
|
||||
return;
|
||||
}
|
||||
// 智能柜扣减库存
|
||||
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.DOOR)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 发送mq消息
|
||||
|
||||
+27
-1
@@ -11,6 +11,7 @@ import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.constant.spu.HardKsCheckStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.spu.HardKsSkuTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.HardPutawayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuJoinDto;
|
||||
@@ -73,7 +74,7 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
|
||||
@Override
|
||||
public List<HardSpuEntity> getByIds(List<Long> spuIds) {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<HardSpuEntity>().in(HardSpuEntity::getId, spuIds));
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<HardSpuEntity>().in(HardSpuEntity::getId, spuIds));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,6 +234,31 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
return spuDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deductionSpuStock(List<DeductionSpuStockDto> list) {
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
log.error("|{}|扣减商品库存失败list为空", TAG);
|
||||
return false;
|
||||
}
|
||||
List<Long> hardSpuIdes = list.stream().map(DeductionSpuStockDto::getHardSpuId).toList();
|
||||
List<HardSpuEntity> hardSpuList = getByIds(hardSpuIdes);
|
||||
if (ObjectUtil.isEmpty(hardSpuList)) {
|
||||
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())){
|
||||
HardSpuEntity entity = new HardSpuEntity();
|
||||
entity.setId(hardSpu.getHardSpuId());
|
||||
entity.setRepertoryCount(i.getRepertoryCount() - hardSpu.getIncrCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean asyncAllGroup(KsBarcodeLikeDto likeDto) {
|
||||
KsBarcodeLikeVo data = remoterThirdKsService.barcodeSkuLike(likeDto).getData();
|
||||
if (ObjectUtil.isEmpty(data) || !data.isSuccess() || ObjectUtil.isEmpty(data.getResultList())) return false;
|
||||
|
||||
+15
-2
@@ -361,10 +361,23 @@ public class ThirdKsApiServiceImpl implements ThirdKsApiService {
|
||||
*/
|
||||
private boolean apiParseSign(String json, String uri, Map<String, String> headers) {
|
||||
String authorization = headers.get("Authorization");
|
||||
if (ObjectUtil.isEmpty(authorization)) {
|
||||
throw new RuntimeException("签名参数缺失");
|
||||
}
|
||||
String referer = headers.get("Referer");
|
||||
if (ObjectUtil.isEmpty(referer)) {
|
||||
throw new RuntimeException("签名参数缺失");
|
||||
}
|
||||
String cleanUrl = referer.replaceAll("^(http|https)://", "");
|
||||
String contentType = headers.get("Content-Type");
|
||||
String timestamp = headers.get("REQUEST-START-TIME");
|
||||
String signAuth = KsRetailSignUtils.getSignAuth(referer, uri, contentType, HttpPost.METHOD_NAME, Long.valueOf(timestamp), ksDiscernConfig.getAccessKey(), ksDiscernConfig.getSecretKey(), json, "");
|
||||
if (ObjectUtil.isEmpty(contentType)) {
|
||||
throw new RuntimeException("签名参数缺失");
|
||||
}
|
||||
String timestamp = headers.get("X-Request-Date");
|
||||
if (ObjectUtil.isEmpty(timestamp)) {
|
||||
throw new RuntimeException("签名参数缺失");
|
||||
}
|
||||
String signAuth = KsRetailSignUtils.getSignAuth(cleanUrl, uri, contentType, HttpPost.METHOD_NAME, Long.valueOf(timestamp), ksDiscernConfig.getAccessKey(), ksDiscernConfig.getSecretKey(), json, "");
|
||||
return ObjectUtil.equals(signAuth, authorization);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user