| @@ -6,6 +6,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCampaignJoin; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCampaignJoinService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -16,6 +17,9 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @@ -45,7 +49,7 @@ public class WxCampaignJoinController extends BaseController { | |||
| @ApiOperation("确认或取消报名") | |||
| @PostMapping("modifyStatus") | |||
| @SystemControllerLog(description = "宣传页-新增") | |||
| @SystemControllerLog(description = "活动参与信息-确认或取消报名") | |||
| public ResultData modifyStatus(@RequestBody WxCampaignJoin wxCampaignJoin) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignJoinController::modifyStatus"); | |||
| @@ -59,4 +63,43 @@ public class WxCampaignJoinController extends BaseController { | |||
| return wxCampaignJoinService.modifyStatus(wxCampaignJoin); | |||
| } | |||
| @ApiOperation("导出报名表") | |||
| @RequestMapping("/exportData") | |||
| @SystemControllerLog(description = "活动参与信息-导出报名表") | |||
| public void exportData(@ModelAttribute WxCampaignJoin wxCampaignJoin, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignJoinController::exportData"); | |||
| if (wxCampaignJoin.getCampaignId() == null) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "campaignId不能为空"); | |||
| } | |||
| wxCampaignJoin.setTenantId(getTenantId()); | |||
| wxCampaignJoinService.exportData(request, response, wxCampaignJoin); | |||
| } | |||
| @ApiOperation("查询报名总数") | |||
| @GetMapping("queryJoinInfo") | |||
| @SystemControllerLog(description = "活动参与信息-查询报名总数") | |||
| public ResultData queryJoinInfo(@ModelAttribute WxCampaignJoin wxCampaignJoin) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignJoinController::queryJoinInfo"); | |||
| if (wxCampaignJoin.getCampaignId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "campaignId不能为空"); | |||
| } | |||
| wxCampaignJoin.setTenantId(getTenantId()); | |||
| return wxCampaignJoinService.queryJoinInfo(wxCampaignJoin); | |||
| } | |||
| @ApiOperation("确认报名完成") | |||
| @GetMapping("confirmCompletion") | |||
| @SystemControllerLog(description = "活动参与信息-确认报名完成") | |||
| public ResultData confirmCompletion(@ModelAttribute WxCampaignJoin wxCampaignJoin) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignJoinController::confirmCompletion"); | |||
| if (wxCampaignJoin.getCampaignId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "campaignId不能为空"); | |||
| } | |||
| wxCampaignJoin.setTenantId(getTenantId()); | |||
| return wxCampaignJoinService.confirmCompletion(wxCampaignJoin); | |||
| } | |||
| } | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.domain.po; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @@ -38,26 +39,36 @@ public class WxCampaignJoin extends BaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "活动ID", name = "campaignId") | |||
| private Long campaignId; | |||
| @Excel(name = "姓名", width = 10, orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value = "姓名", name = "name") | |||
| private String name; | |||
| @Excel(name = "微信昵称", width = 10, orderNum = "4") | |||
| @io.swagger.annotations.ApiModelProperty(value = "昵称", name = "nickName") | |||
| private String nickName; | |||
| @io.swagger.annotations.ApiModelProperty(value = "生日", name = "birthday") | |||
| private Date birthday; | |||
| @Excel(name = "性别", replace = {"保密_0", "男_1", "女_2"}, width = 10, orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value = "性别0保密1男2女", name = "sex") | |||
| private Integer sex; | |||
| @io.swagger.annotations.ApiModelProperty(value = "地址", name = "address") | |||
| private String address; | |||
| @Excel(name = "电话号码", width = 10, orderNum = "2") | |||
| @io.swagger.annotations.ApiModelProperty(value = "手机", name = "phone") | |||
| private String phone; | |||
| @io.swagger.annotations.ApiModelProperty(value = "答案", name = "answer") | |||
| private String answer; | |||
| @Excel(name = "活动签到", replace = {"未签到_0", "已签到_1"}, width = 10, orderNum = "6") | |||
| @io.swagger.annotations.ApiModelProperty(value = "签到状态1签到0未签到", name = "signIn") | |||
| private Integer signIn; | |||
| @Excel(name = "报名状态", replace = {"未确认_0", "已确认_1", "取消报名_2", "活动过期_3"}, width = 10, orderNum = "7") | |||
| @io.swagger.annotations.ApiModelProperty(value = "状态0未确认-报名中1确认-报名成功2取消-报名失败3过期", name = "status") | |||
| private Integer status; | |||
| @Excel(name = "报名时间", format = "yyyy-MM-dd HH:mm:ss", width = 10, orderNum = "5") | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime") | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public enum EnumCampaignJoinSignStatus { | |||
| YES(1, "签到"), | |||
| NO(0, "未签到"),; | |||
| public static EnumCampaignJoinSignStatus getEnum(Integer code) { | |||
| for (EnumCampaignJoinSignStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCampaignJoinSignStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,38 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public enum EnumCampaignJoinStatus { | |||
| NOT_CONFIRMED(0, "未确认"), | |||
| CONFIRMED(1, "已确认"), | |||
| CANCEL(2, "已取消"), | |||
| EXPIRED(3, "活动过期"),; | |||
| public static EnumCampaignJoinStatus getEnum(Integer code) { | |||
| for (EnumCampaignJoinStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCampaignJoinStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -22,6 +22,7 @@ public enum EnumMsgModel { | |||
| ACCEPT_SHARING_ACCOUNT_NOTIFY_MANAGER(14, "商户分账账户使用回执"), | |||
| REJECT_SHARING_ACCOUNT_NOTIFY_MANAGER(15, "商户分账账户不使用回执"), | |||
| DELETE_SHARING_ACCOUNT_NOTIFY_MERCHANT(16, "商户分账账户删除提醒"), | |||
| TIME_LIMIT_CAMPAIGN(17, "限时活动"), | |||
| ; | |||
| public static EnumMsgModel getEnum(Integer code) { | |||
| @@ -4,10 +4,22 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCampaignJoin; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public interface WxCampaignJoinService { | |||
| PageInfo<WxCampaignJoin> listAsPage(WxCampaignJoin wxCampaignJoin, Integer pageNum, Integer pageSize); | |||
| ResultData modifyStatus(WxCampaignJoin wxCampaignJoin); | |||
| void exportData(HttpServletRequest request, HttpServletResponse response, WxCampaignJoin wxCampaignJoin); | |||
| ResultData queryJoinInfo(WxCampaignJoin wxCampaignJoin); | |||
| ResultData confirmCompletion(WxCampaignJoin wxCampaignJoin); | |||
| } | |||
| @@ -4,14 +4,30 @@ import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCampaign; | |||
| import com.iformall.domain.po.WxCampaignJoin; | |||
| import com.iformall.domain.po.msg.WxMsgRecord; | |||
| import com.iformall.domain.vo.WxBillDailyVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.WxCampaignJoinMapper; | |||
| import com.iformall.mapper.WxCampaignMapper; | |||
| import com.iformall.mq.MqBaseProducer; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxCampaignJoinService; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @@ -22,6 +38,14 @@ public class WxCampaignJoinServiceImpl implements WxCampaignJoinService { | |||
| @Autowired | |||
| WxCampaignJoinMapper wxCampaignJoinMapper; | |||
| @Autowired | |||
| WxCampaignMapper wxCampaignMapper; | |||
| @Autowired | |||
| ExcelService excelService; | |||
| @Autowired | |||
| private MqBaseProducer mqBaseProducer; | |||
| @Override | |||
| public PageInfo<WxCampaignJoin> listAsPage(WxCampaignJoin record, Integer pageIndex, Integer pageSize) { | |||
| @@ -34,5 +58,75 @@ public class WxCampaignJoinServiceImpl implements WxCampaignJoinService { | |||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||
| } | |||
| @Override | |||
| public void exportData(HttpServletRequest request, HttpServletResponse response, WxCampaignJoin wxCampaignJoin) { | |||
| WxCampaign wxCampaign = wxCampaignMapper.selectByPrimaryKey(wxCampaignJoin.getCampaignId()); | |||
| String title = wxCampaign.getTitle(); | |||
| List<WxCampaignJoin> list = wxCampaignJoinMapper.findList(wxCampaignJoin); | |||
| excelService.exportExcel(list, null, title, WxBillDailyVo.class, "报名表.xlsx", response, false); | |||
| } | |||
| @Override | |||
| public ResultData queryJoinInfo(WxCampaignJoin wxCampaignJoin) { | |||
| WxCampaign wxCampaign = wxCampaignMapper.selectByPrimaryKey(wxCampaignJoin.getCampaignId()); | |||
| //活动人数 | |||
| Integer personLimit = wxCampaign.getPersonLimit(); | |||
| //总人数 | |||
| int total = wxCampaignJoinMapper.selectCount(wxCampaignJoin); | |||
| wxCampaignJoin.setStatus(EnumCampaignJoinStatus.CONFIRMED.getCode()); | |||
| //确认数 | |||
| int confirm = wxCampaignJoinMapper.selectCount(wxCampaignJoin); | |||
| Map<String, Object> data = new HashMap<>(); | |||
| data.put("personLimit", personLimit); | |||
| data.put("confirm", confirm); | |||
| data.put("total", total); | |||
| return new ResultData(data); | |||
| } | |||
| @Override | |||
| public ResultData confirmCompletion(WxCampaignJoin wxCampaignJoin) { | |||
| //1、修改活动状态 | |||
| WxCampaign wxCampaign = new WxCampaign(); | |||
| wxCampaign.setId(wxCampaignJoin.getCampaignId()); | |||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode()); | |||
| wxCampaign.setUpdateTime(new Date()); | |||
| wxCampaignMapper.updateByPrimaryKeySelective(wxCampaign); | |||
| //2、发送短信 | |||
| WxCampaign campaign = wxCampaignMapper.selectByPrimaryKey(wxCampaignJoin.getCampaignId()); | |||
| List<WxCampaignJoin> joinList = wxCampaignJoinMapper.select(wxCampaignJoin); | |||
| for (WxCampaignJoin join : joinList) { | |||
| sendMessage(join, campaign); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| private void sendMessage(WxCampaignJoin join, WxCampaign campaign) { | |||
| logger.info("》》》》》》》》》》》"); | |||
| logger.info("活动发送短信开始"); | |||
| logger.info("》》》》》》》》》》》"); | |||
| //人名 | |||
| String name = join.getName(); | |||
| name = StringUtils.isNotEmpty(name) ? name : ""; | |||
| //找出用户手机号 | |||
| String phone = join.getPhone(); | |||
| //活动名 | |||
| String party = campaign.getTitle(); | |||
| String time = DateUtils.date2String(campaign.getActivityTime()); | |||
| Map<String, String> msgReplaceMap = new HashMap(); | |||
| msgReplaceMap.put("name", name); | |||
| msgReplaceMap.put("party", party); | |||
| msgReplaceMap.put("time", time); | |||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||
| wxMsgRecord.setModelType(EnumMsgModel.TIME_LIMIT_CAMPAIGN.getCode()); | |||
| wxMsgRecord.setReceiver(phone); | |||
| wxMsgRecord.setTenantId(join.getTenantId()); | |||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| logger.info("》》》》》》》》》》》"); | |||
| logger.info("活动发送短信结束"); | |||
| logger.info("》》》》》》》》》》》"); | |||
| } | |||
| } | |||