fix:创建钱包bug
create:晚上订餐、广播、取餐
This commit is contained in:
1 parent
934a70e0a0
commit
8a8c699757
14 files changed
+91
-14
No files matched your search
+9
@@ -32,5 +32,14 @@ public class HardBroadcastVo extends HardBroadcastEntity implements BaseHardInte
|
||||
|
||||
private String userDeptName;
|
||||
|
||||
/**
|
||||
* 订单相关
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
private String productDesc;
|
||||
|
||||
private String payPrice;
|
||||
|
||||
|
||||
}
|
||||
+17
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
@@ -22,6 +23,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -37,6 +39,21 @@ public class HardBroadcastController {
|
||||
|
||||
private final HardBroadcastService hardBroadcastService;
|
||||
|
||||
/* ************************************* start android start ************************************* */
|
||||
|
||||
@Operation(summary = "android查询今日的广播", description = "android查询今日的广播")
|
||||
@GetMapping("/ad/today")
|
||||
public R<Page<HardBroadcastVo>> androidToday(@ParameterObject Page page) {
|
||||
HardBroadcastDto dto = new HardBroadcastDto();
|
||||
DataScope dataScope = null;
|
||||
LocalDate today = LocalDate.now();
|
||||
dto.setIsDone(YesNoEnum.YES.getCode());
|
||||
dto.setCreateTimeList(new LocalDate[]{today, today.plusDays(1)});
|
||||
return R.ok(hardBroadcastService.scopePageJoin(page, dto, dataScope));
|
||||
}
|
||||
|
||||
/* ************************************* start android start ************************************* */
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page-join")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardBroadcast_view')")
|
||||
|
||||
+1
-1
@@ -21,5 +21,5 @@ public interface HardBroadcastService extends IService<HardBroadcastEntity> {
|
||||
/**
|
||||
* 完成硬件广播
|
||||
*/
|
||||
void doneBroadcast(HardOrderEntity orderdetail);
|
||||
void doneBroadcast(HardOrderEntity orderdetail, UserInfo userInfo);
|
||||
}
|
||||
+1
-1
@@ -73,7 +73,7 @@ public interface HardOrderService extends IService<HardOrderEntity> {
|
||||
/**
|
||||
* 核销二维码
|
||||
*/
|
||||
void cancelCode(HardOrderEntity order);
|
||||
void cancelCode(HardOrderEntity order, UserInfo userInfo);
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
|
||||
+20
-4
@@ -133,6 +133,7 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
msg.setProductDesc(orderdetail.getProductDesc());
|
||||
msg.setPayPrice(orderdetail.getPayPrice());
|
||||
msg.setHourType(orderdetail.getHourType());
|
||||
msg.setIsDone(saveObj.getIsDone());
|
||||
remoteMqttEventService.sendTakeFoodBroadcast(msg);
|
||||
}
|
||||
|
||||
@@ -140,7 +141,7 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
* 完成硬件广播
|
||||
*/
|
||||
@Override
|
||||
public void doneBroadcast(HardOrderEntity orderdetail) {
|
||||
public void doneBroadcast(HardOrderEntity orderdetail, UserInfo userInfo) {
|
||||
if (ObjectUtil.isEmpty(orderdetail)) return;
|
||||
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(orderdetail.getSysType());
|
||||
if (ObjectUtil.isEmpty(orderdetail)) {
|
||||
@@ -154,9 +155,7 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.notEqual(hardOrderType, HardOrderTypeEnum.RESERVE)) return;
|
||||
HardBroadcastEntity broadcastDetail = baseMapper.selectOne(new LambdaQueryWrapper<HardBroadcastEntity>()
|
||||
.eq(HardBroadcastEntity::getBizId, orderdetail.getId())
|
||||
);
|
||||
HardBroadcastEntity broadcastDetail = baseMapper.selectOne(new LambdaQueryWrapper<HardBroadcastEntity>().eq(HardBroadcastEntity::getBizId, orderdetail.getId()));
|
||||
if (ObjectUtil.isEmpty(broadcastDetail)) {
|
||||
log.error("|{}|doneBroadcast发送mq消息失败,广播不存在|{}|", TAG, orderdetail.getId());
|
||||
return;
|
||||
@@ -168,6 +167,23 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
|
||||
.isDoneTime(orderdetail.getCreateTime())
|
||||
.build();
|
||||
baseMapper.updateById(updateObj);
|
||||
// 发送mq
|
||||
String topic = broadcastDetail.getTopic().replaceAll("/#", "");
|
||||
HardTakeFoodBroadcastMsg msg = new HardTakeFoodBroadcastMsg();
|
||||
msg.setTopic(topic);
|
||||
msg.setAction(MqttActionEnum.TAKE_FOOD_BROADCAST);
|
||||
msg.setUserId(String.valueOf(userInfo.getSysUser().getUserId()));
|
||||
msg.setUsername(userInfo.getSysUser().getName());
|
||||
msg.setUserMobile(userInfo.getSysUser().getPhone());
|
||||
msg.setId(String.valueOf(broadcastDetail.getId()));
|
||||
msg.setTitle(broadcastDetail.getTitle());
|
||||
msg.setContent(broadcastDetail.getContent());
|
||||
msg.setBroadcastMaxCount(broadcastDetail.getBroadcastMaxCount());
|
||||
msg.setProductDesc(orderdetail.getProductDesc());
|
||||
msg.setPayPrice(orderdetail.getPayPrice());
|
||||
msg.setHourType(orderdetail.getHourType());
|
||||
msg.setIsDone(updateObj.getIsDone());
|
||||
remoteMqttEventService.sendTakeFoodBroadcast(msg);
|
||||
}
|
||||
|
||||
private void disposeList(List<HardBroadcastVo> list, HardBroadcastDto dto) {
|
||||
|
||||
+10
-2
@@ -592,12 +592,15 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 查询订单
|
||||
HardOrderEntity order = baseMapper.selectById(dto.getOrderId());
|
||||
if (ObjectUtil.isEmpty(order)) throw new RuntimeException("订单不存在");
|
||||
// 查询用户
|
||||
UserInfo userInfo = userService.getByUserId(order.getUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(userInfo)) throw new RuntimeException("用户不存在");
|
||||
// 判断是否被核销过
|
||||
HardOrderTypeEnum orderType = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
boolean isCancel = validateCodeIsCancel(orderType, order.getId());
|
||||
if (isCancel) throw new RuntimeException("该二维码已被核销");
|
||||
// 核销二维码
|
||||
getSelf().cancelCode(order);
|
||||
getSelf().cancelCode(order, userInfo);
|
||||
HardOrderEntity updateObj = HardOrderEntity.builder().id(order.getId()).androidOrderCode(dto.getAndroidOrderCode()).hardId(dto.getHardwareId()).orderStatus(HardOrderStatusEnum.CANCEL.getType()).build();
|
||||
return baseMapper.updateById(updateObj) > 0;
|
||||
}
|
||||
@@ -605,7 +608,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
@Override
|
||||
// @GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelCode(HardOrderEntity order) {
|
||||
public void cancelCode(HardOrderEntity order, UserInfo userInfo) {
|
||||
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
if (!ObjectUtil.isAllNotEmpty(orderTypeEnum)) return;
|
||||
Long id = order.getId();
|
||||
@@ -615,10 +618,15 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
}
|
||||
// 外来人员 | 跨单位 | 线上订餐
|
||||
case FOREIGN_TICKET, STRIDE_DEPT, RESERVE -> {
|
||||
// 核销二维码
|
||||
R<Boolean> result = remoteCodeUseService.cancelCode(id);
|
||||
if (ObjectUtil.isEmpty(result) || result.getCode() != 0 || !result.getData()) {
|
||||
throw new RuntimeException("核销二维码错误");
|
||||
}
|
||||
// 发送mq
|
||||
if (ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) {
|
||||
hardBroadcastService.doneBroadcast(order, userInfo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -76,8 +76,11 @@
|
||||
|
||||
<select id="scopePageJoin" resultType="com.bsd.pjcloud.hard.api.vo.HardBroadcastVo">
|
||||
<include refid="selectA"/>
|
||||
1
|
||||
o.id as orderId,
|
||||
o.product_desc as productDesc,
|
||||
o.pay_price as payPrice
|
||||
from hard_broadcast a
|
||||
left join hard_order o on o.id = a.biz_id
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<if test="dto.spuCategoryIdIsNotNull != null ">
|
||||
<if test="dto.spuCategoryIdIsNotNull == true ">
|
||||
and a.spu_category_id is not null
|
||||
and a.ks_status = 5
|
||||
</if>
|
||||
</if>
|
||||
<if test="dto.status != null and dto.status != '' ">
|
||||
|
||||
+5
@@ -61,4 +61,9 @@ public class HardTakeFoodBroadcastMsg extends MqttHardBaseMsg {
|
||||
*/
|
||||
private String hourType;
|
||||
|
||||
/**
|
||||
* 是否完成
|
||||
*/
|
||||
private String isDone;
|
||||
|
||||
}
|
||||
+3
@@ -191,6 +191,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
if (ObjectUtil.isEmpty(userRoles)) {
|
||||
return false;
|
||||
}
|
||||
// 如果是管理员,直接返回false
|
||||
boolean isAdmin = userRoles.stream().anyMatch(v -> ObjectUtil.equals(v.getRoleCode(), CommonRoleConstant.ROLE_ADMIN));
|
||||
if (isAdmin) return false;
|
||||
return userRoles.stream().anyMatch(v -> ObjectUtil.equals(v.getRoleCode(), CommonRoleConstant.DEPT_ADMIN));
|
||||
}
|
||||
|
||||
|
||||
+16
-5
@@ -59,6 +59,7 @@ import com.bsd.pjcloud.common.core.util.MsgUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
|
||||
import com.bsd.pjcloud.common.data.tenant.TenantContextHolder;
|
||||
import com.bsd.pjcloud.common.excel.vo.ErrorMessage;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
@@ -86,6 +87,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -198,9 +201,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
if (isDeptAdmin) {
|
||||
getSelf().applyFlow(sysUser);
|
||||
} else {
|
||||
// 创建用户默认钱包
|
||||
remoteWalletService.createWallet(sysUser.getUserId());
|
||||
remoteWalletService.userChange(sysUser.getUserId(), Boolean.FALSE);
|
||||
// 创建用户默认钱包、保证线程header
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
remoteWalletService.createWallet(sysUser.getUserId());
|
||||
remoteWalletService.userChange(sysUser.getUserId(), Boolean.FALSE);
|
||||
});
|
||||
}
|
||||
|
||||
return sysUser.getUserId();
|
||||
@@ -405,8 +412,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
|
||||
// 创建用户默认钱包
|
||||
remoteWalletService.createWallet(userDto.getUserId());
|
||||
remoteWalletService.userChange(userDto.getUserId(), Boolean.FALSE);
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
remoteWalletService.createWallet(userDto.getUserId());
|
||||
remoteWalletService.userChange(userDto.getUserId(), Boolean.FALSE);
|
||||
});
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ public interface RemoteWalletService {
|
||||
@GetMapping("/wallet-manage/get-wallet-by-card-number")
|
||||
R<WalletManageEntity> getWalletByCardNumber(@RequestParam String cardNumber);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/wallet-manage/create-wallet")
|
||||
R<WalletManageEntity> createWallet(@RequestParam Long userId);
|
||||
|
||||
|
||||
+1
@@ -72,6 +72,7 @@ public class WalletManageController {
|
||||
return R.ok(wallet);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/create-wallet")
|
||||
public R getWallet(@RequestParam Long userId) {
|
||||
walletManageService.createWallet(userId);
|
||||
|
||||
+2
@@ -27,6 +27,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.common.data.resolver.ParamResolver;
|
||||
import com.bsd.pjcloud.common.data.tenant.TenantContextHolder;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageBalanceDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
@@ -48,6 +49,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
|
||||
Reference in new issue
Block a user