| | |
| | | import cc.mrbird.febs.mall.dto.activity.ApiActivityOrderListDto; |
| | | import cc.mrbird.febs.mall.dto.activity.ApiCheckOrderDto; |
| | | import cc.mrbird.febs.mall.dto.activity.ApiVoteOptionInPageDto; |
| | | import cc.mrbird.febs.mall.dto.activity.ApiVoteOptionRecordInPageDto; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.HappyActivityService; |
| | |
| | | import cc.mrbird.febs.mall.vo.activity.ApiVoteActivityHotVo; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | |
| | | private final IXcxPayService iXcxPayService; |
| | | private final IApiMallMemberWalletService iApiMallMemberWalletService; |
| | | private final HappyActivityCategoryMapper happyActivityCategoryMapper; |
| | | private final AgentProducer agentProducer; |
| | | |
| | | @Override |
| | | public FebsResponse activityList(ApiActivityInfoDto dto) { |
| | |
| | | // 创建分页对象,传入当前页和每页大小 |
| | | Page<ApiActivityOptionListVo> page = new Page<>(dto.getPageNow(), dto.getPageSize()); |
| | | Page<ApiActivityOptionListVo> voteRecordInPage = this.baseMapper.getVoteOptionInPage(page, dto); |
| | | return new FebsResponse().success().data(voteRecordInPage); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse voteOptionRecordInPage(ApiVoteOptionRecordInPageDto dto) { |
| | | // 创建分页对象,传入当前页和每页大小 |
| | | Page<ApiActivityOptionListVo> page = new Page<>(dto.getPageNow(), dto.getPageSize()); |
| | | Page<ApiActivityOptionListVo> voteRecordInPage = this.baseMapper.getVoteOptionRecordInPage(page, dto); |
| | | return new FebsResponse().success().data(voteRecordInPage); |
| | | } |
| | | |
| | |
| | | HappyActivity happyActivity = this.baseMapper.selectById(activityId); |
| | | if (ObjectUtil.isEmpty(happyActivity)) { |
| | | throw new FebsException("活动不存在"); |
| | | } |
| | | if (StateUpDownEnum.ACTIVITY_STATE_NOT_START.getCode() == happyActivity.getState()) { |
| | | throw new FebsException("活动尚未开始"); |
| | | } |
| | | if (StateUpDownEnum.ACTIVITY_STATE_END.getCode() == happyActivity.getState()) { |
| | | throw new FebsException("活动已结束"); |
| | | } |
| | | |
| | | Integer joinCnt = happyActivity.getJoinCnt(); |
| | |
| | | happyActivityOrderItem.setTransferItemId(memberId); |
| | | happyActivityOrderItemMapper.updateById(happyActivityOrderItem); |
| | | |
| | | HappyActivity happyActivity = this.baseMapper.selectById(happyActivityOrderItem.getActivityId()); |
| | | agentProducer.sendCheckActivityItem(happyActivityOrderItem.getOrderId()); |
| | | |
| | | HappyActivity happyActivity = this.baseMapper.selectById(happyActivityOrderItem.getActivityId()); |
| | | ApiCheckOrderVo apiCheckOrderVo = new ApiCheckOrderVo(); |
| | | apiCheckOrderVo.setActivityName(happyActivity.getName()); |
| | | apiCheckOrderVo.setActivityStartTime(happyActivity.getStartTime()); |
| | |
| | | return new FebsResponse().fail().message("核销失败!"); |
| | | } |
| | | |
| | | /** |
| | | * 检查活动订单项的状态 |
| | | * 当指定订单的所有活动订单项都不处于"未使用"状态时,将订单状态更新为"已使用" |
| | | * |
| | | * @param orderId 订单ID,用于查询活动订单项和订单信息 |
| | | */ |
| | | @Override |
| | | public void checkActivityItem(Long orderId) { |
| | | // 查询指定订单ID的活动订单项数量,且状态为"未使用" |
| | | Integer integer = happyActivityOrderItemMapper.selectCount( |
| | | new LambdaQueryWrapper<HappyActivityOrderItem>() |
| | | .eq(HappyActivityOrderItem::getOrderId, orderId) |
| | | .eq(HappyActivityOrderItem::getState, StateUpDownEnum.DOWN.getCode()) |
| | | ); |
| | | // 如果没有找到任何未使用的活动订单项 |
| | | if(0 == integer){ |
| | | // 根据订单ID查询订单信息 |
| | | HappyActivityOrder happyActivityOrder = happyActivityOrderMapper.selectById(orderId); |
| | | if(happyActivityOrder == null){ |
| | | return; |
| | | } |
| | | // 更新订单状态为"已使用" |
| | | happyActivityOrder.setState(StateUpDownEnum.ORDER_STATE_USED.getCode()); |
| | | // 保存更新后的订单信息 |
| | | happyActivityOrderMapper.updateById(happyActivityOrder); |
| | | } |
| | | // 结束方法执行 |
| | | return; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse voteActivityHot(Long id) { |
| | | |
| | | ApiVoteActivityHotVo apiVoteActivityHotVo = new ApiVoteActivityHotVo(); |
| | | HappyActivity happyActivity = this.baseMapper.selectById(id); |
| | | apiVoteActivityHotVo.setStartTime(happyActivity.getStartTime()); |
| | | apiVoteActivityHotVo.setEndTime(happyActivity.getEndTime()); |
| | | |
| | | Integer optionCnt = happyActivityOptionMapper.selectCount( |
| | | new LambdaQueryWrapper<HappyActivityOption>() |