springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/integral/admin/AddComActIntegralUserDTO.java
@@ -29,6 +29,8 @@ @ApiModelProperty(value = "是否是志愿者 0 不是 1 是") private Integer isVolunteer; private Integer integralPartyTime; public AddComActIntegralUserDTO(Long serviceId, Integer integralType, Long communityId, Long userId) { this.serviceId = serviceId; this.integralType = integralType; springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComActActRegistVO.java
@@ -88,4 +88,7 @@ @ApiModelProperty("签到结束时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date endTime; @ApiModelProperty("1签到 2签退") private Integer signType; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/PartyActivityLine.java
New file @@ -0,0 +1,17 @@ package com.panzhihua.common.model.vos.community; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author zzj */ @Data @ApiModel("党员活动柱状图") public class PartyActivityLine { @ApiModelProperty("月份") private String x; @ApiModelProperty("数量") private Integer y; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/PartyActivityStatics.java
@@ -1,12 +1,23 @@ package com.panzhihua.common.model.vos.community; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; /** * @author zzj */ @Data @ApiModel("") @ApiModel("党员统计") public class PartyActivityStatics { @ApiModelProperty("活动总数") private Integer activityCount; @ApiModelProperty("党员总数") private Integer memberCount; @ApiModelProperty("活动饼状图") private List<PartyActivityTypeChart> partyActivityTypeChartList; @ApiModelProperty("活动柱状图") private List<PartyActivityLine> partyActivityLines; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/PartyActivityTypeChart.java
New file @@ -0,0 +1,19 @@ package com.panzhihua.common.model.vos.community; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author zzj */ @Data @ApiModel("党员活动类型饼状图") public class PartyActivityTypeChart { @ApiModelProperty("名称") private String name; @ApiModelProperty("数量") private Integer count; @ApiModelProperty("百分比") private Integer percent; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -9329,4 +9329,7 @@ */ @PostMapping("/fms/service/defaultPraise") R timedTaskFmsServiceDefaultPraise(); @GetMapping("/activity/partyMemberCount") R partyMemberCount(@RequestParam("communityId")Long communityId,@RequestParam("year")String year); } springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityActivityApi.java
@@ -20,6 +20,7 @@ import javax.annotation.Resource; import javax.validation.Valid; import com.panzhihua.common.model.vos.community.*; import com.panzhihua.common.model.vos.community.ComActActivityTypeVO; import com.panzhihua.common.model.vos.user.SysTemplateConfigVO; import io.swagger.annotations.ApiImplicitParams; @@ -48,18 +49,6 @@ import com.panzhihua.common.model.dtos.community.integral.admin.AddComActIntegralUserDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ActivitySignVO; import com.panzhihua.common.model.vos.community.ComActActEvaluateExcelVO; import com.panzhihua.common.model.vos.community.ComActActEvaluateVO; import com.panzhihua.common.model.vos.community.ComActActPictureVO; import com.panzhihua.common.model.vos.community.ComActActRegistExcelVO; import com.panzhihua.common.model.vos.community.ComActActRegistVO; import com.panzhihua.common.model.vos.community.ComActActSignExcelVO; import com.panzhihua.common.model.vos.community.ComActActivityStatisticsVO; import com.panzhihua.common.model.vos.community.ComActActivityVO; import com.panzhihua.common.model.vos.community.ComActDynVO; import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO; import com.panzhihua.common.model.vos.community.ComActMicroWishVO; import com.panzhihua.common.model.vos.community.easyPhoto.ComActEasyPhotoClassifyVO; import com.panzhihua.common.model.vos.community.easyPhoto.ComActEasyPhotoStatisticsVO; import com.panzhihua.common.model.vos.community.easyPhoto.ExportEasyPhotoVO; @@ -1111,4 +1100,16 @@ } return communityService.listActivityType(communityId, type); } /** * 党员活动统计 * @param year * @return */ @ApiOperation(value = "党员活动统计",response = PartyActivityStatics.class) @GetMapping("activity/partyMemberCount") public R partyMemberCount(@RequestParam("year")String year){ return communityService.partyMemberCount(this.getCommunityId(),year); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommunityApi.java
@@ -2560,4 +2560,15 @@ public String getActBelongRegionCode(@RequestParam("communityId") Long communityId) { return comActActivityService.getActBelongRegionCode(communityId); } /** * 党员活动统计 * @param communityId * @param year * @return */ @GetMapping("activity/partyMemberCount") public R partyMemberCount(@RequestParam("communityId")Long communityId,@RequestParam("year")String year){ return comActActivityService.partyMemberCount(communityId,year); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActActivityDAO.java
@@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import com.panzhihua.common.model.vos.community.*; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -291,4 +292,28 @@ * @date 2022/2/17 10:09 */ String getActBelongRegionCode(@Param("communityId") Long communityId); /** * 查询党员活动数量 * @param communityId * @return */ PartyActivityStatics selectActivityStatics(Long communityId); /** * 党员活动饼状图 * @param communityId * @return */ List<PartyActivityTypeChart> selectActivityChart(Long communityId); /** * 党员活动柱状图 * @param communityId * @param year * @param date * @return */ Integer selectActivityLine(@Param("communityId") Long communityId,@Param("year")String year,@Param("date")String date); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActRaffleRecordDao.java
@@ -52,5 +52,13 @@ * @param id * @return */ ComActRaffleRecordVO selectById(Long id); ComActRaffleRecordVO selectOneById(Long id); /** * 抽奖活动失效设置 * @param id * @return */ Integer updateStatusByRaffleId(Long id); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/message/RaffleMessage.java
@@ -66,6 +66,10 @@ } comActRaffle.setStatus(3); comActRaffleDao.updateById(comActRaffle); rabbitTemplate.convertAndSend("raffle.exchange", "raffle.key", comActRaffleVO, message -> { message.getMessageProperties().setHeader("x-delay", dateToSecond(comActRaffle.getRaffleStopTime())); return message; }); } if(comActRaffle!=null&&comActRaffle.getStatus()==0&&comActRaffle.getStartTime().before(new Date())){ comActRaffle.setStatus(1); @@ -83,6 +87,9 @@ return message; }); } if(comActRaffle!=null&&comActRaffle.getStatus()==3&&comActRaffle.getRaffleStopTime().before(new Date())){ comActRaffleRecordDao.updateStatusByRaffleId(comActRaffle.getId()); } } private Long dateToSecond(Date expireTime){ return DateUtil.between(new Date(),expireTime, DateUnit.MS); springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComActIntegralUserDO.java
@@ -112,6 +112,8 @@ */ private Integer status; private Integer integralPartyTime; @Override public String toString() { return "ComActIntegralUserDO{" + "id=" + id + ", userId=" + userId + ", communityId=" + communityId springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActActivityService.java
@@ -304,4 +304,12 @@ * @date 2022/2/17 10:09 */ String getActBelongRegionCode(Long communityId); /** * 党员活动统计 * @param communityId * @param year * @return */ R partyMemberCount(Long communityId,String year); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
@@ -15,10 +15,12 @@ import javax.annotation.Resource; import com.panzhihua.common.model.vos.community.*; import org.apache.commons.lang3.time.DateUtils; import org.springframework.beans.BeanUtils; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; import com.alibaba.fastjson.JSONObject; @@ -887,7 +889,6 @@ if (isNull(activityId)) { return R.fail("签到所属活动id不能为空!"); } if(comActActRegistVO.getActivityType()==1){ ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId); if (isNull(comActActivityDO)) { return R.fail("活动不存在!"); @@ -905,7 +906,42 @@ if (nowDate.before(beginAt) || nowDate.after(endAt)) { return R.fail("不在活动时间范围内"); } Integer haveIntegralReward = comActActivityDO.getHaveIntegralReward(); boolean isHave = nonNull(haveIntegralReward) && haveIntegralReward.equals(1); // String activitySignInKey = String.join(DELIMITER, ACTIVITY_SIGN_IN, userId.toString(), activityId.toString()); // if (stringRedisTemplate.hasKey(activitySignInKey)) { // return R.fail("你已签到,如要再次签到请三十分钟后尝试!"); // } ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); if(comActActRegistVO.getType()!=null&&comActActRegistVO.getType()==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(comActActRegistVO.getId()); comActActRegistDO.setEndTime(new Date()); int result=comActActRegistDAO.updateById(comActActRegistDO); if (result > 0) { if (isHave) { AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO(); addComActIntegralUserDTO.setUserId(userId); addComActIntegralUserDTO.setIntegralType(6); addComActIntegralUserDTO.setActivityType(2); addComActIntegralUserDTO.setCommunityId(comActActivityDO.getCommunityId()); addComActIntegralUserDTO.setServiceId(activityId); comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO); return R.ok(comActActivityDO.getRewardIntegral()); } 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>() @@ -913,21 +949,14 @@ if (signDayCount > 0) { return R.fail("请扫描新的签到码"); } Integer haveIntegralReward = comActActivityDO.getHaveIntegralReward(); boolean isHave = nonNull(haveIntegralReward) && haveIntegralReward.equals(1); if (isHave) { int limit = comActActivityDO.getLimit().intValue(); if(limit != -1 && signAllCount >= limit){ return R.fail("签到次数上限"); } } // String activitySignInKey = String.join(DELIMITER, ACTIVITY_SIGN_IN, userId.toString(), activityId.toString()); // if (stringRedisTemplate.hasKey(activitySignInKey)) { // return R.fail("你已签到,如要再次签到请三十分钟后尝试!"); // } ComActActRegistDO comActActRegistDO = new ComActActRegistDO(); comActActRegistDO.setActivityId(activityId); comActActRegistDO.setStartTime(new Date()); comActActRegistDO.setType(1); comActActRegistDO.setUserId(userId); comActActRegistDO.setIsVolunteer(comActActSignDO.getIsVolunteer()); @@ -937,7 +966,7 @@ comActActRegistDO.setPosition(comActActRegistVO.getPosition()); comActActRegistDO.setTimes(signAllCount+1); int result = comActActRegistDAO.insert(comActActRegistDO); if (result > 0) { if (result > 0&&comActActRegistDO.getType()==1) { if (isHave) { boolean isVolunteerAct = comActActivityDO.getVolunteerMax() != 0; AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO(); @@ -953,8 +982,8 @@ return R.ok(); } } return R.fail("网络错误,请重试"); } return R.fail("网络错误,请重试"); // else { // ComPbActivityDO comPbActivityDO=comBpActivityDAO.selectById(activityId); // if (isNull(comPbActivityDO)) { @@ -1005,8 +1034,6 @@ // } // return R.fail("网络错误,请重试"); // } return R.fail("网络错误,请重试"); } /** @@ -1080,4 +1107,38 @@ public String getActBelongRegionCode(Long communityId) { return baseMapper.getActBelongRegionCode(communityId); } @Override public R partyMemberCount(Long communityId, String year) { PartyActivityStatics partyActivityStatics=this.comActActivityDAO.selectActivityStatics(communityId); List<PartyActivityTypeChart> partyActivityTypeChart=this.comActActivityDAO.selectActivityChart(communityId); if(partyActivityStatics.getActivityCount()!=null&&partyActivityStatics.getActivityCount()>0){ if(!CollectionUtils.isEmpty(partyActivityTypeChart)){ partyActivityTypeChart.forEach(partyActivityTypeChart1 -> { partyActivityTypeChart1.setPercent(partyActivityTypeChart1.getCount()/partyActivityStatics.getActivityCount()); }); } } partyActivityStatics.setPartyActivityTypeChartList(partyActivityTypeChart); partyActivityStatics.setPartyActivityLines(getPoints(communityId,year)); return R.ok(partyActivityStatics); } public List<PartyActivityLine> getPoints(Long communityId,String year){ List<PartyActivityLine> partyActivityLines=new ArrayList<>(); for(int i=1;i<=12;i++){ String x=""; if(i<10){ x="0"+i; } else { x=i+""; } PartyActivityLine partyActivityLine=new PartyActivityLine(); partyActivityLine.setX(i+"月"); Integer y=this.comActActivityDAO.selectActivityLine(communityId,year,x); partyActivityLine.setY(y); partyActivityLines.add(partyActivityLine); } return partyActivityLines; } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActIntegralUserTradeServiceImpl.java
@@ -400,6 +400,9 @@ if (amount < 0) { reduceAmount = integralParty - integralPartyNow; } if(amount>0){ integralUserDO.setIntegralPartyTime(integralUserDO.getIntegralPartyTime()+integralUserDTO.getIntegralPartyTime()); } integralUserDO.setIntegralParty(integralPartyNow); integralUserDO.setIntegralAvailableParty(addIntegral(integralUserDO.getIntegralAvailableParty() + amount)); } else if (identityType.equals(ComActIntegralUserTradeDO.identityType.zyz)) { springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleRecordServiceImpl.java
@@ -6,6 +6,7 @@ import com.panzhihua.common.model.dtos.property.CommonPage; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.raffle.ComActRafflePrizeCount; import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO; import com.panzhihua.common.model.vos.community.warehouse.QRCodeVO; import com.panzhihua.service_community.dao.ComActRafflePrizeDao; import com.panzhihua.service_community.entity.ComActRaffleRecord; @@ -30,6 +31,8 @@ public class ComActRaffleRecordServiceImpl extends ServiceImpl<ComActRaffleRecordDao, ComActRaffleRecord> implements ComActRaffleRecordService { @Resource private ComActRafflePrizeDao comActRafflePrizeDao; @Resource private ComActRaffleRecordDao comActRaffleRecordDao; @Override public R pageList(CommonPage commonPage) { @@ -45,7 +48,7 @@ @Override public R queryQrCode(QRCodeVO qrCodeVO) { ComActRaffleRecord comActRaffleRecord=this.baseMapper.selectById(qrCodeVO.getId()); ComActRaffleRecordVO comActRaffleRecord=comActRaffleRecordDao.selectOneById((long)qrCodeVO.getId()); if(comActRaffleRecord!=null){ return R.ok(QRCodeUtil.getBase64QRCode(JSON.toJSONString(qrCodeVO))); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActActivityMapper.xml
@@ -239,4 +239,17 @@ <select id="getActBelongRegionCode" resultType="java.lang.String"> SELECT district_adcode FROM com_mng_struct_area_district WHERE district_adcode = ( SELECT area_code FROM com_street WHERE street_id =( SELECT street_id FROM com_act WHERE community_id = #{communityId} )) </select> <select id="selectActivityStatics" resultType="com.panzhihua.common.model.vos.community.PartyActivityStatics"> select (select count(*) from com_act_activity where type = 3 and community_id = #{communityId}) activityCount, (select count(*) from com_pb_member where community_id = #{communityId} ) memberCount </select> <select id="selectActivityChart" resultType="com.panzhihua.common.model.vos.community.PartyActivityTypeChart"> select count(*) as count,activity_type as name from com_act_activity where type = 3 and community_id =#{communityId} GROUP BY activity_type </select> <select id="selectActivityLine" resultType="integer"> select count(*) from com_act_activity where type = 3 and publish_at >= DATE_FORMAT( CONCAT(#{year},'-',#{date},'-00'), '%Y-%m-00 00:00:00') and DATE_FORMAT( LAST_DAY(CONCAT(#{year},'-',#{date},'-00')), '%Y-%m-%d 23:59:59') >=publish_at </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActRaffleRecordMapper.xml
@@ -28,6 +28,7 @@ left join sys_user t3 on t.staff_id = t3.user_id left join com_act_raffle t4 on t.raffle_id = t4.id <where> t.status >0 <if test="commonPage.status!=null"> and t.status = #{commonPage.status} </if> @@ -72,10 +73,14 @@ order by t.create_time desc </select> <select id="selectById" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO"> <select id="selectOneById" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO"> select t.*, t1.`name`, t1.image from com_act_raffle_record t LEFT JOIN com_act_raffle_prize t1 on t.prize_id = t1.id where t.id=#{id} </select> <update id="updateStatusByRaffleId"> update com_act_raffle_record set status = 3 where raffle_id = #{id} and status = 1 </update> </mapper>