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 36f968e3b0..22eb8f38ac 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,7 +85,11 @@ public enum EpmetErrorCode { CUSTOMER_VALIDATE_ERROR(8999, "内部数据校验异常"), //公众号 865..开头的码 - PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"); + PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"), + SELECT_CUSTOMER_ERROR(8652,"未查询到注册客户信息"), + SELECT_AGENCY_ERROR(8653,"根据客户信息未查询到注册客户组织信息"), + SELECT_USER_ERROR(8654,"根据客户信息未查询到注册客户管理员信息"), + UPDATE_CUSTOMER_ERROR(8655,"更新注册客户信息为已完成初始化失败"); private int code; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java similarity index 96% rename from epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java rename to epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java index 9d400efb40..c668daeaea 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CustomerCodeOperationHistoryDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java @@ -29,7 +29,7 @@ import lombok.Data; * @since v1.0.0 2020-07-09 */ @Data -public class CustomerCodeOperationHistoryDTO implements Serializable { +public class CodeOperationHistoryDTO implements Serializable { private static final long serialVersionUID = 1L; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java index e659efc669..3ea9efa543 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PaCustomerAgencyDTO.java @@ -19,6 +19,8 @@ package com.epmet.dto; import java.io.Serializable; import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; @@ -52,6 +54,11 @@ public class PaCustomerAgencyDTO implements Serializable { * 级别 */ private String level; + /** + * 级别(0.省级,1市级,2.区县级,3.乡镇街道级 4.社区级 5无) + */ + @JsonIgnore + private String levelNum; /** * 地区编码 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java index 083f145ba6..e854b15992 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeCommonFormDTO.java @@ -20,4 +20,6 @@ public class CodeCommonFormDTO implements Serializable { * 代码ID */ private String codeId; + private Integer page; + private Integer limit; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeHistoryResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeHistoryResultDTO.java new file mode 100644 index 0000000000..1aa68a49c2 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeHistoryResultDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 9:53 + */ +@NoArgsConstructor +@Data +public class CodeHistoryResultDTO implements Serializable { + private static final long serialVersionUID = 6030280825893585115L; + /** + * 操作时间 + */ + private String operationTime; + /** + * 版本 + */ + private String version; + /** + * 操作 上传upload,审核audit,撤回undo,发布release + */ + private String operation; + /** + * 描述 + */ + private String describe; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java new file mode 100644 index 0000000000..3d46c4cebc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/InitCustomerResultDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.result; + +import com.epmet.dto.PaCustomerAgencyDTO; +import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.PaUserDTO; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 运营端初始化客户信息-查询客户各项注册信息-接口返参 + */ +@Data +public class InitCustomerResultDTO implements Serializable { + + private static final long serialVersionUID = 3253989119352850315L; + + /** + * 注册客户信息 + */ + private PaCustomerDTO paCustomer; + /** + * 注册客户组织信息 + */ + private PaCustomerAgencyDTO paAgency; + /** + * 注册客户管理员信息 + */ + private PaUserDTO paUser; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/QrCodeResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/QrCodeResultDTO.java new file mode 100644 index 0000000000..c33b27f8dc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/QrCodeResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 9:46 + */ +@NoArgsConstructor +@Data +public class QrCodeResultDTO implements Serializable { + + private static final long serialVersionUID = -1145375851106140589L; + /** + * 二维码 + */ + private Object qrcode; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ReasonResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ReasonResultDTO.java new file mode 100644 index 0000000000..82223d583a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ReasonResultDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 9:28 + */ +@NoArgsConstructor +@Data +public class ReasonResultDTO implements Serializable { + private static final long serialVersionUID = -1905907350492787127L; + /** + * 失败原因 + */ + private String reason; + /** + * 失败的小程序截图url + */ + private List screenshotUrl; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java index 4b038324ac..996a70e9b2 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdFeignClient.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.SaveUserVisitedFormDTO; import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.InitCustomerResultDTO; import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.feign.fallback.EpmetThirdFeignClientFallback; import me.chanjar.weixin.mp.bean.result.WxMpUser; @@ -49,4 +50,22 @@ public interface EpmetThirdFeignClient { **/ @PostMapping(value = "third/pauservisited/saveuservisited") Result saveUserVisited(@RequestBody SaveUserVisitedFormDTO visited); + + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + @PostMapping(value = "third/pacustomer/getcustomeragencyuser/{customerId}") + Result getCustomerAgencyUser(@PathVariable("customerId") String customerId); + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + @PostMapping(value = "third/pacustomer/updatecustomer/{customerId}") + Result updateCustomer(@PathVariable("customerId") String customerId); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java index b1965cad5a..a1b0cd0ace 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdFeignClientFallback.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.SaveUserVisitedFormDTO; import com.epmet.dto.result.CustomerUserResultDTO; +import com.epmet.dto.result.InitCustomerResultDTO; import com.epmet.dto.result.SaveUserResultDTO; import com.epmet.feign.EpmetThirdFeignClient; import me.chanjar.weixin.mp.bean.result.WxMpUser; @@ -31,4 +32,14 @@ public class EpmetThirdFeignClientFallback implements EpmetThirdFeignClient { public Result saveUserVisited(SaveUserVisitedFormDTO visited) { return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "saveUserVisited", visited); } + + @Override + public Result getCustomerAgencyUser(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getCustomerAgencyUser", customerId); + } + + @Override + public Result updateCustomer(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "updateCustomer", customerId); + } } 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 6089c8b936..e3735ec240 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 @@ -46,4 +46,9 @@ public interface CodeConstant { * 发布失败 */ String RELEASE_FAILED = "release_failed"; + + String OPER_UPLOAD = "上传代码"; + String OPER_SUBMIT = "提交审核"; + String OPER_UNDO = "审核撤回"; + String OPER_RELEASE = "发布"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java index 59eef94f35..bd79db3a9f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java @@ -1,13 +1,16 @@ package com.epmet.controller; +import com.baomidou.mybatisplus.extension.api.R; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.CodeCommonFormDTO; import com.epmet.dto.form.CodeUploadFormDTO; import com.epmet.dto.form.SubmitAuditFormDTO; import com.epmet.dto.form.UploadListFormDTO; -import com.epmet.dto.result.TemplateListResultDTO; -import com.epmet.dto.result.UploadListResultDTO; +import com.epmet.dto.result.*; +import com.epmet.service.CodeService; import oracle.jdbc.proxy.annotation.Post; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -24,62 +27,131 @@ import java.util.List; @RequestMapping("code") public class CodeController { + @Autowired + private CodeService codeService; + /** * 获取代码模板列表 + * + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/14 15:10 - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("templatelist") public Result> templateList() { - return null; + List list = codeService.templateList(); + return new Result>().ok(list); } /** * 代码上传 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/9 14:23 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("upload") public Result upload(@RequestBody CodeUploadFormDTO formDTO) { + codeService.upload(formDTO); return new Result<>(); } /** * 已上传代码列表 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result> * @author zhaoqifeng * @date 2020/7/14 16:30 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result> */ @PostMapping("uploadlist") - public Result> uploadList(@RequestBody UploadListFormDTO formDTO) { - return new Result<>(); + public Result uploadList(@RequestBody UploadListFormDTO formDTO) { + PageData pageData = codeService.uploadList(formDTO); + return new Result().ok(pageData); } /** * 提交审核 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/14 16:40 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("audit") public Result submitAudit(@RequestBody SubmitAuditFormDTO formDTO) { + codeService.submitAudit(formDTO); return new Result<>(); } /** * 审核撤回 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result * @author zhaoqifeng * @date 2020/7/14 17:52 - * @param formDTO - * @return com.epmet.commons.tools.utils.Result */ @PostMapping("undo") public Result undo(@RequestBody CodeCommonFormDTO formDTO) { + codeService.undo(formDTO); return new Result<>(); } + + /** + * 发布 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/14 17:52 + */ + @PostMapping("release") + public Result release(@RequestBody CodeCommonFormDTO formDTO) { + codeService.release(formDTO); + return new Result<>(); + } + + /** + * 审核失败原因 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/14 17:52 + */ + @PostMapping("reason") + public Result reason(@RequestBody CodeCommonFormDTO formDTO) { + ReasonResultDTO resultDTO = codeService.reason(formDTO); + return new Result().ok(resultDTO); + } + + /** + * 获取体验版二维码 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/14 17:52 + */ + @PostMapping("qrcode") + public Result qrCode(@RequestBody CodeCommonFormDTO formDTO) { + QrCodeResultDTO resultDTO = codeService.qrCode(formDTO); + return new Result().ok(resultDTO); + } + + /** + * 操作历史 + * + * @param formDTO 参数 + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/7/16 10:16 + */ + @PostMapping("history") + public Result history(@RequestBody CodeCommonFormDTO formDTO) { + PageData result = codeService.history(formDTO); + return new Result().ok(result); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeOperationHistoryController.java similarity index 62% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeOperationHistoryController.java index a764889ed6..4a7fb08c98 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CustomerCodeOperationHistoryController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeOperationHistoryController.java @@ -24,8 +24,8 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; -import com.epmet.dto.CustomerCodeOperationHistoryDTO; -import com.epmet.service.CustomerCodeOperationHistoryService; +import com.epmet.dto.CodeOperationHistoryDTO; +import com.epmet.service.CodeOperationHistoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -39,37 +39,37 @@ import java.util.Map; * @since v1.0.0 2020-07-09 */ @RestController -@RequestMapping("customercodeoperationhistory") -public class CustomerCodeOperationHistoryController { +@RequestMapping("codeoperationhistory") +public class CodeOperationHistoryController { @Autowired - private CustomerCodeOperationHistoryService customerCodeOperationHistoryService; + private CodeOperationHistoryService codeOperationHistoryService; @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = customerCodeOperationHistoryService.page(params); - return new Result>().ok(page); + public Result> page(@RequestParam Map params){ + PageData page = codeOperationHistoryService.page(params); + return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - CustomerCodeOperationHistoryDTO data = customerCodeOperationHistoryService.get(id); - return new Result().ok(data); + public Result get(@PathVariable("id") String id){ + CodeOperationHistoryDTO data = codeOperationHistoryService.get(id); + return new Result().ok(data); } @PostMapping - public Result save(@RequestBody CustomerCodeOperationHistoryDTO dto){ + public Result save(@RequestBody CodeOperationHistoryDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - customerCodeOperationHistoryService.save(dto); + codeOperationHistoryService.save(dto); return new Result(); } @PutMapping - public Result update(@RequestBody CustomerCodeOperationHistoryDTO dto){ + public Result update(@RequestBody CodeOperationHistoryDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - customerCodeOperationHistoryService.update(dto); + codeOperationHistoryService.update(dto); return new Result(); } @@ -77,7 +77,7 @@ public class CustomerCodeOperationHistoryController { public Result delete(@RequestBody String[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); - customerCodeOperationHistoryService.delete(ids); + codeOperationHistoryService.delete(ids); return new Result(); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index 3dc7390935..16084e2d99 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -11,13 +11,11 @@ import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterInfoFormDTO; import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; +import com.epmet.dto.result.InitCustomerResultDTO; import com.epmet.dto.result.MyInfoResultDTO; import com.epmet.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -101,5 +99,27 @@ public class PaCustomerController { return new Result().ok(paCustomerService.registerInfo(formDTO)); } + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + @PostMapping(value = "getcustomeragencyuser/{customerId}") + public Result getCustomerAgencyUser(@PathVariable("customerId") String customerId) { + return new Result().ok(paCustomerService.getCustomerAgencyUser(customerId)); + } + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + @PostMapping(value = "updatecustomer/{customerId}") + public Result updateCustomer(@PathVariable("customerId") String customerId) { + paCustomerService.updateCustomer(customerId); + return new Result(); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java index 7b3e60abe3..60e77b7bcf 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CodeCustomerDTO; import com.epmet.dto.form.UploadListFormDTO; import com.epmet.dto.result.UploadListResultDTO; import com.epmet.dto.form.CodeAuditRecordFormDTO; @@ -61,4 +62,23 @@ public interface CodeCustomerDao extends BaseDao { */ String selectCodeCustomerId(CodeAuditRecordFormDTO codeAuditRecord); + /** + * 删除旧的上传记录 + * @author zhaoqifeng + * @date 2020/7/15 18:06 + * @param customerId + * @param clientType + * @return void + */ + void deleteCode(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 获取审核中代码列表 + * @author zhaoqifeng + * @date 2020/7/15 18:17 + * @param + * @return java.util.List + */ + List selectAuditingCodeList(); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeOperationHistoryDao.java similarity index 60% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeOperationHistoryDao.java index 63ca70fb2b..f624c2212e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerCodeOperationHistoryDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeOperationHistoryDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.entity.CustomerCodeOperationHistoryEntity; +import com.epmet.dto.result.CodeHistoryResultDTO; +import com.epmet.entity.CodeOperationHistoryEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 客户代码操作历史 @@ -28,6 +32,17 @@ import org.apache.ibatis.annotations.Mapper; * @since v1.0.0 2020-07-09 */ @Mapper -public interface CustomerCodeOperationHistoryDao extends BaseDao { - +public interface CodeOperationHistoryDao extends BaseDao { + + List selectHistoryList(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 更新描述 + * @author zhaoqifeng + * @date 2020/7/16 16:11 + * @param codeId + * @param describe + * @return void + */ + void updateDescribeByCodeId(@Param("codeId") String codeId, @Param("describe") String describe); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java index c8609064e9..622c42b56e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java @@ -81,4 +81,14 @@ public interface CustomerMpDao extends BaseDao { */ String selectClientTypeByCustomerIdAndAuthId(@Param("customerId")String customerId,@Param("authAppId")String authAppId); + /** + * 获取授权状态 + * @param customerId + * @param clientType + * @return java.lang.Boolean + * @author zhaoqifeng + * @date 2020/7/16 15:28 + */ + Boolean selectAuthFlag(@Param("customerId")String customerId, @Param("clientType")String clientType); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java index 219d88fd83..a3031b9b15 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java @@ -46,4 +46,12 @@ public interface PaCustomerAgencyDao extends BaseDao { * @Description 公众号-查询客户组织信息 **/ PaCustomerAgencyDTO selectCustomerAgency(@Param("customerId") String customerId); + + /** + * @param customerId + * @return + * @Author sun + * @Description 公众号-查询客户组织信息 + **/ + PaCustomerAgencyDTO selectAgency(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java index de4111e6c6..d0b00c2357 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java @@ -50,4 +50,12 @@ public interface PaCustomerDao extends BaseDao { * @Description 查询公众号注册的客户信息列表 **/ List registerInfo(); + + /** + * @param dto + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + int updateCustomerById(PaCustomerDTO dto); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java index 2ced9f5760..2cdd7a9bb4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaUserDao.java @@ -41,4 +41,12 @@ public interface PaUserDao extends BaseDao { * @Description 根据手机号查询公众号用户基本信息,校验用户是否存在 **/ List selectUserByPhone(@Param("phone") String phone); + + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id级联查询客户管理员注册信息 + **/ + PaUserDTO selectPaUser(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java similarity index 92% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java index e747bb57d4..fe56ddd312 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CustomerCodeOperationHistoryEntity.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java @@ -33,8 +33,8 @@ import java.util.Date; */ @Data @EqualsAndHashCode(callSuper=false) -@TableName("customer_code_operation_history") -public class CustomerCodeOperationHistoryEntity extends BaseEpmetEntity { +@TableName("code_operation_history") +public class CodeOperationHistoryEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeOperationHistoryRedis.java similarity index 96% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeOperationHistoryRedis.java index 247e724de9..cb698781b0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CustomerCodeOperationHistoryRedis.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/CodeOperationHistoryRedis.java @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component; * @since v1.0.0 2020-07-09 */ @Component -public class CustomerCodeOperationHistoryRedis { +public class CodeOperationHistoryRedis { @Autowired private RedisUtils redisUtils; 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 bfa85cc383..fc2190a39d 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 @@ -102,4 +102,23 @@ public interface CodeCustomerService extends BaseService { * @return com.epmet.commons.tools.page.PageData */ PageData getCodeList(UploadListFormDTO formDTO); + + /** + * 获取审核中代码列表 + * @author zhaoqifeng + * @date 2020/7/15 18:16 + * @param + * @return java.util.List + */ + List getAuditingCodeList(); + + /** + * 删除旧代码记录 + * @author zhaoqifeng + * @date 2020/7/15 18:10 + * @param customerId + * @param clientType + * @return void + */ + void deleteCode(String customerId, String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeOperationHistoryService.java similarity index 65% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeOperationHistoryService.java index 986fce9c09..7f0ba1752c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerCodeOperationHistoryService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeOperationHistoryService.java @@ -19,8 +19,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; -import com.epmet.dto.CustomerCodeOperationHistoryDTO; -import com.epmet.entity.CustomerCodeOperationHistoryEntity; +import com.epmet.dto.CodeOperationHistoryDTO; +import com.epmet.dto.result.CodeHistoryResultDTO; +import com.epmet.entity.CodeOperationHistoryEntity; import java.util.List; import java.util.Map; @@ -31,7 +32,7 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-07-09 */ -public interface CustomerCodeOperationHistoryService extends BaseService { +public interface CodeOperationHistoryService extends BaseService { /** * 默认分页 @@ -41,7 +42,7 @@ public interface CustomerCodeOperationHistoryService extends BaseService page(Map params); + PageData page(Map params); /** * 默认查询 @@ -51,7 +52,7 @@ public interface CustomerCodeOperationHistoryService extends BaseService list(Map params); + List list(Map params); /** * 单条查询 @@ -61,7 +62,7 @@ public interface CustomerCodeOperationHistoryService extends BaseService getHistoryList(String customerId, String clientType); + + /** + * 更新描述 + * @author zhaoqifeng + * @date 2020/7/16 16:10 + * @param codeId + * @param describe + * @return void + */ + void updateDescribe(String codeId, String describe); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java index 2ba332f663..8c7e0c6cc5 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java @@ -1,12 +1,12 @@ package com.epmet.service; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.CodeCommonFormDTO; import com.epmet.dto.form.CodeUploadFormDTO; import com.epmet.dto.form.SubmitAuditFormDTO; import com.epmet.dto.form.UploadListFormDTO; -import com.epmet.dto.result.TemplateListResultDTO; -import com.epmet.dto.result.UploadListResultDTO; +import com.epmet.dto.result.*; import java.util.List; @@ -29,7 +29,7 @@ public interface CodeService { /** * 代码上传 * - * @param formDTO + * @param formDTO 参数 * @author zhaoqifeng * @date 2020/7/14 18:15 */ @@ -38,7 +38,7 @@ public interface CodeService { /** * 已上传代码列表 * - * @param formDTO + * @param formDTO 参数 * @return java.util.List < com.epmet.dto.result.UploadListResultDTO> * @author zhaoqifeng * @date 2020/7/14 18:15 @@ -48,7 +48,7 @@ public interface CodeService { /** * 提交审核 * - * @param formDTO + * @param formDTO 参数 * @author zhaoqifeng * @date 2020/7/14 18:15 */ @@ -57,9 +57,48 @@ public interface CodeService { /** * 审核撤回 * - * @param formDTO + * @param formDTO 参数 * @author zhaoqifeng * @date 2020/7/14 18:15 */ void undo(CodeCommonFormDTO formDTO); + + /** + * 发布 + * + * @param formDTO 参数 + * @author zhaoqifeng + * @date 2020/7/14 18:15 + */ + void release(CodeCommonFormDTO formDTO); + + /** + * 审核失败原因 + * + * @param formDTO 参数 + * @return com.epmet.dto.result.ReasonResultDTO + * @author zhaoqifeng + * @date 2020/7/16 9:38 + */ + ReasonResultDTO reason(CodeCommonFormDTO formDTO); + + /** + * 获取体验版二维码 + * + * @param formDTO 参数 + * @return com.epmet.dto.result.QrCodeResultDTO + * @author zhaoqifeng + * @date 2020/7/16 9:49 + */ + QrCodeResultDTO qrCode(CodeCommonFormDTO formDTO); + + /** + * 操作历史 + * + * @param formDTO 参数 + * @return com.epmet.dto.result.CodeHistoryResultDTO + * @author zhaoqifeng + * @date 2020/7/16 10:16 + */ + PageData history(CodeCommonFormDTO formDTO); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java index ba98b8b295..cf43427f6a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CustomerMpService.java @@ -92,4 +92,14 @@ public interface CustomerMpService extends BaseService { * @date 2020-07-09 */ void delete(String[] ids); + + /** + * 获取授权状态 + * @author zhaoqifeng + * @date 2020/7/16 15:34 + * @param customerId + * @param clientType + * @return java.lang.Boolean + */ + Boolean getAuthFlag(String customerId, String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index 3ffdaaea88..8e45d47fa3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -26,6 +26,7 @@ import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterInfoFormDTO; import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO; +import com.epmet.dto.result.InitCustomerResultDTO; import com.epmet.dto.result.MyInfoResultDTO; import com.epmet.entity.PaCustomerEntity; @@ -138,4 +139,20 @@ public interface PaCustomerService extends BaseService { * @Description 查询公众号注册的客户信息列表 **/ PageData registerInfo(RegisterInfoFormDTO formDTO); + + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + InitCustomerResultDTO getCustomerAgencyUser(String customerId); + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + void updateCustomer(String customerId); } \ No newline at end of file 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 3181daebdc..f2e9d5fd4c 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 @@ -113,4 +113,14 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl(list, pageInfo.getTotal()); } + @Override + public List getAuditingCodeList() { + return baseDao.selectAuditingCodeList(); + } + + @Override + public void deleteCode(String customerId, String clientType) { + baseDao.deleteCode(customerId, clientType); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeOperationHistoryServiceImpl.java similarity index 52% rename from epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java rename to epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeOperationHistoryServiceImpl.java index fc424619cc..c50199c644 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerCodeOperationHistoryServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeOperationHistoryServiceImpl.java @@ -23,11 +23,12 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.dao.CustomerCodeOperationHistoryDao; -import com.epmet.dto.CustomerCodeOperationHistoryDTO; -import com.epmet.entity.CustomerCodeOperationHistoryEntity; -import com.epmet.redis.CustomerCodeOperationHistoryRedis; -import com.epmet.service.CustomerCodeOperationHistoryService; +import com.epmet.dao.CodeOperationHistoryDao; +import com.epmet.dto.CodeOperationHistoryDTO; +import com.epmet.dto.result.CodeHistoryResultDTO; +import com.epmet.entity.CodeOperationHistoryEntity; +import com.epmet.redis.CodeOperationHistoryRedis; +import com.epmet.service.CodeOperationHistoryService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -44,53 +45,53 @@ import java.util.Map; * @since v1.0.0 2020-07-09 */ @Service -public class CustomerCodeOperationHistoryServiceImpl extends BaseServiceImpl implements CustomerCodeOperationHistoryService { +public class CodeOperationHistoryServiceImpl extends BaseServiceImpl implements CodeOperationHistoryService { @Autowired - private CustomerCodeOperationHistoryRedis customerCodeOperationHistoryRedis; + private CodeOperationHistoryRedis customerCodeOperationHistoryRedis; @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( + public PageData page(Map params) { + IPage page = baseDao.selectPage( getPage(params, FieldConstant.CREATED_TIME, false), getWrapper(params) ); - return getPageData(page, CustomerCodeOperationHistoryDTO.class); + return getPageData(page, CodeOperationHistoryDTO.class); } @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); - return ConvertUtils.sourceToTarget(entityList, CustomerCodeOperationHistoryDTO.class); + return ConvertUtils.sourceToTarget(entityList, CodeOperationHistoryDTO.class); } - private QueryWrapper getWrapper(Map params){ + private QueryWrapper getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); - QueryWrapper wrapper = new QueryWrapper<>(); + QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); return wrapper; } @Override - public CustomerCodeOperationHistoryDTO get(String id) { - CustomerCodeOperationHistoryEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, CustomerCodeOperationHistoryDTO.class); + public CodeOperationHistoryDTO get(String id) { + CodeOperationHistoryEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CodeOperationHistoryDTO.class); } @Override @Transactional(rollbackFor = Exception.class) - public void save(CustomerCodeOperationHistoryDTO dto) { - CustomerCodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CustomerCodeOperationHistoryEntity.class); + public void save(CodeOperationHistoryDTO dto) { + CodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CodeOperationHistoryEntity.class); insert(entity); } @Override @Transactional(rollbackFor = Exception.class) - public void update(CustomerCodeOperationHistoryDTO dto) { - CustomerCodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CustomerCodeOperationHistoryEntity.class); + public void update(CodeOperationHistoryDTO dto) { + CodeOperationHistoryEntity entity = ConvertUtils.sourceToTarget(dto, CodeOperationHistoryEntity.class); updateById(entity); } @@ -101,4 +102,14 @@ public class CustomerCodeOperationHistoryServiceImpl extends BaseServiceImpl getHistoryList(String customerId, String clientType) { + return baseDao.selectHistoryList(customerId, clientType); + } + + @Override + public void updateDescribe(String codeId, String describe) { + baseDao.updateDescribeByCodeId(codeId, describe); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java index 8cf9b54571..db0e6dfcf1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java @@ -9,30 +9,31 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CodeConstant; import com.epmet.dao.AuthorizationInfoDao; import com.epmet.dao.ComponentAccessTokenDao; -import com.epmet.dto.AuthorizationInfoDTO; -import com.epmet.dto.CodeAuditResultDTO; -import com.epmet.dto.CodeCustomerDTO; -import com.epmet.dto.CustomerDTO; +import com.epmet.dto.*; import com.epmet.dto.form.CodeCommonFormDTO; import com.epmet.dto.form.CodeUploadFormDTO; import com.epmet.dto.form.SubmitAuditFormDTO; import com.epmet.dto.form.UploadListFormDTO; -import com.epmet.dto.result.TemplateListResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.OperCrmOpenFeignClient; -import com.epmet.service.CodeAuditResultService; -import com.epmet.service.CodeCustomerService; -import com.epmet.service.CodeService; +import com.epmet.service.*; import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.WxMaCodeCommitReq; import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest; +import com.epmet.wxapi.param.WxMaNewsReq; import com.epmet.wxapi.result.WxMaAuditStatusResult; +import com.epmet.wxapi.result.WxMaNewsResult; import com.epmet.wxapi.result.WxMaTemplateResult; import com.epmet.wxapi.result.WxResult; import com.epmet.wxapi.service.WxMaCodeService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; 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.Collections; import java.util.List; /** @@ -55,6 +56,10 @@ public class CodeServiceImpl implements CodeService { private OperCrmOpenFeignClient operCrmOpenFeignClient; @Autowired private CodeAuditResultService codeAuditResultService; + @Autowired + private CustomerMpService customerMpService; + @Autowired + private CodeOperationHistoryService codeOperationHistoryService; @Override public List templateList() { @@ -81,7 +86,12 @@ public class CodeServiceImpl implements CodeService { } @Override + @Transactional(rollbackFor = Exception.class) public void upload(CodeUploadFormDTO formDTO) { + //是否授权 + if (customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) { + throw new RenException("未授权"); + } //获取小程序调用令牌 AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); if (null == authInfo) { @@ -96,6 +106,7 @@ public class CodeServiceImpl implements CodeService { WxResult wxResult = wxMaCodeService.commit(authInfo.getAuthorizerAccessToken(), request); //上传失败,抛出异常 if (!wxResult.success()) { + saveOperation(formDTO.getCustomerId(), null, formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } //获取客户信息 @@ -105,7 +116,8 @@ public class CodeServiceImpl implements CodeService { if (!customerInfo.success()) { throw new RenException(customerInfo.getCode(), customerInfo.getMsg()); } - //TODO 将之前上传信息删除 + //将之前上传信息删除 + codeCustomerService.deleteCode(formDTO.getCustomerId(), formDTO.getClientType()); //将上传信息存入表中 CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class); @@ -113,11 +125,42 @@ public class CodeServiceImpl implements CodeService { codeCustomerDTO.setExtJson(extJson); codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); codeCustomerService.save(codeCustomerDTO); + + saveOperation(formDTO.getCustomerId(), codeCustomerDTO.getId(), formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, "上传成功"); } @Override public PageData uploadList(UploadListFormDTO formDTO) { - //TODO 更新审核状态 + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); + List auditingList = codeCustomerService.getAuditingCodeList(); + auditingList.forEach(code -> { + //获取审核结果信息 + CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId()); + //调用微信API获取最新审核状态 + WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); + request.setAuditId(auditResult.getAuditId()); + WxResult wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); + if (wxAuditResult.success()) { + WxMaAuditStatusResult result = wxAuditResult.getData(); + if(result.getStatus() == NumConstant.ZERO) { + code.setStatus(CodeConstant.AUDIT_SUCCESS); + auditResult.setResult(CodeConstant.AUDIT_SUCCESS); + codeOperationHistoryService.updateDescribe(code.getId(), "审核成功"); + } else if(result.getStatus() == NumConstant.ONE) { + code.setStatus(CodeConstant.AUDIT_FAILED); + auditResult.setResult(CodeConstant.AUDIT_FAILED); + auditResult.setReason(result.getReason()); + codeOperationHistoryService.updateDescribe(code.getId(), result.getReason()); + } else if(result.getStatus() == NumConstant.FOUR) { + code.setStatus(CodeConstant.DELAY); + auditResult.setResult(CodeConstant.DELAY); + codeOperationHistoryService.updateDescribe(code.getId(), "审核延后"); + } + codeCustomerService.update(code); + codeAuditResultService.update(auditResult); + } + }); return codeCustomerService.getCodeList(formDTO); } @@ -125,12 +168,18 @@ public class CodeServiceImpl implements CodeService { public void submitAudit(SubmitAuditFormDTO formDTO) { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } //获取小程序调用令牌 AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); //调用微信API上提交审核 WxMaCodeSubmitAuditRequest request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeSubmitAuditRequest.class); WxResult wxResult = wxMaCodeService.submitAudit(authInfo.getAuthorizerAccessToken(), request); if (!wxResult.success()) { + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, + wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } //将数据存入代码审核表 @@ -143,12 +192,18 @@ public class CodeServiceImpl implements CodeService { //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.AUDITING); codeCustomerService.update(codeCustomerDTO); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, + "审核中"); } @Override public void undo(CodeCommonFormDTO formDTO) { //获取上传代码信息 CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } //获取审核结果信息 CodeAuditResultDTO codeAuditResultDTO = codeAuditResultService.getAuditResultByCodeId(formDTO.getCodeId()); //获取小程序调用令牌 @@ -166,6 +221,8 @@ public class CodeServiceImpl implements CodeService { //调用微信API撤销审核 WxResult wxResult = wxMaCodeService.undoCodeAudit(authInfo.getAuthorizerAccessToken()); if (!wxResult.success()) { + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_UNDO, + wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } //更新审核结果 @@ -174,6 +231,111 @@ public class CodeServiceImpl implements CodeService { //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.WITHDRAWN); codeCustomerService.update(codeCustomerDTO); + //更新审核操作记录描述 + codeOperationHistoryService.updateDescribe(codeCustomerDTO.getId(), "已撤回"); + + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_UNDO, + "成功"); + } + + @Override + public void release(CodeCommonFormDTO formDTO) { + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + //调用微信API发布代码 + WxResult wxResult = wxMaCodeService.release(authInfo.getAuthorizerAccessToken()); + if (!wxResult.success()) { + //更新代码表状态 + codeCustomerDTO.setStatus(CodeConstant.RELEASE_FAILED); + codeCustomerService.update(codeCustomerDTO); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, + wxResult.getErrorMsg()); + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + //更新代码表状态 + codeCustomerDTO.setStatus(CodeConstant.RELEASE_SUCCESS); + codeCustomerService.update(codeCustomerDTO); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, + "发布成功"); + } + + @Override + public ReasonResultDTO reason(CodeCommonFormDTO formDTO) { + ReasonResultDTO result = new ReasonResultDTO(); + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } + //TODO 获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + //获取审核结果信息 + CodeAuditResultDTO codeAuditResultDTO = codeAuditResultService.getAuditResultByCodeId(formDTO.getCodeId()); + result.setReason(codeAuditResultDTO.getReason()); + String[] mediaIds = codeAuditResultDTO.getScreenShot().split("[|]"); + List mediaIdList = new ArrayList<>(mediaIds.length); + Collections.addAll(mediaIdList, mediaIds); + List urlList = new ArrayList<>(); + mediaIdList.forEach(mediaId -> { + //调用微信API获取素材 + WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); + 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()); + }); + }); + result.setScreenshotUrl(urlList); + return result; + } + + @Override + public QrCodeResultDTO qrCode(CodeCommonFormDTO formDTO) { + QrCodeResultDTO result = new QrCodeResultDTO(); + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + //是否授权 + if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) { + throw new RenException("未授权"); + } + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + //调用微信API获取获取体验版二维码 + WxResult wxResult = wxMaCodeService.getQrCode(authInfo.getAuthorizerAccessToken(), null); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + result.setQrcode(wxResult.getData()); + return result; + } + + @Override + public PageData history(CodeCommonFormDTO formDTO) { + PageHelper.startPage(formDTO.getPage(), formDTO.getLimit()); + //获取上传代码信息 + CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); + List list = codeOperationHistoryService.getHistoryList(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + + private void saveOperation(String customerId, String codeId, String version, String operation, String describe) { + CodeOperationHistoryDTO operationDTO = new CodeOperationHistoryDTO(); + operationDTO.setCustomerId(customerId); + operationDTO.setCodeId(codeId); + operationDTO.setVersion(version); + operationDTO.setOperation(operation); + operationDTO.setDescribe(describe); + codeOperationHistoryService.save(operationDTO); } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java index 5bb85272a0..1377699edc 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CustomerMpServiceImpl.java @@ -101,4 +101,9 @@ public class CustomerMpServiceImpl extends BaseServiceImpl(list, pageInfo.getTotal()); } + /** + * @param customerId + * @return + * @Author sun + * @Description 根据客户Id查询各项注册信息 + **/ + @Override + public InitCustomerResultDTO getCustomerAgencyUser(String customerId) { + InitCustomerResultDTO result = new InitCustomerResultDTO(); + //1.查询注册客户信息,并判断是否已完成初始化 + PaCustomerEntity entity = baseDao.selectById(customerId); + //未查询到注册客户信息 + if (null == entity) { + throw new RenException(EpmetErrorCode.SELECT_CUSTOMER_ERROR.getCode()); + } + //客户已完成初始化 + if (NumConstant.ONE == entity.getIsInitialize()) { + throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode()); + } + PaCustomerDTO paCustomer = ConvertUtils.sourceToTarget(entity, PaCustomerDTO.class); + result.setPaCustomer(paCustomer); + + //2.查询注册客户对应的组织信息 + PaCustomerAgencyDTO paAgency = paCustomerAgencyDao.selectAgency(customerId); + if (null == paAgency) { + throw new RenException(EpmetErrorCode.SELECT_AGENCY_ERROR.getCode()); + } + result.setPaAgency(paAgency); + + //3.查询组织客户对应的管理员信息 + PaUserDTO paUser = paUserDao.selectPaUser(customerId); + if (null == paUser) { + throw new RenException(EpmetErrorCode.SELECT_USER_ERROR.getCode()); + } + result.setPaUser(paUser); + return result; + } + + /** + * @param customerId + * @return + * @Author sun + * @Description 修改客户数据状态为已完成初始化 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateCustomer(String customerId) { + //更新pa_customer表数据状态 + PaCustomerDTO dto = new PaCustomerDTO(); + dto.setId(customerId); + dto.setIsInitialize(NumConstant.ONE); + if (baseDao.updateCustomerById(dto) < NumConstant.ONE) { + logger.error(EpmetErrorCode.UPDATE_CUSTOMER_ERROR.getMsg()); + throw new RenException(EpmetErrorCode.UPDATE_CUSTOMER_ERROR.getCode()); + } + } } \ No newline at end of file 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 3fe8d49f7e..b8d243c43f 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 @@ -71,4 +71,9 @@ public interface WxMaCodeConstant { * 小程序审核撤回 */ String UNDO_CODE_AUDIT_URL = "https://api.weixin.qq.com/wxa/undocodeaudit"; + + /** + * 获取永久素材 + */ + String GET_MATERIAL_URL = "https://api.weixin.qq.com/cgi-bin/material/get_material"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaNewsReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaNewsReq.java new file mode 100644 index 0000000000..b0cc794400 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaNewsReq.java @@ -0,0 +1,20 @@ +package com.epmet.wxapi.param; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 14:42 + */ +@Data +public class WxMaNewsReq implements Serializable { + private static final long serialVersionUID = -2575933909006637636L; + + @SerializedName("media_id") + private String mediaId; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaNewsResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaNewsResult.java new file mode 100644 index 0000000000..7bce05e30a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxMaNewsResult.java @@ -0,0 +1,60 @@ +package com.epmet.wxapi.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/7/16 14:43 + */ +@Data +public class WxMaNewsResult implements Serializable { + private static final long serialVersionUID = -5844290246590127322L; + + @SerializedName("news_item") + private List newsItem; + + @Data + public static class NewsItemBean { + /** + * 图文消息的标题 + */ + private String title; + /** + * 图文消息的封面图片素材id + */ + @SerializedName("thumb_media_id") + private String thumbMediaId; + /** + * 是否显示封面,0为false,即不显示,1为true,即显示 + */ + @SerializedName("show_cover_pic") + private Integer showCoverPic; + /** + * 作者 + */ + private String author; + /** + * 图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空 + */ + private String digest; + /** + * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS + */ + private String content; + /** + * 图文页的URL + */ + private String url; + /** + * 图文消息的原文地址,即点击“阅读原文”后的URL + */ + @SerializedName("content_source_url") + private String contentSourceUrl; + } +} 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 60d243f62d..7a3f6dd641 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 @@ -3,7 +3,9 @@ package com.epmet.wxapi.service; import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.WxMaCodeCommitReq; import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest; +import com.epmet.wxapi.param.WxMaNewsReq; import com.epmet.wxapi.result.WxMaAuditStatusResult; +import com.epmet.wxapi.result.WxMaNewsResult; import com.epmet.wxapi.result.WxMaTemplateResult; import com.epmet.wxapi.result.WxResult; @@ -48,7 +50,7 @@ public interface WxMaCodeService { * @author zhaoqifeng * @date 2020/7/10 15:25 */ - WxResult getQrCode(String accessToken, String path); + WxResult getQrCode(String accessToken, String path); /** * 获取授权小程序帐号的可选类目. @@ -101,6 +103,17 @@ public interface WxMaCodeService { */ WxResult undoCodeAudit(String accessToken); + /** + * 获取永久图文素材 + * + * @param accessToken 提交审核参数 + * @param request 参数 + * @return com.epmet.wxapi.result.WxResult + * @author zhaoqifeng + * @date 2020/7/16 14:52 + */ + WxResult getMaterial(String accessToken, WxMaNewsReq request); + //TODO 设置服务器域名 //TODO 设置业务域名 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 41c1e17f7e..b4b8a29778 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 @@ -7,6 +7,7 @@ import com.epmet.wxapi.constant.WxMaCodeConstant; import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.WxMaCodeCommitReq; import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest; +import com.epmet.wxapi.param.WxMaNewsReq; import com.epmet.wxapi.result.*; import com.epmet.wxapi.service.WxMaCodeService; import com.google.gson.Gson; @@ -65,7 +66,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { } @Override - public WxResult getQrCode(String accessToken, String path) { + public WxResult getQrCode(String accessToken, String path) { WxResult result = new WxResult<>(); StringBuilder url = new StringBuilder(WxMaCodeConstant.GET_QRCODE_URL).append("?access_token").append(accessToken); if (StringUtils.isNotBlank(path)) { @@ -190,6 +191,21 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { return result; } + @Override + 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)); + if (!statusResult.success()) { + result.setErrorCode(statusResult.getCode()); + result.setErrorMsg(statusResult.getMsg()); + return result; + } + WxMaNewsResult newsResult = JSONObject.parseObject(statusResult.getData(), WxMaNewsResult.class); + result.ok(newsResult); + return result; + } + public static void main(String[] args) { String url = "{\"errcode\":0,\"errmsg\":\"ok\",\"category_list\":[{\"first_class\":\"工具\",\"second_class\":\"备忘录\",\"first_id\":1,\"second_id\":2,}\n" + "{\"first_class\":\"教育\",\"second_class\":\"学历教育\",\"third_class\":\"高等\",\"first_id\":3,\"second_id\":4,\"third_id\":5,}]}"; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml index 6761472660..22d77316e6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml @@ -82,6 +82,16 @@ AND app_id = #{authAppId} AND template_id = #{templateId} - + + + UPDATE code_customer + SET + DEL_FLAG = '1' + WHERE CUSTOMER_ID = #{customerId} + AND CLIENT_TYPE = #{clientType} + AND DEL_FLAG = '0' + \ 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 new file mode 100644 index 0000000000..277beabe35 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + UPDATE code_operation_history SET + `DESCRIBE` = #{describe} + WHERE CODE_ID = #{codeId} + AND OPERATION = 'audit' + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml deleted file mode 100644 index 09ae8b2e78..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerCodeOperationHistoryDao.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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 ac7b8b4346..8167f6e8b4 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 @@ -74,5 +74,15 @@ ORDER BY customer_id ASC, client ASC + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml index a573549065..9911ae88ff 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml @@ -48,4 +48,38 @@ LIMIT 1 + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml index 484b409121..074145416f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml @@ -56,4 +56,12 @@ pca.CREATED_TIME DESC + + UPDATE pa_customer + SET is_initialize = #{isInitialize} + WHERE + del_flag = '0' + AND id = #{id} + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml index 56db230fa9..f97263c5b0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaUserDao.xml @@ -16,4 +16,21 @@ AND phone = #{phone} + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java new file mode 100644 index 0000000000..65882c543f --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyAndStaffFormDTO.java @@ -0,0 +1,48 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import com.epmet.dto.CustomerAgencyDTO; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 单客户-添加根组织及管理员-接口入参 + * + * @author sun + */ +@Data +public class AddAgencyAndStaffFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 根级组织对象 + */ + private CustomerAgencyDTO agencyDTO; + /** + * 客户管理员信息 + */ + private AdminStaffFromDTO staffDTO; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java new file mode 100644 index 0000000000..926e17b75e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AdminStaffFromDTO.java @@ -0,0 +1,63 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.io.Serializable; +import java.util.List; + +/** + * @author sun + * @dscription 客户管理员信息 + */ +@NoArgsConstructor +@Data +public class AdminStaffFromDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户ID + */ + private String customerId; + /** + * 机关ID + */ + private String agencyId; + /** + * 人员ID + */ + private String staffId; + /** + * 姓名 + */ + @Length(max = 15, message = "姓名仅允许输入15个字符") + private String name; + /** + * 手机 + */ + @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号") + private String mobile; + /** + * 性别 + */ + private Integer gender; + /** + * 专兼职 + */ + private String workType; + /** + * 角色id列表 + */ + private List roles; + /** + * 来源app(政府端:gov、居民端:resi、运营端:oper) + */ + private String app; + /** + * 来源client(PC端:web、微信小程序:wxmp) + */ + private String client; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index 99bccaa484..cbfadb76f6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -4,6 +4,8 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerPartyBranchDTO; +import com.epmet.dto.form.AddAgencyAndStaffFormDTO; +import com.epmet.dto.form.AddRootAgencyFormDTO; import com.epmet.dto.form.ListPartyBranchFormDTO; import com.epmet.dto.result.ArticleGridResultDTO; import com.epmet.dto.result.GridInfoResultDTO; @@ -15,6 +17,7 @@ import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Map; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -131,4 +134,13 @@ public interface GovOrgOpenFeignClient { **/ @GetMapping(value = "gov/org/customerpartybranch/decrPartyBranchMember/{partyBranchId}") Result decrPartyBranchMember(@PathVariable("partyBranchId") String partyBranchId); + + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + **/ + @PostMapping("/gov/org/agency/saverootagency") + Result saveRootAgency(@RequestBody AddAgencyAndStaffFormDTO agencyAndStaff); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index bcc224dd86..0c508b7a00 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerPartyBranchDTO; +import com.epmet.dto.form.AddAgencyAndStaffFormDTO; import com.epmet.dto.form.ListPartyBranchFormDTO; import com.epmet.dto.result.ArticleGridResultDTO; import com.epmet.dto.result.GridInfoResultDTO; @@ -77,4 +78,9 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { public Result decrPartyBranchMember(String partyBranchId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "decrPartyBranchMember",partyBranchId); } + + @Override + public Result saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "saveRootAgency", agencyAndStaff); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index af64c49645..cb1865ba35 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -219,4 +219,17 @@ public class AgencyController { return new Result().ok(customerRootAgencies); } + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + * @Date 2020/7/16 17:13 + **/ + @PostMapping("saverootagency") + public Result saveRootAgency(@RequestBody AddAgencyAndStaffFormDTO agencyAndStaff) { + agencyService.saveRootAgency(agencyAndStaff); + return new Result(); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java index 2f187a123d..2eb012ca11 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -99,4 +99,13 @@ public interface AgencyService { CustomerAgencyDTO getCustomerRootAgency(String customerId); String addRootAgency(AddRootAgencyFormDTO form); + + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + * @Date 2020/7/16 17:13 + **/ + void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index 498aa11b62..4b37250b73 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -17,17 +17,23 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerAgencyConstant; +import com.epmet.constant.RoleKeyConstants; +import com.epmet.constant.UserWorkType; import com.epmet.dao.CustomerAgencyDao; import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.CustomerAgencyRedis; import com.epmet.service.AgencyService; import com.epmet.service.CustomerAgencyService; @@ -54,9 +60,12 @@ public class AgencyServiceImpl implements AgencyService { private CustomerAgencyDao customerAgencyDao; @Autowired private CustomerAgencyService customerAgencyService; - @Autowired private CustomerAgencyRedis customerAgencyRedis; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private StaffServiceImpl staffServiceImpl; /** * @param formDTO @@ -291,4 +300,58 @@ public class AgencyServiceImpl implements AgencyService { customerAgencyDao.insert(entity); return entity.getId(); } + + /** + * @param agencyAndStaff + * @return + * @Author sun + * @Description 单客户-添加根组织及客户管理员信息 + * @Date 2020/7/16 17:13 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff) { + CustomerAgencyDTO agencyDTO = agencyAndStaff.getAgencyDTO(); + AdminStaffFromDTO staffDTO = agencyAndStaff.getStaffDTO(); + + //1.判断当前客户是否已存在根级组织 + CustomerAgencyDTO rootAgencyExists = customerAgencyDao.getCustomerRootAgency(agencyDTO.getCustomerId()); + if (rootAgencyExists != null) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS.getCode(), + EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS.getMsg()); + } + + //2.新增根级组织 + CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(agencyDTO, CustomerAgencyEntity.class); + entity.setPid("0"); + entity.setPids(""); + entity.setAllParentName(""); + entity.setTotalUser(0); + if (customerAgencyDao.insert(entity) < NumConstant.ONE) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR.getCode()); + } + + //3.查询客户具有指定RoleKey的角色信息 + CustomerRoleFormDTO customerRoleForm = new CustomerRoleFormDTO(); + customerRoleForm.setCustomerId(agencyDTO.getCustomerId()); + customerRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_MANAGER); + Result getRoleResult = epmetUserOpenFeignClient.getRoleOfCustomer(customerRoleForm); + if (!getRoleResult.success() || getRoleResult.getData() == null) { + log.error("查询客户具有指定RoleKey的角色信息失败:".concat(getRoleResult.toString())); + throw new RenException("查询客户具有指定RoleKey的角色信息失败:".concat(getRoleResult.toString())); + } + + //4.新增客户管理员信息 + StaffSubmitFromDTO staffSubmitFrom = ConvertUtils.sourceToTarget(staffDTO, StaffSubmitFromDTO.class); + staffSubmitFrom.setRoles(Arrays.asList(getRoleResult.getData().getId())); + staffSubmitFrom.setApp("gov"); + staffSubmitFrom.setClient("wxmp"); + Result staffResult = staffServiceImpl.addStaff(staffSubmitFrom); + if (!staffResult.success()) { + log.error(String.format("新增客户管理员失败,调用gov-org-server服务异常%s", JSON.toJSONString(staffResult))); + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_MANAGER_ERROR.getCode(), staffResult.getMsg()); + } + + } + } \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java new file mode 100644 index 0000000000..93f5146e40 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 运营端-初始化在公众号注册的客户-接口入参 + * @Author sun + */ +@Data +public class CustomerInitFormDTO implements Serializable { + + public interface GetCustomerDetailGroup { + } + + @NotBlank(message = "客户Id不能为空", groups = {GetCustomerDetailGroup.class}) + private String customerId; + +} + diff --git a/epmet-module/oper-crm/oper-crm-server/pom.xml b/epmet-module/oper-crm/oper-crm-server/pom.xml index e2b5bca7e2..789da984d9 100644 --- a/epmet-module/oper-crm/oper-crm-server/pom.xml +++ b/epmet-module/oper-crm/oper-crm-server/pom.xml @@ -81,6 +81,12 @@ 2.0.0 compile + + com.epmet + epmet-third-client + 2.0.0 + compile + diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java index 84574bdf85..c8c17dcfad 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java @@ -30,10 +30,7 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerDTO; -import com.epmet.dto.form.AddRootAgencyFormDTO; -import com.epmet.dto.form.CustomerFormDTO; -import com.epmet.dto.form.CustomerManagerFormDTO; -import com.epmet.dto.form.PageQueryFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.CustomerDetailResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.CustomerExcel; @@ -235,4 +232,19 @@ public class CustomerController { ValidatorUtils.validateEntity(formDTO); return new Result().ok(customerService.pageQuery(formDTO)); } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-运营端-初始化在公众号注册的客户 + * @Date 2020/7/16 17:13 + **/ + @PostMapping("init") + public Result init(@RequestBody CustomerInitFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.GetCustomerDetailGroup.class); + customerService.init(formDTO); + return new Result(); + } + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java index b59a5c7a20..015b0d3684 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java @@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; //@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class, url = "localhost:8089") -@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class) +@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class,url="localhost:8089") public interface OperCustomizeFeignClient { /** diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java index bf0c569e53..bf486a4ef2 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.CustomerFormDTO; +import com.epmet.dto.form.CustomerInitFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; import com.epmet.dto.form.PageQueryFormDTO; import com.epmet.dto.result.CustomerDetailResultDTO; @@ -158,4 +159,14 @@ public interface CustomerService extends BaseService { * @Description 运营端-客户列表查询 **/ PageData pageQuery(PageQueryFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 单客户-运营端-初始化在公众号注册的客户 + * @Date 2020/7/16 17:13 + **/ + void init(CustomerInitFormDTO formDTO); + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java index dbd6c2a666..71eca76603 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; @@ -30,16 +31,11 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.RoleKeyConstants; import com.epmet.constant.UserWorkType; import com.epmet.dao.CustomerDao; -import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.CustomerDTO; -import com.epmet.dto.CustomerHomeDTO; -import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerEntity; -import com.epmet.feign.EpmetUserFeignClient; -import com.epmet.feign.GovOrgFeignClient; -import com.epmet.feign.OperCustomizeFeignClient; +import com.epmet.feign.*; import com.epmet.redis.CustomerRedis; import com.epmet.service.CustomerService; import com.github.pagehelper.PageHelper; @@ -64,18 +60,18 @@ import java.util.stream.Collectors; public class CustomerServiceImpl extends BaseServiceImpl implements CustomerService { private static final Logger log = LoggerFactory.getLogger(CustomerServiceImpl.class); - @Autowired private CustomerRedis customerRedis; - @Autowired private EpmetUserFeignClient epmetUserFeignClient; - @Autowired private GovOrgFeignClient govOrgFeignClient; - @Autowired private OperCustomizeFeignClient operCustomizeFeignClient; + @Autowired + private EpmetThirdFeignClient epmetThirdFeignClient; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; @Override public PageData page(Map params) { @@ -394,4 +390,94 @@ public class CustomerServiceImpl extends BaseServiceImpl thirdResult = epmetThirdFeignClient.getCustomerAgencyUser(formDTO.getCustomerId()); + if (!thirdResult.success()) { + throw new RenException(thirdResult.getCode(), thirdResult.getInternalMsg()); + } + InitCustomerResultDTO initCustomer = thirdResult.getData(); + PaCustomerDTO paCustomer = initCustomer.getPaCustomer(); + PaCustomerAgencyDTO paAgency = initCustomer.getPaAgency(); + PaUserDTO paUser = initCustomer.getPaUser(); + + //2.校验当前客户是否已初始化,不存在则初始客户信息 + CustomerEntity entity = baseDao.selectById(formDTO.getCustomerId()); + if (null != entity) { + throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode()); + } + //2-1.新增客户信息 + CustomerEntity customerEntity = new CustomerEntity(); + customerEntity.setId(formDTO.getCustomerId()); + customerEntity.setCustomerName(paCustomer.getCustomerName()); + customerEntity.setTitle(""); + customerEntity.setOrganizationNumber(""); + customerEntity.setOrganizationImg(""); + customerEntity.setValidityTime(getValidityTime()); + customerEntity.setOrganizationLevel(paAgency.getLevelNum()); + customerEntity.setLogo(""); + if (baseDao.insert(customerEntity) < NumConstant.ONE) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ERROR.getCode()); + } + + //3.调用epmet-user服务,初始化客户对应的角色;调用access服务给角色分配权限信息 + Result initResult = epmetUserFeignClient.initGovStaffRolesForCustomer(formDTO.getCustomerId()); + if (!initResult.success()) { + throw new RenException("客户新增:调用user服务为客户初始化角色数据失败:".concat(initResult.toString())); + } + + //4.调用oper-customize服务,初始化客户定制化首页模板数据 + CustomerHomeDTO initHomeForm = new CustomerHomeDTO(); + initHomeForm.setCustomerId(formDTO.getCustomerId()); + Result initHomeResult = operCustomizeFeignClient.init(initHomeForm); + if (!initHomeResult.success()) { + throw new RenException("初始化客户首页数据失败:".concat(initHomeResult.getInternalMsg())); + } + + //5.调用gov-org服务,初始化客户根级组织信息、客户管理员信息 + AddAgencyAndStaffFormDTO agencyAndStaff = new AddAgencyAndStaffFormDTO(); + //客户组织信息 + CustomerAgencyDTO agencyDTO = new CustomerAgencyDTO(); + agencyDTO.setId(paAgency.getId()); + agencyDTO.setCustomerId(formDTO.getCustomerId()); + agencyDTO.setOrganizationName(paAgency.getAgencyName()); + agencyDTO.setLevel(paAgency.getLevel()); + agencyDTO.setAreaCode(paAgency.getAreaCode()); + agencyDTO.setProvince(paAgency.getProvince()); + agencyDTO.setCity(paAgency.getCity()); + agencyDTO.setDistrict(paAgency.getDistrict()); + agencyAndStaff.setAgencyDTO(agencyDTO); + + //客户管理员信息 + AdminStaffFromDTO staffSubmitFrom = new AdminStaffFromDTO(); + staffSubmitFrom.setCustomerId(formDTO.getCustomerId()); + staffSubmitFrom.setAgencyId(paAgency.getId()); + staffSubmitFrom.setGender(Integer.parseInt(paUser.getGender())); + staffSubmitFrom.setMobile(paUser.getPhone()); + staffSubmitFrom.setName(paUser.getRealName()); + staffSubmitFrom.setWorkType(UserWorkType.FULL_TIME); + agencyAndStaff.setStaffDTO(staffSubmitFrom); + + Result agencyResult = govOrgOpenFeignClient.saveRootAgency(agencyAndStaff); + if (!agencyResult.success()) { + throw new RenException(agencyResult.getCode(), agencyResult.getInternalMsg()); + } + + //6.更新第三方数据库中客户数据状态为已初始化 + Result customerResult = epmetThirdFeignClient.updateCustomer(formDTO.getCustomerId()); + if (!customerResult.success()) { + throw new RenException(customerResult.getCode(), customerResult.getInternalMsg()); + } + + } + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 0faea1fb73..456290260a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.EpmetUserOpenFeignClientFallback; @@ -86,4 +87,12 @@ public interface EpmetUserOpenFeignClient { **/ @PostMapping(value = "/epmetuser/customerstaff/resetstaffpassword", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result resetStaffPassword(@RequestBody StaffResetPwFormDTO staffResetPwFormDTO); + + /** + * 根据客户ID和角色key查询角色信息 + * @param form + * @return + */ + @PostMapping("/epmetuser/staffrole/roleofcustomer") + Result getRoleOfCustomer(@RequestBody CustomerRoleFormDTO form); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index ec9cac1b00..8a63b4a08f 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.EpmetUserOpenFeignClient; @@ -55,4 +56,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "resetStaffPassword", staffResetPwFormDTO); } + @Override + public Result getRoleOfCustomer(CustomerRoleFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRoleOfCustomer", form); + } + }