| | |
| | | package com.panzhihua.service_dangjian.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.partybuilding.NeedProblemClaimDTO; |
| | | import com.panzhihua.common.model.dtos.partybuilding.NeedProblemInventoryDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_dangjian.dao.NeedProblemClaimDAO; |
| | | import com.panzhihua.service_dangjian.entity.UserIntegral; |
| | | import com.panzhihua.service_dangjian.entity.UserTrade; |
| | | import com.panzhihua.service_dangjian.service.NeedProblemClaimService; |
| | | import com.panzhihua.service_dangjian.service.NeedProblemInventoryService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | private NeedProblemInventoryService inventoryService; |
| | | |
| | | @Override |
| | | public IPage<NeedProblemClaimDTO> getList(int pageNum, int pageSize, |
| | | String taskId, String userId,String unitId) |
| | | public List<NeedProblemClaimDTO> getList(String taskId, String userId, String unitId) |
| | | { |
| | | Page page = new Page<>(pageNum,pageSize); |
| | | return baseMapper.getList(page,taskId,userId,unitId); |
| | | // Page page = new Page<>(pageNum,pageSize); |
| | | return baseMapper.getList(taskId,userId,unitId); |
| | | } |
| | | |
| | | @Override |
| | | public NeedProblemClaimDTO getDetails(String id) { |
| | | return baseMapper.getDetails(id); |
| | | public NeedProblemClaimDTO getDetails(String id,String taskId, String userId) { |
| | | return baseMapper.getDetails(id,taskId,userId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | { |
| | | return R.fail("报名已结束"); |
| | | } |
| | | |
| | | if(StringUtils.equals(inventoryDTO.getJoinNum(),inventoryDTO.getClaimNum())) |
| | | { |
| | | return R.fail("认领人数已满"); |
| | | } |
| | | |
| | | int isJion= baseMapper.getJionNum(item.getTaskId(),item.getUserId()); |
| | | if(isJion>0) |
| | | { |
| | |
| | | return R.fail("参与人数已满"); |
| | | } |
| | | } |
| | | return R.ok(baseMapper.addData(item)); |
| | | |
| | | int num=baseMapper.addData(item); |
| | | if(num!=1) |
| | | { |
| | | return R.fail("报名失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R expurgateData(String id) |
| | | public R expurgateData(String id,String taskId,String userId) |
| | | { |
| | | //报名信息 |
| | | NeedProblemClaimDTO claimDTO=baseMapper.getDetails(id); |
| | | NeedProblemClaimDTO claimDTO=baseMapper.getDetails(id,taskId,userId); |
| | | NeedProblemInventoryDTO inventoryDTO=inventoryService.getDetails(claimDTO.getTaskId(),claimDTO.getUserId()); |
| | | long times=System.currentTimeMillis(); |
| | | |
| | |
| | | return R.fail("任务已开始!不能取消"); |
| | | } |
| | | |
| | | int num=baseMapper.expurgateData(id); |
| | | int num=baseMapper.expurgateData(id, taskId, userId); |
| | | if(num>0) |
| | | { |
| | | return R.ok(); |
| | |
| | | //开始打卡 |
| | | item.setPunchStartTime(new Date()); |
| | | } |
| | | else |
| | | { |
| | | NeedProblemClaimDTO userDto=baseMapper.getUserIdDetails(taskId,userId); |
| | | else { |
| | | NeedProblemClaimDTO userDto = baseMapper.getUserIdDetails(taskId, userId); |
| | | //结束打卡 |
| | | Date newDate=new Date(); |
| | | Date newDate = new Date(); |
| | | item.setPunchEndTime(newDate); |
| | | |
| | | long times=newDate.getTime()-userDto.getPunchStartTime().getTime(); |
| | | item.setServiceTime(times+""); |
| | | long times = newDate.getTime() - userDto.getPunchStartTime().getTime(); |
| | | item.setServiceTime(times + ""); |
| | | |
| | | NeedProblemInventoryDTO dto=inventoryService.getDetails(taskId,userId); |
| | | UserTrade userTrade=new UserTrade(); |
| | | //增加积分 |
| | | UserIntegral integral = baseMapper.getUserIntegral(userId,dto.getCommunityId()); |
| | | if (integral == null) { |
| | | UserIntegral addIn = new UserIntegral(); |
| | | addIn.setId(Snowflake.getId()+""); |
| | | addIn.setUserId(userId); |
| | | addIn.setCommunityId(dto.getCommunityId()); |
| | | addIn.setIntegralAvailableSum(dto.getAward()); |
| | | addIn.setIntegralSum(dto.getAward()); |
| | | userTrade.setIntegralId(addIn.getId()); |
| | | baseMapper.addUserIntegral(addIn); |
| | | } |
| | | else |
| | | { |
| | | int award=0; |
| | | int integralAvailableSum=0; |
| | | int integralSum=0; |
| | | |
| | | if(!StringUtils.isEmpty(dto.getAward())) |
| | | { |
| | | award=Integer.valueOf(dto.getAward()); |
| | | } |
| | | |
| | | if(!StringUtils.isEmpty(integral.getIntegralAvailableSum())) |
| | | { |
| | | integralAvailableSum=Integer.valueOf(integral.getIntegralAvailableSum())+award; |
| | | } |
| | | |
| | | if(!StringUtils.isEmpty(integral.getIntegralSum())) |
| | | { |
| | | integralSum=Integer.valueOf(integral.getIntegralSum())+award; |
| | | } |
| | | |
| | | userTrade.setIntegralId(integral.getId()); |
| | | integral.setIntegralAvailableSum(integralAvailableSum+""); |
| | | integral.setIntegralSum(integralSum+""); |
| | | baseMapper.editUserIntegral(integral); |
| | | } |
| | | |
| | | userTrade.setServiceId(dto.getId()); |
| | | userTrade.setId(Snowflake.getId()+""); |
| | | userTrade.setAmount(dto.getAward()); |
| | | userTrade.setChangeType("1"); |
| | | userTrade.setUserId(userId); |
| | | userTrade.setCommunityId(dto.getCommunityId()); |
| | | userTrade.setCreateBy(userId); |
| | | |
| | | // @ApiModelProperty("1问题清单 2需求清单") |
| | | // private String kind; |
| | | if(StringUtils.equals("2",dto.getKind())) |
| | | { |
| | | //19 完成需求任务 |
| | | userTrade.setServiceType("19"); |
| | | userTrade.setRemark("完成需求清单任务奖励"); |
| | | } |
| | | else |
| | | { |
| | | //20完成问题任务 |
| | | userTrade.setServiceType("20"); |
| | | userTrade.setRemark("完成问题清单任务奖励"); |
| | | } |
| | | baseMapper.addUserIntegralTrade(userTrade); |
| | | } |
| | | return baseMapper.editData(item); |
| | | } |