springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommunityConvenientApi.java
@@ -1,29 +1,35 @@ package com.panzhihua.applets.api; import java.util.Objects; import javax.annotation.Resource; import javax.validation.Valid; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageMerchantProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PagePopularMerchantDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.model.dtos.community.PageComCvtBusinessAppletsDTO; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PagePopularMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComCvtBusinessDetailVO; import com.panzhihua.common.model.vos.community.ComCvtBusinessVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductLevelInfoVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import com.panzhihua.common.service.community.CommunityService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import java.util.Objects; /** * @description: 社区便民服务商家接口 @@ -84,9 +90,45 @@ return communityService.getMerchantDetail(merchantId); } @ApiOperation(value = "分页获取商家产品", response = ConvenientProductVO.class) @PostMapping("/merchant/product") public R getMerchantProduct(@RequestBody @Valid PageMerchantProductDTO pageMerchantProductDTO) { return communityService.getMerchantProduct(pageMerchantProductDTO); @ApiOperation(value = "获取商家产品", response = ConvenientProductLevelInfoVO.class) @GetMapping("/product/list") public R getMerchantProduct(@RequestParam("merchantId") Long merchantId) { return communityService.getMerchantProduct(merchantId); } @ApiOperation(value = "获取产品详情", response = ConvenientProductVO.class) @GetMapping("/product/detail") public R getProductDetail(@RequestParam("productId") Long productId) { return communityService.getProductDetail(productId); } @ApiOperation(value = "商家分页搜索", response = ConvenientMerchantVO.class) @PostMapping("/merchant/search") public R pageSearchMerchant(@RequestBody @Valid PageSearchDTO pageSearchDTO) { return communityService.pageSearchMerchant(pageSearchDTO); } @ApiOperation(value = "商品分页搜索", response = ConvenientProductVO.class) @PostMapping("/product/search") public R pageSearchProduct(@RequestBody @Valid PageSearchDTO pageSearchDTO) { return communityService.pageSearchProduct(pageSearchDTO); } @ApiOperation(value = "增加商家咨询量") @GetMapping("/merchant/incr-consult") public R incrMerchantConsult(@RequestParam("merchantId") Long merchantId) { return communityService.consultMerchant(merchantId); } @ApiOperation(value = "增加商家浏览量") @GetMapping("/merchant/incr-view") public R incrMerchantView(@RequestParam("merchantId") Long merchantId) { return communityService.incrMerchantView(merchantId); } @ApiOperation(value = "增加产品浏览量") @GetMapping("/product/incr-view") public R incrProductView(@RequestParam("productId") Long productId) { return communityService.incrProductView(productId); } } springcloud_k8s_panzhihuazhihuishequ/applets_backstage/src/main/java/com/panzhihua/applets_backstage/api/CommunityConvenientApi.java
@@ -314,6 +314,7 @@ @PutMapping("/merchant/put") public R putMerchant(@RequestBody @Validated(PutGroup.class) ConvenientMerchantDTO convenientMerchantDTO) { convenientMerchantDTO.setUpdatedBy(this.getUserId()); convenientMerchantDTO.setCreatedBy(this.getUserId()); return communityService.putMerchant(convenientMerchantDTO); } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/ConvenientProductDTO.java
@@ -52,4 +52,7 @@ @ApiModelProperty(value = "更新人", hidden = true) private Long updatedBy; @ApiModelProperty(value = "所属商家", hidden = true) private Long merchantId; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/ExportMerchantDTO.java
New file @@ -0,0 +1,37 @@ package com.panzhihua.common.model.dtos.community.convenient; import java.util.List; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @title: ExportMerchantDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 商家导出请求参数 * @author: hans * @date: 2021/09/23 15:23 */ @Data @ApiModel("商家导出请求参数") public class ExportMerchantDTO { @ApiModelProperty(value = "批量勾选时传参数组") private List<Long> ids; @ApiModelProperty("关键词") private String keyword; @ApiModelProperty("服务分类id") private Long serviceId; @ApiModelProperty("营业状态(1.在营 0.已关闭)") private Integer businessStatus; @ApiModelProperty("账号状态(1.启用 2.禁用)") private Integer accountStatus; @ApiModelProperty(value = "服务分类id", hidden = true) private Long communityId; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageConvenientProductDTO.java
@@ -36,4 +36,7 @@ @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageSize; @ApiModelProperty(value = "所属商家", hidden = true) private Long merchantId; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageSearchDTO.java
File was renamed from springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageMerchantProductDTO.java @@ -1,27 +1,27 @@ package com.panzhihua.common.model.dtos.community.convenient; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; /** * @title: PageMerchantProductDTO * @title: PageSearchMerchantDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 分页获取商家所属产品信息请求参数 * @description: 分页搜索商家/商品信息请求参数 * @author: hans * @date: 2021/09/22 22:51 * @date: 2021/09/23 12:34 */ @Data @ApiModel("分页获取商家所属产品信息请求参数") public class PageMerchantProductDTO { @ApiModel("分页搜索商家/商品信息请求参数") public class PageSearchDTO { @ApiModelProperty(value = "商家id") @NotNull(message = "商家id不能为空") @Min(value = 1) private Long merchantId; @ApiModelProperty(value = "关键词") @NotBlank(message = "关键词不能为空") private String keyword; @ApiModelProperty(value = "分页-当前页数", example = "1") @NotNull(message = "分页参数不能为空") @@ -32,5 +32,4 @@ @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageSize; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientConsultationStatisticsVO.java
New file @@ -0,0 +1,20 @@ package com.panzhihua.common.model.vos.community.convenient; import io.swagger.annotations.ApiModel; import lombok.Data; /** * @title: ConvenientConsultationStatisticsVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家咨询量 * @author: hans * @date: 2021/09/16 13:49 */ @Data @ApiModel("便民服务商家咨询量") public class ConvenientConsultationStatisticsVO { private Long merchantId; private Integer totalConsultationNum; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientMerchantVO.java
@@ -70,6 +70,18 @@ @ApiModelProperty("月咨询量") private Integer monthConsultationVolume; @ApiModelProperty("日咨询量") private Integer dayConsultationVolume; @ApiModelProperty("总浏览量") private Integer viewNum; @ApiModelProperty("月浏览量") private Integer monthViewNum; @ApiModelProperty("日总浏览量") private Integer dayViewNum; @ApiModelProperty("商家绑定账户") private String account; @@ -88,6 +100,9 @@ @ApiModelProperty("服务类型id列表") private List<Long> serviceIds; @ApiModelProperty("该商家存有商品,最多返回两条") private List<ConvenientProductVO> productVOList; public void setPeriod(String period) { this.period = MerchantBusinessPeriod.valueOf(period); } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientProductLevelInfoVO.java
New file @@ -0,0 +1,25 @@ package com.panzhihua.common.model.vos.community.convenient; import java.util.List; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @title: ConvenientProductLevelInfoVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 商品层级信息VO * @author: hans * @date: 2021/09/23 9:55 */ @Data @ApiModel("商品层级信息VO") public class ConvenientProductLevelInfoVO { @ApiModelProperty("商品分类名称") private String categoryName; @ApiModelProperty("该分类下商品") private List<ConvenientProductVO> productVOList; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientProductShelfVO.java
New file @@ -0,0 +1,23 @@ package com.panzhihua.common.model.vos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @title: ConvenientProductShelfVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家后台产品信息 * @author: hans * @date: 2021/09/20 21:23 */ @Data @ApiModel("便民服务商家后台产品信息") public class ConvenientProductShelfVO { @ApiModelProperty("上架产品数量") private Integer onShelfTotalNum; @ApiModelProperty("下架产品数量") private Integer offShelfTotalNum; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientProductVO.java
@@ -1,10 +1,11 @@ package com.panzhihua.common.model.vos.community.convenient; import java.util.Date; import java.util.List; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; /** * @title: ConvenientProductVO @@ -43,4 +44,10 @@ @ApiModelProperty("上架状态,1.上架 0.下架") private Integer onShelf; @ApiModelProperty("上架时间") private Date onShelfAt; @ApiModelProperty("浏览量") private Integer viewNum; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientViewStatisticsVO.java
New file @@ -0,0 +1,20 @@ package com.panzhihua.common.model.vos.community.convenient; import io.swagger.annotations.ApiModel; import lombok.Data; /** * @title: ConvenientViewStatisticsVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家浏览量 * @author: hans * @date: 2021/09/16 13:49 */ @Data @ApiModel("便民服务商家浏览量") public class ConvenientViewStatisticsVO { private Long merchantId; private Integer totalViewNum; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ExportMerchantVO.java
New file @@ -0,0 +1,73 @@ package com.panzhihua.common.model.vos.community.convenient; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; /** * @title: ExportMerchantVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 商家导出VO * @author: hans * @date: 2021/09/23 15:41 */ @Data public class ExportMerchantVO { @ExcelProperty("商家名称") private String name; @ExcelProperty("联系人") private String contacts; @ExcelProperty("负责人身份证号") private String idCard; @ExcelProperty("咨询电话") private String phone; @ExcelProperty("商家地址") private String address; @ExcelProperty("营业时间") private String businessTime; @ExcelProperty("商家介绍") private String introduction; @ExcelProperty("营业状态") private String businessStatus; @ExcelProperty("总咨询量") private Integer consultationVolume; @ExcelProperty("管理账号") private String account; @ExcelProperty("账户状态") private String accountStatus; @ExcelProperty("所属社区") private String communityName; @ExcelProperty("服务范围") private String serviceScope; public void setBusinessStatus(Boolean businessStatus) { this.businessStatus = businessStatus ? "在营" : "已关闭"; } public void setAccountStatus(Integer accountStatus) { this.accountStatus = accountStatus.intValue() == 1 ? "启用" : "禁用"; } public void setBusinessTimeTime(String businessTime) { if (businessTime.contains("EVERY_DAY")) { this.businessTime = businessTime.replace("EVERY_DAY", "每天:"); } else if (businessTime.contains("WEEKDAY")) { this.businessTime = businessTime.replace("WEEKDAY", "周一至周五:"); } else { this.businessTime = businessTime.replace("WEEKEND", "周末:"); } } } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -9,21 +9,21 @@ import com.panzhihua.common.model.dtos.community.convenient.ConvenientServiceCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.DisableOrEnableConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.ExportMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientServiceCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageMerchantProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PagePopularMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.dtos.community.convenient.ResetPasswordConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.discuss.ComActDiscussDetailDTO; import com.panzhihua.common.model.dtos.community.discuss.ComActDiscussPublishResultDTO; import com.panzhihua.common.model.dtos.neighbor.*; import com.panzhihua.common.model.vos.community.*; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -120,7 +120,6 @@ import com.panzhihua.common.model.vos.community.questnaire.EditComActQuestnaireVo; import com.panzhihua.common.model.vos.community.questnaire.QuestnaireVO; import com.panzhihua.common.model.vos.community.questnaire.UsersAnswerQuestnaireVO; import com.panzhihua.common.model.vos.community.reserve.*; import com.panzhihua.common.model.vos.neighbor.AddNeighborCircleAdminVO; import com.panzhihua.common.model.vos.neighbor.ChangeCommentReplyStatusByAdminVO; import com.panzhihua.common.model.vos.neighbor.ChangeCommentStatusByAdminVO; @@ -5960,9 +5959,80 @@ /** * 获取商家产品 * @param pageMerchantProductDTO * @param merchantId * @return */ @PostMapping("/convenient/merchant/product") R getMerchantProduct(@RequestBody PageMerchantProductDTO pageMerchantProductDTO); @GetMapping("/convenient/product/list") R getMerchantProduct(@RequestParam("merchantId") Long merchantId); /** * 获取产品详情 * @param productId * @return */ @GetMapping("/convenient/product/detail") R getProductDetail(@RequestParam("productId") Long productId); /** * 搜索商家信息 * @param pageSearchDTO * @return */ @PostMapping("/convenient/merchant/search") R pageSearchMerchant(@RequestBody PageSearchDTO pageSearchDTO); /** * 搜索商品信息 * @param pageSearchDTO * @return */ @PostMapping("/convenient/product/search") R pageSearchProduct(@RequestBody PageSearchDTO pageSearchDTO); /** * 增加商家店铺咨询量 * @param merchantId * @return */ @GetMapping("/convenient/merchant/consult") R consultMerchant(@RequestParam("merchantId") Long merchantId); /** * 增加产品浏览量 * @param productId * @return */ @GetMapping("/convenient/product/incr-view") R incrProductView(@RequestParam("productId") Long productId); /** * 获取商家导出数据 * @param exportMerchantDTO * @return */ @PostMapping("/convenient/merchant/export") R exportMerchant(@RequestBody ExportMerchantDTO exportMerchantDTO); /** * 增加商家店铺浏览量 * @param merchantId * @return */ @GetMapping("/convenient/merchant/incr-view") R incrMerchantView(@RequestParam("merchantId") Long merchantId); /** * 定时任务每隔半小时将商家浏览量和咨询量总值计入指定商家数据中 * @return */ @PostMapping("/convenient/timedTaskWriteDataToMerchantJobHandler") R timedTaskWriteDataToMerchantJobHandler(); /** * 获取商家上下架产品数量 * @param merchantId * @return */ @GetMapping("/convenient/product/shelf-num") R getProductShelfNum(@RequestParam("merchantId") Long merchantId); } springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityConvenientApi.java
@@ -1,23 +1,33 @@ package com.panzhihua.community_backstage.api; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.UUID; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSONArray; import com.jcraft.jsch.SftpException; import com.panzhihua.common.constants.FtpConstants; import com.panzhihua.common.controller.BaseController; @@ -26,9 +36,18 @@ import com.panzhihua.common.model.dtos.community.ComCvtServeDTO; import com.panzhihua.common.model.dtos.community.PageComCvtBusinessDTO; import com.panzhihua.common.model.dtos.community.PageComCvtServeDTO; import com.panzhihua.common.model.dtos.community.convenient.ExportMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.*; import com.panzhihua.common.model.vos.community.ComActVO; import com.panzhihua.common.model.vos.community.ComCvtBusinessVO; import com.panzhihua.common.model.vos.community.ComCvtCategoryVO; import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO; import com.panzhihua.common.model.vos.community.ComCvtServeVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import com.panzhihua.common.model.vos.community.convenient.ExportMerchantVO; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.utlis.DateUtils; import com.panzhihua.common.utlis.SFTPUtil; @@ -244,4 +263,56 @@ return communityService.getAllServiceCategories(); } @ApiOperation(value = "便民服务商家导出") @PostMapping("/merchant/export") public R exportMerchant(@RequestBody ExportMerchantDTO exportMerchantDTO) { String url = excelUrl; String name = "便民服务商家.xlsx"; String ftpUrl = "/mnt/data/web/excel/"; R r = communityService.exportMerchant(exportMerchantDTO); if (R.isOk(r)) { List<ExportMerchantVO> exportMerchantVOList = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ExportMerchantVO.class); try { SFTPUtil sftp = new SFTPUtil(userName, password, host, port); sftp.login(); boolean existDir = sftp.isExistDir(ftpUrl + name); if (!existDir) { String property = System.getProperty("user.dir"); String fileName = property + File.separator + name; // 这里 需要指定写用哪个class去写 ExcelWriter excelWriter = null; InputStream inputStream = null; try { excelWriter = EasyExcel.write(fileName, ExportMerchantVO.class).build(); WriteSheet writeSheet = EasyExcel.writerSheet("便民服务商家导出").build(); excelWriter.write(exportMerchantVOList, writeSheet); excelWriter.finish(); File file = new File(fileName); inputStream = new FileInputStream(file); sftp.uploadMore(ftpUrl, name, inputStream); sftp.logout(); inputStream.close(); String absolutePath = file.getAbsolutePath(); boolean delete = file.delete(); log.info("删除excel【{}】结果【{}】", absolutePath, delete); } finally { // 千万别忘记finish 会帮忙关闭流 if (inputStream != null) { inputStream.close(); } if (excelWriter != null) { excelWriter.finish(); } } } return R.ok(url + name); } catch (Exception e) { e.printStackTrace(); log.error("文件传输失败【{}】", e.getMessage()); return R.fail(); } } return R.fail("未查询到数据"); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ConvenientApi.java
@@ -5,9 +5,10 @@ import javax.annotation.Resource; import javax.validation.Valid; import com.panzhihua.common.model.dtos.community.convenient.ExportMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageMerchantProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PagePopularMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -617,11 +618,100 @@ /** * 小程序获取商家产品 * @param pageMerchantProductDTO * @param merchantId * @return */ @PostMapping("/merchant/product") public R getMerchantProduct(@RequestBody PageMerchantProductDTO pageMerchantProductDTO) { return convenientProductService.getMerchantProduct(pageMerchantProductDTO); @GetMapping("/product/list") public R getMerchantProduct(@RequestParam("merchantId") Long merchantId) { return convenientProductService.getMerchantProduct(merchantId); } /** * 获取产品详情 * @param productId * @return */ @GetMapping("/product/detail") public R getProductDetail(@RequestParam("productId") Long productId) { return convenientProductService.getProduct(productId); } /** * 搜索商家信息 * @param pageSearchDTO * @return */ @PostMapping("/merchant/search") public R pageSearchMerchant(@RequestBody PageSearchDTO pageSearchDTO) { return convenientMerchantService.pageSearchMerchant(pageSearchDTO); } /** * 搜索商品信息 * @param pageSearchDTO * @return */ @PostMapping("/product/search") public R pageSearchProduct(@RequestBody PageSearchDTO pageSearchDTO) { return convenientProductService.pageSearchProduct(pageSearchDTO); } /** * 增加商家店铺咨询量 * @param merchantId * @return */ @GetMapping("/merchant/consult") public R consultMerchant(@RequestParam("merchantId") Long merchantId) { return convenientMerchantService.consultMerchant(merchantId); } /** * 增加商家店铺浏览量 * @param merchantId * @return */ @GetMapping("/merchant/incr-view") public R incrMerchantView(@RequestParam("merchantId") Long merchantId) { return convenientMerchantService.incrMerchantView(merchantId); } /** * 增加产品浏览量 * @param productId * @return */ @GetMapping("/product/incr-view") public R incrProductView(@RequestParam("productId") Long productId) { return convenientProductService.incrProductView(productId); } /** * 获取商家导出数据 * @param exportMerchantDTO * @return */ @PostMapping("/merchant/export") public R exportMerchant(@RequestBody ExportMerchantDTO exportMerchantDTO) { return convenientMerchantService.exportMerchant(exportMerchantDTO); } /** * 定时任务每隔半小时将商家浏览量和咨询量总值计入指定商家数据中 * @return */ @PostMapping("/timedTaskWriteDataToMerchantJobHandler") public R timedTaskWriteDataToMerchantJobHandler() { return convenientMerchantService.timedTaskWriteDataToMerchantJobHandler(); } /** * 获取商家上下架产品数量 * @param merchantId * @return */ @GetMapping("/product/shelf-num") public R getProductShelfNum(@RequestParam("merchantId") Long merchantId) { return convenientProductService.getProductShelfNum(merchantId); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientConsultationStatisticsDAO.java
New file @@ -0,0 +1,58 @@ package com.panzhihua.service_community.dao; import com.panzhihua.common.model.vos.community.convenient.ConvenientConsultationStatisticsVO; import org.apache.ibatis.annotations.Mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.panzhihua.service_community.model.dos.ConvenientConsultationStatisticsDO; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @title: ConvenientConsultationStatisticsDAO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家咨询量统计DAO * @author: hans * @date: 2021/09/23 13:55 */ @Mapper public interface ConvenientConsultationStatisticsDAO extends BaseMapper<ConvenientConsultationStatisticsDO> { /** * 创建当天统计数据 * @param merchantId * @return */ int createTodayStatistic(@Param("merchantId") Long merchantId); /** * 增加当天浏览量 * @param merchantId * @param nowDate * @return */ int incrConsultationNum(@Param("merchantId") Long merchantId, @Param("nowDate") String nowDate); /** * 获取月咨询量 * @param merchantId * @param moth * @return */ int selectMonthConsultationVolume(@Param("merchantId") Long merchantId, @Param("moth") String moth); /** * 获取当天咨询量 * @param merchantId * @param day * @return */ int selectDayConsultationVolume(@Param("merchantId") Long merchantId, @Param("day") String day); /** * 获取商家总咨询量 * @return */ List<ConvenientConsultationStatisticsVO> selectSumForConsultationNum(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientMerchantDAO.java
@@ -2,14 +2,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.panzhihua.common.model.dtos.community.convenient.ExportMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientConsultationStatisticsVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientViewStatisticsVO; import com.panzhihua.common.model.vos.community.convenient.ExportMerchantVO; import org.apache.ibatis.annotations.Mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.panzhihua.service_community.model.dos.ConvenientMerchantDO; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @title: ConvenientMerchantDAO @@ -70,4 +77,34 @@ * @return */ ConvenientMerchantVO getMerchantDetail(@Param("merchantId") Long merchantId, @Param("currentMon") String currentMon); /** * 分页搜索商家信息 * @param page * @param pageSearchDTO * @param currentMon * @return */ IPage<ConvenientMerchantVO> pageSearchMerchant(@Param("page") Page page, @Param("pageSearchDTO") PageSearchDTO pageSearchDTO, @Param("currentMon") String currentMon); /** * 获取商家导出数据 * @param exportMerchantDTO * @return */ List<ExportMerchantVO> exportMerchant(@Param("exportMerchantDTO") ExportMerchantDTO exportMerchantDTO); /** * 批量更新商家咨询量 * @param consultationVOList * @return */ int batchUpdateMerchantConsultationNum(@Param("consultationVOList") List<ConvenientConsultationStatisticsVO> consultationVOList); /** * 批量更新商家浏览量 * @param viewVOList * @return */ int batchUpdateMerchantViewNum(@Param("viewVOList") List<ConvenientViewStatisticsVO> viewVOList); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientProductDAO.java
@@ -4,7 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageMerchantProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductSpecificationVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.service_community.model.dos.ConvenientProductDO; import org.apache.ibatis.annotations.Mapper; @@ -49,9 +50,30 @@ /** * 小程序获取商家产品 * @param page * @param pageMerchantProductDTO * @param merchantId * @return */ IPage<ConvenientProductVO> getMerchantProduct(@Param("page") Page page, @Param("pageMerchantProductDTO") PageMerchantProductDTO pageMerchantProductDTO); List<ConvenientProductVO> getMerchantProduct(@Param("merchantId") Long merchantId); /** * 获取产品规格 * @param merchantId * @return */ List<ConvenientProductSpecificationVO> getProductSpecifications(@Param("merchantId") Long merchantId); /** * 分页搜索产品信息 * @param page * @param pageSearchDTO * @return */ IPage<ConvenientProductVO> pageSearchProduct(@Param("page") Page page, @Param("pageSearchDTO") PageSearchDTO pageSearchDTO); /** * 增加产品浏览量 * @param productId * @return */ int incrProductView(@Param("productId") Long productId); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientViewStatisticsDAO.java
New file @@ -0,0 +1,58 @@ package com.panzhihua.service_community.dao; import com.panzhihua.common.model.vos.community.convenient.ConvenientViewStatisticsVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.panzhihua.service_community.model.dos.ConvenientViewStatisticsDO; import java.util.List; /** * @title: ConvenientViewStatisticsDAO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家浏览量统计DAO * @author: hans * @date: 2021/09/23 16:53 */ @Mapper public interface ConvenientViewStatisticsDAO extends BaseMapper<ConvenientViewStatisticsDO> { /** * 创建当天统计数据 * @param merchantId * @return */ int createTodayStatistic(@Param("merchantId") Long merchantId); /** * 增加当天浏览量 * @param merchantId * @param nowDate * @return */ int incrViewNum(@Param("merchantId") Long merchantId, @Param("nowDate") String nowDate); /** * 获取月浏览量 * @param merchantId * @param moth * @return */ int selectMonthViewNum(@Param("merchantId") Long merchantId, @Param("moth") String moth); /** * 获取当天浏览量 * @param merchantId * @param day * @return */ int selectDayViewNum(@Param("merchantId") Long merchantId, @Param("day") String day); /** * 获取商家总浏览量 * @return */ List<ConvenientViewStatisticsVO> selectSumForViewNum(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ConvenientConsultationStatisticsDO.java
New file @@ -0,0 +1,42 @@ package com.panzhihua.service_community.model.dos; import java.io.Serializable; import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; /** * @title: ConvenientConsultationStatisticsDO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家咨询量统计DO * @author: hans * @date: 2021/09/23 13:56 */ @Data @TableName(value = "com_convenient_consultation_statistics") public class ConvenientConsultationStatisticsDO implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(type = IdType.AUTO) private Long id; /** * 商家id */ private Long merchantId; /** * 统计日期 */ private Date statisticDate; /** * 咨询量 */ private Integer consultationVolume; } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ConvenientViewStatisticsDO.java
New file @@ -0,0 +1,42 @@ package com.panzhihua.service_community.model.dos; import java.io.Serializable; import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; /** * @title: ConvenientViewStatisticsDO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家浏览量统计DO * @author: hans * @date: 2021/09/23 16:54 */ @Data @TableName(value = "com_convenient_view_statistics") public class ConvenientViewStatisticsDO implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(type = IdType.AUTO) private Long id; /** * 商家id */ private Long merchantId; /** * 统计日期 */ private Date statisticDate; /** * 浏览量 */ private Integer viewNum; } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientMerchantService.java
@@ -3,9 +3,11 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.DisableOrEnableConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.ExportMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PagePopularMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.dtos.community.convenient.ResetPasswordConvenientMerchantDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; @@ -103,4 +105,38 @@ * @return */ R getMerchantDetail(Long merchantId); /** * 搜索商家信息 * @param pageSearchDTO * @return */ R pageSearchMerchant(PageSearchDTO pageSearchDTO); /** * 增加商家店铺咨询量 * @param merchantId * @return */ R consultMerchant(Long merchantId); /** * 增加商家店铺浏览量 * @param merchantId * @return */ R incrMerchantView(Long merchantId); /** * 获取商家导出数据 * @param exportMerchantDTO * @return */ R exportMerchant(ExportMerchantDTO exportMerchantDTO); /** * 定时任务每隔半小时将商家浏览量和咨询量总值计入指定商家数据中 * @return */ R timedTaskWriteDataToMerchantJobHandler(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientProductService.java
@@ -5,7 +5,7 @@ import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageMerchantProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.service_community.model.dos.ConvenientProductDO; @@ -62,8 +62,29 @@ /** * 小程序获取商家产品 * @param pageMerchantProductDTO * @param merchantId * @return */ R getMerchantProduct(PageMerchantProductDTO pageMerchantProductDTO); R getMerchantProduct(Long merchantId); /** * 搜索商品信息 * @param pageSearchDTO * @return */ R pageSearchProduct(PageSearchDTO pageSearchDTO); /** * 增加产品浏览量 * @param productId * @return */ R incrProductView(Long productId); /** * 获取商家上下架产品数量 * @param merchantId * @return */ R getProductShelfNum(Long merchantId); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java
@@ -1,5 +1,20 @@ package com.panzhihua.service_community.service.impl; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.annotation.Resource; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -9,34 +24,33 @@ import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.DisableOrEnableConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.ExportMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PagePopularMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.dtos.community.convenient.ResetPasswordConvenientMerchantDTO; import com.panzhihua.common.model.dtos.grid.EventGridMemberPassResetDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientConsultationStatisticsVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductSpecificationVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientViewStatisticsVO; import com.panzhihua.common.service.user.UserService; import com.panzhihua.service_community.dao.ComActDAO; import com.panzhihua.service_community.dao.ConvenientConsultationStatisticsDAO; import com.panzhihua.service_community.dao.ConvenientMerchantDAO; import com.panzhihua.service_community.dao.ConvenientProductDAO; import com.panzhihua.service_community.dao.ConvenientServiceCategoryDAO; import com.panzhihua.service_community.dao.ConvenientViewStatisticsDAO; import com.panzhihua.service_community.model.dos.ComActDO; import com.panzhihua.service_community.model.dos.ConvenientConsultationStatisticsDO; import com.panzhihua.service_community.model.dos.ConvenientMerchantDO; import com.panzhihua.service_community.model.dos.ConvenientServiceCategoryDO; import com.panzhihua.service_community.model.dos.ConvenientViewStatisticsDO; import com.panzhihua.service_community.service.ConvenientMerchantService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; import static org.apache.commons.lang3.StringUtils.isNotBlank; /** * @title: ConvenientMerchantServiceImpl @@ -54,6 +68,12 @@ private ConvenientServiceCategoryDAO convenientServiceCategoryDAO; @Resource private ComActDAO comActDAO; @Resource private ConvenientProductDAO convenientProductDAO; @Resource private ConvenientConsultationStatisticsDAO convenientConsultationStatisticsDAO; @Resource private ConvenientViewStatisticsDAO convenientViewStatisticsDAO; @Override @Transactional(rollbackFor = Exception.class) @@ -119,6 +139,7 @@ convenientServiceCategoryDO.getName(), convenientMerchantDTO.getCreatedBy()); }); } BeanUtils.copyProperties(convenientMerchantDTO, convenientMerchantDO); this.baseMapper.updateById(convenientMerchantDO); return R.ok(); } @@ -138,14 +159,6 @@ page.setSize(pageConvenientMerchantDTO.getPageSize()); page.setCurrent(pageConvenientMerchantDTO.getPageNum()); IPage<ConvenientMerchantVO> iPage = this.baseMapper.pageMerchant(page, pageConvenientMerchantDTO); //填充服务范围 List<ConvenientMerchantVO> records = iPage.getRecords(); if (!records.isEmpty()) { records.forEach(record -> { String serviceScope = convenientServiceCategoryDAO.selectServiceScopeByMerchantId(record.getId()); record.setServiceScope(serviceScope); }); } return R.ok(iPage); } @@ -206,10 +219,24 @@ if (isNull(merchantDO)) { return R.fail("商家不存在"); } Long merchantId = merchantDO.getId(); ConvenientMerchantVO convenientMerchantVO = new ConvenientMerchantVO(); BeanUtils.copyProperties(merchantDO, convenientMerchantVO); List<Long> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantDO.getId()); List<Long> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantId); convenientMerchantVO.setServiceIds(serviceIds); Date nowDate = new Date(); SimpleDateFormat mothFormat = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd"); String moth = mothFormat.format(nowDate); String day = dayFormat.format(nowDate); int monthConsultationVolume = convenientConsultationStatisticsDAO.selectMonthConsultationVolume(merchantId, moth); int dayConsultationVolume = convenientConsultationStatisticsDAO.selectDayConsultationVolume(merchantId, day); int monthViewNum = convenientViewStatisticsDAO.selectMonthViewNum(merchantId, moth); int dayViewNum = convenientViewStatisticsDAO.selectDayViewNum(merchantId, day); convenientMerchantVO.setMonthConsultationVolume(monthConsultationVolume); convenientMerchantVO.setDayConsultationVolume(dayConsultationVolume); convenientMerchantVO.setMonthViewNum(monthViewNum); convenientMerchantVO.setDayViewNum(dayViewNum); return R.ok(convenientMerchantVO); } @@ -249,4 +276,84 @@ String currentMon = simpleDateFormat.format(nowDate).concat("%"); return R.ok(this.baseMapper.getMerchantDetail(merchantId, currentMon)); } @Override public R pageSearchMerchant(PageSearchDTO pageSearchDTO) { Date nowDate = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); String currentMon = simpleDateFormat.format(nowDate).concat("%"); Page page = new Page<>(); page.setSize(pageSearchDTO.getPageSize()); page.setCurrent(pageSearchDTO.getPageNum()); IPage<ConvenientMerchantVO> merchantVOIPage = this.baseMapper.pageSearchMerchant(page, pageSearchDTO, currentMon); List<ConvenientMerchantVO> records = merchantVOIPage.getRecords(); if (!records.isEmpty()) { records.forEach(record -> { List<ConvenientProductVO> merchantProduct = convenientProductDAO.getMerchantProduct(record.getId()); List<ConvenientProductSpecificationVO> productSpecifications = convenientProductDAO.getProductSpecifications(record.getId()); if (!merchantProduct.isEmpty()) { if (merchantProduct.size() > 2) { merchantProduct = merchantProduct.subList(0, 2); } merchantProduct.forEach(product -> { List<ConvenientProductSpecificationVO> list = new ArrayList<>(); productSpecifications.forEach(specification -> { if (product.getId().equals(specification.getProductId())) { list.add(specification); } }); product.setProductSpecificationVOList(list); }); } record.setProductVOList(merchantProduct); }); } return R.ok(merchantVOIPage); } @Override public R consultMerchant(Long merchantId) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String nowDate = simpleDateFormat.format(new Date()); ConvenientConsultationStatisticsDO statisticsDO = convenientConsultationStatisticsDAO.selectOne(new LambdaQueryWrapper<ConvenientConsultationStatisticsDO>() .eq(ConvenientConsultationStatisticsDO::getMerchantId, merchantId).eq(ConvenientConsultationStatisticsDO::getStatisticDate, nowDate)); if (isNull(statisticsDO)) { convenientConsultationStatisticsDAO.createTodayStatistic(merchantId); } else { convenientConsultationStatisticsDAO.incrConsultationNum(merchantId, nowDate); } return R.ok(); } @Override public R incrMerchantView(Long merchantId) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String nowDate = simpleDateFormat.format(new Date()); ConvenientViewStatisticsDO statisticsDO = convenientViewStatisticsDAO.selectOne(new LambdaQueryWrapper<ConvenientViewStatisticsDO>() .eq(ConvenientViewStatisticsDO::getMerchantId, merchantId).eq(ConvenientViewStatisticsDO::getStatisticDate, nowDate)); if (isNull(statisticsDO)) { convenientViewStatisticsDAO.createTodayStatistic(merchantId); } else { convenientViewStatisticsDAO.incrViewNum(merchantId, nowDate); } return R.ok(); } @Override public R exportMerchant(ExportMerchantDTO exportMerchantDTO) { return R.ok(this.baseMapper.exportMerchant(exportMerchantDTO)); } /** * 定时任务每隔半小时将商家浏览量和咨询量总值计入指定商家数据中 * @return */ @Override public R timedTaskWriteDataToMerchantJobHandler() { List<ConvenientConsultationStatisticsVO> consultationVOList = convenientConsultationStatisticsDAO.selectSumForConsultationNum(); List<ConvenientViewStatisticsVO> viewVOList = convenientViewStatisticsDAO.selectSumForViewNum(); this.baseMapper.batchUpdateMerchantConsultationNum(consultationVOList); this.baseMapper.batchUpdateMerchantViewNum(viewVOList); return R.ok(); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java
@@ -1,5 +1,23 @@ package com.panzhihua.service_community.service.impl; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Resource; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -9,8 +27,10 @@ import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageMerchantProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageSearchDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductLevelInfoVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductShelfVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductSpecificationVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.service_community.dao.ConvenientProductCategoryDAO; @@ -20,18 +40,6 @@ import com.panzhihua.service_community.model.dos.ConvenientProductDO; import com.panzhihua.service_community.model.dos.ConvenientProductSpecificationDO; import com.panzhihua.service_community.service.ConvenientProductService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; /** * @title: ConvenientProductServiceImpl @@ -152,9 +160,9 @@ //图片填充 if (!convenientProductVOList.isEmpty()) { convenientProductVOList.forEach(product -> { ConvenientProductSpecificationDO specificationDO = convenientProductSpecificationDAO.selectList(new LambdaQueryWrapper<ConvenientProductSpecificationDO>() .eq(ConvenientProductSpecificationDO::getProductId, product.getId())).get(0); product.setImage(specificationDO.getImage()); List<ConvenientProductSpecificationDO> specificationDOList = convenientProductSpecificationDAO.selectList(new LambdaQueryWrapper<ConvenientProductSpecificationDO>() .eq(ConvenientProductSpecificationDO::getProductId, product.getId()).isNotNull(ConvenientProductSpecificationDO::getImage)); product.setImage(specificationDOList.isEmpty() ? null : specificationDOList.get(0).getImage()); }); } return R.ok(productVOIPage); @@ -192,15 +200,93 @@ /** * 小程序获取商家产品 * @param pageMerchantProductDTO * @param merchantId * @return */ @Override public R getMerchantProduct(PageMerchantProductDTO pageMerchantProductDTO) { public R getMerchantProduct(Long merchantId) { List<ConvenientProductVO> productVOList = this.baseMapper.getMerchantProduct(merchantId); List<ConvenientProductSpecificationVO> specificationVOList = this.baseMapper.getProductSpecifications(merchantId); List<ConvenientProductLevelInfoVO> levelInfoVOList = new ArrayList<>(); if (!productVOList.isEmpty()) { productVOList.forEach(productVO -> { List<ConvenientProductSpecificationVO> currentProductSpecificationVOList = new ArrayList<>(); specificationVOList.forEach(specificationVO -> { if (productVO.getId().equals(specificationVO.getProductId())) { currentProductSpecificationVOList.add(specificationVO); } }); productVO.setProductSpecificationVOList(currentProductSpecificationVOList); }); //分类 Map<String, List<ConvenientProductVO>> levelGroup = productVOList.stream() .collect(Collectors.groupingBy(ConvenientProductVO::getCategoryName)); Set<String> categoryNames = levelGroup.keySet(); Iterator<String> iterator = categoryNames.iterator(); while (iterator.hasNext()) { String categoryName = iterator.next(); ConvenientProductLevelInfoVO levelInfoVOLevelInfoVO = new ConvenientProductLevelInfoVO(); levelInfoVOLevelInfoVO.setCategoryName(categoryName); List<ConvenientProductVO> productVOS = levelGroup.get(categoryName); List<ConvenientProductVO> sortedProductVOS = productVOS.stream() .sorted(Comparator.comparing(ConvenientProductVO::getOnShelfAt).reversed()).collect(Collectors.toList()); levelInfoVOLevelInfoVO.setProductVOList(sortedProductVOS); levelInfoVOList.add(levelInfoVOLevelInfoVO); } } return R.ok(levelInfoVOList); } @Override public R pageSearchProduct(PageSearchDTO pageSearchDTO) { Page page = new Page<>(); page.setSize(pageMerchantProductDTO.getPageSize()); page.setCurrent(pageMerchantProductDTO.getPageNum()); IPage<ConvenientProductVO> productVOIPage = this.baseMapper.getMerchantProduct(page, pageMerchantProductDTO); return null; page.setSize(pageSearchDTO.getPageSize()); page.setCurrent(pageSearchDTO.getPageNum()); IPage<ConvenientProductVO> productVOIPage = this.baseMapper.pageSearchProduct(page, pageSearchDTO); List<ConvenientProductVO> records = productVOIPage.getRecords(); if (!records.isEmpty()) { List<Long> productIds = records.stream().map(ConvenientProductVO::getId).collect(Collectors.toList()); List<ConvenientProductSpecificationDO> specificationDOS = convenientProductSpecificationDAO .selectList(new LambdaQueryWrapper<ConvenientProductSpecificationDO>().in(ConvenientProductSpecificationDO::getProductId, productIds)); List<ConvenientProductSpecificationVO> specificationVOList = new ArrayList<>(); if (!specificationDOS.isEmpty()) { specificationDOS.forEach(specificationDO -> { ConvenientProductSpecificationVO specificationVO = new ConvenientProductSpecificationVO(); BeanUtils.copyProperties(specificationDO, specificationVO); specificationVOList.add(specificationVO); }); Map<Long, List<ConvenientProductSpecificationVO>> collect = specificationVOList .stream().collect(Collectors.groupingBy(ConvenientProductSpecificationVO::getProductId)); Set<Long> keySet = collect.keySet(); Iterator<Long> iterator = keySet.iterator(); while (iterator.hasNext()) { Long productId = iterator.next(); records.forEach(record -> { if (record.getId().equals(productId)) { record.setProductSpecificationVOList(collect.get(productId)); } }); } } } return R.ok(productVOIPage); } @Override public R incrProductView(Long productId) { this.baseMapper.incrProductView(productId); return R.ok(); } @Override public R getProductShelfNum(Long merchantId) { int onShelfTotalNum = this.baseMapper.selectCount(new LambdaQueryWrapper<ConvenientProductDO>().eq(ConvenientProductDO::getMerchantId, merchantId) .eq(ConvenientProductDO::getIsDel, false).eq(ConvenientProductDO::getOnShelf, true)); int offShelfTotalNum = this.baseMapper.selectCount(new LambdaQueryWrapper<ConvenientProductDO>().eq(ConvenientProductDO::getMerchantId, merchantId) .eq(ConvenientProductDO::getIsDel, false).eq(ConvenientProductDO::getOnShelf, false)); ConvenientProductShelfVO convenientProductShelfVO = new ConvenientProductShelfVO(); convenientProductShelfVO.setOnShelfTotalNum(onShelfTotalNum); convenientProductShelfVO.setOffShelfTotalNum(offShelfTotalNum); return R.ok(convenientProductShelfVO); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientConsultationStatisticsMapper.xml
New file @@ -0,0 +1,37 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.panzhihua.service_community.dao.ConvenientConsultationStatisticsDAO"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientConsultationStatisticsDO"> <id column="id" property="id" /> <id column="merchant_id" property="merchantId" /> <id column="statistic_date" property="statisticDate" /> <id column="consultation_volume" property="consultationVolume" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id,merchant_id,statistic_date,consultation_volume </sql> <insert id="createTodayStatistic"> INSERT INTO com_convenient_consultation_statistics (merchant_id, statistic_date) VALUES (#{merchantId}, NOW()) </insert> <update id="incrConsultationNum"> UPDATE com_convenient_consultation_statistics SET consultation_volume = consultation_volume + 1 WHERE merchant_id = #{merchantId} AND statistic_date = #{nowDate} </update> <select id="selectMonthConsultationVolume" resultType="java.lang.Integer"> SELECT SUM(consultation_volume) FROM com_convenient_consultation_statistics WHERE merchant_id = #{merchantId} AND statistic_date LIKE CONCAT(#{moth}, '%') </select> <select id="selectDayConsultationVolume" resultType="java.lang.Integer"> SELECT consultation_volume FROM com_convenient_consultation_statistics WHERE merchant_id = #{merchantId} AND statistic_date = #{day} </select> <select id="selectSumForConsultationNum" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientConsultationStatisticsVO"> SELECT merchant_id, SUM(consultation_volume) AS totalConsultationNum FROM com_convenient_consultation_statistics GROUP BY merchant_id </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientMerchantMapper.xml
@@ -35,13 +35,11 @@ business_status,user_id,consultation_volume,is_del,created_at,created_by,updated_at,updated_by </sql> <select id="pageMerchant" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO"> SELECT ccm.*, su.account, su.status AS accountStatus SELECT ccm.*, su.account, su.status AS accountStatus, GROUP_CONCAT(ccss.service_name) AS serviceScope FROM com_convenient_merchants ccm LEFT JOIN sys_user su ON ccm.user_id = su.user_id <if test="pageConvenientMerchantDTO.serviceId != null and pageConvenientMerchantDTO.serviceId != 0"> LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id </if> WHERE is_del = 0 WHERE ccm.is_del = 0 <if test="pageConvenientMerchantDTO.serviceId != null and pageConvenientMerchantDTO.serviceId != 0"> AND ccss.service_category_id = #{pageConvenientMerchantDTO.serviceId} </if> @@ -59,6 +57,7 @@ OR ccm.address LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%') OR ccm.phone LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%') </if> GROUP BY ccm.id </select> <select id="selectMerchantById" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO"> SELECT ccm.*, su.account, su.status AS accountStatus @@ -108,7 +107,68 @@ WHERE ccm.id = #{merchantId} AND cccs.statistic_date LIKE #{currentMon} GROUP BY cccs.id ) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC </select> <select id="pageSearchMerchant" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO"> SELECT temp.id, temp.name, temp.introduction, temp.logo, temp.serviceScope, SUM(temp.consultation_volume) as monthConsultationVolume FROM ( SELECT ccm.id, ccm.name, ccm.introduction, ccm.logo, cccs.consultation_volume,GROUP_CONCAT(ccss.service_name) AS serviceScope FROM com_convenient_merchants ccm INNER JOIN com_convenient_consultation_statistics cccs ON ccm.id = cccs.merchant_id LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id WHERE ccm.`name` LIKE CONCAT('%', #{pageSearchDTO.keyword}, '%') AND ccm.is_del = 0 AND cccs.statistic_date LIKE #{currentMon} GROUP BY cccs.id ) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC </select> <select id="exportMerchant" resultType="com.panzhihua.common.model.vos.community.convenient.ExportMerchantVO"> SELECT ccm.*, su.account, su.status AS accountStatus, GROUP_CONCAT(ccss.service_name) AS serviceScope, CONCAT(ccm.period,DATE_FORMAT(ccm.begin_at,'%T'),'~',DATE_FORMAT(ccm.end_at,'%T')) AS businessTime FROM com_convenient_merchants ccm LEFT JOIN sys_user su ON ccm.user_id = su.user_id LEFT JOIN com_convenient_service_scope ccss ON ccm.id = ccss.merchant_id WHERE ccm.community_id = #{exportMerchantDTO.communityId} AND ccm.is_del = 0 <if test="exportMerchantDTO.serviceId != null and exportMerchantDTO.serviceId != 0"> AND ccss.service_category_id = #{exportMerchantDTO.serviceId} </if> <if test="exportMerchantDTO.accountStatus != null"> AND su.status = #{exportMerchantDTO.accountStatus} </if> <if test="exportMerchantDTO.businessStatus != null"> AND ccm.business_status = #{exportMerchantDTO.businessStatus} </if> <if test="exportMerchantDTO.keyword != null and exportMerchantDTO.keyword != """> AND ccm.name LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%') OR ccm.address LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%') OR ccm.phone LIKE CONCAT('%', #{exportMerchantDTO.keyword}, '%') </if> GROUP BY ccm.id </select> <update id="deleteMerchantById"> UPDATE com_convenient_merchants SET is_del = 1, updated_by = #{operator} WHERE id = #{merchantId} </update> <update id="batchUpdateMerchantConsultationNum"> UPDATE `com_convenient_merchants` SET consultation_volume = CASE id <foreach collection="consultationVOList" item="item" index="index"> WHEN #{item.merchantId} THEN #{item.totalConsultationNum} </foreach> END WHERE id = CASE id <foreach collection="consultationVOList" item="item" index="index"> WHEN #{item.merchantId} THEN #{item.merchantId} </foreach> END </update> <update id="batchUpdateMerchantViewNum"> UPDATE `com_convenient_merchants` SET view_num = CASE id <foreach collection="viewVOList" item="item" index="index"> WHEN #{item.merchantId} THEN #{item.totalViewNum} </foreach> END WHERE id = CASE id <foreach collection="viewVOList" item="item" index="index"> WHEN #{item.merchantId} THEN #{item.merchantId} </foreach> END </update> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductMapper.xml
@@ -34,11 +34,14 @@ #{item} </foreach> </update> <update id="incrProductView"> UPDATE com_convenient_products SET view_num = view_num + 1 WHERE id = #{productId} </update> <select id="pageProduct" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO"> SELECT ccp.name,ccpc.name AS categoryName,ccp.view_num,ccp.on_shelf SELECT ccp.id, ccp.name,ccpc.name AS categoryName,ccp.view_num,ccp.on_shelf FROM com_convenient_products ccp LEFT JOIN com_convenient_product_categories ccpc ON ccp.category_id = ccpc.id WHERE ccp.is_del = 0 WHERE ccp.merchant_id = #{pageConvenientProductDTO.merchantId} AND ccp.is_del = 0 <if test="pageConvenientProductDTO.name != null and pageConvenientProductDTO.name != """> AND ccp.name LIKE CONCAT('%', #{pageConvenientProductDTO.name}, '%') </if> @@ -50,9 +53,22 @@ </if> </select> <select id="getMerchantProduct" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO"> SELECT ccp.id, ccp.name, ccp. SELECT ccp.id, ccp.name, ccp.category_id, ccp.on_shelf_at, ccpc.name AS categoryName FROM com_convenient_products ccp LEFT JOIN com_convenient_product_specifications ccps ON ccp.id = ccps.product_id WHERE ccp.merchant_id = #{pageMerchantProductDTO.merchantId} LEFT JOIN com_convenient_product_categories ccpc ON ccp.category_id = ccpc.id INNER JOIN com_convenient_product_specifications ccps ON ccp.id = ccps.product_id WHERE ccp.merchant_id = #{merchantId} AND ccp.is_del = 0 AND ccp.on_shelf = 1 AND ccps.is_del = 0 GROUP BY ccp.id ORDER BY ccpc.weight DESC </select> <select id="getProductSpecifications" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductSpecificationVO"> SELECT ccps.id, ccps.name, ccps.price, ccps.image, ccps.product_id FROM com_convenient_products ccp LEFT JOIN com_convenient_product_categories ccpc ON ccp.category_id = ccpc.id INNER JOIN com_convenient_product_specifications ccps ON ccp.id = ccps.product_id WHERE ccp.merchant_id = #{merchantId} AND ccp.is_del = 0 AND ccp.on_shelf = 1 AND ccps.is_del = 0 </select> <select id="pageSearchProduct" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO"> SELECT id,`name`,category_id,merchant_id,introduction FROM com_convenient_products WHERE `name` LIKE CONCAT('%', #{pageSearchDTO.keyword}, '%') </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientViewStatisticsMapper.xml
New file @@ -0,0 +1,37 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.panzhihua.service_community.dao.ConvenientViewStatisticsDAO"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientViewStatisticsDO"> <id column="id" property="id" /> <id column="merchant_id" property="merchantId" /> <id column="statistic_date" property="statisticDate" /> <id column="view_num" property="viewNum" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id,merchant_id,statistic_date,view_num </sql> <insert id="createTodayStatistic"> INSERT INTO com_convenient_view_statistics (merchant_id, statistic_date) VALUES (#{merchantId}, NOW()) </insert> <update id="incrViewNum"> UPDATE com_convenient_view_statistics SET view_num = view_num + 1 WHERE merchant_id = #{merchantId} AND statistic_date = #{nowDate} </update> <select id="selectMonthViewNum" resultType="java.lang.Integer"> SELECT SUM(view_num) FROM com_convenient_view_statistics WHERE merchant_id = #{merchantId} AND statistic_date LIKE CONCAT(#{moth}, '%') </select> <select id="selectDayViewNum" resultType="java.lang.Integer"> SELECT view_num FROM com_convenient_view_statistics WHERE merchant_id = #{merchantId} AND statistic_date = #{day} </select> <select id="selectSumForViewNum" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientViewStatisticsVO"> SELECT merchant_id, SUM(view_num) AS totalViewNum FROM com_convenient_view_statistics GROUP BY merchant_id </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/ConvenientApi.java
@@ -1,13 +1,13 @@ package com.panzhihua.shop_backstage.api; import java.io.InputStream; import java.util.UUID; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import com.panzhihua.common.constants.FtpConstants; import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import com.panzhihua.common.utlis.SFTPUtil; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductShelfVO; import org.apache.commons.io.FilenameUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; @@ -20,9 +20,12 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import com.alibaba.fastjson.JSONObject; import com.panzhihua.common.constants.FtpConstants; import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; @@ -36,11 +39,13 @@ import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductCategoryVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import com.panzhihua.common.model.vos.shop.LoginMerchantUserInfoVO; import com.panzhihua.common.model.vos.user.ChangePasswordVO; import com.panzhihua.common.service.auth.TokenService; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.service.user.UserService; import com.panzhihua.common.utlis.SFTPUtil; import com.panzhihua.common.validated.AddGroup; import com.panzhihua.common.validated.PutGroup; import com.panzhihua.shop_backstage.model.vos.LoginBody; @@ -49,10 +54,6 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.web.multipart.MultipartFile; import java.io.InputStream; import java.util.UUID; /** * @title: ConvenientApi @@ -166,6 +167,7 @@ @PutMapping("/merchant/put") public R putMerchant(@RequestBody @Validated(PutGroup.class) ConvenientMerchantDTO convenientMerchantDTO) { convenientMerchantDTO.setUpdatedBy(this.getUserId()); convenientMerchantDTO.setCreatedBy(this.getUserId()); return communityService.putMerchant(convenientMerchantDTO); } @@ -232,15 +234,31 @@ @ApiOperation(value = "便民服务商家后台新增产品") @PostMapping("/product/add") public R addProduct(@RequestBody @Validated(AddGroup.class) ConvenientProductDTO convenientProductDTO) { convenientProductDTO.setCreatedBy(this.getUserId()); Long userId = this.getUserId(); convenientProductDTO.setCreatedBy(userId); R<ConvenientMerchantVO> merchantInfo = communityService.getUserConvenientMerchantInfo(userId); if (R.isOk(merchantInfo)) { ConvenientMerchantVO merchantVO = JSONObject.parseObject(JSONObject.toJSONString(merchantInfo.getData()), ConvenientMerchantVO.class); convenientProductDTO.setMerchantId(merchantVO.getId()); return communityService.addProduct(convenientProductDTO); } return R.fail("新增失败,请重试"); } @ApiOperation(value = "便民服务商家后台编辑产品") @PutMapping("/product/put") public R putProduct(@RequestBody @Validated(PutGroup.class) ConvenientProductDTO convenientProductDTO) { convenientProductDTO.setUpdatedBy(this.getUserId()); Long userId = this.getUserId(); convenientProductDTO.setUpdatedBy(userId); R<ConvenientMerchantVO> merchantInfo = communityService.getUserConvenientMerchantInfo(userId); if (R.isOk(merchantInfo)) { ConvenientMerchantVO merchantVO = JSONObject.parseObject(JSONObject.toJSONString(merchantInfo.getData()), ConvenientMerchantVO.class); convenientProductDTO.setMerchantId(merchantVO.getId()); return communityService.putProduct(convenientProductDTO); } return R.fail("保存失败,请重试"); } @ApiOperation(value = "便民服务商家后台查询产品详情", response = ConvenientProductVO.class) @@ -252,7 +270,15 @@ @ApiOperation(value = "便民服务商家后台分页查询产品", response = ConvenientProductVO.class) @PostMapping("/product/page") public R pageProduct(@RequestBody PageConvenientProductDTO pageConvenientProductDTO) { Long userId = this.getUserId(); R<ConvenientMerchantVO> merchantInfo = communityService.getUserConvenientMerchantInfo(userId); if (R.isOk(merchantInfo)) { ConvenientMerchantVO merchantVO = JSONObject.parseObject(JSONObject.toJSONString(merchantInfo.getData()), ConvenientMerchantVO.class); pageConvenientProductDTO.setMerchantId(merchantVO.getId()); return communityService.pageProduct(pageConvenientProductDTO); } return R.fail("获取失败,请重新尝试"); } @ApiOperation(value = "便民服务商家后台删除产品") @@ -268,4 +294,16 @@ onShelfOrOffShelfProductDTO.setUpdatedBy(this.getUserId()); return communityService.onShelfOrOffShelfProduct(onShelfOrOffShelfProductDTO); } @ApiOperation(value = "便民服务商家后台查询产品上下架数量", response = ConvenientProductShelfVO.class) @GetMapping("/product/shelf-num") public R getProductShelfNum() { R<ConvenientMerchantVO> merchantInfo = communityService.getUserConvenientMerchantInfo(this.getUserId()); if (R.isOk(merchantInfo)) { ConvenientMerchantVO merchantVO = JSONObject.parseObject(JSONObject.toJSONString(merchantInfo.getData()), ConvenientMerchantVO.class); return communityService.getProductShelfNum(merchantVO.getId()); } return R.fail("获取失败,请重试"); } } springcloud_k8s_panzhihuazhihuishequ/timejob/src/main/java/com/panzhihua/timejob/jobhandler/CommunityJobHandler.java
@@ -249,4 +249,15 @@ log.info("执行结果【{}】", r.toString()); return ReturnT.SUCCESS; } /** * 定时任务每隔半小时将商家浏览量和咨询量总值计入指定商家数据中 */ @XxlJob("timedTaskWriteDataToMerchantJobHandler") public ReturnT<String> timedTaskWriteDataToMerchantJobHandler(String param) { log.info("定时任务每隔半小时将商家浏览量和咨询量总值计入指定商家数据中"); R r = communityService.timedTaskWriteDataToMerchantJobHandler(); log.info("执行结果【{}】", r.toString()); return ReturnT.SUCCESS; } }