feat:智能柜订单取消
This commit is contained in:
1 parent
8cf5bc717a
commit
2529ab7d81
13 files changed
+144
-17
No files matched your search
+18
-15
@@ -373,21 +373,24 @@ CREATE TABLE hard_broadcast
|
||||
DROP TABLE IF EXISTS hard_auth;
|
||||
CREATE TABLE hard_auth
|
||||
(
|
||||
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
auth_type varchar(32) DEFAULT NULL COMMENT '授权类型如微信小程序、支付宝、浙政钉',
|
||||
user_id bigint NOT NULL COMMENT '预定用户',
|
||||
hard_id bigint NOT NULL COMMENT '硬件id',
|
||||
cabinet_no int DEFAULT NULL COMMENT '货柜编号',
|
||||
auth_status char(1) DEFAULT '0' COMMENT '是否授权',
|
||||
auth_time datetime DEFAULT NULL COMMENT '授权时间',
|
||||
is_done char(1) DEFAULT '0' COMMENT '是否完成',
|
||||
is_done_time datetime DEFAULT 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 '修改人',
|
||||
update_time datetime DEFAULT NULL COMMENT '修改时间',
|
||||
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
auth_type varchar(32) DEFAULT NULL COMMENT '授权类型如微信小程序、支付宝、浙政钉',
|
||||
user_id bigint NOT NULL COMMENT '预定用户',
|
||||
hard_id bigint NOT NULL COMMENT '硬件id',
|
||||
cabinet_no int DEFAULT NULL COMMENT '货柜编号',
|
||||
auth_status char(1) DEFAULT '0' COMMENT '是否授权',
|
||||
auth_time datetime DEFAULT NULL COMMENT '授权时间',
|
||||
is_done char(1) DEFAULT '0' COMMENT '是否完成',
|
||||
is_done_time datetime DEFAULT NULL COMMENT '完成时间',
|
||||
is_manual_change varchar(32) DEFAULT NULL COMMENT '是否人工处理',
|
||||
manual_change_time datetime DEFAULT NULL COMMENT '人工处理时间',
|
||||
manual_change_remark varchar(512) DEFAULT 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 '修改人',
|
||||
update_time datetime DEFAULT NULL COMMENT '修改时间',
|
||||
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB COMMENT ='硬件授权';
|
||||
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ public enum HardOrderStatusEnum {
|
||||
OFFLINE_PAY("6", "没有网络本地支付"),
|
||||
REFUND("10", "退款"),
|
||||
CANCEL("20", "已核销"),
|
||||
UNFOLLOW("30", "已取消(智能柜使用)"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
+4
@@ -3,7 +3,11 @@ package com.bsd.pjcloud.hard.api.dto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class HardDoorFlowDto extends HardDoorFlowEntity {
|
||||
|
||||
private LocalDate[] createTimeList;
|
||||
|
||||
}
|
||||
+18
@@ -77,6 +77,24 @@ public class HardAuthEntity extends Model<HardAuthEntity> {
|
||||
@Schema(description = "完成时间")
|
||||
private LocalDateTime isDoneTime;
|
||||
|
||||
/**
|
||||
* 是否人工处理
|
||||
*/
|
||||
@Schema(description = "是否人工处理")
|
||||
private String isManualChange;
|
||||
|
||||
/**
|
||||
* 人工处理时间
|
||||
*/
|
||||
@Schema(description = "人工处理时间")
|
||||
private LocalDateTime manualChangeTime;
|
||||
|
||||
/**
|
||||
* 人工处理备注
|
||||
*/
|
||||
@Schema(description = "人工处理时间")
|
||||
private String manualChangeRemark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
||||
+7
-1
@@ -178,11 +178,17 @@ public class HardOrderEntity extends Model<HardOrderEntity> {
|
||||
private String refundStatus;
|
||||
|
||||
/**
|
||||
* 订单取消时间
|
||||
* 订单取消时间(退款订单)
|
||||
*/
|
||||
@Schema(description = "订单取消时间")
|
||||
private LocalDateTime applyCancelTime;
|
||||
|
||||
/**
|
||||
* 订单取消时间(智能柜)
|
||||
*/
|
||||
@Schema(description = "订单取消时间(智能柜)")
|
||||
private LocalDateTime unfollowTime;
|
||||
|
||||
/**
|
||||
* 设备上的唯一订单号
|
||||
*/
|
||||
|
||||
+7
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardDoorFlowVo;
|
||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -24,6 +25,12 @@ public interface HardDoorFlowMapper extends PjcloudBaseMapper<HardDoorFlowEntity
|
||||
.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())
|
||||
.between(
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
|
||||
HardDoorFlowEntity::getCreateTime,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
|
||||
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
|
||||
)
|
||||
.orderByDesc(HardDoorFlowEntity::getCreateTime)
|
||||
.orderByDesc(HardDoorFlowEntity::getId);
|
||||
return selectJoinPage(page, HardDoorFlowVo.class, wrapper);
|
||||
|
||||
+5
@@ -24,4 +24,9 @@ public interface HardAuthService extends IService<HardAuthEntity> {
|
||||
* app智能柜授权
|
||||
*/
|
||||
Long appAuthHardDoor(HardAuthAppDto dto);
|
||||
|
||||
/**
|
||||
* 判断当前用户信誉
|
||||
*/
|
||||
boolean judgeUserCredit(Long userId);
|
||||
}
|
||||
+5
@@ -54,6 +54,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
|
||||
*/
|
||||
Long payHardDoorOrder(HardOrderEntity dto, List<KsRecognitionCallbackDto.ResultSku> ksSpuList);
|
||||
|
||||
/**
|
||||
* 智能柜取消订单
|
||||
*/
|
||||
Long cancelHardDoorOrder(Long orderId);
|
||||
|
||||
/**
|
||||
* 快速扣款,离线订单使用
|
||||
*/
|
||||
|
||||
+15
@@ -1,6 +1,7 @@
|
||||
package com.bsd.pjcloud.hard.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.feign.RemoteUserService;
|
||||
@@ -115,6 +116,20 @@ public class HardAuthServiceImpl extends ServiceImpl<HardAuthMapper, HardAuthEnt
|
||||
return dto.getAuthId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前用户信誉
|
||||
*/
|
||||
@Override
|
||||
public boolean judgeUserCredit(Long userId) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<HardAuthEntity>()
|
||||
.eq(HardAuthEntity::getUserId, userId)
|
||||
.eq(HardAuthEntity::getAuthStatus, YesNoEnum.YES.getCode())
|
||||
.eq(HardAuthEntity::getIsDone, YesNoEnum.NO.getCode())
|
||||
.ne(HardAuthEntity::getIsManualChange, YesNoEnum.YES.getCode())
|
||||
);
|
||||
return count <= 5;
|
||||
}
|
||||
|
||||
private void disposeList(List<HardAuthVo> list, HardAuthDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 设备
|
||||
|
||||
+22
-1
@@ -40,8 +40,10 @@ import com.bsd.pjcloud.thirdparty.dto.ks.KsRecognitionCallbackDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.ks.KsRecognitionDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.door.DoorOpenVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.ks.KsRecognitionVo;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -67,6 +69,8 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
private final HardDoorCabinetService hardDoorCabinetService;
|
||||
private final HardSpuJoinService hardSpuJoinService;
|
||||
private final HardOrderService hardOrderService;
|
||||
@Lazy
|
||||
private final HardAuthService hardAuthService;
|
||||
|
||||
private final HardAuthMapper hardAuthMapper;
|
||||
private final HardManagerMapper hardManagerMapper;
|
||||
@@ -74,6 +78,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
private final RemoterThirdDoorApiService thirdDoorApiService;
|
||||
private final RemoterThirdKsService thirdKsService;
|
||||
private final RemoteUserService remoteUserService;
|
||||
private final RemoteWalletService remoteWalletService;
|
||||
|
||||
/**
|
||||
* 复杂查询
|
||||
@@ -184,6 +189,16 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
if (ObjectUtil.isNotEmpty(dto.getHardDoorFlowId()) || ObjectUtil.isEmpty(hardDoorDetail)) {
|
||||
return;
|
||||
}
|
||||
// 查看用户消费钱包余额
|
||||
String walletErrorMsg = remoteWalletService.innserIsUseDoor(dto.getUserId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(walletErrorMsg)) {
|
||||
throw new RuntimeException(walletErrorMsg);
|
||||
}
|
||||
// 查看用户信誉
|
||||
boolean userCredit = hardAuthService.judgeUserCredit(dto.getUserId());
|
||||
if (!userCredit) {
|
||||
throw new RuntimeException("用户信誉不足,请联系管理员");
|
||||
}
|
||||
// 查询货柜是否配置spu信息
|
||||
List<HardSpuJoinVo> spuList = hardSpuJoinService.getSpuList(hardDoorDetail.getId(), dto.getCabinetNo());
|
||||
if (ObjectUtil.isEmpty(spuList) || spuList.isEmpty()) throw new RuntimeException("货柜商品信息为空,请上架");
|
||||
@@ -223,7 +238,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
Long orderId = hardOrderService.createHardDoorOrder(flowDetail.getUserId(), flowDetail.getHardId());
|
||||
updateObj.setOrderId(orderId);
|
||||
}
|
||||
flowStatusControl(updateObj, null, dto, null);
|
||||
getSelf().flowStatusControl(updateObj, null, dto, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,6 +340,12 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
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.notEqual(ksRecognitionCode, "2")) {
|
||||
// 未拿商品取消订单
|
||||
hardOrderService.cancelHardDoorOrder(flowDetail.getOrderId());
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, "");
|
||||
return;
|
||||
}
|
||||
String ksErrorMsg = String.format("商品识别响应错误:ksFlowCode:%s;ksRecognitionCode:%s;", ksFlowCode, ksRecognitionCode);
|
||||
log.error(ksErrorMsg);
|
||||
getSelf().flowStatusControl(flowDetail, null, dto, ksErrorMsg);
|
||||
|
||||
+28
@@ -494,6 +494,34 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
return orderObj.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能柜取消订单
|
||||
*/
|
||||
@Override
|
||||
public Long cancelHardDoorOrder(Long orderId) {
|
||||
// 查询订单
|
||||
HardOrderEntity order = baseMapper.selectById(orderId);
|
||||
if (ObjectUtil.isEmpty(order)) {
|
||||
log.error("|{}|智能柜订单取消失败,订单不存在|{}|", TAG, orderId);
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(order.getPayPrice()) && order.getPayPrice() > 0) {
|
||||
log.error("|{}|智能柜订单取消失败,订单价格大于0|{}|", TAG, orderId);
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(order.getOrderStatus()) && ObjectUtil.equals(order.getOrderStatus(), HardOrderStatusEnum.UNFOLLOW.getType())) {
|
||||
log.error("|{}|智能柜订单取消失败,订单已核销|{}|", TAG, orderId);
|
||||
return null;
|
||||
}
|
||||
HardOrderEntity updateObj = HardOrderEntity.builder()
|
||||
.id(order.getId())
|
||||
.orderStatus(HardOrderStatusEnum.UNFOLLOW.getType())
|
||||
.unfollowTime(LocalDateTime.now())
|
||||
.build();
|
||||
baseMapper.updateById(updateObj);
|
||||
return updateObj.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void fastReduceBalance(HardOrderEntity order) {
|
||||
|
||||
+3
@@ -52,4 +52,7 @@ public interface RemoteWalletService {
|
||||
|
||||
@GetMapping("/wallet-manage/is-del")
|
||||
R<String> isDel(@RequestParam Long userId);
|
||||
|
||||
@GetMapping("/wallet-manage/inner/is-use-door")
|
||||
R<String> innserIsUseDoor(@RequestParam Long userId);
|
||||
}
|
||||
+11
@@ -126,11 +126,22 @@ public class WalletManageController {
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 这个用户是否能够删除
|
||||
*/
|
||||
@GetMapping("/is-del")
|
||||
public R<String> isDel(@RequestParam Long userId) {
|
||||
return R.ok(walletManageService.isDel(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 这个用户是否能够使用智能柜
|
||||
*/
|
||||
@GetMapping("/inner/is-use-door")
|
||||
public R<String> innserIsUseDoor(@RequestParam Long userId) {
|
||||
return R.ok(walletManageService.isUseDoor(userId));
|
||||
}
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user