springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommunityConvenientApi.java
@@ -1,7 +1,12 @@ package com.panzhihua.applets.api; 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.PagePopularMerchantDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import org.springframework.web.bind.annotation.*; import com.panzhihua.common.controller.BaseController; @@ -15,6 +20,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import java.util.Objects; /** * @description: 社区便民服务商家接口 @@ -30,6 +37,7 @@ @Resource private CommunityService communityService; @Deprecated @ApiOperation(value = "分页查询便民服务商家", response = ComCvtBusinessVO.class) @PostMapping("/business/area/page") public R pageComCvtBusiness(@RequestBody PageComCvtBusinessAppletsDTO comCvtBusinessAppletsDTO) { @@ -40,10 +48,31 @@ return communityService.pageComCvtBusinessByServiceArea(comCvtBusinessAppletsDTO); } @Deprecated @ApiOperation(value = "查询便民服务商家详情", response = ComCvtBusinessDetailVO.class) @GetMapping("/business/get") public R getComCvtBusinessServeDetail(@RequestParam("id") Long id) { return communityService.getComCvtBusinessServeDetail(id); } @ApiOperation(value = "获取商家数量大于0的服务类型", response = ConvenientServiceCategoryVO.class) @GetMapping("/service-category/suitable") public R getSuitableServiceCategories(@RequestParam("communityId") Long communityId) { if (Objects.isNull(communityId)) { return R.fail("社区id不能为空"); } return communityService.getSuitableServiceCategories(communityId); } @ApiOperation(value = "分页获取热门商家", response = ConvenientMerchantVO.class) @PostMapping("/merchant/popular") public R getPopularMerchants(@RequestBody @Valid PagePopularMerchantDTO pagePopularMerchantDTO) { return communityService.getPopularMerchants(pagePopularMerchantDTO); } @ApiOperation(value = "分页获取服务类型下商家", response = ConvenientMerchantVO.class) @PostMapping("/merchant/classify") public R getClassifyMerchants(@RequestBody @Valid PageClassifyMerchantDTO pageClassifyMerchantDTO) { return communityService.getClassifyMerchants(pageClassifyMerchantDTO); } } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageClassifyMerchantDTO.java
New file @@ -0,0 +1,41 @@ package com.panzhihua.common.model.dtos.community.convenient; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @title: PageClassifyMerchantDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 分页获取服务类型下商家信息请求参数 * @author: hans * @date: 2021/09/22 16:45 */ @Data @ApiModel("分页获取服务类型下商家信息请求参数") public class PageClassifyMerchantDTO { @ApiModelProperty(value = "商家服务分类id") @NotNull(message = "商家服务分类id不能为空") @Min(value = 1) private Long serviceId; @ApiModelProperty(value = "社区id") @NotNull(message = "社区id不能为空") @Min(value = 1) private Long communityId; @ApiModelProperty(value = "分页-当前页数", example = "1") @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageNum; @ApiModelProperty(value = "分页-每页记录数", example = "10") @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageSize; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageConvenientMerchantDTO.java
@@ -18,14 +18,8 @@ @ApiModel("分页查询便民服务商家请求参数") public class PageConvenientMerchantDTO { @ApiModelProperty("商家名称") private String name; @ApiModelProperty("商家地址") private String address; @ApiModelProperty("咨询电话") private String phone; @ApiModelProperty("关键词") private String keyword; @ApiModelProperty("社区id") private Long communityId; springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PagePopularMerchantDTO.java
New file @@ -0,0 +1,36 @@ package com.panzhihua.common.model.dtos.community.convenient; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @title: PagePopularMerchantDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 分页查询热门商家请求参数 * @author: hans * @date: 2021/09/22 16:29 */ @Data @ApiModel("分页查询热门商家请求参数") public class PagePopularMerchantDTO { @ApiModelProperty(value = "社区id") @NotNull(message = "社区id不能为空") @Min(value = 1) private Long communityId; @ApiModelProperty(value = "分页-当前页数", example = "1") @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageNum; @ApiModelProperty(value = "分页-每页记录数", example = "10") @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageSize; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientMerchantVO.java
@@ -3,6 +3,7 @@ import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import com.panzhihua.common.enums.MerchantBusinessPeriod; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -47,9 +48,11 @@ private String lon; @ApiModelProperty("营业开始时间") @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") private Date beginAt; @ApiModelProperty("营业截止时间") @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8") private Date endAt; @ApiModelProperty("营业周期") @@ -61,8 +64,11 @@ @ApiModelProperty("营业状态") private Integer businessStatus; @ApiModelProperty("咨询量") @ApiModelProperty("总咨询量") private Integer consultationVolume; @ApiModelProperty("月咨询量") private Integer monthConsultationVolume; @ApiModelProperty("商家绑定账户") private String account; @@ -81,4 +87,12 @@ @ApiModelProperty("服务类型id列表") private List<Long> serviceIds; public void setPeriod(String period) { this.period = MerchantBusinessPeriod.valueOf(period); } public void setBusinessStatus(Boolean businessStatus) { this.businessStatus = businessStatus ? 1 : 0; } } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -10,10 +10,12 @@ 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.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.PagePopularMerchantDTO; 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; @@ -5915,4 +5917,35 @@ */ @PutMapping("/convenient/product/onShelf-or-offShelf") R onShelfOrOffShelfProduct(@RequestBody OnShelfOrOffShelfProductDTO onShelfOrOffShelfProductDTO); /** * 获取所有产品分类 * @return */ @GetMapping("/convenient/product-category/all") R getAllProductCategory(); /** * 获取该社区商家数量大于0的分类 * @param communityId * @return */ @GetMapping("/convenient/service-category/suitable") R getSuitableServiceCategories(@RequestParam("communityId") Long communityId); /** * 获取该社区下的热门商家 * @param pagePopularMerchantDTO * @return */ @PostMapping("/convenient/merchant/popular") R getPopularMerchants(@RequestBody PagePopularMerchantDTO pagePopularMerchantDTO); /** * 分页获取服务类型下商家信息 * @param pageClassifyMerchantDTO * @return */ @PostMapping("/convenient/merchant/classify") R getClassifyMerchants(PageClassifyMerchantDTO pageClassifyMerchantDTO); } springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommunityConvenientApi.java
@@ -8,6 +8,9 @@ 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; @@ -74,6 +77,7 @@ @Resource private MinioUtil minioUtil; @Deprecated @ApiOperation(value = "分页查询便民服务商家", response = ComCvtBusinessVO.class) @PostMapping("/business/page") public R pageComCvtBusiness(@RequestBody PageComCvtBusinessDTO pageComCvtBusinessDTO) { @@ -82,6 +86,7 @@ return communityService.pageComCvtBusiness(pageComCvtBusinessDTO); } @Deprecated @ApiOperation(value = "新增便民服务商家") @PostMapping("/business/add") public R addComCvtBusiness(@RequestBody @Validated(AddGroup.class) ComCvtBusinessDTO comCvtBusinessDTO) { @@ -93,42 +98,49 @@ return communityService.addComCvtBusiness(comCvtBusinessDTO); } @Deprecated @ApiOperation(value = "社区下拉列表", response = ComActVO.class) @GetMapping("/community") public R listCommunity() { return communityService.listCommunityAll(); } @Deprecated @ApiOperation(value = "编辑便民服务商家") @PutMapping("/business/put") public R putComCvtBusiness(@Validated(AddGroup.class) @RequestBody ComCvtBusinessDTO comCvtBusinessDTO) { return communityService.putComCvtBusiness(comCvtBusinessDTO); } @Deprecated @ApiOperation(value = "查询便民服务商家详情") @GetMapping("/business/get") public R getComCvtBusiness(@RequestParam("id") Long id) { return communityService.getComCvtBusiness(id); } @Deprecated @ApiOperation(value = "删除便民服务商家详情") @DeleteMapping("/business/delete") public R deleteComCvtBusiness(@RequestParam("id") Long id) { return communityService.deleteComCvtBusiness(id); } @Deprecated @ApiOperation(value = "分页查询便民服务", response = ComCvtServeVO.class) @PostMapping("/serve/page") public R pageComCvtServe(@RequestBody PageComCvtServeDTO pageComCvtServeDTO) { return communityService.pageComCvtServe(pageComCvtServeDTO); } @Deprecated @ApiOperation(value = "查询便民服务所有分类,下拉框", response = ComCvtCategoryVO.class) @PostMapping("/category/all") public R allComCvtCategory() { return communityService.allComCvtCategory(); } @Deprecated @ApiOperation(value = "新增便民服务") @PostMapping("/serve/add") public R addComCvtServe(@RequestBody ComCvtServeDTO comCvtServeDTO) { @@ -138,24 +150,28 @@ return communityService.addComCvtServe(comCvtServeDTO); } @Deprecated @ApiOperation(value = "编辑便民服务") @PutMapping("/serve/put") public R putComCvtServe(@RequestBody ComCvtServeDTO comCvtServeDTO) { return communityService.putComCvtServe(comCvtServeDTO); } @Deprecated @ApiOperation(value = "查询便民服务详情", response = ComCvtServeVO.class) @GetMapping("/serve/get") public R getComCvtServe(@RequestParam("id") Long id) { return communityService.getComCvtServe(id); } @Deprecated @ApiOperation(value = "删除便民服务信息") @DeleteMapping("/serve/delete") public R deleteComCvtServe(@RequestParam("id") Long id) { return communityService.deleteComCvtServe(id); } @Deprecated @ApiOperation(value = "下载模板-便民服务") @GetMapping(value = "/serve/download/template") public R downloadTemplate(HttpServletResponse response) throws IOException, SftpException { @@ -214,4 +230,18 @@ return R.ok(); } @ApiOperation(value = "分页查询便民服务商家", response = ConvenientMerchantVO.class) @PostMapping("/merchant/page") public R pageMerchant(@RequestBody PageConvenientMerchantDTO pageConvenientMerchantDTO) { LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); pageConvenientMerchantDTO.setCommunityId(loginUserInfo.getCommunityId()); return communityService.pageMerchant(pageConvenientMerchantDTO); } @ApiOperation(value = "所有服务分类", response = ConvenientServiceCategoryVO.class) @GetMapping("/service-category/all") public R getAllServiceCategories() { return communityService.getAllServiceCategories(); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ConvenientApi.java
@@ -1,5 +1,21 @@ package com.panzhihua.service_community.api; import java.util.List; 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.PagePopularMerchantDTO; 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 com.panzhihua.common.model.dtos.community.ComCvtBusinessDTO; import com.panzhihua.common.model.dtos.community.ComCvtCategoryDTO; import com.panzhihua.common.model.dtos.community.ComCvtServeDTO; @@ -29,19 +45,8 @@ import com.panzhihua.service_community.service.ConvenientProductCategoryService; import com.panzhihua.service_community.service.ConvenientProductService; import com.panzhihua.service_community.service.ConvenientServiceCategoryService; import lombok.extern.slf4j.Slf4j; 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 javax.annotation.Resource; import javax.validation.Valid; import java.util.List; import lombok.extern.slf4j.Slf4j; /** * @description: 便民服务接口 @@ -559,4 +564,43 @@ public R onShelfOrOffShelfProduct(@RequestBody OnShelfOrOffShelfProductDTO onShelfOrOffShelfProductDTO) { return convenientProductService.onShelfOrOffShelfProduct(onShelfOrOffShelfProductDTO); } /** * 获取所有产品分类 * @return */ @GetMapping("/product-category/all") public R getAllProductCategory() { return convenientProductCategoryService.getAllProductCategory(); } /** * 获取该社区商家数量大于0的分类 * @param communityId * @return */ @GetMapping("/service-category/suitable") public R getSuitableServiceCategories(@RequestParam("communityId") Long communityId) { return convenientServiceCategoryService.getSuitableServiceCategories(communityId); } /** * 获取该社区下的热门商家 * @param pagePopularMerchantDTO * @return */ @PostMapping("/merchant/popular") public R getPopularMerchants(@RequestBody PagePopularMerchantDTO pagePopularMerchantDTO) { return convenientMerchantService.getPopularMerchants(pagePopularMerchantDTO); } /** * 分页获取服务类型下商家信息 * @param pageClassifyMerchantDTO * @return */ @PostMapping("/merchant/classify") public R getClassifyMerchants(PageClassifyMerchantDTO pageClassifyMerchantDTO) { return convenientMerchantService.getClassifyMerchants(pageClassifyMerchantDTO); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientMerchantDAO.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.panzhihua.common.model.dtos.community.convenient.PageClassifyMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import org.apache.ibatis.annotations.Mapper; @@ -42,4 +43,23 @@ * @return */ ConvenientMerchantVO selectMerchantById(@Param("merchantId") Long merchantId); /** * 获取社区下热门商家 * * @param page * @param communityId * @param currentMon * @return */ IPage<ConvenientMerchantVO> getPopularMerchants(@Param("page") Page page, @Param("communityId") Long communityId, @Param("currentMon") String currentMon); /** * 获取指定类型的商家 * @param page * @param pageClassifyMerchantDTO * @param currentMon * @return */ IPage<ConvenientMerchantVO> getClassifyMerchants(@Param("page") Page page, @Param("pageClassifyMerchantDTO") PageClassifyMerchantDTO pageClassifyMerchantDTO, @Param("currentMon") String currentMon); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientProductCategoryDAO.java
@@ -9,6 +9,8 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @title: ConvenientProductCategoryDAO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 @@ -26,4 +28,10 @@ * @return 产品分类详情 */ IPage<ConvenientProductCategoryVO> pageProductCategory(@Param("page") Page page, @Param("pageConvenientProductCategoryDTO") PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO); /** * 查询所有分类 * @return */ List<ConvenientProductCategoryVO> selectAllCategories(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientServiceCategoryDAO.java
@@ -67,4 +67,11 @@ * @return */ int checkCategoryIsUsing(@Param("categoryId") Long categoryId); /** * 获取该社区商家数量大于0的分类 * @param communityId * @return */ List<ConvenientServiceCategoryVO> selectSuitableServiceCategories(@Param("communityId") Long communityId); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientMerchantService.java
@@ -3,7 +3,9 @@ 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.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.ResetPasswordConvenientMerchantDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; @@ -80,4 +82,18 @@ * @return */ R<ConvenientMerchantVO> getUserConvenientMerchantInfo(Long userId); /** * 获取该社区下的热门商家 * @param pagePopularMerchantDTO * @return */ R getPopularMerchants(PagePopularMerchantDTO pagePopularMerchantDTO); /** * 分页获取服务类型下商家信息 * @param pageClassifyMerchantDTO * @return */ R getClassifyMerchants(PageClassifyMerchantDTO pageClassifyMerchantDTO); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientProductCategoryService.java
@@ -50,4 +50,10 @@ * @return */ R pageProductCategory(PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO); /** * 获取所有产品分类 * @return */ R getAllProductCategory(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientServiceCategoryService.java
@@ -55,4 +55,11 @@ * @return */ R getAllServiceCategories(); /** * 获取该社区商家数量大于0的分类 * @param communityId * @return */ R getSuitableServiceCategories(Long communityId); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientMerchantServiceImpl.java
@@ -4,25 +4,28 @@ import static java.util.Objects.nonNull; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import javax.annotation.Resource; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.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.ResetPasswordConvenientMerchantDTO; import com.panzhihua.common.model.dtos.grid.EventGridMemberPassResetDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; @@ -209,6 +212,30 @@ BeanUtils.copyProperties(merchantDO, convenientMerchantVO); List<Long> serviceIds = convenientServiceCategoryDAO.selectServiceIdsForMerchant(merchantDO.getId()); convenientMerchantVO.setServiceIds(serviceIds); return null; return R.ok(convenientMerchantVO); } @Override public R getPopularMerchants(PagePopularMerchantDTO pagePopularMerchantDTO) { Date nowDate = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); String currentMon = simpleDateFormat.format(nowDate).concat("%"); Page page = new Page<>(); page.setSize(pagePopularMerchantDTO.getPageSize()); page.setCurrent(pagePopularMerchantDTO.getPageNum()); IPage<ConvenientMerchantVO> merchantVOList = this.baseMapper.getPopularMerchants(page, pagePopularMerchantDTO.getCommunityId(), currentMon); return R.ok(merchantVOList); } @Override public R getClassifyMerchants(PageClassifyMerchantDTO pageClassifyMerchantDTO) { Date nowDate = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); String currentMon = simpleDateFormat.format(nowDate).concat("%"); Page page = new Page<>(); page.setSize(pageClassifyMerchantDTO.getPageSize()); page.setCurrent(pageClassifyMerchantDTO.getPageNum()); IPage<ConvenientMerchantVO> merchantVOList = this.baseMapper.getClassifyMerchants(page, pageClassifyMerchantDTO, currentMon); return R.ok(merchantVOList); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductCategoryServiceImpl.java
@@ -1,5 +1,12 @@ package com.panzhihua.service_community.service.impl; import static java.util.Objects.isNull; import java.util.Date; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -10,12 +17,6 @@ import com.panzhihua.service_community.dao.ConvenientProductCategoryDAO; import com.panzhihua.service_community.model.dos.ConvenientProductCategoryDO; import com.panzhihua.service_community.service.ConvenientProductCategoryService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import java.util.Date; import static java.util.Objects.isNull; /** * @title: ConvenientProductCategoryServiceImpl @@ -93,4 +94,9 @@ IPage<ConvenientProductCategoryVO> iPage = this.baseMapper.pageProductCategory(page, pageConvenientProductCategoryDTO); return R.ok(iPage); } @Override public R getAllProductCategory() { return R.ok(this.baseMapper.selectAllCategories()); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientServiceCategoryServiceImpl.java
@@ -22,8 +22,6 @@ import com.panzhihua.service_community.model.dos.ConvenientServiceCategoryDO; import com.panzhihua.service_community.service.ConvenientServiceCategoryService; import javax.annotation.Resource; /** * @title: ConvenientServiceCategoryServiceImpl * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 @@ -120,4 +118,9 @@ } return R.ok(categoryVOList); } @Override public R getSuitableServiceCategories(Long communityId) { return R.ok(this.baseMapper.selectSuitableServiceCategories(communityId)); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientMerchantMapper.xml
@@ -48,20 +48,16 @@ <if test="pageConvenientMerchantDTO.accountStatus != null"> AND su.status = #{pageConvenientMerchantDTO.accountStatus} </if> <if test="pageConvenientMerchantDTO.name != null and pageConvenientMerchantDTO.name != """> AND ccm.name LIKE CONCAT('%', #{pageConvenientMerchantDTO.name}, '%') </if> <if test="pageConvenientMerchantDTO.address != null and pageConvenientMerchantDTO.address != """> AND ccm.address LIKE CONCAT('%', #{pageConvenientMerchantDTO.address}, '%') </if> <if test="pageConvenientMerchantDTO.phone != null and pageConvenientMerchantDTO.phone != """> AND ccm.phone LIKE CONCAT('%', #{pageConvenientMerchantDTO.phone}, '%') </if> <if test="pageConvenientMerchantDTO.communityId != null and pageConvenientMerchantDTO.communityId != 0"> AND ccm.community_id = #{pageConvenientMerchantDTO.communityId} </if> <if test="pageConvenientMerchantDTO.businessStatus != null"> AND ccm.business_status = #{pageConvenientMerchantDTO.businessStatus} </if> <if test="pageConvenientMerchantDTO.keyword != null and pageConvenientMerchantDTO.keyword != """> AND ccm.name LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%') OR ccm.address LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%') OR ccm.phone LIKE CONCAT('%', #{pageConvenientMerchantDTO.keyword}, '%') </if> </select> <select id="selectMerchantById" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO"> @@ -70,6 +66,34 @@ LEFT JOIN sys_user su ON ccm.user_id = su.user_id WHERE ccm.id = #{merchantId} </select> <select id="getPopularMerchants" 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.community_id = #{communityId} 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="getClassifyMerchants" 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.community_id = #{pageClassifyMerchantDTO.communityId} AND ccss.service_category_id = #{pageClassifyMerchantDTO.serviceId} AND cccs.statistic_date LIKE #{currentMon} GROUP BY cccs.id ) temp GROUP BY temp.id ORDER BY SUM(temp.consultation_volume) DESC </select> <update id="deleteMerchantById"> UPDATE com_convenient_merchants SET is_del = 1, updated_by = #{operator} WHERE id = #{merchantId} </update> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductCategoryMapper.xml
@@ -28,5 +28,10 @@ </if> ORDER BY weight DESC </select> <select id="selectAllCategories" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductCategoryVO"> SELECT <include refid="Base_Column_List"/> FROM com_convenient_product_categories WHERE is_del = 0 ORDER BY weight DESC </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientServiceCategoryMapper.xml
@@ -45,4 +45,11 @@ <select id="checkCategoryIsUsing" resultType="java.lang.Integer"> SELECT COUNT(1) FROM com_convenient_service_scope WHERE service_category_id = #{categoryId} </select> <select id="selectSuitableServiceCategories" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO"> SELECT ccsc.id, ccsc.name, ccsc.icon, ccsc.remark, ccsc.weight FROM com_convenient_service_categories ccsc INNER JOIN com_convenient_service_scope ccss ON ccsc.id = ccss.service_category_id LEFT JOIN com_convenient_merchants ccm ON ccss.merchant_id = ccm.id WHERE ccsc.is_del = 0 AND ccm.is_del = 0 AND ccm.community_id = #{communityId} GROUP BY ccsc.id </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/ConvenientApi.java
@@ -1,8 +1,28 @@ package com.panzhihua.shop_backstage.api; 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 org.apache.commons.io.FilenameUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.annotation.Validated; 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 com.alibaba.fastjson.JSONObject; import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.interfaces.ShopOperLog; 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; @@ -24,23 +44,15 @@ import com.panzhihua.common.validated.AddGroup; import com.panzhihua.common.validated.PutGroup; import com.panzhihua.shop_backstage.model.vos.LoginBody; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.validation.annotation.Validated; 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 javax.annotation.Resource; import javax.validation.Valid; import java.io.InputStream; import java.util.UUID; /** * @title: ConvenientApi @@ -62,8 +74,23 @@ @Resource private CommunityService communityService; // FTP 登录用户名 @Value("${ftp.username}") private String userName; // FTP 登录密码 @Value("${ftp.password}") private String password; // FTP 服务器地址IP地址 @Value("${ftp.host}") private String host; // FTP 端口 @Value("${ftp.port}") private int port; @Value("${ftp.url}") private String url; @ApiOperation(value = "便民服务商家后台登录", response = LoginReturnVO.class) @ShopOperLog(operType = 1) // @ShopOperLog(operType = 1) @PostMapping("/login") public R login(@RequestBody @Valid LoginBody loginBody) { String account = loginBody.getAccount(); @@ -89,7 +116,7 @@ @ApiOperation(value = "修改密码") @PutMapping("/reset-password") @ShopOperLog(operType = 2) // @ShopOperLog(operType = 2) public R resetPassword(@RequestBody @Valid ConvenientResetPasswordDTO convenientResetPasswordDTO) { String newPassword = convenientResetPasswordDTO.getNewPassword(); String oldPassword = convenientResetPasswordDTO.getOldPassword(); @@ -118,12 +145,45 @@ if (R.isOk(merchantVO) && merchantVO.getData() != null) { ConvenientMerchantVO convenientMerchantVO = JSONObject.parseObject(JSONObject.toJSONString(merchantVO.getData()), ConvenientMerchantVO.class); convenientMerchantVO.setAccount(loginUserInfoVO.getAccount()); convenientMerchantVO.setAccountStatus(loginUserInfoVO.getStatus()); loginMerchantUserInfoVO.setMerchantInfo(convenientMerchantVO); } return R.ok(loginMerchantUserInfoVO); } catch (Exception e) { e.printStackTrace(); return R.fail("获取登陆商家用户信息失败"); } } @ApiOperation(value = "所有服务分类", response = ConvenientServiceCategoryVO.class) @GetMapping("/service-category/all") public R getAllServiceCategories() { return communityService.getAllServiceCategories(); } @ApiOperation(value = "编辑便民服务商家") @PutMapping("/merchant/put") public R putMerchant(@RequestBody @Validated(PutGroup.class) ConvenientMerchantDTO convenientMerchantDTO) { convenientMerchantDTO.setUpdatedBy(this.getUserId()); return communityService.putMerchant(convenientMerchantDTO); } @ApiOperation(value = "上传文件") @PostMapping(value = "/upload/file", consumes = "multipart/*", headers = "content-type=multipart/form-date") public R uploadImage(@RequestParam MultipartFile file, HttpServletRequest request) { String extension = FilenameUtils.getExtension(file.getOriginalFilename()); String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + extension; try { SFTPUtil sftp = new SFTPUtil(userName, password, host, port); sftp.login(); InputStream is = file.getInputStream(); sftp.uploadMore(FtpConstants.FTPFILEPATH_IDCARD, name, is); sftp.logout(); return R.ok(url + "/idcard/" + name); } catch (Exception e) { log.error("上传照片失败【{}】", e.getMessage()); return R.fail(); } } @@ -163,6 +223,12 @@ return communityService.pageProductCategory(pageConvenientProductCategoryDTO); } @ApiOperation(value = "获取所有产品分类", response = ConvenientProductCategoryVO.class) @GetMapping("/product-category/all") public R getAllProductCategory() { return communityService.getAllProductCategory(); } @ApiOperation(value = "便民服务商家后台新增产品") @PostMapping("/product/add") public R addProduct(@RequestBody @Validated(AddGroup.class) ConvenientProductDTO convenientProductDTO) { springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/filter/StoreValidFilter.java
@@ -3,10 +3,16 @@ import java.io.IOException; import javax.annotation.Resource; import javax.servlet.*; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.panzhihua.common.constants.HttpStatus; import com.panzhihua.common.utlis.ResultUtil; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; @@ -15,6 +21,7 @@ import com.panzhihua.common.constants.TokenConstant; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.shop.ShopStoreVO; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.utlis.AES; @@ -42,35 +49,73 @@ HttpServletResponse response = (HttpServletResponse)servletResponse; String uri = request.getRequestURI(); boolean isDoc = uri.contains("doc.html") || uri.contains("-docs"); boolean convenientLogin = "/convenient/login".equals(uri); boolean isConvenientReq = uri.contains("/convenient"); boolean storeLogin = "/login".equals(uri); if (!"/login".equals(uri)) { String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO); boolean empty = ObjectUtils.isEmpty(userInfo); if (empty) { log.error("获取登录用户信息失败【{}】", request); return; } byte[] bytes = AES.parseHexStr2Byte(userInfo); byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY); userInfo = new String(decrypt); LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(userInfo, LoginUserInfoVO.class); if (isDoc) { //放过swagger请求 } else { if (!storeLogin && !isConvenientReq) { String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO); boolean empty = ObjectUtils.isEmpty(userInfo); if (empty) { log.error("获取登录用户信息失败【{}】", request); ResultUtil.responseJson(response, R.fail(HttpStatus.UNAUTHORIZED, "token过期")); return; } byte[] bytes = AES.parseHexStr2Byte(userInfo); byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY); userInfo = new String(decrypt); LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(userInfo, LoginUserInfoVO.class); R r = communityService.getUserStoreInfo(loginUserInfoVO.getUserId()); boolean shopStoreValid = false; if (R.isOk(r) && r.getData() != null) { ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(r.getData()), ShopStoreVO.class); shopStoreValid = shopStoreVO.getStatus() == 1; } if (!shopStoreValid) { // 返回请求被拒绝响应 response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(JSONObject.toJSONString(R.fail(403))); response.flushBuffer(); return; R r = communityService.getUserStoreInfo(loginUserInfoVO.getUserId()); boolean shopStoreValid = false; if (R.isOk(r) && r.getData() != null) { ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(r.getData()), ShopStoreVO.class); shopStoreValid = shopStoreVO.getStatus() == 1; } if (!shopStoreValid) { // 返回请求被拒绝响应 response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(JSONObject.toJSONString(R.fail(403))); response.flushBuffer(); return; } } else if (!convenientLogin && isConvenientReq) { String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO); boolean empty = ObjectUtils.isEmpty(userInfo); if (empty) { log.error("获取登录用户信息失败【{}】", request); ResultUtil.responseJson(response, R.fail(HttpStatus.UNAUTHORIZED, "token过期")); return; } byte[] bytes = AES.parseHexStr2Byte(userInfo); byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY); userInfo = new String(decrypt); LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(userInfo, LoginUserInfoVO.class); R r = communityService.getUserMerchantInfoByAccount(loginUserInfoVO.getAccount()); boolean merchantValid = false; if (R.isOk(r) && r.getData() != null) { ConvenientMerchantVO merchantVO = JSONObject.parseObject(JSONObject.toJSONString(r.getData()), ConvenientMerchantVO.class); merchantValid = merchantVO.getAccountStatus() == 1; } if (!merchantValid) { // 返回请求被拒绝响应 response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(JSONObject.toJSONString(R.fail(403))); response.flushBuffer(); return; } } } filterChain.doFilter(servletRequest, servletResponse); } }