From bda6cd23ba9af8a09ec5e4202ce4fafb1933c39a Mon Sep 17 00:00:00 2001
From: lidongdong <1459917685@qq.com>
Date: 星期三, 06 三月 2024 14:59:56 +0800
Subject: [PATCH] 修改参加活动金汇币明细报错4
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java | 305 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 305 insertions(+), 0 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
index 288f7fe..a26b627 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
@@ -22,11 +22,17 @@
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.hutool.core.collection.CollUtil;
import com.panzhihua.common.constants.HttpStatus;
+import com.panzhihua.common.model.dtos.PageBaseDTO;
import com.panzhihua.common.model.dtos.community.ActivityInviteDTO;
+import com.panzhihua.common.model.vos.jinhui.JinhuiCoinGeneralTableVO;
+import com.panzhihua.common.model.vos.jinhui.JinhuiGoldCoinRecordVO;
+import com.panzhihua.common.service.jinhui.JinhuiCommunityService;
+import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.ComActNeighborCircleDAO;
import com.panzhihua.service_community.dao.ComActNeighborCircleTopicWestMapper;
import com.panzhihua.service_community.dao.ComPbMemberDAO;
import com.panzhihua.service_community.entity.ComActActivityInvite;
+import com.panzhihua.service_community.entity.JinhuiCoinGeneralTable;
import com.panzhihua.service_community.model.dos.ComActNeighborCircleTopicWestDO;
import com.panzhihua.service_community.service.ComActActivityInviteService;
import com.panzhihua.service_community.util.WxMaConfiguration;
@@ -144,6 +150,8 @@
private ComActNeighborCircleDAO comActNeighborCircleDAO;
@Resource
private WxMaConfiguration wxMaConfiguration;
+ @Resource
+ private JinhuiCommunityService jinhuiCommunityService;
/**
* 新增社区活动
@@ -690,6 +698,7 @@
comActActSignDO.setStatus(0);
comActActSignDO.setReason(signactivityVO.getReason());
num = comActActSignDAO.updateById(comActActSignDO);
+ //计算用户积分
if (num > 0) {
AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO();
addComActIntegralUserDTO.setUserId(userId);
@@ -1303,4 +1312,300 @@
}
return partyActivityLines;
}
+
+ @Override
+ public R pageActivityBigScreen(PageBaseDTO pageBaseDTO) {
+ return R.ok(comActActivityDAO.pageActivityBigScreen(new Page<>(pageBaseDTO.getPageNum(),pageBaseDTO.getPageSize())));
+ }
+
+ @Override
+ public R jinhuiSignActivity(SignactivityVO signactivityVO) {
+ Long activityId = signactivityVO.getActivityId();
+ Integer type = signactivityVO.getType();
+ Long userId = signactivityVO.getUserId();
+ Integer isVolunteer = 0;
+ // 查询社区活动
+ ComActActivityDO actActivityDO = this.baseMapper.selectById(activityId);
+ if (isNull(actActivityDO)) {
+ return R.fail("活动不存在");
+ }
+ if(actActivityDO.getSignUpBegin().after(new Date())){
+ return R.fail("未到报名时间");
+ }
+ int num = 0;
+ ComActActSignDO comActActSignDO = comActActSignDAO.selectOne(new QueryWrapper<ComActActSignDO>()
+ .lambda().eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getUserId, userId));
+ Integer signIdentity = signactivityVO.getSignIdentity();
+ if (1 == type) {
+ if (nonNull(comActActSignDO) && comActActSignDO.getStatus().equals(1)) {
+ return R.fail("已经报名过了,请勿重复提交");
+ }
+ Integer activityType = actActivityDO.getType();
+ Boolean isInvite = false;
+ if (activityType == 1) {
+ if (signIdentity == 1) {
+ //以居民身份参与活动
+ Integer residentMax = actActivityDO.getParticipantMax();
+ if (residentMax == null) {
+ return R.fail("活动暂未对居民开放");
+ }
+ // 查询当前活动下参与居民
+ Integer residentCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda()
+ .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getSignIdentity, 1).eq(ComActActSignDO::getStatus, 1));
+ if (residentMax != -1 && residentMax <= residentCount) {
+ return R.fail("报名人数已满");
+ }
+ } else if (signIdentity == 2) {
+ //以党员身份参与活动
+ Integer partyMemberMax = actActivityDO.getPartyMemberMax();
+ if (partyMemberMax == null) {
+ return R.fail("活动暂未对党员开放");
+ }
+ ComActActivityInvite activityInvite = comActActivityInviteService.getBaseMapper().selectOne(new LambdaQueryWrapper<ComActActivityInvite>()
+ .eq(ComActActivityInvite::getActivityId, activityId).eq(ComActActivityInvite::getUserId, userId));
+ if (isNull(activityInvite)) {
+ int count = pbMemberDAO.checkIsPbMember(userId);
+ if (count < 1) {
+ return R.fail(HttpStatus.NOT_ACCEPTABLE, "您还不是党员");
+ }
+ // 查询当前活动下参与志愿者
+ Integer partyMemberCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda()
+ .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getSignIdentity, 2)
+ .eq(ComActActSignDO::getStatus, 1).eq(ComActActSignDO::getIsInvite, false));
+ if (partyMemberMax != -1 && partyMemberMax <= partyMemberCount) {
+ return R.fail("报名人数已满");
+ }
+ } else {
+ isInvite = true;
+ }
+ } else {
+ //以志愿者身份参与活动
+ Integer volunteerMax = actActivityDO.getVolunteerMax();
+ if (volunteerMax == null) {
+ return R.fail("活动暂未对志愿者开放");
+ }
+ int count = pbMemberDAO.checkIsVolunteer(userId);
+ if (count < 1) {
+ return R.fail(HttpStatus.NOT_ACCEPTABLE, "您还不是志愿者");
+ }
+ // 查询当前活动下参与志愿者
+ Integer volunteerCount = comActActSignDAO.selectCount(new QueryWrapper<ComActActSignDO>().lambda()
+ .eq(ComActActSignDO::getActivityId, activityId).eq(ComActActSignDO::getSignIdentity, 3).eq(ComActActSignDO::getStatus, 1));
+ if (volunteerMax != -1 && volunteerMax <= volunteerCount) {
+ return R.fail("报名人数已满");
+ }
+ }
+ }
+ if (nonNull(comActActSignDO)) {
+ comActActSignDO.setStatus(1);
+ comActActSignDO.setCreateAt(new Date());
+ comActActSignDO.setReason(null);
+ comActActSignDO.setSignIdentity(signIdentity);
+ comActActSignDO.setTimes(comActActSignDO.getTimes()+1);
+ comActActSignDO.setIsInvite(isInvite);
+ comActActSignDO.setCheckUnitId(signactivityVO.getCheckUnitId());
+ num = comActActSignDAO.updateById(comActActSignDO);
+ } else {
+ comActActSignDO = new ComActActSignDO();
+ comActActSignDO.setActivityId(activityId);
+ comActActSignDO.setUserId(userId);
+ comActActSignDO.setSignIdentity(signIdentity);
+ comActActSignDO.setTimes(1);
+ comActActSignDO.setIsInvite(isInvite);
+ comActActSignDO.setCheckUnitId(signactivityVO.getCheckUnitId());
+ num = comActActSignDAO.insert(comActActSignDO);
+ }
+ } else {
+ Integer regTimes = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>().lambda()
+ .eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getType, 1));
+ Integer canCancel = actActivityDO.getCanCancel();
+ if (nonNull(canCancel) && canCancel.equals(2)) {
+ return R.fail("该活动暂不支持取消");
+ }
+ if (regTimes > 0) {
+ return R.fail("您已参与活动,不可取消");
+ }
+ if (isNull(signactivityVO.getReason())) {
+ return R.fail("缺少取消原因");
+ }
+ if (isNull(comActActSignDO)) {
+ return R.fail("未报名");
+ }
+ comActActSignDO.setStatus(0);
+ comActActSignDO.setReason(signactivityVO.getReason());
+ num = comActActSignDAO.updateById(comActActSignDO);
+ //计算用户金汇币
+ if (num > 0)
+ {
+ if(!StringUtils.isEmpty(actActivityDO.getJinhuiCoinPunishment()) && !StringUtils.equals(actActivityDO.getJinhuiCoinPunishment(),"0"))
+ {
+ //查询个人金汇币总额
+ R<JinhuiCoinGeneralTable> jinhuiCoinGeneralTable=jinhuiCommunityService.coinTableGetDetails(userId+"");
+ if(jinhuiCoinGeneralTable!=null)
+ {
+ if (!StringUtils.isEmpty(jinhuiCoinGeneralTable.getData().getGoldCoin()))
+ {
+ JinhuiCoinGeneralTableVO jinhuiVO=new JinhuiCoinGeneralTableVO();
+ jinhuiVO.setId(jinhuiCoinGeneralTable.getData().getId());
+
+ int punishmentGold=Integer.valueOf(actActivityDO.getJinhuiCoinPunishment());
+ int allGold=Integer.valueOf(jinhuiCoinGeneralTable.getData().getGoldCoin());
+ if(punishmentGold>=allGold)
+ {
+ jinhuiVO.setGoldCoin("0");
+ }
+ else
+ {
+ allGold=allGold-punishmentGold;
+ jinhuiVO.setGoldCoin(allGold+"");
+ }
+ jinhuiCommunityService.coinTableEditData(jinhuiVO);
+ }
+ }
+
+ JinhuiGoldCoinRecordVO jVo=new JinhuiGoldCoinRecordVO();
+ jVo.setCommunityId(actActivityDO.getCommunityId()+"");
+ jVo.setTitle("取消志愿者活动");
+ jVo.setUserId(userId+"");
+ jVo.setRemark("取消志愿者活动");
+ jVo.setType("2");
+ jVo.setGoldCoin(actActivityDO.getJinhuiCoinPunishment());
+ jinhuiCommunityService.recordAddData(jVo);
+
+
+ }
+ }
+ }
+ if (num > 0) {
+ return R.ok(isVolunteer);
+ }
+ return R.fail();
+ }
+
+ @Override
+ public R jinhuiActivitySignIn(ComActActRegistVO comActActRegistVO) {
+ Long activityId = comActActRegistVO.getActivityId();
+ Long userId = comActActRegistVO.getUserId();
+ if (isNull(activityId)) {
+ return R.fail("签到所属活动id不能为空!");
+ }
+ ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId);
+ if (isNull(comActActivityDO)) {
+ return R.fail("活动不存在!");
+ }
+
+ ComActActSignDO comActActSignDO = comActActSignDAO
+ .selectOne(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getActivityId, activityId)
+ .eq(ComActActSignDO::getUserId, userId).eq(ComActActSignDO::getStatus, 1));
+ if (isNull(comActActSignDO)) {
+ return R.fail("活动未报名");
+ }
+
+ Date beginAt = comActActivityDO.getBeginAt();
+ Date endAt = comActActivityDO.getEndAt();
+ Date nowDate = new Date();
+ if (nowDate.before(beginAt) || nowDate.after(endAt)) {
+ return R.fail("不在活动时间范围内");
+ }
+ //奖励的金汇币
+ Integer rewardIntegral = Integer.valueOf(comActActivityDO.getJinhuiCoinAward());
+ boolean isHave = rewardIntegral > 0;
+ ComActActRegistDO comActActRegistDO = new ComActActRegistDO();
+ if (comActActRegistVO.getSignType() != null && comActActRegistVO.getSignType() == 2) {
+ ComActActRegistDO comActActActRegistDO = comActActRegistDAO.selectOne(new QueryWrapper<ComActActRegistDO>()
+ .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId)
+ .eq(ComActActRegistDO::getCodeId, comActActRegistVO.getCodeId()));
+ if (comActActActRegistDO == null) {
+ return R.fail("未签到无法签退");
+ }
+ if (comActActActRegistDO.getEndTime() != null) {
+ return R.fail("无法重复签退");
+ }
+ comActActRegistDO.setId(comActActActRegistDO.getId());
+ comActActRegistDO.setEndTime(nowDate);
+ comActActRegistDO.setAward(0);
+ int result = comActActRegistDAO.updateById(comActActRegistDO);
+ if (result > 0) {
+ if (isHave) {
+// AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO();
+// addComActIntegralUserDTO.setUserId(userId);
+// addComActIntegralUserDTO.setIntegralType(integralType);
+// addComActIntegralUserDTO.setIntegral(retrieveIntegral);
+// addComActIntegralUserDTO.setSignIdentity(comActActSignDO.getSignIdentity());
+// addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId());
+// addComActIntegralUserDTO.setServiceId(activityId);
+// addComActIntegralUserDTO.setRemark(remark);
+// comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO);
+
+ //查询个人金汇币总额
+ R<JinhuiCoinGeneralTable> jinhuiCoinGeneralTable=jinhuiCommunityService.coinTableGetDetails(userId+"");
+ JinhuiCoinGeneralTable table=jinhuiCoinGeneralTable.getData();
+ if(table!=null)
+ {
+ JinhuiCoinGeneralTableVO jinhuiVO=new JinhuiCoinGeneralTableVO();
+ jinhuiVO.setId(table.getId());
+ int allGold=0;
+ if (!StringUtils.isEmpty(table.getGoldCoin()))
+ {
+ allGold=Integer.valueOf(table.getGoldCoin());
+ }
+ allGold=allGold+rewardIntegral;
+ jinhuiVO.setGoldCoin(allGold+"");
+ jinhuiCommunityService.coinTableEditData(jinhuiVO);
+ }
+ else
+ {
+ JinhuiCoinGeneralTableVO jinhuiVO=new JinhuiCoinGeneralTableVO();
+ jinhuiVO.setCommunityId(comActActivityDO.getCommunityId()+"");
+ jinhuiVO.setGoldCoin(rewardIntegral+"");
+ jinhuiVO.setUserId(userId+"");
+ jinhuiCommunityService.coinTableAddData(jinhuiVO);
+ }
+
+ JinhuiGoldCoinRecordVO jVo=new JinhuiGoldCoinRecordVO();
+ jVo.setCommunityId(comActActivityDO.getCommunityId()+"");
+ jVo.setTitle("志愿者活动奖励");
+ jVo.setUserId(userId+"");
+ jVo.setRemark("志愿者活动奖励");
+ jVo.setType("1");
+ jVo.setGoldCoin(rewardIntegral+"");
+ jinhuiCommunityService.recordAddData(jVo);
+ return R.ok();
+ } else {
+ return R.ok();
+ }
+ }
+ } else {
+ int signDayCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>().lambda()
+ .eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId)
+ .eq(ComActActRegistDO::getCodeId, comActActRegistVO.getCodeId()));
+ int signAllCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>().lambda()
+ .eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId));
+ if (signDayCount > 0) {
+ return R.fail("请扫描新的签到码");
+ }
+ if (isHave) {
+ int limit = comActActivityDO.getLimit().intValue();
+ if (limit != -1 && signAllCount >= limit) {
+ return R.fail("签到次数上限");
+ }
+ }
+ comActActRegistDO.setActivityId(activityId);
+ comActActRegistDO.setStartTime(new Date());
+ comActActRegistDO.setType(comActActivityDO.getType());
+ comActActRegistDO.setUserId(userId);
+ comActActRegistDO.setSignIdentity(comActActSignDO.getSignIdentity());
+ comActActRegistDO.setCreateAt(nowDate);
+ comActActRegistDO.setCodeId(comActActRegistVO.getCodeId());
+ comActActRegistDO.setAward(0);
+ comActActRegistDO.setPosition(comActActRegistVO.getPosition());
+ comActActRegistDO.setCheckUnitId(comActActSignDO.getCheckUnitId());
+ comActActRegistDO.setTimes(signAllCount + 1);
+ int result = comActActRegistDAO.insert(comActActRegistDO);
+ if (result > 0) {
+ return R.ok();
+ }
+ }
+ return R.fail("网络错误,请重试");
+ }
}
--
Gitblit v1.7.1