fix:硬件核销流程
This commit is contained in:
1 parent
eca9919674
commit
93add403c7
19 files changed
+146
-70
No files matched your search
@@ -9,6 +9,7 @@ CREATE TABLE mch_manage
|
||||
(
|
||||
id bigint NOT NULL COMMENT '主键',
|
||||
dept_id bigint NOT NULL COMMENT '绑定的部门id',
|
||||
hard_group_id bigint COMMENT '设备分组id',
|
||||
name varchar(64) NOT NULL COMMENT '商户名',
|
||||
types varchar(64) NOT NULL COMMENT '店铺类型,逗号分隔',
|
||||
logo_pic varchar(256) NOT NULL COMMENT '商户logo图片',
|
||||
|
||||
+5
-2
@@ -72,8 +72,11 @@ public class HardApiController {
|
||||
|
||||
@PostMapping("/cancel-code")
|
||||
@Operation(summary = "核销二维码")
|
||||
@Idempotent(expireTime = 10, info = "正在支付中,请勿重复操作")
|
||||
public R<Boolean> handCancelCode(@Valid @RequestBody HandCancelCodeDto dto) {
|
||||
@Idempotent(expireTime = 10, info = "正在核销中,请勿重复操作")
|
||||
public R<Boolean> handCancelCode(@RequestBody HandCancelCodeDto dto) {
|
||||
if (!ObjectUtil.isAllNotEmpty(dto.getOrderId(), dto.getHardwareId())) {
|
||||
throw new RuntimeException("参数不正确");
|
||||
}
|
||||
return R.ok(hardwareOrderService.handCancelCode(dto));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -67,5 +67,5 @@ public interface HardOrderService extends IService<HardOrderEntity> {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Boolean handCancelCode(@Valid HandCancelCodeDto dto);
|
||||
Boolean handCancelCode(HandCancelCodeDto dto);
|
||||
}
|
||||
+18
-12
@@ -116,9 +116,12 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
|
||||
|
||||
@Override
|
||||
public Long create(HardManagerDto dto, PjcloudUser user) {
|
||||
R<MchManageVo> mch = mchService.getById(dto.getMerchantId());
|
||||
Long mchDeptId = Optional.of(mch).map(R::getData).map(MchManageVo::getDeptId).orElseThrow(() -> new RuntimeException("商户不存在"));
|
||||
MchManageVo mch = mchService.getById(dto.getMerchantId()).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) {
|
||||
throw new RuntimeException("商户不存在");
|
||||
}
|
||||
dto.setDeptId(user.getDeptId());
|
||||
dto.setHardGroupId(mch.getHardGroupId());
|
||||
// mq地址和端口
|
||||
dto.setMqSocketAddress(mqttConfig.getAndroidAddress());
|
||||
dto.setMqSocketPort(mqttConfig.getAndroidPort());
|
||||
@@ -126,13 +129,13 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
|
||||
baseMapper.insert(dto);
|
||||
// topic
|
||||
HardManagerEntity updateObj = HardManagerEntity.builder().id(dto.getId()).build();
|
||||
String topic = createMqConfigByAction(dto.getHardGroupId(), null, 1) + "/#";
|
||||
String topic = createMqConfigByAction(mch.getHardGroupId(), null, null, 1) + "/#";
|
||||
updateObj.setMainTopic(topic);
|
||||
// client id
|
||||
String clientId = createMqConfigByAction(dto.getHardGroupId(), dto.getId(), 2);
|
||||
String clientId = createMqConfigByAction(null, null, dto.getId(), 2);
|
||||
updateObj.setMqClientId(clientId);
|
||||
// username TODO 密码9位随机数字加字母
|
||||
String mqUsername = createMqConfigByAction(dto.getHardGroupId(), dto.getId(), 3);
|
||||
String mqUsername = createMqConfigByAction(null, null, dto.getId(), 3);
|
||||
updateObj.setMqUsername(mqUsername);
|
||||
updateObj.setMqPassword(RandomUtil.randomString(9));
|
||||
baseMapper.updateById(updateObj);
|
||||
@@ -145,17 +148,20 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
|
||||
if (ObjectUtil.isEmpty(detail)) {
|
||||
throw new RuntimeException("设备不存在");
|
||||
}
|
||||
R<MchManageVo> mch = mchService.getById(dto.getMerchantId());
|
||||
Long mchDeptId = Optional.of(mch).map(R::getData).map(MchManageVo::getDeptId).orElseThrow(() -> new RuntimeException("商户不存在"));
|
||||
MchManageVo mch = mchService.getById(dto.getMerchantId()).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) {
|
||||
throw new RuntimeException("商户不存在");
|
||||
}
|
||||
dto.setHardGroupId(mch.getHardGroupId());
|
||||
if (!ObjectUtil.equals(dto.getMerchantId(), detail.getMerchantId())) {
|
||||
// topic
|
||||
String topic = createMqConfigByAction(mchDeptId, null, 1) + "/#";
|
||||
String topic = createMqConfigByAction(mch.getHardGroupId(), null, null, 1) + "/#";
|
||||
dto.setMainTopic(topic);
|
||||
// client id
|
||||
String clientId = createMqConfigByAction(mchDeptId, dto.getId(), 2);
|
||||
String clientId = createMqConfigByAction(null, null, dto.getId(), 2);
|
||||
dto.setMqClientId(clientId);
|
||||
// username TODO 密码9位随机数字加字母
|
||||
String mqUsername = createMqConfigByAction(mchDeptId, dto.getId(), 3);
|
||||
String mqUsername = createMqConfigByAction(null, null, dto.getId(), 3);
|
||||
dto.setMqUsername(mqUsername);
|
||||
}
|
||||
baseMapper.updateById(dto);
|
||||
@@ -185,8 +191,8 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
|
||||
return vo;
|
||||
}
|
||||
|
||||
private String createMqConfigByAction(Long deptId, Long hardId, Integer action) {
|
||||
MqTopicUtil eventDto = MqTopicUtil.builder().deptId(deptId).hardId(hardId).build();
|
||||
private String createMqConfigByAction(Long groupId, Long deptId, Long hardId, Integer action) {
|
||||
MqTopicUtil eventDto = MqTopicUtil.builder().groupId(groupId).deptId(deptId).hardId(hardId).build();
|
||||
if (ObjectUtil.equals(action, 1)) {
|
||||
return eventDto.getTopic();
|
||||
}
|
||||
|
||||
+19
-12
@@ -407,7 +407,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
boolean isCancel = validateCodeIsCancel(orderType, order.getId());
|
||||
if (isCancel) throw new RuntimeException("该二维码已被核销");
|
||||
// 核销二维码
|
||||
cancelCode(order);
|
||||
getSelf().cancelCode(order);
|
||||
HardOrderEntity updateObj = HardOrderEntity.builder().id(order.getId()).androidOrderCode(dto.getAndroidOrderCode()).hardId(dto.getHardwareId()).orderStatus(HardOrderStatusEnum.CANCEL.getType()).build();
|
||||
return baseMapper.updateById(updateObj) > 0;
|
||||
}
|
||||
@@ -417,14 +417,20 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelCode(HardOrderEntity order) {
|
||||
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
if (!ObjectUtil.isAllNotEmpty(orderTypeEnum, order.getOrderSourceTypeId())) return;
|
||||
Long id = order.getOrderSourceTypeId();
|
||||
if (!ObjectUtil.isAllNotEmpty(orderTypeEnum)) return;
|
||||
Long id = order.getId();
|
||||
switch (orderTypeEnum) {
|
||||
// 线下购买
|
||||
case BELOW -> {
|
||||
}
|
||||
// 外来人员 | 跨单位 | 线上订餐
|
||||
case FOREIGN_TICKET, STRIDE_DEPT, RESERVE -> remoteCodeUseService.cancelCode(id);
|
||||
case FOREIGN_TICKET, STRIDE_DEPT, RESERVE -> {
|
||||
R<Boolean> result = remoteCodeUseService.cancelCode(id);
|
||||
if (ObjectUtil.isEmpty(result) || result.getCode() != 0 || !result.getData()) {
|
||||
throw new RuntimeException("核销二维码错误");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,18 +508,19 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
}
|
||||
}
|
||||
|
||||
// 二维码类型的订单是否被核销
|
||||
private boolean validateCodeIsCancel(HardOrderTypeEnum orderType, Long orderSourceTypeId) {
|
||||
// 二维码类型的订单是否被核销 true被核销 false未核销
|
||||
private boolean validateCodeIsCancel(HardOrderTypeEnum orderType, Long orderId) {
|
||||
Boolean flag = switch (orderType) {
|
||||
case RESERVE -> false;
|
||||
case FOREIGN_TICKET, STRIDE_DEPT -> {
|
||||
R<Boolean> result = remoteCodeUseService.isCancelCode(orderSourceTypeId);
|
||||
if (ObjectUtil.isEmpty(result.getData())) yield false;
|
||||
case FOREIGN_TICKET, STRIDE_DEPT, RESERVE -> {
|
||||
R<Boolean> result = remoteCodeUseService.isCancelCode(orderId);
|
||||
if (ObjectUtil.isEmpty(result.getData()) || result.getCode() != 0) {
|
||||
yield true;
|
||||
}
|
||||
yield result.getData();
|
||||
}
|
||||
default -> false;
|
||||
default -> true;
|
||||
};
|
||||
if (!flag) throw new RuntimeException("该二维码已被核销");
|
||||
if (flag) throw new RuntimeException("该二维码已被核销");
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
+17
-14
@@ -11,6 +11,12 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class MqTopicUtil {
|
||||
|
||||
/**
|
||||
* 分组id
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@@ -22,31 +28,28 @@ public class MqTopicUtil {
|
||||
private Long hardId;
|
||||
|
||||
public String getTopic() {
|
||||
if (ObjectUtil.isAllNotEmpty(deptId, hardId)) {
|
||||
return String.format("topic/android/%s/%s", deptId, hardId);
|
||||
if (ObjectUtil.isAllNotEmpty(groupId, deptId, hardId)) {
|
||||
return String.format("topic/android/%s/%s/%s", groupId, deptId, hardId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(deptId)) {
|
||||
return String.format("topic/android/%s", deptId);
|
||||
if (ObjectUtil.isAllNotEmpty(groupId, deptId)) {
|
||||
return String.format("topic/android/%s/%s", groupId, deptId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(groupId)) {
|
||||
return String.format("topic/android/%s", groupId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
if (ObjectUtil.isAllNotEmpty(deptId, hardId)) {
|
||||
return String.format("client_id/android/%s/%s", deptId, hardId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(deptId)) {
|
||||
return String.format("client_id/android/%s", deptId);
|
||||
if (ObjectUtil.isAllNotEmpty(hardId)) {
|
||||
return String.format("client_id/android/%s", hardId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
if (ObjectUtil.isAllNotEmpty(deptId, hardId)) {
|
||||
return String.format("username_android_/android/%s/%s", deptId, hardId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(deptId)) {
|
||||
return String.format("username_android_/android/%s", deptId);
|
||||
if (ObjectUtil.isAllNotEmpty(hardId)) {
|
||||
return String.format("username/android/%s", hardId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,5 +58,5 @@ public interface RemoteMqttEventService {
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/mqtt/send-face-change-msg")
|
||||
R<Boolean> sendFaceChangeMsg(@RequestParam List<Long> parentDeptList, @RequestParam Long userId, @RequestParam(required = false) Boolean isGlobalFace);
|
||||
R<Boolean> sendFaceChangeMsg(@RequestParam Long userDeptId, @RequestParam Long userId, @RequestParam(required = false) Boolean isGlobalFace);
|
||||
}
|
||||
+9
-7
@@ -6,6 +6,9 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MqttBaseDto<T extends MqttHardBaseMsg> {
|
||||
// 硬件分组id
|
||||
private Long hardGroupId;
|
||||
|
||||
// 商户id
|
||||
private Long merchantDeptId;
|
||||
|
||||
@@ -18,16 +21,15 @@ public class MqttBaseDto<T extends MqttHardBaseMsg> {
|
||||
|
||||
private T data;
|
||||
|
||||
public Boolean isExistMchDeptId() {
|
||||
return ObjectUtil.isNotEmpty(merchantDeptId);
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
if (ObjectUtil.isAllNotEmpty(merchantDeptId, hardwareId)) {
|
||||
if (ObjectUtil.isAllNotEmpty(hardGroupId, merchantDeptId, hardwareId)) {
|
||||
return String.format("topic/android/%s/%s/%s", hardGroupId, merchantDeptId, hardwareId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(hardGroupId, merchantDeptId)) {
|
||||
return String.format("topic/android/%s/%s", merchantDeptId, hardwareId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(merchantDeptId)) {
|
||||
return String.format("topic/android/%s", merchantDeptId);
|
||||
if (ObjectUtil.isAllNotEmpty(hardGroupId)) {
|
||||
return String.format("topic/android/%s", hardGroupId);
|
||||
}
|
||||
return "topic/android";
|
||||
}
|
||||
|
||||
+4
-11
@@ -7,16 +7,13 @@ import com.bsd.pjcloud.mqtt.constant.MqttActionEnum;
|
||||
import com.bsd.pjcloud.mqtt.dto.MqttBaseDto;
|
||||
import com.bsd.pjcloud.mqtt.dto.hard.HardCustomerMsg;
|
||||
import com.bsd.pjcloud.mqtt.service.MqttEventService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -28,8 +25,6 @@ public class MqttEventController {
|
||||
|
||||
private final MqttEventService mqttEventService;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
|
||||
@Inner
|
||||
@PostMapping("/send-default-msg")
|
||||
public R<Boolean> sendDefaultMsg(@RequestBody MqttBaseDto dto) {
|
||||
@@ -109,13 +104,11 @@ public class MqttEventController {
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/send-face-change-msg")
|
||||
public R<Boolean> sendFaceChangeMsg(@RequestParam List<Long> parentDeptList, @RequestParam Long userId, @RequestParam(required = false) Boolean isGlobalFace) {
|
||||
public R<Boolean> sendFaceChangeMsg(@RequestParam Long userDeptId, @RequestParam Long userId, @RequestParam(required = false) Boolean isGlobalFace) {
|
||||
MqttBaseDto dto = new MqttBaseDto();
|
||||
MchManageVo mchDept = remoteMchService.getFirstMch(parentDeptList).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchDept)) {
|
||||
dto.setMerchantDeptId(mchDept.getDeptId());
|
||||
}
|
||||
mqttEventService.getTopicParamsByUserDeptId(dto, userDeptId);
|
||||
dto.setAction(MqttActionEnum.FACE);
|
||||
// msg
|
||||
HardCustomerMsg msg = new HardCustomerMsg();
|
||||
msg.setUserId(String.valueOf(userId));
|
||||
if (ObjectUtil.isNotEmpty(isGlobalFace)) {
|
||||
|
||||
+14
@@ -1,12 +1,17 @@
|
||||
package com.bsd.pjcloud.mqtt.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bsd.pjcloud.mqtt.dto.MqttBaseDto;
|
||||
import com.bsd.pjcloud.mqtt.dto.MqttHardBaseMsg;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -14,6 +19,7 @@ public class MqttEventService {
|
||||
|
||||
private final MqttService mqttService;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
|
||||
public <T extends MqttBaseDto> Boolean defaultAction(T dto) {
|
||||
MqttHardBaseMsg msg = dto.getData();
|
||||
@@ -21,4 +27,12 @@ public class MqttEventService {
|
||||
mqttService.publish(dto.getQos(), false, dto.getTopic(), JSON.toJSONString(msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
public <T extends MqttBaseDto> void getTopicParamsByUserDeptId(T dto, Long deptId) {
|
||||
MchManageVo mch = remoteMchService.getFirstMchByDeptId(deptId).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) {
|
||||
return;
|
||||
}
|
||||
dto.setHardGroupId(mch.getHardGroupId());
|
||||
}
|
||||
}
|
||||
+10
@@ -74,4 +74,14 @@ public interface RemoteDeptService {
|
||||
*/
|
||||
@GetMapping("/dept/getDeptListByDeptId")
|
||||
R<SysDept> getDeptByDeptId(@RequestParam("deptId") Long deptId);
|
||||
|
||||
/**
|
||||
* 获得指定部门的所有父部门
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/dept/getParentDeptList")
|
||||
R<List<SysDept>> getParentDeptList(@RequestParam("deptId") Long deptId);
|
||||
}
|
||||
+6
@@ -198,4 +198,10 @@ public class SysDeptController {
|
||||
public R<SysDept> getDeptByDeptId(@RequestParam("deptId") Long deptId) {
|
||||
return R.ok(sysDeptService.getById(deptId));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/getParentDeptList")
|
||||
public R<List<SysDept>> getParentDeptList(@RequestParam("deptId") Long deptId) {
|
||||
return R.ok(sysDeptService.getParentDeptList(deptId));
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -122,10 +122,7 @@ public class SysUserFaceServiceImpl extends ServiceImpl<SysUserFaceMapper, SysUs
|
||||
List<SysUser> list = sysUserService.list(new LambdaQueryWrapper<SysUser>().in(SysUser::getUserId, userIds));
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
for (SysUser v : list) {
|
||||
List<SysDept> parentDeptList = sysDeptService.getParentDeptList(v.getDeptId());
|
||||
if (ObjectUtil.isEmpty(parentDeptList)) continue;
|
||||
List<Long> deptIds = parentDeptList.stream().map(SysDept::getDeptId).toList();
|
||||
remoteMqttEventService.sendFaceChangeMsg(deptIds, v.getUserId(), isGlobalFace);
|
||||
remoteMqttEventService.sendFaceChangeMsg(v.getDeptId(), v.getUserId(), isGlobalFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -32,6 +32,12 @@ public class MchManageEntity extends Model<MchManageEntity> {
|
||||
@Schema(description="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备分组id
|
||||
*/
|
||||
@Schema(description="设备分组id")
|
||||
private Long hardGroupId;
|
||||
|
||||
/**
|
||||
* 绑定的部门id
|
||||
*/
|
||||
|
||||
+3
@@ -33,4 +33,7 @@ public interface RemoteMchService {
|
||||
@GetMapping("/mch-manage/get-first-mch")
|
||||
R<MchManageVo> getFirstMch(@RequestParam List<Long> deptIds);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/mch-manage/get-first-mch-by-dept-id")
|
||||
R<MchManageVo> getFirstMchByDeptId(@RequestParam Long deptId);
|
||||
}
|
||||
+8
@@ -80,6 +80,14 @@ public class MchManageController {
|
||||
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
|
||||
return R.ok(mchManage);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/get-first-mch-by-dept-id")
|
||||
public R<MchManageVo> getFirstMchByDeptId(@RequestParam Long deptId) {
|
||||
MchManageVo mchManage = mchManageService.getFirstMchByDeptId(deptId);
|
||||
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
|
||||
return R.ok(mchManage);
|
||||
}
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
|
||||
+2
@@ -28,4 +28,6 @@ public interface MchManageService extends IService<MchManageEntity> {
|
||||
MchManageVo getByDeptId(Long deptId);
|
||||
|
||||
MchManageVo getFirstMch(List<Long> deptIds);
|
||||
|
||||
MchManageVo getFirstMchByDeptId(Long deptId);
|
||||
}
|
||||
+11
-1
@@ -112,7 +112,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
@Override
|
||||
public void delByIds(ArrayList<Long> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
delByIds(list);
|
||||
baseMapper.deleteByIds(list);
|
||||
// 删除缓存
|
||||
list.forEach(v -> redisTemplate.opsForValue().getAndDelete(CacheConstants.WALLET_MCH + v));
|
||||
}
|
||||
@@ -189,6 +189,16 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MchManageVo getFirstMchByDeptId(Long deptId) {
|
||||
List<SysDept> parentDeptIdList = remoteDeptService.getParentDeptList(deptId).getData();
|
||||
if (ObjectUtil.isEmpty(parentDeptIdList)) {
|
||||
return null;
|
||||
}
|
||||
List<Long> deptIds = parentDeptIdList.stream().map(SysDept::getDeptId).toList();
|
||||
return getFirstMch(deptIds);
|
||||
}
|
||||
|
||||
private boolean existName(String name, Long id) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchManageEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(name), MchManageEntity::getName, name)
|
||||
|
||||
+10
-5
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.wallet.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.entity.SysUser;
|
||||
@@ -107,18 +108,22 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean cancelCode(Long id) {
|
||||
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(codeUse)) return false;
|
||||
WalletCodeUseEntity codeUse = baseMapper.selectOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
|
||||
.eq(WalletCodeUseEntity::getBizId, id)
|
||||
);
|
||||
if (ObjectUtil.isEmpty(codeUse)) return null;
|
||||
if (ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode())) return false;
|
||||
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().id(id).status(YesNoEnum.YES.getCode()).useTime(LocalDateTime.now()).build();
|
||||
WalletCodeUseEntity updateObj = WalletCodeUseEntity.builder().id(codeUse.getId()).status(YesNoEnum.YES.getCode()).useTime(LocalDateTime.now()).build();
|
||||
return baseMapper.updateById(updateObj) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean isCancelCode(Long id) {
|
||||
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(codeUse)) return false;
|
||||
WalletCodeUseEntity codeUse = baseMapper.selectOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
|
||||
.eq(WalletCodeUseEntity::getBizId, id)
|
||||
);
|
||||
if (ObjectUtil.isEmpty(codeUse)) return null;
|
||||
return ObjectUtil.equals(codeUse.getStatus(), YesNoEnum.YES.getCode());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user