|
|
@ -2,10 +2,8 @@ package com.lottery.admin.service.Impl; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum; |
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.lottery.dto.FundingActivityDto; |
|
|
|
import com.lottery.dto.FundingRecordDto; |
|
|
|
import com.lottery.dto.FundingUserDto; |
|
|
|
import com.lottery.entity.Activity; |
|
|
|
import com.lottery.admin.mapper.IFundingMapper; |
|
|
@ -13,17 +11,16 @@ import com.lottery.admin.service.IFundingService; |
|
|
|
import com.lottery.entity.FundingExport; |
|
|
|
import com.lottery.result.Result; |
|
|
|
import com.lottery.utils.ConvertBeanUtil; |
|
|
|
import com.lottery.utils.HttpUtils; |
|
|
|
import com.lottery.utils.ValidationUtils; |
|
|
|
import com.lottery.vo.FundingActivityVo; |
|
|
|
import com.lottery.vo.FundingDataVO; |
|
|
|
import com.lottery.vo.FundingUserVo; |
|
|
|
import com.lottery.vo.MarketVo; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
@ -96,7 +93,7 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
if (fundingActivityDto.getEndTime().isBefore(ChronoLocalDate.from(now))) { |
|
|
|
return Result.failure("结束时间不能早于当前时间"); |
|
|
|
} |
|
|
|
if(fundingActivityDto.getMarketOne().equals(fundingActivityDto.getMarketTwo())){ |
|
|
|
if(fundingActivityDto.getMarketOne()==(fundingActivityDto.getMarketTwo())){ |
|
|
|
if(fundingMapper.selectStatus()==1){ |
|
|
|
return Result.failure("市场添加重复"); |
|
|
|
} |
|
|
@ -104,6 +101,9 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
//查询状态 |
|
|
|
Integer status = fundingMapper.selectStatus(); |
|
|
|
Integer statuss = fundingActivityDto.getStatus(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(statuss == 1){ |
|
|
|
if(status >= 1){ |
|
|
|
return Result.failure("当前有活动正在进行,新添加活动状态应为禁用"); |
|
|
@ -117,8 +117,9 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
activity.setUpdatedTime(creatTime); |
|
|
|
fundingMapper.addActivity(activity); |
|
|
|
|
|
|
|
String one = fundingActivityDto.getMarketOne(); |
|
|
|
String two = fundingActivityDto.getMarketTwo(); |
|
|
|
Integer one = fundingActivityDto.getMarketOne(); |
|
|
|
Integer two = fundingActivityDto.getMarketTwo(); |
|
|
|
|
|
|
|
Integer activityId = activity.getId(); |
|
|
|
Integer time = 0; |
|
|
|
Integer addTotal = 0; |
|
|
@ -150,6 +151,7 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
fundingUserDto.getJwcode(), |
|
|
|
fundingUserDto.getMarketSign() |
|
|
|
); |
|
|
|
|
|
|
|
// 构建返回结果 |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put("list", list); |
|
|
@ -165,11 +167,16 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
|
|
|
|
//参与总人数 |
|
|
|
Integer people_total = fundingMapper.searchPeopleTotal(activityId); |
|
|
|
|
|
|
|
//根据活动id查询俩个市场,俩个市场是一条数据 |
|
|
|
Map<String, Object> market = fundingMapper.getMarket(activityId); |
|
|
|
|
|
|
|
if(market == null){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
//获取map |
|
|
|
String marketOne = (String) market.get("market_one"); |
|
|
|
String marketTwo = (String) market.get("market_two"); |
|
|
|
Integer marketOne =(Integer) market.get("market_one"); |
|
|
|
Integer marketTwo = (Integer) market.get("market_two"); |
|
|
|
//参与市场一的人数 |
|
|
|
Integer markerOnePeople = fundingMapper.searchMarketPeople(activityId, marketOne); |
|
|
|
//市场一的总的助力次数 |
|
|
@ -222,6 +229,11 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> setActivityTime(Integer activityId, Integer time) { |
|
|
|
//检验activity Id存在 |
|
|
|
Integer status = fundingMapper.selectCount(activityId); |
|
|
|
if(status ==null || status == 0){ |
|
|
|
return Result.failure("活动不存在"); |
|
|
|
} |
|
|
|
if(time == null){ |
|
|
|
return Result.failure("初始时间不能为空"); |
|
|
|
} |
|
|
@ -233,13 +245,16 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<String> addVirtual(Integer activityId, String stock, Integer addTotal) { |
|
|
|
public Result<String> addVirtual(Integer activityId, Integer stock, Integer addTotal) { |
|
|
|
if(addTotal == null){ |
|
|
|
return Result.failure("添加次数不能为空"); |
|
|
|
} |
|
|
|
if(!ValidationUtils.validateInteger(addTotal)){ |
|
|
|
return Result.failure("添加次数格式错误"); |
|
|
|
} |
|
|
|
if(stock == null){ |
|
|
|
return Result.failure("库存不能为空"); |
|
|
|
} |
|
|
|
fundingMapper.setVirtual(activityId, stock, addTotal); |
|
|
|
|
|
|
|
return Result.success("设置虚拟次数成功"); |
|
|
@ -247,25 +262,44 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public FundingDataVO getDate1(Integer activityId) { |
|
|
|
|
|
|
|
//根据活动id查询俩个市场,俩个市场是一条数据 |
|
|
|
Map<String, Object> market = fundingMapper.getMarket(activityId); |
|
|
|
//获取map |
|
|
|
String marketOne = (String) market.get("market_one"); |
|
|
|
Integer One = (Integer) market.get("market_one"); |
|
|
|
//根据id查名称 |
|
|
|
String marketOne = fundingMapper.selectMarketName(One); |
|
|
|
//市场一的总的助力次数 |
|
|
|
Integer markerOneTotal = fundingMapper.searchMarketTotal(activityId, marketOne); |
|
|
|
Integer markerOneTotal = fundingMapper.searchMarketTotal(activityId, One); |
|
|
|
if(markerOneTotal == null){ |
|
|
|
markerOneTotal = 0; |
|
|
|
} |
|
|
|
|
|
|
|
//市场一的虚拟次数 |
|
|
|
Integer markerOneVirtual = fundingMapper.searchVirtual(activityId, marketOne); |
|
|
|
Integer markerOneVirtual = fundingMapper.searchVirtual(activityId, One); |
|
|
|
if(markerOneVirtual == null){ |
|
|
|
markerOneVirtual = 0; |
|
|
|
} |
|
|
|
|
|
|
|
Integer Two = (Integer) market.get("market_two"); |
|
|
|
String marketTwo = fundingMapper.selectMarketName(Two); |
|
|
|
|
|
|
|
String marketTwo = (String) market.get("market_two"); |
|
|
|
//市场二的总的助力次数 |
|
|
|
Integer markerTwoTotal = fundingMapper.searchMarketTotal(activityId, marketTwo); |
|
|
|
Integer markerTwoTotal = fundingMapper.searchMarketTotal(activityId, Two); |
|
|
|
if(markerTwoTotal == null){ |
|
|
|
markerTwoTotal = 0; |
|
|
|
} |
|
|
|
//市场二的虚拟次数 |
|
|
|
Integer markerTwoVirtual = fundingMapper.searchVirtual(activityId, marketTwo); |
|
|
|
Integer markerTwoVirtual = fundingMapper.searchVirtual(activityId, Two); |
|
|
|
if(markerTwoVirtual != null ){ |
|
|
|
markerTwoVirtual = 0; |
|
|
|
} |
|
|
|
|
|
|
|
Integer showOne = markerOneTotal + markerOneVirtual; |
|
|
|
Integer showTwo = markerTwoTotal + markerTwoVirtual; |
|
|
|
|
|
|
|
Integer time = fundingMapper.getTime(activityId,marketOne); |
|
|
|
Integer time = fundingMapper.getTime(activityId,One); |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
FundingDataVO fundingDataVO = new FundingDataVO(marketOne, marketTwo, time, showOne, showTwo, markerOneVirtual, markerTwoVirtual, markerOneTotal, markerTwoTotal); |
|
|
@ -274,7 +308,7 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List getMarketList() { |
|
|
|
public List<MarketVo> getMarketList() { |
|
|
|
return fundingMapper.getMarketList(); |
|
|
|
} |
|
|
|
|
|
|
@ -309,5 +343,12 @@ public class FundingServiceImpl implements IFundingService { |
|
|
|
.sheet(activityName+"用户助力统计") |
|
|
|
.doWrite(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void deleteActivity(Integer id) { |
|
|
|
fundingMapper.deleteActivity(id); |
|
|
|
fundingMapper.deleteDate(id); |
|
|
|
fundingMapper.deleteZuser(id); |
|
|
|
} |
|
|
|
} |
|
|
|
|