diff --git a/epmet-auth/deploy/docker-compose-dev.yml b/epmet-auth/deploy/docker-compose-dev.yml index e32e5e5432..7ee9697721 100644 --- a/epmet-auth/deploy/docker-compose-dev.yml +++ b/epmet-auth/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-auth-server: container_name: epmet-auth-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.56 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.57 ports: - "8081:8081" network_mode: host # 使用现有网络 diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 8ffde60165..489c6b5373 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.56 + 0.3.57 com.epmet epmet-cloud diff --git a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java index 461dd1ab48..924c1a4070 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java @@ -3,7 +3,10 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.LoginFormDTO; +import com.epmet.dto.form.StaffOrgsFormDTO; +import com.epmet.dto.form.ThirdStaffOrgsFormDTO; import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.ThirdLoginService; import org.springframework.beans.factory.annotation.Autowired; @@ -12,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * @Description 第三方-居民端、政府端登陆服务 * @author sun @@ -60,4 +65,30 @@ public class ThirdLoginController { return new Result().ok(userTokenResultDTO); } + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-手机验证码获取组织 + **/ + @PostMapping(value = "/getmyorg") + public Result> getmyorg(@RequestBody ThirdStaffOrgsFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffOrgsFormDTO.AddUserShowGroup.class, StaffOrgsFormDTO.GetMyOrgByLoginWxmp.class); + List staffOrgs = thirdLoginService.getMyOrg(formDTO); + return new Result>().ok(staffOrgs); + } + + /** + * @param formDTO + * @return + * @author sun + * @description 单客户-手机号密码获取组织 + **/ + @PostMapping(value = "/getmyorgbypassword") + public Result> getMyOrgByPassword(@RequestBody ThirdStaffOrgsFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffOrgsFormDTO.AddUserShowGroup.class, StaffOrgsFormDTO.GetMyOrgByPassWordGroup.class); + List staffOrgs = thirdLoginService.getMyOrgByPassword(formDTO); + return new Result>().ok(staffOrgs); + } + } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgsFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgsFormDTO.java new file mode 100644 index 0000000000..c5027dcd82 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgsFormDTO.java @@ -0,0 +1,48 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description appId、手机号、验证码获取组织-接口入参 + * @Author sun + */ +@Data +public class ThirdStaffOrgsFormDTO implements Serializable { + private static final long serialVersionUID = 4193133227120225342L; + /** + * 添加用户操作的用户可见异常分组 + * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup + * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 + */ + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface GetMyOrgByPassWordGroup extends CustomerClientShowGroup { + } + public interface GetMyOrgByLoginWxmp extends CustomerClientShowGroup{} + /** + * 小程序appId + */ + @NotBlank(message = "appId不能为空", groups = {AddUserShowGroup.class}) + private String appId; + + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class}) + private String mobile; + + /** + * 验证码 + */ + @NotBlank(message="验证码不能为空", groups = {GetMyOrgByLoginWxmp.class}) + private String smsCode; + + @NotBlank(message = "密码不能为空",groups ={GetMyOrgByPassWordGroup.class}) + private String password; +} + diff --git a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java index a532adec56..b343bf5a22 100644 --- a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java @@ -1,9 +1,13 @@ package com.epmet.service; import com.epmet.dto.form.LoginFormDTO; +import com.epmet.dto.form.ThirdStaffOrgsFormDTO; import com.epmet.dto.form.ThirdWxmpEnteOrgFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; +import java.util.List; + /** * @Description 第三方-居民端、政府端登陆服务 * @author sun @@ -33,4 +37,20 @@ public interface ThirdLoginService { * @Description 单客户-选择组织,进入首页 **/ UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-手机验证码获取组织 + **/ + List getMyOrg(ThirdStaffOrgsFormDTO formDTO); + + /** + * @param formDTO + * @return + * @author sun + * @description 单客户-手机号密码获取组织 + **/ + List getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index df85d0ccd1..2bb6c09a7e 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -2,38 +2,36 @@ package com.epmet.service.impl; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.*; import com.epmet.dto.form.*; -import com.epmet.dto.result.DepartmentListResultDTO; -import com.epmet.dto.result.GridByStaffResultDTO; -import com.epmet.dto.result.StaffLatestAgencyResultDTO; -import com.epmet.dto.result.UserTokenResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.EpmetThirdFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; +import com.epmet.redis.CaptchaRedis; import com.epmet.service.ThirdLoginService; import lombok.extern.slf4j.Slf4j; +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 org.springframework.util.CollectionUtils; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -48,6 +46,8 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { @Autowired private JwtTokenUtils jwtTokenUtils; @Autowired + private CaptchaRedis captchaRedis; + @Autowired private JwtTokenProperties jwtTokenProperties; @Autowired private CpUserDetailRedis cpUserDetailRedis; @@ -142,6 +142,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { **/ @Override public UserTokenResultDTO workLogin(LoginFormDTO formDTO) { + //1.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息 WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO(); resiLoginFormDTO.setAppId(formDTO.getAppId()); @@ -379,66 +380,150 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey()); wxMaJscode2SessionResult.setUnionid(""); // end - //3、记录staff_wechat,并记录用户激活状态,激活时间 - this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); + this.savestaffwechat(customerStaff.getUserId(), userWechatDTO.getWxOpenId()); //4、记录登录日志 - this.saveGovStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); + StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = new StaffLatestAgencyResultDTO(); + staffLatestAgencyResultDTO.setCustomerId(formDTO.getCustomerId()); + staffLatestAgencyResultDTO.setStaffId(customerStaff.getUserId()); + staffLatestAgencyResultDTO.setWxOpenId(userWechatDTO.getWxOpenId()); + staffLatestAgencyResultDTO.setMobile(formDTO.getMobile()); + staffLatestAgencyResultDTO.setAgencyId(formDTO.getRootAgencyId()); + this.saveStaffLoginRecord(staffLatestAgencyResultDTO); //5.1、获取用户token String token = this.generateGovWxmpToken(customerStaff.getUserId()); //5.2、保存到redis - this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token); + StaffLatestAgencyResultDTO staffLatestAgency = new StaffLatestAgencyResultDTO(); + staffLatestAgency.setAgencyId(formDTO.getRootAgencyId()); + staffLatestAgency.setCustomerId(formDTO.getCustomerId()); + staffLatestAgency.setStaffId(customerStaff.getUserId()); + this.saveLatestGovTokenDto(staffLatestAgency, userWechatDTO, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); userTokenResultDTO.setToken(token); return userTokenResultDTO; } - //保存登录日志 - private Result saveGovStaffLoginRecord(ThirdWxmpEnteOrgFormDTO formDTO, String staffId, String openId) { - StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); - staffLoginAgencyRecordFormDTO.setCustomerId(formDTO.getCustomerId()); - staffLoginAgencyRecordFormDTO.setStaffId(staffId); - staffLoginAgencyRecordFormDTO.setWxOpenId(openId); - staffLoginAgencyRecordFormDTO.setMobile(formDTO.getMobile()); - staffLoginAgencyRecordFormDTO.setAgencyId(formDTO.getRootAgencyId()); - Result staffLoginRecordResult = epmetUserOpenFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); - return staffLoginRecordResult; + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-手机验证码获取组织 + **/ + @Override + public List getMyOrg(ThirdStaffOrgsFormDTO formDTO) { + //0、验证码是否正确 + String rightSmsCode = captchaRedis.getSmsCode(formDTO.getMobile()); + if (!formDTO.getSmsCode().equals(rightSmsCode)) { + logger.error(String.format("验证码错误code[%s],msg[%s]",EpmetErrorCode.MOBILE_CODE_ERROR.getCode(),EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); + throw new RenException(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); + } + //1.根据appId查询对应客户Id + Result resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); + if (!resultDTO.success()) { + logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId())); + throw new RenException(resultDTO.getMsg()); + } + PaCustomerDTO customer = resultDTO.getData().getCustomer(); + + //7.28 根据appId只能存在一个客户Id,后边的批量操作逻辑 + //2.根据手机号查询到用户信息 + ThirdCustomerStaffFormDTO dto = new ThirdCustomerStaffFormDTO(); + dto.setCustomerId(customer.getId()); + dto.setMobile(formDTO.getMobile()); + Result> customerStaffResult = epmetUserOpenFeignClient.getCustsomerStaffByIdAndPhone(dto); + if (!customerStaffResult.success()) { + logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); + throw new RenException(customerStaffResult.getCode()); + } + + //3、查询用户所有的组织信息 + List customerIdList = new ArrayList<>(); + for (CustomerStaffDTO customerStaffDTO : customerStaffResult.getData()) { + customerIdList.add(customerStaffDTO.getCustomerId()); + } + StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO(); + staffOrgFormDTO.setCustomerIdList(customerIdList); + Result> result = govOrgOpenFeignClient.getStaffOrgList(staffOrgFormDTO); + if(result.success()&&null!=result.getData()){ + return result.getData(); + } + logger.error(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,验证码%s,返回错误码%s,错误提示信息%s", ServiceConstant.GOV_ORG_SERVER,formDTO.getMobile(),formDTO.getSmsCode(),result.getCode(),result.getMsg())); + return new ArrayList<>(); } /** - * @Description 生成token - * @Date 2020/4/18 23:04 + * @param formDTO + * @return + * @author sun + * @description 单客户-手机号密码获取组织 **/ - private void saveGovTokenDto(String orgId, - String customerId, - String staffId, - WxMaJscode2SessionResult wxMaJscode2SessionResult, - String token) { - int expire = jwtTokenProperties.getExpire(); - GovTokenDto govTokenDto = new GovTokenDto(); - govTokenDto.setApp(LoginConstant.APP_GOV); - govTokenDto.setClient(LoginConstant.CLIENT_WXMP); - govTokenDto.setUserId(staffId); - govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); - govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); - govTokenDto.setUnionId(null == wxMaJscode2SessionResult.getUnionid() ? "" : wxMaJscode2SessionResult.getUnionid()); - govTokenDto.setToken(token); - govTokenDto.setUpdateTime(System.currentTimeMillis()); - govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); - govTokenDto.setRootAgencyId(orgId); - govTokenDto.setCustomerId(customerId); + @Override + public List getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO) { + //0.根据appId查询对应客户Id + Result resultDTO = epmetThirdFeignClient.getCustomerMsg(formDTO.getAppId()); + if (!resultDTO.success()) { + logger.error(String.format("根据appId查询客户Id失败,对应appId->" + formDTO.getAppId())); + throw new RenException(resultDTO.getMsg()); + } + PaCustomerDTO customer = resultDTO.getData().getCustomer(); + //7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun + //1、根据手机号查询到用户信息 + ThirdCustomerStaffFormDTO dto = new ThirdCustomerStaffFormDTO(); + dto.setCustomerId(customer.getId()); + dto.setMobile(formDTO.getMobile()); + Result> customerStaffResult = epmetUserOpenFeignClient.getCustsomerStaffByIdAndPhone(dto); + if (!customerStaffResult.success()) { + logger.error(String.format("手机密码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); + throw new RenException(customerStaffResult.getCode()); + } + //2、密码是否正确 + List customerStaffList=customerStaffResult.getData(); + //3、查询用户所有的组织信息 + List customerIdList = new ArrayList<>(); + //是否设置过密码 + boolean havePasswordFlag=false; + //密码是否正确 + boolean passwordRightFlag=false; + for (CustomerStaffDTO customerStaffDTO : customerStaffList) { + if(StringUtils.isNotBlank(customerStaffDTO.getPassword())){ + havePasswordFlag=true; + }else{ + logger.warn(String.format("当前用户:手机号%s,客户Id%s下未设置密码.",formDTO.getMobile(),customerStaffDTO.getCustomerId())); + continue; + } + if (!PasswordUtils.matches(formDTO.getPassword(), customerStaffDTO.getPassword())) { + logger.warn(String.format("当前用户:手机号%s,客户Id%s密码匹配错误.",formDTO.getMobile(),customerStaffDTO.getCustomerId())); - //设置部门,网格,角色列表 - govTokenDto.setDeptIdList(getDeptartmentIdList(staffId)); - govTokenDto.setGridIdList(getGridIdList(staffId)); - CustomerAgencyDTO agency = getAgencyByStaffId(staffId); - if (agency != null) { - govTokenDto.setAgencyId(agency.getId()); - govTokenDto.setRoleList(queryGovStaffRoles(staffId, agency.getId())); + }else{ + logger.warn(String.format("当前用户:手机号%s,客户Id%s密码匹配正确.",formDTO.getMobile(),customerStaffDTO.getCustomerId())); + passwordRightFlag=true; + customerIdList.add(customerStaffDTO.getCustomerId()); + } } - govTokenDto.setOrgIdPath(getOrgIdPath(staffId)); - cpUserDetailRedis.set(govTokenDto, expire); - logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + //根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码 + if(!havePasswordFlag){ + logger.error(String.format("当前手机号(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getMobile())); + throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); + } + //密码错误 + if(!passwordRightFlag){ + logger.error(String.format("根据当前手机号(%s)密码未找到所属组织,密码错误",formDTO.getMobile())); + throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode()); + } + StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO(); + staffOrgFormDTO.setCustomerIdList(customerIdList); + Result> result = govOrgOpenFeignClient.getStaffOrgList(staffOrgFormDTO); + if(result.success()&&null!=result.getData()){ + return result.getData(); + } + logger.error(String .format("手机验证码获取组织,调用%s服务失败,入参手机号%s,密码%s,返回错误码%s,错误提示信息%s", + ServiceConstant.GOV_ORG_SERVER, + formDTO.getMobile(), + formDTO.getPassword(), + result.getCode(), + result.getMsg())); + return new ArrayList<>(); } } diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index 01d92799d7..1a21a9a30e 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -133,6 +133,15 @@ org.apache.httpcomponents httpmime + + org.apache.httpcomponents + httpmime + + + commons-httpclient + commons-httpclient + 3.1 + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 1cd6ba736c..78c341fcb4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -85,6 +85,7 @@ public enum EpmetErrorCode { NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"), NON_CERTIFIED_VOLUNTEER(8511, "活动报名失败,请先认证志愿者"), ACT_TIME_CONFLICT(8512, "报名失败。您本次报名活动时间与已报名活动时间间隔较短,为了不影响您已报名的活动,请选择其他时间的活动,谢谢。"), + ACT_REGISTRATION_SUCCESS(8513, "报名成功。"), // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java index a9623b7cde..f309630863 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java @@ -1,37 +1,65 @@ package com.epmet.commons.tools.utils; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +/** + * @author kamui + */ public class FileUtils { - /** - * 创建临时文件. - * - * @param inputStream 输入文件流 - * @param name 文件名 - * @param ext 扩展名 - * @param tmpDirFile 临时文件夹目录 - */ - public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { - File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile); - - resultFile.deleteOnExit(); - org.apache.commons.io.FileUtils.copyToFile(inputStream, resultFile); - return resultFile; - } - - /** - * 创建临时文件. - * - * @param inputStream 输入文件流 - * @param name 文件名 - * @param ext 扩展名 - */ - public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { - return createTmpFile(inputStream, name, ext, Files.createTempDirectory("weixin-java-tools-temp").toFile()); - } + /** + * 创建临时文件 + * + * @param inputStream + * @param name 文件名 + * @param ext 扩展名 + * @param tmpDirFile 临时文件夹目录 + */ + public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { + File tmpFile; + if (tmpDirFile == null) { + tmpFile = File.createTempFile(name, '.' + ext); + } else { + tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile); + } + + tmpFile.deleteOnExit(); + FileOutputStream fos = new FileOutputStream(tmpFile); + try { + int read = 0; + byte[] bytes = new byte[1024 * 100]; + while ((read = inputStream.read(bytes)) != -1) { + fos.write(bytes, 0, read); + } + + fos.flush(); + } catch (Exception e) { + + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + } + } + + } + return tmpFile; + } + + /** + * 创建临时文件 + * + * @param inputStream + * @param name 文件名 + * @param ext 扩展名 + */ + public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { + return createTmpFile(inputStream, name, ext, null); + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java index 151ad8e10d..7d456a6707 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java @@ -22,7 +22,6 @@ import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -171,20 +170,14 @@ public class HttpClientManager { try { HttpPost httppost = new HttpPost(url); httppost.setConfig(requestConfig); - String boundaryStr = "------------" + System.currentTimeMillis(); - httppost.addHeader("Connection", "keep-alive"); - httppost.addHeader("Accept", "*/*"); - httppost.addHeader("Content-Type", "multipart/form-data;boundary=" + boundaryStr); - httppost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); - MultipartEntityBuilder meb = MultipartEntityBuilder.create(); - meb.setBoundary(boundaryStr).setCharset(StandardCharsets.UTF_8).setMode(HttpMultipartMode.BROWSER_COMPATIBLE); - meb.addBinaryBody("media", file, ContentType.APPLICATION_OCTET_STREAM, file.getName()); - HttpEntity entity = meb.build(); - httppost.setEntity(entity); -// FileBody fileBody = new FileBody(file); -// HttpEntity reqEntity = MultipartEntityBuilder.create() -// .addPart("media", fileBody).build(); -// httppost.setEntity(reqEntity); + if (file != null) { + HttpEntity entity = MultipartEntityBuilder + .create() + .addBinaryBody("media", file) + .setMode(HttpMultipartMode.RFC6532) + .build(); + httppost.setEntity(entity); + } return execute(httppost,false); } catch (Exception e) { log.error("send exception", e); diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActRegistrationResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActRegistrationResultDTO.java new file mode 100644 index 0000000000..96ca7a6e61 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActRegistrationResultDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.result.resi; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 活动报名 - 返回值 + * + * @Auther: zhangyong + * @Date: 2020-07-28 16:22 + */ +@Data +public class ResiActRegistrationResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 异常编码 + */ + private Integer flag; + + /** + * 提示信息 + */ + private String tip; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActResultDTO.java index 887a457b4e..4c8b013287 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActResultDTO.java @@ -52,4 +52,9 @@ public class CanceledActResultDTO implements Serializable { * 活动取消的原因 */ private String cancelReason; + + /** + * 活动地点 + */ + private String actAddress; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActResultDTO.java index 25f9d7e46b..6a23d0498b 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActResultDTO.java @@ -53,4 +53,9 @@ public class FinishedActResultDTO implements Serializable { */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date actualEndTime; + + /** + * 活动地点 + */ + private String actAddress; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActResultDTO.java index 5e25e5fab0..c7c73f6a96 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActResultDTO.java @@ -77,4 +77,9 @@ public class InProgressActResultDTO implements Serializable { @JsonIgnore @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date signUpStartTime; + + /** + * 活动地点 + */ + private String actAddress; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/JoinedUserResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/JoinedUserResultDTO.java index 821364850a..aae8d212e7 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/JoinedUserResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/JoinedUserResultDTO.java @@ -51,6 +51,12 @@ public class JoinedUserResultDTO implements Serializable { */ private Boolean signInFlag; + /** + * 已签到:signed_in; 默认"" + */ + @JsonIgnore + private String signInFlagStr; + /** * true: 是志愿者 false : 不是志愿者 */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-dev.yml index a0a80e2b1a..98dfa4eb08 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-heart/epmet-heart-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-heart-server: container_name: epmet-heart-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-heart-server:0.0.4 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-heart-server:0.0.5 ports: - "8111:8111" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-heart/epmet-heart-server/pom.xml b/epmet-module/epmet-heart/epmet-heart-server/pom.xml index 7f9cd25c89..428cba0d77 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/pom.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.0.4 + 0.0.5 com.epmet epmet-heart diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java index 1dfb2ed28a..e08ecfb96d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java @@ -293,17 +293,18 @@ public class ResiActListController { return actSignInRecService.actSignIn(tokenDto, formDTO); } - /** + /* * 活动报名 * * @param tokenDto * @param formDTO - * @return com.epmet.commons.tools.utils.Result + * + * @return com.epmet.commons.tools.utils.Result * @Author zhangyong - * @Date 16:46 2020-07-23 + * @Date 16:26 2020-07-28 **/ @PostMapping("registration") - public Result registration(@LoginUser TokenDto tokenDto, @RequestBody ResiActRegistrationFormDTO formDTO) { + public Result registration(@LoginUser TokenDto tokenDto, @RequestBody ResiActRegistrationFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, ResiActRegistrationFormDTO.AddUserInternalGroup.class); return actUserRelationService.registration(tokenDto, formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java index 7deae2b1af..81fd46ce1e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java @@ -73,7 +73,7 @@ public class WorkActController { * @return com.epmet.commons.tools.utils.Result * @param formDTO * @author yinzuomei - * @description 进行中活动列表 + * @description 进行中-活动列表 * @Date 2020/7/23 21:24 **/ @PostMapping("inprogresslist") diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java index f3a135ee6a..a290d59c5f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java @@ -24,6 +24,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.ActUserRelationDTO; import com.epmet.dto.form.resi.ResiActRegistrationFormDTO; import com.epmet.dto.form.resi.ResiActUserCancelSignUpFormDTO; +import com.epmet.dto.result.resi.ResiActRegistrationResultDTO; import com.epmet.entity.ActUserRelationEntity; import org.apache.ibatis.annotations.Param; @@ -145,9 +146,9 @@ public interface ActUserRelationService extends BaseService> * @Author zhangyong - * @Date 16:46 2020-07-23 + * @Date 15:54 2020-07-28 **/ - Result registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO); + Result registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java index 5d6ed5249b..22bc9b42dc 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java @@ -39,6 +39,7 @@ import com.epmet.dto.ActUserRelationDTO; import com.epmet.dto.form.resi.ResiActRegistrationFormDTO; import com.epmet.dto.form.resi.ResiActUserCancelSignUpFormDTO; import com.epmet.dto.result.UserRoleResultDTO; +import com.epmet.dto.result.resi.ResiActRegistrationResultDTO; import com.epmet.entity.ActUserLogEntity; import com.epmet.entity.ActUserRelationEntity; import com.epmet.entity.HeartUserInfoEntity; @@ -54,10 +55,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 用户活动关系表 @@ -197,9 +195,10 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); boolean satisfy = false; + ResiActRegistrationResultDTO resultDTO = new ResiActRegistrationResultDTO(); // 查询活动信息 ActInfoDTO actInfoDTO = actInfoService.get(formDTO.getActId()); // >0 当前用户是志愿者 @@ -207,15 +206,35 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl().ok(resultDTO); + } } else { // 活动不限制志愿者身份,但要求是 居民身份, 当前用户是否满足条件 satisfy = this.resiParticipationAct(formDTO.getUserId()); + if (!satisfy){ + logger.info("活动报名失败,请完善居民信息"); + resultDTO.setFlag(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); + resultDTO.setTip(EpmetErrorCode.CANNOT_AUDIT_WARM.getMsg()); + return new Result().ok(resultDTO); + } } if (satisfy){ // 开始报名 - this.actStartSignUp(actInfoDTO, formDTO, volunteerFlag); + boolean actTimeConflict = this.actStartSignUp(actInfoDTO, formDTO, volunteerFlag); + if (!actTimeConflict){ + logger.info("报名失败。您本次报名活动时间与已报名活动时间间隔较短,为了不影响您已报名的活动,请选择其他时间的活动,谢谢。"); + resultDTO.setFlag(EpmetErrorCode.ACT_TIME_CONFLICT.getCode()); + resultDTO.setTip(EpmetErrorCode.ACT_TIME_CONFLICT.getMsg()); + return new Result().ok(resultDTO); + } } - return new Result(); + resultDTO.setFlag(EpmetErrorCode.ACT_REGISTRATION_SUCCESS.getCode()); + resultDTO.setTip(EpmetErrorCode.ACT_REGISTRATION_SUCCESS.getMsg()); + return new Result().ok(resultDTO); } /** @@ -228,7 +247,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl NumConstant.ZERO){ @@ -237,8 +256,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl NumConstant.ZERO){ signUp = false; - logger.info("报名失败。您本次报名活动时间与已报名活动时间间隔较短,为了不影响您已报名的活动,请选择其他时间的活动,谢谢。"); - throw new RenException(EpmetErrorCode.ACT_TIME_CONFLICT.getCode()); + return signUp; } } else { // 3.第一次报名 @@ -249,7 +267,8 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl NumConstant.ZERO){ satisfy = true; return satisfy; - } else { - logger.info("活动报名失败,请先认证志愿者"); - throw new RenException(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode()); } + return satisfy; } /** @@ -289,12 +306,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl inProgressActResultDTO.getSignedUp()) { + logger.info("活动限制名额,未报满,界面显示报名中"); inProgressActResultDTO.setStatus("signing_up"); continue; } else if (inProgressActResultDTO.getActQuota().equals(inProgressActResultDTO.getSignedUp())) { inProgressActResultDTO.setStatus("enough"); + logger.info("活动限制名额,且已报满,界面显示已报满"); continue; } } } else if (nowDate.compareTo(inProgressActResultDTO.getSignUpEndTime()) == 1 - || nowDate.compareTo(inProgressActResultDTO.getActStartTime()) == -1) { + &&nowDate.compareTo(inProgressActResultDTO.getActStartTime()) == -1) { + logger.info(String.format("当前时间%s报名截止时间%s活动预计开始时间%s界面显示截止报名", + DateUtils.format(nowDate,DateUtils.DATE_TIME_PATTERN), + DateUtils.format(inProgressActResultDTO.getSignUpEndTime(),DateUtils.DATE_TIME_PATTERN), + DateUtils.format(inProgressActResultDTO.getActStartTime(),DateUtils.DATE_TIME_PATTERN))); //活动报名截止-活动预计开始之间显示截止报名 inProgressActResultDTO.setStatus("end_sign_up"); continue; } else if (nowDate.compareTo(inProgressActResultDTO.getActStartTime()) == 1 || nowDate.compareTo(inProgressActResultDTO.getActStartTime()) == 0) { + logger.info(String.format("当前时间%s活动预计开始时间%s界面显示已开始", + DateUtils.format(nowDate,DateUtils.DATE_TIME_PATTERN), + DateUtils.format(inProgressActResultDTO.getActStartTime(),DateUtils.DATE_TIME_PATTERN))); //活动预计开始时间点之后,包含活动预计开始时间点,显示 已开始 inProgressActResultDTO.setStatus("in_progress"); continue; @@ -596,6 +608,7 @@ public class WorkActServiceImpl implements WorkActService { * @Date 2020/7/26 17:26 **/ @Override + @Transactional(rollbackFor = Exception.class) public void cancelAct(CancelActFormDTO formDTO) { ActInfoDTO actInfoDTO=actInfoService.get(formDTO.getActId()); if(null==actInfoDTO){ @@ -671,14 +684,15 @@ public class WorkActServiceImpl implements WorkActService { * @Date 2020/7/26 19:49 **/ @Override + @Transactional(rollbackFor = Exception.class) public void saveActualTime(SaveActualTimeFormDTO formDTO) { - if(formDTO.getActualStartTime().compareTo(formDTO.getActualEndTime())!=-1){ + Date actualStartTime= DateUtils.minStrToSecondDate(formDTO.getActualStartTime()); + Date actualEndTime= DateUtils.minStrToSecondDate(formDTO.getActualEndTime()); + if(actualStartTime.compareTo(actualEndTime)!=-1){ throw new RenException(EpmetErrorCode.ACT_ACTUAL_START_TIME_ERROR.getCode()); } ActInfoDTO actInfoDTO=actInfoService.get(formDTO.getActId()); - Date actualStartTime= DateUtils.minStrToSecondDate(formDTO.getActualStartTime()); actInfoDTO.setActualStartTime(actualStartTime); - Date actualEndTime= DateUtils.minStrToSecondDate(formDTO.getActualEndTime()); actInfoDTO.setActualEndTime(actualEndTime); actInfoDTO.setServiceMin(DateUtils.calculateMin(actualStartTime,actualEndTime)); actInfoService.update(actInfoDTO); @@ -736,6 +750,7 @@ public class WorkActServiceImpl implements WorkActService { * @Date 2020/7/26 21:48 **/ @Override + @Transactional(rollbackFor = Exception.class) public void finishAct(String actId) { ActInfoDTO actInfoDTO=actInfoService.get(actId); if(null==actInfoDTO){ @@ -762,7 +777,7 @@ public class WorkActServiceImpl implements WorkActService { private void grantActPoints(ActInfoDTO actInfoDTO) { //查询已经给分的用户 QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(actInfoDTO.getId()), FieldConstant.ID, actInfoDTO.getId()) + wrapper.eq(StringUtils.isNotBlank(actInfoDTO.getId()), "ACT_ID", actInfoDTO.getId()) .eq("PROCESS_FLAG",ActConstant.HANDLED) .eq("REWARD_FLAG",ActConstant.ACT_USER_STATUS_AGREE); List actUserRelationEntityList=actUserRelationDao.selectList(wrapper); @@ -862,10 +877,13 @@ public class WorkActServiceImpl implements WorkActService { if(!actInfoDTO.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); } + //如果活动设置的分支大于0,需要判断是否已经处理完毕 //待处理事项为空时才可以结束活动 - List list=actUserRelationDao.selectInProgress(actInfoDTO.getId()); - if(null!=list&&list.size()>0){ - throw new RenException(EpmetErrorCode.HAVE_HANDLE.getCode()); + if(actInfoDTO.getReward()>0){ + List list=actUserRelationDao.selectInProgress(actInfoDTO.getId()); + if(null!=list&&list.size()>0){ + throw new RenException(EpmetErrorCode.HAVE_HANDLE.getCode()); + } } //先填写实际开始时间、实际结束时间 if(null==actInfoDTO.getActualStartTime()||null==actInfoDTO.getActualEndTime()){ @@ -882,6 +900,7 @@ public class WorkActServiceImpl implements WorkActService { * @Date 2020/7/27 10:45 **/ @Override + @Transactional(rollbackFor = Exception.class) public void summaryAct(SummaryActFormDTO formDTO) { ActInfoDTO actInfoDTO=actInfoService.get(formDTO.getActId()); if(null==actInfoDTO){ @@ -958,6 +977,7 @@ public class WorkActServiceImpl implements WorkActService { * @Date 2020/7/27 13:55 **/ @Override + @Transactional(rollbackFor = Exception.class) public PublishActResultDTO rePublish(RePublishFormDTO rePublishFormDTO) { ActInfoDTO originalActInfo=actInfoService.get(rePublishFormDTO.getActId()); if(null==originalActInfo){ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java index c2f121e972..87d8575e03 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java @@ -13,11 +13,15 @@ import com.epmet.constant.ReadFlagConstant; import com.epmet.dao.ActInfoDao; import com.epmet.dao.ActUserLogDao; import com.epmet.dao.ActUserRelationDao; +import com.epmet.dto.ActInfoDTO; import com.epmet.dto.ActUserLogDTO; import com.epmet.dto.ActUserRelationDTO; import com.epmet.dto.HeartUserInfoDTO; import com.epmet.dto.form.UserMessageFormDTO; -import com.epmet.dto.form.work.*; +import com.epmet.dto.form.work.AactUserDetailFormDTO; +import com.epmet.dto.form.work.ActIdFormDTO; +import com.epmet.dto.form.work.AuditUserFormDTO; +import com.epmet.dto.form.work.UserHistoricalActFormDTO; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.work.*; import com.epmet.entity.ActInfoEntity; @@ -25,6 +29,7 @@ import com.epmet.entity.ActUserLogEntity; import com.epmet.entity.ActUserRelationEntity; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.service.ActInfoService; import com.epmet.service.ActUserRelationService; import com.epmet.service.HeartUserInfoService; import com.epmet.service.WorkActUserService; @@ -32,6 +37,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Date; @@ -62,6 +68,8 @@ public class WorkActUserServiceImpl implements WorkActUserService { private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; @Autowired private LoginUserUtil loginUserUtil; + @Autowired + private ActInfoService actInfoService; /** * @param formDTO * @return java.util.List @@ -358,6 +366,7 @@ public class WorkActUserServiceImpl implements WorkActUserService { * @Date 2020/7/23 17:30 **/ @Override + @Transactional(rollbackFor = Exception.class) public void auditPass(String actUserRelationId) { ActUserRelationEntity actUserRelationEntity=actUserRelationDao.selectById(actUserRelationId); if(null==actUserRelationEntity||!ActConstant.ACT_USER_STATUS_AUDITING.equals(actUserRelationEntity.getStatus())){ @@ -404,6 +413,7 @@ public class WorkActUserServiceImpl implements WorkActUserService { * @Date 2020/7/23 18:14 **/ @Override + @Transactional(rollbackFor = Exception.class) public void auditRefuse(AuditUserFormDTO formDTO) { ActUserRelationEntity actUserRelationEntity=actUserRelationDao.selectById(formDTO.getActUserRelationId()); if(null==actUserRelationEntity||!ActConstant.ACT_USER_STATUS_AUDITING.equals(actUserRelationEntity.getStatus())){ @@ -451,6 +461,11 @@ public class WorkActUserServiceImpl implements WorkActUserService { **/ @Override public List queryJoinUserList(ActIdFormDTO formDTO) { + ActInfoDTO actInfoDTO=actInfoService.get(formDTO.getActId()); + if(null==actInfoDTO){ + logger.error("act_info is null"); + return new ArrayList<>(); + } List list=actInfoDao.queryJoinUserList(formDTO.getActId()); if(null!=list&&list.size()>0){ //查询已通过审核的人员id集合 @@ -458,11 +473,21 @@ public class WorkActUserServiceImpl implements WorkActUserService { //根据已通过的人员集合,查询出用户基本信息 List userInfoList=this.queryUserBaseInfoList(userIdList); for(JoinedUserResultDTO joinedUserResultDTO:list){ - //积分描述赋值 - if(ActConstant.ACT_USER_STATUS_AGREE.equals(joinedUserResultDTO.getRewardFlag())){ - joinedUserResultDTO.setPointsDes(String.format("积分+%s",joinedUserResultDTO.getReward())); - }else if(ActConstant.ACT_USER_STATUS_DENY.equals(joinedUserResultDTO.getRewardFlag())){ - joinedUserResultDTO.setPointsDes("积分+0"); + if(actInfoDTO.getActStatus().equals(ActConstant.ACT_STATUS_FINISHED)){ + //积分描述赋值 + if(ActConstant.ACT_USER_STATUS_AGREE.equals(joinedUserResultDTO.getRewardFlag())){ + joinedUserResultDTO.setPointsDes(String.format("积分+%s",joinedUserResultDTO.getReward())); + }else if(ActConstant.ACT_USER_STATUS_DENY.equals(joinedUserResultDTO.getRewardFlag())){ + joinedUserResultDTO.setPointsDes("积分+0"); + } + }else{ + logger.info("当前活动未结束,活动状态:"+actInfoDTO.getActStatus()); + joinedUserResultDTO.setPointsDes(StrConstant.EPMETY_STR); + } + if(ActConstant.ACT_USER_STATUS_SIGNED_IN.equals(joinedUserResultDTO.getSignInFlagStr())){ + joinedUserResultDTO.setSignInFlag(true); + }else{ + joinedUserResultDTO.setSignInFlag(false); } //志愿者标识赋值 joinedUserResultDTO.setVolunteerFlag(this.getVolunteerFlag(joinedUserResultDTO.getUserId())); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql index c2b485aaf5..67ee2b23de 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/epmet_heart.sql @@ -11,7 +11,7 @@ Target Server Version : 50728 File Encoding : 65001 - Date: 28/07/2020 13:38:27 + Date: 28/07/2020 15:17:47 */ SET NAMES utf8mb4; @@ -175,7 +175,6 @@ CREATE TABLE `act_point_log` ( `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键(给分或者不给分,以及重新处理插入本表)', `ACT_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动id', `USER_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户id', - `POINT_TYPE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '加积分:add ; 减积分:subtract', `POINTS` int(11) NOT NULL COMMENT '积分值', `OPERATE_TYPE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作类型:\r\n同意给分agree; 不给分:deny;重新处理: reset', `REMARK` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注:拒绝给分和重新处理时录入的理由', diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml index 2c83ec6ded..3828a814f8 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml @@ -483,7 +483,8 @@ AND ( aur.`STATUS` = 'auditing' OR aur.`STATUS` = 'passed' ) ) AS signedUp, ai.SIGN_UP_END_TIME as signUpEndTime, - ai.SIGN_UP_START_TIME as signUpStartTime + ai.SIGN_UP_START_TIME as signUpStartTime, + ai.ACT_ADDRESS as actAddress FROM act_info ai WHERE @@ -502,7 +503,8 @@ ai.ACT_START_TIME AS actStartTime, ai.ACT_END_TIME AS actEndTime, ai.CANCEL_TIME AS cancelTime, - ai.CANCEL_REASON AS cancelReason + ai.CANCEL_REASON AS cancelReason, + ai.ACT_ADDRESS as actAddress FROM act_info ai WHERE @@ -522,7 +524,8 @@ ai.ACT_START_TIME AS actStartTime, ai.ACT_END_TIME AS actEndTime, ai.ACTUAL_START_TIME as actualStartTime, - ai.ACTUAL_END_TIME as actualEndTime + ai.ACTUAL_END_TIME as actualEndTime, + ai.ACT_ADDRESS as actAddress FROM act_info ai WHERE @@ -539,7 +542,7 @@ aur.id as actUserRelationId, aur.ACT_ID , aur.USER_ID , - aur.SIGN_IN_FLAG, + aur.SIGN_IN_FLAG as signInFlagStr, aur.CREATED_TIME as signUpTime, ai.REWARD, aur.REWARD_FLAG, diff --git a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml index 42619a92cf..2992ed14e2 100644 --- a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-third-server: container_name: epmet-third-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.67 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.73 ports: - "8110:8110" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index 7a44b88d3b..8e297df54a 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.0.67 + 0.0.73 com.epmet diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java index e3735ec240..58da54fe8f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/CodeConstant.java @@ -49,6 +49,9 @@ public interface CodeConstant { String OPER_UPLOAD = "上传代码"; String OPER_SUBMIT = "提交审核"; + String OPER_SUCCESS = "审核成功"; + String OPER_FAILED = "审核被拒绝"; + String OPER_DELAY = "审核延后"; String OPER_UNDO = "审核撤回"; String OPER_RELEASE = "发布"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java index fc2190a39d..588b428c5d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java @@ -72,7 +72,7 @@ public interface CodeCustomerService extends BaseService { * @author generator * @date 2020-07-09 */ - void save(CodeCustomerDTO dto); + String save(CodeCustomerDTO dto); /** * 默认更新 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java index 1962b917a9..92c1b86a9c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java @@ -86,9 +86,10 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl { + List sortList = + wxResult.getData().stream().sorted(Comparator.comparing(WxMaTemplateResult::getCreateTime).reversed()).collect(Collectors.toList()); + sortList.forEach(temp -> { TemplateListResultDTO dto = new TemplateListResultDTO(); dto.setId(temp.getTemplateId()); dto.setUserVersion(temp.getUserVersion()); dto.setUserDesc(temp.getUserDesc()); - dto.setCreateTime(DateUtils.formatTimestamp(temp.getCreateTime(), DateUtils.DATE_PATTERN)); + dto.setCreateTime(DateUtils.formatTimestamp(temp.getCreateTime(), DateUtils.DATE_TIME_PATTERN)); resultList.add(dto); }); return resultList; @@ -101,14 +103,6 @@ public class CodeServiceImpl implements CodeService { return codeExtDTO.getExtJson(); } - public static void main(String[] args) { - String json = "{\"extEnable\":true,\"extAppid\":\"wx2679392c4cc2af22\",\"directCommit\":false,\"ext\":{\"extAppid\":\"wx2679392c4cc2af22\",\"footbar\":{\"work\":{\"name\":\"工作\",\"pageTile\":\"工作\"},\"org\":{\"name\":\"组织\",\"pageTile\":\"组织\"},\"data\":{\"name\":\"数据\",\"pageTile\":\"数据\"},\"find\":{\"name\":\"更多\",\"pageTile\":\"更多\"}}}}"; - WxExtJson wxExtJson = JSONObject.parseObject(json, WxExtJson.class); - wxExtJson.setExtAppid("123456"); - wxExtJson.getExt().setExtAppid("123456"); - String extJson = JSON.toJSONString(wxExtJson); - System.out.println(extJson); - } @Override @Transactional(rollbackFor = Exception.class) @@ -122,14 +116,11 @@ public class CodeServiceImpl implements CodeService { if (null == authInfo) { throw new RenException("未授权"); } - if (!isJson(formDTO.getExtJson())) { - throw new RenException("第三方配置不是有效的Json"); - } - - WxExtJson wxExtJson = JSONObject.parseObject(formDTO.getExtJson(), WxExtJson.class); + String extJson = getExtJson(formDTO); + WxExtJson wxExtJson = JSONObject.parseObject(extJson, WxExtJson.class); wxExtJson.setExtAppid(authInfo.getAuthorizerAppid()); wxExtJson.getExt().setExtAppid(authInfo.getAuthorizerAppid()); - String extJson = JSON.toJSONString(wxExtJson); + extJson = JSON.toJSONString(wxExtJson); CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); if (null == codeExtDTO) { codeExtDTO = new CodeExtDTO(); @@ -164,9 +155,9 @@ public class CodeServiceImpl implements CodeService { codeCustomerDTO.setExtJson(extJson); codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid()); codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); - codeCustomerService.save(codeCustomerDTO); + String codeId = codeCustomerService.save(codeCustomerDTO); - saveOperation(formDTO.getCustomerId(), codeCustomerDTO.getId(), formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, "上传成功"); + saveOperation(formDTO.getCustomerId(), codeId, formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, "上传成功"); } @Override @@ -187,18 +178,18 @@ public class CodeServiceImpl implements CodeService { if (result.getStatus() == NumConstant.ZERO) { code.setStatus(CodeConstant.AUDIT_SUCCESS); auditResult.setResult(CodeConstant.AUDIT_SUCCESS); - codeOperationHistoryService.updateDescribe(code.getId(), "审核成功"); + saveOperation(formDTO.getCustomerId(), code.getId(), code.getUserVersion(), CodeConstant.OPER_SUCCESS, "审核成功"); } else if (result.getStatus() == NumConstant.ONE) { code.setStatus(CodeConstant.AUDIT_FAILED); auditResult.setResult(CodeConstant.AUDIT_FAILED); auditResult.setReason(result.getReason()); auditResult.setScreenShot(result.getScreenshot()); - codeOperationHistoryService.updateDescribe(code.getId(), result.getReason()); + saveOperation(formDTO.getCustomerId(), code.getId(), code.getUserVersion(), CodeConstant.OPER_FAILED, result.getReason()); } else if (result.getStatus() == NumConstant.FOUR) { code.setStatus(CodeConstant.DELAY); auditResult.setResult(CodeConstant.DELAY); auditResult.setReason(result.getReason()); - codeOperationHistoryService.updateDescribe(code.getId(), "审核延后"); + saveOperation(formDTO.getCustomerId(), code.getId(), code.getUserVersion(), CodeConstant.OPER_DELAY, result.getReason()); } codeCustomerService.update(code); codeAuditResultService.update(auditResult); @@ -247,6 +238,7 @@ public class CodeServiceImpl implements CodeService { codeAuditResultDTO.setResult(CodeConstant.AUDITING); codeAuditResultService.save(codeAuditResultDTO); } else { + codeAuditResultDTO.setAuditId(wxResult.getData()); codeAuditResultDTO.setResult(CodeConstant.AUDITING); codeAuditResultService.update(codeAuditResultDTO); } @@ -358,10 +350,10 @@ public class CodeServiceImpl implements CodeService { request.setAuditId(codeAuditResultDTO.getAuditId()); WxMaNewsReq wxMaNewsReq = new WxMaNewsReq(); wxMaNewsReq.setMediaId(mediaId); - WxResult wxAuditResult = wxMaCodeService.getMaterial(authInfo.getAuthorizerAccessToken(), wxMaNewsReq); - wxAuditResult.getData().getNewsItem().forEach(news -> { - urlList.add(news.getUrl()); - }); + WxResult wxAuditResult = wxMaCodeService.getMaterial(authInfo.getAuthorizerAccessToken(), wxMaNewsReq); + MultipartFile file = new MockMultipartFile("file", "QRCode.jpg", "image/jpeg", wxAuditResult.getData()); + Result uploadResult = ossFeignClient.uploadQrCode(file); + urlList.add(uploadResult.getData().getUrl()); }); result.setScreenshotUrl(urlList); return result; @@ -373,7 +365,7 @@ public class CodeServiceImpl implements CodeService { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); if (null != codeCustomerDTO.getQrCode()) { - result.setQrcode(codeCustomerDTO.getQrCode()); + result.setQrcode(codeCustomerDTO.getQrCode()); return result; } //是否授权 @@ -409,8 +401,8 @@ public class CodeServiceImpl implements CodeService { @Override public String mediaUpload(MediaUploadFormDTO formDTO) { try { - Result uploadWxImg = ossFeignClient.uploadWxImg(formDTO.getMedia()); - File file = new File(uploadWxImg.getData().getUrl()); + File file = new File(formDTO.getMedia().getOriginalFilename()); + FileUtils.copyInputStreamToFile(formDTO.getMedia().getInputStream(), file); //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); //获取小程序调用令牌 @@ -443,50 +435,4 @@ public class CodeServiceImpl implements CodeService { codeOperationHistoryService.save(operationDTO); } - /** - * 校验是否是Json - * - * @param content - * @return boolean - * @author zhaoqifeng - * @date 2020/7/17 15:43 - */ - private boolean isJson(String content) { - try { - JSONObject jsonStr = JSONObject.parseObject(content); - return true; - } catch (Exception e) { - return false; - } - } - - private byte[] toPrimitives(Byte[] oBytes) { - byte[] bytes = new byte[oBytes.length]; - - for (int i = 0; i < oBytes.length; i++) { - bytes[i] = oBytes[i]; - } - return bytes; - } - - private void byteToFile(byte[] bytes) - { - try - { - // 根据绝对路径初始化文件 - File localFile = new File("."); - if (!localFile.exists()) - { - localFile.createNewFile(); - } - // 输出流 - OutputStream os = new FileOutputStream(localFile); - os.write(bytes); - os.close(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index 74f723aed1..2cbb986d40 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -241,23 +241,25 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); log.info(String.format(POST_RESULT,post)); Map hashMap = JSON.parseObject(post, Map.class); - preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString(); - Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); - Date expiresInTime = this.countExpirationTime(expiresIn.toString()); - if (StringUtils.isNotEmpty(preAuthCode)) { - //预授权码 存DB - PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO(); - formDTO.setPreAuthToken(preAuthCode); - formDTO.setExpiresInTime(expiresInTime); - //先逻辑删除,在插入DB - preAuthTokenDao.updateOldPreAuthCode(); - preAuthTokenDao.insertPreAuthToken(formDTO); - //预授权码 放入缓存 - redisThird.setPreAuthCode(preAuthCode); - } else { - throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE); + if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) { + preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString(); + Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); + Date expiresInTime = this.countExpirationTime(expiresIn.toString()); + if (StringUtils.isNotEmpty(preAuthCode)) { + //预授权码 存DB + PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO(); + formDTO.setPreAuthToken(preAuthCode); + formDTO.setExpiresInTime(expiresInTime); + //先逻辑删除,在插入DB + preAuthTokenDao.updateOldPreAuthCode(); + preAuthTokenDao.insertPreAuthToken(formDTO); + //预授权码 放入缓存 + redisThird.setPreAuthCode(preAuthCode); + } else { + throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE); + } + log.info(END_GET_PRE_AUTH_CODE); } - log.info(END_GET_PRE_AUTH_CODE); return preAuthCode; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java index 9302f876ff..6d82fae8da 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java @@ -159,10 +159,10 @@ public interface WxMaCodeConstant { /** * 新增临时素材 */ - String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain"; + String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload"; /** - * 新增临时素材 + * 获取模板列表 */ String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/gettemplatelist"; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java index dca678a55e..b22c03e451 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java @@ -110,7 +110,7 @@ public interface WxMaCodeService { * @author zhaoqifeng * @date 2020/7/16 14:52 */ - WxResult getMaterial(String accessToken, WxMaNewsReq request); + WxResult getMaterial(String accessToken, WxMaNewsReq request); /** * 设置服务器郁闷 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java index 97f7cac543..3c9917d9e8 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java @@ -10,6 +10,7 @@ import com.epmet.wxapi.result.*; import com.epmet.wxapi.service.WxMaCodeService; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,7 +20,9 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.Collections; import java.util.List; +import java.util.Map; /** * 描述一下 @@ -156,7 +159,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { return result; } WxMaAuditStatusResult auditStatusResult = JSONObject.parseObject(statusResult.getData(), WxMaAuditStatusResult.class); - if (!auditStatusResult.success()){ + if (!auditStatusResult.success()) { result.setErrorCode(auditStatusResult.getErrcode()); result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(auditStatusResult.getErrcode())); return result; @@ -198,19 +201,16 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { } @Override - public WxResult getMaterial(String accessToken, WxMaNewsReq request) { - WxResult result = new WxResult<>(); + public WxResult getMaterial(String accessToken, WxMaNewsReq request) { + WxResult result = new WxResult<>(); String url = WxMaCodeConstant.GET_MATERIAL_URL + "?" + "access_token=" + accessToken; - Result statusResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); + Result statusResult = HttpClientManager.getInstance().getByteArray(url, toMap(request)); if (!statusResult.success()) { result.setErrorCode(statusResult.getCode()); result.setErrorMsg(statusResult.getMsg()); return result; } - Gson gson = new Gson(); - InputStream inputStream = gson.fromJson(statusResult.getData(), InputStream.class); - WxMaNewsResult newsResult = gson.fromJson(statusResult.getData(), WxMaNewsResult.class); - result.ok(newsResult); + result.ok(statusResult.getData()); return result; } @@ -269,6 +269,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { WxMaUploadMediaResult mediaInfo = gson.fromJson(mediaResult.getData(), WxMaUploadMediaResult.class); result.setErrorCode(mediaInfo.getErrCode()); result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(mediaInfo.getErrCode())); + result.ok(mediaInfo); return result; } @@ -278,4 +279,12 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { Gson gson = gsonBuilder.create(); return gson.toJson(object); } + + private Map toMap(Object object) { + Gson gson = new Gson(); + if(object == null){ + return Collections.emptyMap(); + } + return gson.fromJson(toJson(object), new TypeToken>() {}.getType()); + } } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml index 2e18d09f58..e3082547af 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml @@ -28,7 +28,7 @@ DATE_FORMAT(coh.CREATED_TIME, '%Y-%m-%d %T') AS "operationTime", coh.VERSION, coh.OPERATION, - coh.`DESCRIPTION` + coh.`DESCRIPTION` AS "describe" FROM code_operation_history coh INNER JOIN code_customer cc ON coh.CODE_ID = cc.ID WHERE diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml index 2024c79005..20632a7f3c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml @@ -96,6 +96,9 @@ WHERE del_flag = '0' AND app_id = #{appId} + AND AUTHORIZATION_FLAG = '1' + ORDER BY CREATED_TIME DESC + LIMIT 1 + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml index 1bc8034712..c453d319a7 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml @@ -68,4 +68,24 @@ uw.DEL_FLAG = '0' AND uw.USER_ID = #{userId} - \ No newline at end of file + + + +