| @@ -7,6 +7,7 @@ import com.iformall.domain.po.WxActivity; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumActivityStatus; | |||
| import com.iformall.service.WxActivityService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @@ -45,11 +47,29 @@ public class WxActivityController extends BaseController { | |||
| if (null == wxActivity) wxActivity = new WxActivity(); | |||
| wxActivity.setStatus(EnumActivityStatus.INJECT_ONLINE.getCode()); | |||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||
| wxActivity.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| wxActivity.setSortColumns(BaseEntity.SortField.ActivityStartTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxActivity> page = wxActivityService.listAsPage(wxActivity, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("") | |||
| @GetMapping("listStatus") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData listStatus(@ModelAttribute WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::list"); | |||
| if (null == wxActivity) wxActivity = new WxActivity(); | |||
| wxActivity.setStatus(EnumActivityStatus.INJECT_ONLINE.getCode()); | |||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||
| wxActivity.setSortColumns(BaseEntity.SortField.ActivityStartTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| if(wxActivity.getStartDate() == null || wxActivity.getEndDate() == null){ | |||
| wxActivity.setStartDate(DateUtils.getFirstDayForCurrMonth()); | |||
| wxActivity.setEndDate(DateUtils.getLastDayForMonth(new Date())); | |||
| } | |||
| return wxActivityService.getListStatus(wxActivity); | |||
| } | |||
| @ApiOperation("查询活动状态") | |||
| @GetMapping("/queryStatus") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @@ -8,7 +8,7 @@ import com.iformall.domain.po.WxCreditHistory; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCUserBasicSignService; | |||
| import com.iformall.service.WxCreditHistoryService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.HashMap; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| @RestController | |||
| @@ -54,6 +54,33 @@ public class WxCUserBasicSignController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("") | |||
| @GetMapping("listStatus") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData listStatus(@ModelAttribute WxCUserBasicSign wxCUserBasicSign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicSignController::listStatus"); | |||
| if (null == wxCUserBasicSign){ | |||
| wxCUserBasicSign = new WxCUserBasicSign(); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException me) { | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } | |||
| // wxCUserBasicSign.updateTenantInfo(getTenantInfo()); | |||
| wxCUserBasicSign.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxCUserBasicSign.setUserId(memberId); | |||
| if(wxCUserBasicSign.getStartDate() == null || wxCUserBasicSign.getEndDate() == null){ | |||
| wxCUserBasicSign.setStartDate(DateUtils.getFirstDayForCurrMonth()); | |||
| wxCUserBasicSign.setEndDate(DateUtils.getLastDayForMonth(new Date())); | |||
| } | |||
| return wxCUserBasicSignService.getListStatus(wxCUserBasicSign); | |||
| } | |||
| @ApiOperation("签到") | |||
| @PostMapping("signIn") | |||
| @ApiImplicitParams({ | |||
| @@ -72,11 +72,11 @@ public class WxActivity extends TenantEntity { | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "开始时间", name = "starttime") | |||
| private Date starttime; | |||
| private Date startDate; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "结束时间", name = "endtime") | |||
| private Date endtime; | |||
| private Date endDate; | |||
| @TableField(exist = false) | |||
| @@ -205,6 +205,10 @@ public class BaseEntity implements Serializable { | |||
| ReportDate_ASC("`report_date` ASC"), | |||
| ReportDate_DESC("`report_date` DESC"), | |||
| ActivityStartTime_ASC("`activity_start_time` ASC"), | |||
| ActivityStartTime_DESC("`activity_start_time` DESC"), | |||
| ; | |||
| private String value; | |||
| @@ -47,4 +47,6 @@ public interface WxActivityService { | |||
| Integer queryStatus(Long id, Long userId); | |||
| ResultData offLineCampaign(WxActivity wxActivity); | |||
| ResultData getListStatus(WxActivity wxActivity); | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUserBasicSign; | |||
| import com.iformall.enums.EnumScoreType; | |||
| @@ -25,4 +26,6 @@ public interface WxCUserBasicSignService { | |||
| Map<String,Integer> getLastSignIn(WxCUserBasicSign record); | |||
| void signInCreditHistory(WxCUserBasicSign record, EnumScoreType enumScoreType); | |||
| ResultData getListStatus(WxCUserBasicSign wxCUserBasicSign); | |||
| } | |||
| @@ -17,6 +17,7 @@ import com.iformall.mapper.WxActivityMapper; | |||
| import com.iformall.mapper.WxCampaignMapper; | |||
| import com.iformall.service.WxActivityService; | |||
| import com.iformall.service.WxCampaignService; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -30,7 +31,7 @@ import java.io.ByteArrayInputStream; | |||
| import java.io.InputStream; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.net.URLDecoder; | |||
| import java.util.Date; | |||
| import java.util.*; | |||
| /** | |||
| * @author gongbiao | |||
| @@ -121,6 +122,10 @@ public class WxActivityServiceImpl implements WxActivityService { | |||
| if (activity == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| if (wxActivity.getStatus().equals(EnumActivityStatus.INJECT_ONLINE.getCode()) | |||
| && activity.getEndTime().before(new Date())) { | |||
| return new ResultData(ErrorCode.ACTIVITY_JOIN_TIME_END); | |||
| } | |||
| wxActivity.setUpdateTime(new Date()); | |||
| wxActivityMapper.updateById(wxActivity); | |||
| if (wxActivity.getStatus().equals(EnumActivityStatus.STATUS_TAKE_OFFF.getCode())) { | |||
| @@ -257,5 +262,37 @@ public class WxActivityServiceImpl implements WxActivityService { | |||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||
| } | |||
| @Override | |||
| public ResultData getListStatus(WxActivity wxActivity) { | |||
| List list = new ArrayList(); | |||
| List<WxActivity> activityList = wxActivityMapper.findList(wxActivity); | |||
| if(activityList != null){ | |||
| for (WxActivity activity:activityList) { | |||
| Date start = activity.getActivityStartTime(); | |||
| Date end = activity.getActivityEndTime(); | |||
| Calendar dd = Calendar.getInstance(); | |||
| dd.setTime(start); | |||
| while (start.getTime() < end.getTime()) { | |||
| Map map = new HashMap<>(); | |||
| map.put("yyyy", DateUtils.getYear(start)); | |||
| map.put("mm", DateUtils.getMonth(start)); | |||
| map.put("dd", DateUtils.getMonthOfDate(start)); | |||
| list.add(map); | |||
| // 天数加上1 | |||
| dd.add(Calendar.DAY_OF_MONTH, 1); | |||
| start = dd.getTime(); | |||
| } | |||
| } | |||
| } | |||
| if(list.size() > 0){ | |||
| HashSet h = new HashSet(list); | |||
| list.clear(); | |||
| list.addAll(h); | |||
| } | |||
| return new ResultData(list); | |||
| } | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUserBasicSign; | |||
| import com.iformall.domain.po.WxCreditHistory; | |||
| import com.iformall.enums.EnumScoreType; | |||
| @@ -212,6 +213,22 @@ public class WxCUserBasicSignServiceImpl implements WxCUserBasicSignService { | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory,null); | |||
| } | |||
| @Override | |||
| public ResultData getListStatus(WxCUserBasicSign record) { | |||
| List list = new ArrayList(); | |||
| List<WxCUserBasicSign> recordList = wxCUserBasicSignMapper.findList(record); | |||
| if(recordList != null){ | |||
| for (WxCUserBasicSign sign:recordList) { | |||
| Map map = new HashMap<>(); | |||
| map.put("yyyy", DateUtils.getYear(sign.getSigninDate())); | |||
| map.put("mm", DateUtils.getMonth(sign.getSigninDate())); | |||
| map.put("dd", DateUtils.getMonthOfDate(sign.getSigninDate())); | |||
| list.add(map); | |||
| } | |||
| } | |||
| return new ResultData(list); | |||
| } | |||
| private void continueSignInAddCredit(WxCUserBasicSign record){ | |||
| int i = record.getContinueSign() % 28; | |||
| if(record.getContinueSign() > 0 && i == 0){ | |||
| @@ -89,12 +89,12 @@ | |||
| and `is_expired` = #{isExpired} | |||
| </if> | |||
| <if test=" null != starttime and null != endtime "> | |||
| and `create_time` between #{starttime} and #{endtime} | |||
| </if> | |||
| <!-- <if test=" null != startDate and null != endDate ">--> | |||
| <!-- and `create_time` between #{starttime} and #{endtime}--> | |||
| <!-- </if>--> | |||
| <if test=" null != starttime and null != endtime "> | |||
| and `activity_start_time` >= #{starttime} and `activity_end_time` <= #{starttime} | |||
| <if test=" null != startDate and null != endDate "> | |||
| and `activity_start_time` >= #{startDate} and `activity_end_time` < #{endDate} | |||
| </if> | |||
| <if test=" null != sendMsg "> | |||