|
@ -17,17 +17,23 @@ |
|
|
|
|
|
|
|
|
package com.epmet.modules.act.service.impl; |
|
|
package com.epmet.modules.act.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
|
|
import com.epmet.dto.result.UploadImgResultDTO; |
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
|
|
import com.epmet.feign.OssFeignClient; |
|
|
import com.epmet.modules.act.dao.ActSignInRecordDao; |
|
|
import com.epmet.modules.act.dao.ActSignInRecordDao; |
|
|
import com.epmet.modules.act.dao.GroupActInfoDao; |
|
|
import com.epmet.modules.act.dao.GroupActInfoDao; |
|
|
|
|
|
import com.epmet.modules.act.entity.ActSignInCodeEntity; |
|
|
import com.epmet.modules.act.entity.ActSignInRecordEntity; |
|
|
import com.epmet.modules.act.entity.ActSignInRecordEntity; |
|
|
import com.epmet.modules.act.entity.GroupActInfoEntity; |
|
|
import com.epmet.modules.act.entity.GroupActInfoEntity; |
|
|
import com.epmet.modules.act.service.ActSignInCodeService; |
|
|
import com.epmet.modules.act.service.ActSignInCodeService; |
|
@ -35,20 +41,23 @@ import com.epmet.modules.act.service.ActSignInRecordService; |
|
|
import com.epmet.modules.act.service.GroupActInfoService; |
|
|
import com.epmet.modules.act.service.GroupActInfoService; |
|
|
import com.epmet.modules.constant.GroupActConstant; |
|
|
import com.epmet.modules.constant.GroupActConstant; |
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
|
|
|
import com.epmet.modules.utils.ModuleConstant; |
|
|
|
|
|
import com.epmet.resi.group.dto.QRCodeMultipartFileDTO; |
|
|
import com.epmet.resi.group.dto.act.ActSignInCodeDTO; |
|
|
import com.epmet.resi.group.dto.act.ActSignInCodeDTO; |
|
|
import com.epmet.resi.group.dto.act.GroupActInfoDTO; |
|
|
import com.epmet.resi.group.dto.act.GroupActInfoDTO; |
|
|
import com.epmet.resi.group.dto.act.form.SetSignTimeFormDTO; |
|
|
import com.epmet.resi.group.dto.act.form.*; |
|
|
import com.epmet.resi.group.dto.act.form.SignInFormDTO; |
|
|
|
|
|
import com.epmet.resi.group.dto.act.form.SignInRecFormDTO; |
|
|
|
|
|
import com.epmet.resi.group.dto.act.result.SetSignTimeResultDTO; |
|
|
import com.epmet.resi.group.dto.act.result.SetSignTimeResultDTO; |
|
|
import com.epmet.resi.group.dto.act.result.SignInRecResultDTO; |
|
|
import com.epmet.resi.group.dto.act.result.SignInRecResultDTO; |
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
|
|
|
import com.epmet.utils.ThirdUtils; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -73,6 +82,9 @@ public class ActSignInRecordServiceImpl extends BaseServiceImpl<ActSignInRecordD |
|
|
private ActSignInCodeService actSignInCodeService; |
|
|
private ActSignInCodeService actSignInCodeService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private OssFeignClient ossFeignClient; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询当前用户是否签到 |
|
|
* 查询当前用户是否签到 |
|
|
* |
|
|
* |
|
@ -115,30 +127,12 @@ public class ActSignInRecordServiceImpl extends BaseServiceImpl<ActSignInRecordD |
|
|
} |
|
|
} |
|
|
groupActInfoDao.updateById(groupActInfoEntity); |
|
|
groupActInfoDao.updateById(groupActInfoEntity); |
|
|
SetSignTimeResultDTO result = new SetSignTimeResultDTO(); |
|
|
SetSignTimeResultDTO result = new SetSignTimeResultDTO(); |
|
|
//3、如果签到时间修改了,重新生成签到码
|
|
|
|
|
|
result.setSignInCodeUrl(getSignInCodeUrl(groupActInfoEntity, originalActInfo)); |
|
|
|
|
|
result.setGroupActId(formDTO.getGroupActId()); |
|
|
result.setGroupActId(formDTO.getGroupActId()); |
|
|
result.setSignInStartTime(groupActInfoEntity.getSignInStartTime()); |
|
|
result.setSignInStartTime(groupActInfoEntity.getSignInStartTime()); |
|
|
result.setSignInEndTime(groupActInfoEntity.getSignInEndTime()); |
|
|
result.setSignInEndTime(groupActInfoEntity.getSignInEndTime()); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private String getSignInCodeUrl(GroupActInfoEntity actInfoEntity, GroupActInfoDTO groupActInfoDTO) { |
|
|
|
|
|
ActSignInCodeDTO actSignInCodeDTO = actSignInCodeService.selectLastRec(actInfoEntity.getId()); |
|
|
|
|
|
if (null != actSignInCodeDTO) { |
|
|
|
|
|
if (actInfoEntity.getSignInStartTime().equals(groupActInfoDTO.getSignInStartTime()) |
|
|
|
|
|
&& actInfoEntity.getSignInEndTime().equals(groupActInfoDTO.getSignInEndTime())) { |
|
|
|
|
|
log.info("签到开始时间、签到截止时间未变更,不需要重新生成签到码"); |
|
|
|
|
|
return actSignInCodeDTO.getUrl(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//todo
|
|
|
|
|
|
//别忘了插入数据库act_sign_in_code
|
|
|
|
|
|
return "重新生成新的url"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 007、签到 |
|
|
* 007、签到 |
|
|
* |
|
|
* |
|
@ -242,4 +236,66 @@ public class ActSignInRecordServiceImpl extends BaseServiceImpl<ActSignInRecordD |
|
|
} |
|
|
} |
|
|
return resultDTO; |
|
|
return resultDTO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 018、获取签到码图片 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return com.epmet.resi.group.dto.act.result.SignInRecResultDTO |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public BuildSignInCodeResultDTO getSignInUrl(BuildSignInCodeFormDTO formDTO) { |
|
|
|
|
|
BuildSignInCodeResultDTO resultDTO = new BuildSignInCodeResultDTO(); |
|
|
|
|
|
ActSignInCodeDTO actSignInCodeDTO = actSignInCodeService.selectLastRec(formDTO.getGroupActId()); |
|
|
|
|
|
if (null != actSignInCodeDTO) { |
|
|
|
|
|
resultDTO.setSignInCodeUrl(actSignInCodeDTO.getUrl()); |
|
|
|
|
|
} else { |
|
|
|
|
|
//获取AccessToken
|
|
|
|
|
|
String accessToken = ThirdUtils.getAccessToken(formDTO.getCustomerId()).getResiToken(); |
|
|
|
|
|
if (StringUtils.isBlank(accessToken)) { |
|
|
|
|
|
log.warn("获取accessToken失败,customerId:{}", formDTO.getCustomerId()); |
|
|
|
|
|
throw new RenException("获取accessToken失败,customerId:{}", formDTO.getCustomerId()); |
|
|
|
|
|
} |
|
|
|
|
|
//跳转的页面
|
|
|
|
|
|
//todo
|
|
|
|
|
|
StringBuilder path = new StringBuilder(ModuleConstant.GROUP_ACT_DETAIL_PAGE); |
|
|
|
|
|
path.append("?groupActId=").append(formDTO.getGroupActId()); |
|
|
|
|
|
|
|
|
|
|
|
//需要发送的Json
|
|
|
|
|
|
JSONObject data = new JSONObject(); |
|
|
|
|
|
data.put("path", path.toString()); |
|
|
|
|
|
data.put("width", 400); |
|
|
|
|
|
//发送
|
|
|
|
|
|
byte[] buffer = HttpClientManager.getInstance().getMediaByteArray(ModuleConstant.GET_CODE_URL + accessToken, JSON.toJSONString(data)).getData(); |
|
|
|
|
|
if (buffer != null && buffer.length < 500) { |
|
|
|
|
|
String wxResult = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
wxResult = new String(buffer, "UTF-8"); |
|
|
|
|
|
if (-1 != wxResult.indexOf("errcode")) { |
|
|
|
|
|
log.error("获取二维码接口返回错误:{}", wxResult); |
|
|
|
|
|
throw new RenException("获取二维码失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//上传
|
|
|
|
|
|
QRCodeMultipartFileDTO qrCodeMultipartFile = new QRCodeMultipartFileDTO(); |
|
|
|
|
|
qrCodeMultipartFile.setBytes(buffer); |
|
|
|
|
|
String originalFilename = formDTO.getGroupActId().concat(".jpg"); |
|
|
|
|
|
qrCodeMultipartFile.setOriginalFilename(originalFilename); |
|
|
|
|
|
Result<UploadImgResultDTO> uploadResult = ossFeignClient.uploadQrCode(qrCodeMultipartFile); |
|
|
|
|
|
if (!uploadResult.success()) { |
|
|
|
|
|
throw new RenException("调用oss服务上传活动签到码失败"); |
|
|
|
|
|
} |
|
|
|
|
|
//别忘了插入数据库act_sign_in_code
|
|
|
|
|
|
ActSignInCodeEntity actSignInCodeEntity = new ActSignInCodeEntity(); |
|
|
|
|
|
actSignInCodeEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
|
|
actSignInCodeEntity.setGroupActId(formDTO.getGroupActId()); |
|
|
|
|
|
actSignInCodeEntity.setUrl(uploadResult.getData().getUrl()); |
|
|
|
|
|
actSignInCodeService.saveActSignInCodeEntity(actSignInCodeEntity); |
|
|
|
|
|
resultDTO.setSignInCodeUrl(uploadResult.getData().getUrl()); |
|
|
|
|
|
} |
|
|
|
|
|
return resultDTO; |
|
|
|
|
|
} |
|
|
} |
|
|
} |