| | |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cc.mrbird.febs.mall.dto.ApiOperateDoDto; |
| | | import cc.mrbird.febs.mall.vo.activity.ApiActivityOrderInfoVo; |
| | | import cc.mrbird.febs.mall.vo.activity.ApiActivityOrderListVo; |
| | | import cc.mrbird.febs.mall.vo.activity.ApiCheckOrderVo; |
| | | import cc.mrbird.febs.mall.vo.activity.ApiVoteActivityHotVo; |
| | | import cc.mrbird.febs.mall.vo.activity.*; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | |
| | | private final HappyActivityOptionMapper happyActivityOptionMapper; |
| | | private final HappyActivityConnectMapper happyActivityConnectMapper; |
| | | private final HappyActivityOrderMapper happyActivityOrderMapper; |
| | | private final HappyActivityCommentMapper happyActivityCommentMapper; |
| | | private final HappyActivityOrderItemMapper happyActivityOrderItemMapper; |
| | | private final IXcxPayService iXcxPayService; |
| | | private final IApiMallMemberWalletService iApiMallMemberWalletService; |
| | |
| | | ); |
| | | if(happyActivity != null){ |
| | | BeanUtil.copyProperties(happyActivity,apiActivityVo); |
| | | |
| | | Integer commentCount = happyActivityCommentMapper.selectCount( |
| | | new LambdaQueryWrapper<HappyActivityComment>() |
| | | .eq(HappyActivityComment::getActivityId, happyActivity.getId()) |
| | | .eq(HappyActivityComment::getShowState, StateUpDownEnum.UP.getCode()) |
| | | ); |
| | | apiActivityVo.setCommentCount(commentCount); |
| | | |
| | | List<HappyFollow> happyFollows = happyFollowMapper.selectList( |
| | | new LambdaQueryWrapper<HappyFollow>() |
| | | .select(HappyFollow::getId, HappyFollow::getType) |
| | |
| | | new LambdaQueryWrapper<HappyActivityConnect>() |
| | | .eq(HappyActivityConnect::getMemberId, memberId) |
| | | .eq(HappyActivityConnect::getName, dto.getName()) |
| | | .eq(HappyActivityConnect::getPhone, dto.getPhone()) |
| | | ); |
| | | if(CollUtil.isNotEmpty(happyActivityConnects)){ |
| | | throw new FebsException("已经添加过该联系人"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse expireOrder(ApiExpireOrderDto dto) { |
| | | if(CollUtil.isEmpty(dto.getIds())){ |
| | | throw new FebsException("请选择订单"); |
| | | } |
| | | |
| | | dto.getIds().forEach(id -> { |
| | | HappyActivityOrder happyActivityOrder = happyActivityOrderMapper.selectById(id); |
| | | if(ObjectUtil.isNotEmpty(happyActivityOrder)){ |
| | | Long activityId = happyActivityOrder.getActivityId(); |
| | | Integer numCnt = happyActivityOrder.getNumCnt(); |
| | | this.baseMapper.updateHappyActivitySurplusCnt(activityId,numCnt); |
| | | |
| | | happyActivityOrder.setState(StateUpDownEnum.ORDER_STATE_OVERTIME.getCode()); |
| | | happyActivityOrderMapper.updateById(happyActivityOrder); |
| | | } |
| | | }); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse createOrder(ApiCreateOrderDto dto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | if(CollUtil.isEmpty(dto.getConnectIds())){ |
| | |
| | | } |
| | | |
| | | Long activityId = dto.getActivityId(); |
| | | |
| | | List<HappyActivityOrderItem> happyActivityOrderItems = happyActivityOrderItemMapper.selectList( |
| | | new LambdaQueryWrapper<HappyActivityOrderItem>() |
| | | .eq(HappyActivityOrderItem::getActivityId, activityId) |
| | | .in(HappyActivityOrderItem::getConnectId, connectIds) |
| | | ); |
| | | if(CollUtil.isNotEmpty(happyActivityOrderItems)){ |
| | | //stream流操作happyActivityOrderItems,返回一个orderId的Set集合 |
| | | Set<Long> orderIdSet = happyActivityOrderItems.stream().map(HappyActivityOrderItem::getOrderId).collect(Collectors.toSet()); |
| | | List<HappyActivityOrder> happyActivityOrders = happyActivityOrderMapper.selectList( |
| | | new LambdaQueryWrapper<HappyActivityOrder>() |
| | | .in(HappyActivityOrder::getId, orderIdSet) |
| | | .in(HappyActivityOrder::getState, Arrays.asList(StateUpDownEnum.ORDER_STATE_WAIT_PAY.getCode(),StateUpDownEnum.ORDER_STATE_WAIT_USE.getCode())) |
| | | ); |
| | | if(CollUtil.isNotEmpty(happyActivityOrders)){ |
| | | throw new FebsException("有报名人重复报名了活动,请重新选择"); |
| | | } |
| | | } |
| | | HappyActivity happyActivity = this.baseMapper.selectById(activityId); |
| | | if (ObjectUtil.isEmpty(happyActivity)) { |
| | | throw new FebsException("活动不存在"); |
| | |
| | | if(amount.compareTo(BigDecimal.ZERO) < 0){ |
| | | throw new FebsException("支付金额错误"); |
| | | } |
| | | DateTime failTime = DateUtil.offsetMinute(new Date(), StateUpDownEnum.ORDER_OVERTIME.getCode()); |
| | | HappyActivityOrder happyActivityOrder = new HappyActivityOrder(); |
| | | happyActivityOrder.setOrderNo(MallUtils.getOrderNum()); |
| | | happyActivityOrder.setMemberId(memberId); |
| | |
| | | happyActivityOrder.setNumCnt(dto.getNumCnt()); |
| | | happyActivityOrder.setAmount(amount); |
| | | happyActivityOrder.setPayState(StateUpDownEnum.PAY_STATE_NOT_PAY.getCode()); |
| | | happyActivityOrder.setPayType(StateUpDownEnum.PAY_METHOD_WECHAT.getCode()); |
| | | happyActivityOrder.setFailTime(failTime); |
| | | log.info("创建订单,订单号="+JSONUtil.parse(happyActivityOrder)); |
| | | happyActivityOrderMapper.insert(happyActivityOrder); |
| | | |
| | | for(Long connectId : connectIds){ |
| | |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(); |
| | | stringObjectHashMap.put("orderId",happyActivityOrder.getId()); |
| | | stringObjectHashMap.put("amount",amount); |
| | | stringObjectHashMap.put("failTime",failTime); |
| | | |
| | | return new FebsResponse().success().data(stringObjectHashMap); |
| | | } |
| | |
| | | log.error("支付失败,订单ID:{},支付类型:{}", orderId, payType, e); |
| | | throw new FebsException("支付失败:" + e.getMessage()); |
| | | } |
| | | |
| | | // todo 支付失败要把对应的人数加回来 |
| | | |
| | | // 构造返回结果,包含支付相关信息 |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | |
| | | LambdaQueryWrapper<HappyActivityOrder> happyActivityOrderLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | happyActivityOrderLambdaQueryWrapper.eq(HappyActivityOrder::getMemberId, memberId); |
| | | if(ObjectUtil.isNotEmpty(dto.getState())){ |
| | | if(ObjectUtil.isNotEmpty(dto.getState()) && dto.getState() != 0){ |
| | | happyActivityOrderLambdaQueryWrapper.eq(HappyActivityOrder::getState, dto.getState()); |
| | | } |
| | | happyActivityOrderLambdaQueryWrapper.eq(HappyActivityOrder::getDeleteFlag, StateUpDownEnum.DOWN.getCode()); |
| | |
| | | List<HappyActivity> happyActivities = this.baseMapper.selectList( |
| | | new LambdaQueryWrapper<HappyActivity>() |
| | | .select( |
| | | HappyActivity::getId, |
| | | HappyActivity::getCategoryId, |
| | | HappyActivity::getName, |
| | | HappyActivity::getStartTime, |
| | |
| | | |
| | | List<HappyActivityOrderItem> happyActivityOrderItems = happyActivityOrderItemMapper.selectList( |
| | | new LambdaQueryWrapper<HappyActivityOrderItem>() |
| | | .eq(HappyActivityOrderItem::getOrderId, happyActivityOrder.getActivityId()) |
| | | .eq(HappyActivityOrderItem::getOrderId, happyActivityOrder.getId()) |
| | | .eq(HappyActivityOrderItem::getMemberId, memberId) |
| | | ); |
| | | if(CollUtil.isNotEmpty(happyActivityOrderItems)){ |
| | |
| | | .last("limit 1") |
| | | ); |
| | | if(happyActivityOrderItem != null){ |
| | | happyActivityOrderItem.setState(StateUpDownEnum.UP.getCode()); |
| | | happyActivityOrderItem.setTransferItemId(memberId); |
| | | happyActivityOrderItemMapper.updateById(happyActivityOrderItem); |
| | | |
| | | agentProducer.sendCheckActivityItem(happyActivityOrderItem.getOrderId()); |
| | | if(StateUpDownEnum.UP.getCode() == happyActivityOrderItem.getState()){ |
| | | throw new FebsException("该票号已核销!"); |
| | | } |
| | | |
| | | HappyActivity happyActivity = this.baseMapper.selectById(happyActivityOrderItem.getActivityId()); |
| | | ApiCheckOrderVo apiCheckOrderVo = new ApiCheckOrderVo(); |
| | |
| | | apiCheckOrderVo.setName(happyActivityOrderItem.getName()); |
| | | apiCheckOrderVo.setPhone(happyActivityOrderItem.getPhone()); |
| | | apiCheckOrderVo.setPrice(happyActivityOrderItem.getPrice()); |
| | | apiCheckOrderVo.setState(happyActivityOrderItem.getState()); |
| | | |
| | | return new FebsResponse().success().data(apiCheckOrderVo); |
| | | } |
| | | |
| | | return new FebsResponse().fail().message("核销失败!"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse insureOrder(ApiCheckOrderDto dto) { |
| | | // 获取当前登录用户的ID |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | |
| | | MallMember mallMember = mallMemberMapper.selectById(memberId); |
| | | |
| | | if(StateUpDownEnum.UP.getCode() != mallMember.getCheckOrder()){ |
| | | throw new FebsException("您不是核销员!"); |
| | | } |
| | | |
| | | String orderItemCode = dto.getOrderItemCode(); |
| | | |
| | | HappyActivityOrderItem happyActivityOrderItem = happyActivityOrderItemMapper.selectOne( |
| | | new LambdaQueryWrapper<HappyActivityOrderItem>() |
| | | .eq(HappyActivityOrderItem::getCode, orderItemCode) |
| | | .eq(HappyActivityOrderItem::getState, StateUpDownEnum.DOWN.getCode()) |
| | | .last("limit 1") |
| | | ); |
| | | if(happyActivityOrderItem != null){ |
| | | if(StateUpDownEnum.UP.getCode() == happyActivityOrderItem.getState()){ |
| | | throw new FebsException("该票号已核销!"); |
| | | } |
| | | |
| | | happyActivityOrderItem.setState(StateUpDownEnum.UP.getCode()); |
| | | happyActivityOrderItem.setTransferItemId(memberId); |
| | | happyActivityOrderItemMapper.updateById(happyActivityOrderItem); |
| | | agentProducer.sendCheckActivityItem(happyActivityOrderItem.getOrderId()); |
| | | } |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | /** |
| | |
| | | List<HappyActivityOrder> happyActivityOrders = happyActivityOrderMapper.selectList( |
| | | new LambdaQueryWrapper<HappyActivityOrder>() |
| | | .eq(HappyActivityOrder::getState, StateUpDownEnum.ORDER_STATE_WAIT_PAY.getCode()) |
| | | .lt(HappyActivityOrder::getCreatedTime, DateUtil.offsetMinute(new Date(), -10)) |
| | | .lt(HappyActivityOrder::getFailTime, new Date()) |
| | | ); |
| | | if(CollUtil.isNotEmpty(happyActivityOrders)){ |
| | | happyActivityOrders.forEach(happyActivityOrder -> { |
| | |
| | | Long activityId = happyActivityOrder.getActivityId(); |
| | | Integer numCnt = happyActivityOrder.getNumCnt(); |
| | | this.baseMapper.updateHappyActivitySurplusCnt(activityId,numCnt); |
| | | }); |
| | | |
| | | happyActivityOrder.setState(StateUpDownEnum.ORDER_STATE_OVERTIME.getCode()); |
| | | happyActivityOrderMapper.updateById(happyActivityOrder); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse addComment(ApiPayOrderAddCommentDto dto) { |
| | | // 获取当前登录用户的ID |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | Long orderId = dto.getOrderId(); |
| | | |
| | | HappyActivityOrder happyActivityOrder = happyActivityOrderMapper.selectById(orderId); |
| | | if(StateUpDownEnum.ORDER_STATE_USED.getCode() != happyActivityOrder.getState()){ |
| | | throw new FebsException("该订单状态不是已使用状态!"); |
| | | } |
| | | |
| | | happyActivityOrder.setState(StateUpDownEnum.ORDER_STATE_COMMENT.getCode()); |
| | | happyActivityOrderMapper.updateById(happyActivityOrder); |
| | | |
| | | HappyActivity happyActivity = this.baseMapper.selectById(happyActivityOrder.getActivityId()); |
| | | |
| | | HappyActivityComment happyActivityComment = new HappyActivityComment(); |
| | | happyActivityComment.setActivityId(happyActivity.getId()); |
| | | happyActivityComment.setActivityName(happyActivity.getName()); |
| | | happyActivityComment.setMemberId(memberId); |
| | | happyActivityComment.setOrderId(orderId); |
| | | happyActivityComment.setStar(dto.getStar()); |
| | | happyActivityComment.setComment(dto.getComment()); |
| | | happyActivityComment.setImages(dto.getImages()); |
| | | happyActivityCommentMapper.insert(happyActivityComment); |
| | | |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiActivityCommentVo> commentByActivityId(ApiActivityCommentDto dto) { |
| | | Page<ApiActivityCommentVo> page = new Page<>(dto.getPageNow(), dto.getPageSize()); |
| | | return this.baseMapper.selectActivityCommentPage(page,dto); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse voteActivityHot(Long id) { |
| | | |
| | | ApiVoteActivityHotVo apiVoteActivityHotVo = new ApiVoteActivityHotVo(); |