diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index c2e3b4cf..30b9b3f0 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -244,7 +244,7 @@ dubbo: bxg: shop: # API_URL: http://192.168.10.113:48080/bxgApp - API_URL: https://c522-27-19-79-200.jp.ngrok.io + API_URL: https://9783-27-19-79-200.jp.ngrok.io SITE_URL: http://192.168.10.113:48080/bxgApp UNI_SITE_URL: http://192.168.10.113:48080/bxgApp ADMIN_API_URL: http://192.168.10.113:48080/bxg diff --git a/zsw-bxg/pom.xml b/zsw-bxg/pom.xml index b53df462..26124ebb 100644 --- a/zsw-bxg/pom.xml +++ b/zsw-bxg/pom.xml @@ -77,6 +77,12 @@ ${revision} + + org.springframework.boot + spring-boot-starter-websocket + 2.5.10 + + cn.iocoder.boot yudao-spring-boot-starter-security diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreBargainController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreBargainController.java index ed23466e..a2a4231f 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreBargainController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreBargainController.java @@ -92,12 +92,10 @@ public class AppStoreBargainController { @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int",dataTypeClass = Integer.class) }) @ApiOperation(value = "砍价产品列表",notes = "砍价产品列表") - public ApiResult getYxStoreBargainPageList(@RequestParam(value = "page",defaultValue = "1") int page, + public ApiResult>> getYxStoreBargainPageList(@RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "limit",defaultValue = "10") int limit){ - - return ApiResult.resultPage(storeBargainService.getList(page, limit),limit); + return ApiResult.ok(storeBargainService.getList(page, limit)); } - /** * 砍价详情 */ diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreCombinationController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreCombinationController.java index 64ae148a..cf0e188d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreCombinationController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreCombinationController.java @@ -82,6 +82,21 @@ public class AppStoreCombinationController { return ApiResult.ok(storeCombinationService.getList(page, limit)); } + /** + * 用户已发起的拼团的列表 + */ + @GetMapping("/userCombination/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int",dataTypeClass = Integer.class), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int",dataTypeClass = Integer.class) + }) + @ApiOperation(value = "已发起的拼团的列表",notes = "已发起的拼团的列表") + public ApiResult getUserCombinationList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + return ApiResult.ok(storeCombinationService.getCombinationList(page, limit)); + } + + /** * 拼团产品详情 */ diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java index 6ea86d8d..442b40bd 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java @@ -2,9 +2,11 @@ package co.yixiang.app.modules.hotList.rest; import cn.iocoder.yudao.framework.common.pojo.ApiResult; import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.app.modules.activity.param.YxStoreBargainUserHelpQueryParam; import co.yixiang.modules.evaluation.service.YxEvaluationService; import co.yixiang.modules.hotList.service.YxStoreHotListService; -import co.yixiang.modules.hotList.service.dto.YxStoreHotListDto; +import co.yixiang.modules.hotList.param.YxStoreHotListRecordQueryParam; +import co.yixiang.modules.product.domain.YxStoreProduct; import co.yixiang.utils.EvaluationDTO; import co.yixiang.utils.HotListDTO; import io.swagger.annotations.Api; @@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; /** *

@@ -38,21 +41,29 @@ public class AppStoreHotListController { * 热门榜单列表 */ @AnonymousAccess - @GetMapping("/hotList") - @ApiOperation(value = "热门榜单列表",notes = "热门榜单") - public ApiResult> getYxStoreHotList(){ - - return ApiResult.ok(yxStoreHotListService.getList()); + @GetMapping("/hotListData") + @ApiOperation(value = "榜单可选月及每月可选分类",notes = "榜单信息") + public ApiResult> getYxStoreHotDataList(){ + return ApiResult.ok(yxStoreHotListService.getHotListDataList()); } /** * 热门榜单列表 */ @AnonymousAccess - @GetMapping("/hotList/{mouth}") - @ApiOperation(value = "根据年月查询热门榜单列表",notes = "热门榜单") - public ApiResult> getYxStoreHotList(@PathVariable String mouth){ + @GetMapping("/hotList") + @ApiOperation(value = "榜单列表",notes = "热门榜单") + public ApiResult> getYxStoreHotListRecord(YxStoreHotListRecordQueryParam QueryParam){ + return ApiResult.ok(yxStoreHotListService.getList(QueryParam)); + } - return ApiResult.ok(yxStoreHotListService.getList(mouth)); + /** + * 热门榜单列表 + */ + @AnonymousAccess + @GetMapping("/indexHotList") + @ApiOperation(value = "首页的榜单内容",notes = "首页的榜单内容") + public ApiResult> getYxStoreHotList(){ + return ApiResult.ok(yxStoreHotListService.getList()); } } diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java index 2cfa1700..5d335cdb 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java @@ -99,7 +99,7 @@ public class LetterAppUserController { * 获取各类轮播图 */ @GetMapping("/menu/banner/{type}") - @ApiOperation(value = "获取各种轮播图(0:首页 1:品牌馆 2:优惠券 3:活动专区)",notes = "获取轮播图") + @ApiOperation(value = "获取各种轮播图(0:首页 1:品牌馆 2:优惠券 3:活动专区 4:榜单列表)",notes = "获取轮播图") public ApiResult> bannerMenu(@PathVariable Integer type){ Map map = new LinkedHashMap<>(); // map.put("banner",systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_BANNER)); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponUser.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponUser.java index f5e97e2c..b245f616 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponUser.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponUser.java @@ -16,6 +16,7 @@ import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.Date; @@ -30,6 +31,7 @@ import java.util.Date; @AllArgsConstructor @NoArgsConstructor @TableName("yx_store_coupon_user") +@Service public class YxStoreCouponUser extends BaseDomain { /** 优惠券发放记录id */ diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainService.java index 8e758146..ac2f06f0 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainService.java @@ -91,9 +91,9 @@ public interface YxStoreBargainService extends BaseService{ * @param limit limit * @return List */ - List getList(int page, int limit); - + Map> getList(int page, int limit); +// List getUserBargainList(int page, int limit); /** * 查询数据分页 * @param criteria 条件 @@ -122,4 +122,6 @@ public interface YxStoreBargainService extends BaseService{ * @param id */ void deleteBargainImg(String id); + + } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserService.java index aa3be303..43bd6b64 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserService.java @@ -84,6 +84,14 @@ public interface YxStoreBargainUserService extends BaseService getList(int page, int limit) { + public Map> getList(int page, int limit) { + Map> map=new HashMap<>(); Page pageModel = new Page<>(page, limit); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); Date nowTime = new Date(); @@ -343,16 +340,24 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl yxStoreBargainQueryVos = generator.convert( yxStoreBargainMapper.selectPage(pageModel,wrapper).getRecords(), YxStoreBargainQueryVo.class); - + long uid = LocalUser.getUidByToken(); + List isParticipation=new ArrayList<>(); + List isNotParticipation=new ArrayList<>(); yxStoreBargainQueryVos.forEach(item->{ - item.setPeople(storeBargainUserService.getBargainUserCount(item.getId(), - OrderInfoEnum.BARGAIN_STATUS_1.getValue())); + item.setPeople(storeBargainUserService.getBargainUserCount(item.getId(), OrderInfoEnum.BARGAIN_STATUS_1.getValue())); + item.setIsParticipation(storeBargainUserService.getUserIsParticipation(uid, item.getId())); + if (item.getIsParticipation()){ + isParticipation.add(item); + }else { + isNotParticipation.add(item); + } }); - - return yxStoreBargainQueryVos; + map.put("yxStoreBargainQueryVos",yxStoreBargainQueryVos); + map.put("isParticipation",isParticipation); + map.put("isNotParticipation",isNotParticipation); + return map; } - /** * 增加分享次数 * @param id 砍价商品id diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserServiceImpl.java index f31cf3a1..b01d5406 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserServiceImpl.java @@ -207,6 +207,17 @@ public class YxStoreBargainUserServiceImpl extends BaseServiceImpl0){ + return true; + } + return false; + } + // // /** diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java index c8728128..e080ed9f 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java @@ -14,6 +14,7 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.exception.YshopException; +import co.yixiang.app.common.bean.LocalUser; import co.yixiang.common.service.impl.BaseServiceImpl; import co.yixiang.common.utils.QueryHelpPlus; import co.yixiang.dozer.service.IGenerator; @@ -29,6 +30,7 @@ import co.yixiang.modules.activity.service.YxStorePinkService; import co.yixiang.modules.activity.service.dto.PinkAllDto; import co.yixiang.modules.activity.service.dto.YxStoreCombinationDto; import co.yixiang.modules.activity.service.dto.YxStoreCombinationQueryCriteria; +import co.yixiang.modules.activity.service.dto.YxStorePinkDto; import co.yixiang.modules.activity.service.mapper.YxStoreCombinationMapper; import co.yixiang.modules.activity.service.mapper.YxStorePinkMapper; import co.yixiang.modules.activity.service.mapper.YxStoreVisitMapper; @@ -48,6 +50,7 @@ import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.template.domain.YxShippingTemplates; import co.yixiang.modules.template.service.YxShippingTemplatesService; +import co.yixiang.modules.user.domain.YxUser; import co.yixiang.utils.FileUtil; import co.yixiang.utils.RedisUtils; @@ -202,6 +205,28 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl pageModel=new Page<>(page, limit); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + //Status:1 进行中 KId:0 发起人是自己 + wrapper.eq(YxStorePink::getStatus,1) + .eq(YxStorePink::getUid,uid); +// .eq(YxStorePink::getKId,0); + IPage yxStorePinkIPage = yxStorePinkMapper.selectPage(pageModel, wrapper); + List collect = yxStorePinkIPage.getRecords().stream().map(i -> { + YxStoreCombinationQueryVo yxStoreCombinationQueryVo = new YxStoreCombinationQueryVo(); + YxStoreCombination yxStoreCombination=yxStoreCombinationMapper.selectById(i.getCid()); + BeanUtils.copyProperties(yxStoreCombination, yxStoreCombinationQueryVo); + return yxStoreCombinationQueryVo; + }).collect(Collectors.toList()); + CombinationQueryVo combinationQueryVo = new CombinationQueryVo(); + combinationQueryVo.setStoreCombinationQueryVos(collect); + combinationQueryVo.setLastPage(yxStorePinkIPage.getPages()); + return combinationQueryVo; + }; + //=======================================// diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java index 0ca1f6c3..9feb7638 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java @@ -39,7 +39,7 @@ public interface YxStoreCouponUserMapper extends CoreMapper { - @Select("select *from yx_store_coupon_user where status = 0 AND is_fail=0 AND use_end_time <= #{endTime}") + @Select("select *from yx_store_coupon_user where status = 0 AND is_fail=0 AND use_end_time <= #{endTime} AND tenant_id = 138") List selectUserCouponList(@Param("endTime") Date endTime); //"状态(0:未使用,1:已使用, 2:已过期)" } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java index cd63e225..c6bcabd5 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java @@ -117,5 +117,6 @@ public class YxStoreBargainQueryVo implements Serializable { @ApiModelProperty(value = "砍价产品参与人数") private Long people; - + @ApiModelProperty(value = "该用户是否已发起砍价") + private Boolean isParticipation; } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotList.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotList.java index 997abb8b..4f5d36cd 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotList.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotList.java @@ -7,19 +7,18 @@ * 一经发现盗用、分享等行为,将追究法律责任,后果自负 */ package co.yixiang.modules.hotList.domain; -import co.yixiang.modules.product.domain.YxStoreProduct; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import lombok.Data; import com.baomidou.mybatisplus.annotation.TableName; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.validation.constraints.*; -import java.sql.Timestamp; +import lombok.Data; + +import javax.validation.constraints.NotBlank; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; +import java.sql.Timestamp; /** * @author ssj diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotListRecord.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotListRecord.java new file mode 100644 index 00000000..0289a9f1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotListRecord.java @@ -0,0 +1,62 @@ +package co.yixiang.modules.hotList.domain; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.stereotype.Service; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; + +@Data +@TableName("yx_store_hot_list_record") +@Service +public class YxStoreHotListRecord implements Serializable { + /** 生成记录时候的ID */ + private Integer id; + + @ApiModelProperty(value = "商品ID") + private Long productId; + + @ApiModelProperty(value = "榜单Id") + private Integer hotListId; + + /**榜单生成时商品的分类id */ + @ApiModelProperty(value = "分类id") + private String cateId; + + /** 榜单虚拟销量 */ + @ApiModelProperty(value = "榜单记录时候商品的虚拟销量") + private Integer hotSales; + + /** 商品的价格 */ + @ApiModelProperty(value = "榜单记录商品的价格") + private BigDecimal price; + + /** 是否显示 */ + private Integer isShow; + + /** 此条记录所属月份 */ + private String mouth; + + /** 添加时间 */ + @TableField(fill= FieldFill.INSERT) + private Timestamp createTime; + + @TableField(fill= FieldFill.INSERT_UPDATE) + private Timestamp updateTime; + + /** 删除状态 */ + private Integer isDel; + + private Long tenantId; + + public void copy(YxStoreHotListRecord source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/param/YxStoreHotListRecordQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/param/YxStoreHotListRecordQueryParam.java new file mode 100644 index 00000000..300acf0d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/param/YxStoreHotListRecordQueryParam.java @@ -0,0 +1,31 @@ +package co.yixiang.modules.hotList.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreHotListRecordQueryParam对象", description="热榜记录表查询参数") +public class YxStoreHotListRecordQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "商品分类ID") + private Long cateId; + + @ApiModelProperty(value = "榜单ID") + private Long hotListId; + + @ApiModelProperty(value = "所属月份") + private String mouth; + + @ApiModelProperty(value = "价格排序 desc降序/asc升序") + private String priceOrder; + + @ApiModelProperty(value = "销量排序 desc降序/asc升序") + private String salesOrder; +} + + diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java index 1c6518a4..641ac9d6 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListController.java @@ -8,20 +8,22 @@ */ package co.yixiang.modules.hotList.rest; -import cn.hutool.core.date.DateUtil; import co.yixiang.domain.PageResult; import co.yixiang.dozer.service.IGenerator; -import co.yixiang.event.TemplateBean; -import co.yixiang.event.TemplateEvent; -import co.yixiang.event.TemplateListenEnum; +import co.yixiang.enums.CommonEnum; +import co.yixiang.enums.ShopCommonEnum; import co.yixiang.logging.aop.log.Log; -import co.yixiang.modules.activity.domain.YxStoreCouponUser; import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; import co.yixiang.modules.hotList.domain.YxStoreHotList; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import co.yixiang.modules.hotList.service.YxStoreHotListRecordService; import co.yixiang.modules.hotList.service.YxStoreHotListService; import co.yixiang.modules.hotList.service.dto.YxStoreHotListDto; import co.yixiang.modules.hotList.service.dto.YxStoreHotListQueryCriteria; import co.yixiang.modules.hotList.service.vo.YxStoreHotListVo; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.mapper.StoreProductMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; @@ -30,14 +32,13 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Arrays; -import java.util.Date; +import java.util.Calendar; import java.util.List; /** @@ -56,8 +57,16 @@ public class YxStoreHotListController { @Autowired private YxStoreCouponUserMapper yxStoreCouponUserMapper; + @Autowired + private StoreProductMapper storeProductMapper; + @Autowired private ApplicationEventPublisher publisher; + + @Autowired + private YxStoreHotListRecord yxStoreHotListRecord; + @Autowired + private YxStoreHotListRecordService yxStoreHotListRecordService; @Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") @@ -71,20 +80,6 @@ public class YxStoreHotListController { @ApiOperation("查询hotList") // @PreAuthorize("@el.check('admin','yxStoreHotList:list')") public ResponseEntity> getYxStoreHotLists(YxStoreHotListQueryCriteria criteria, Pageable pageable){ -// //查出所有用户拥有的券使用时间小于24小时且未使用的券 -// Date now=new Date(); -// Date endTime = DateUtil.offsetDay(now,1); -// List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); -// storeCouponUsers.forEach(storeCouponUser->{ -// //这里调用微信订阅模板发送消息 -// TemplateBean templateBean = TemplateBean.builder() -// .couponId(storeCouponUser.getCid()) -// .uid(storeCouponUser.getUid()) -// .templateType(TemplateListenEnum.TYPE_11.getValue()) -// .time(DateUtil.formatTime(new Date())) -// .build(); -// publisher.publishEvent(new TemplateEvent(this, templateBean)); -// }); return new ResponseEntity<>(yxStoreHotListService.queryAll(criteria,pageable),HttpStatus.OK); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListRecordController.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListRecordController.java new file mode 100644 index 00000000..61ea61e5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/rest/YxStoreHotListRecordController.java @@ -0,0 +1,108 @@ +/** + * Copyright (C) 2018-2020 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.hotList.rest; + +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; +import co.yixiang.modules.hotList.domain.YxStoreHotList; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import co.yixiang.modules.hotList.service.YxStoreHotListRecordService; +import co.yixiang.modules.hotList.service.YxStoreHotListService; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListRecordDto; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListRecordQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @author ssj + * @date 2022-10-08 + */ +@AllArgsConstructor +@Api(tags = "hotListRecord管理") +@RestController +@RequestMapping("/api/yxStoreHotListRecord") +public class YxStoreHotListRecordController { + + private final YxStoreHotListRecordService yxStoreHotListRecordService; + private final IGenerator generator; + + @Autowired + private YxStoreCouponUserMapper yxStoreCouponUserMapper; + + @Autowired + private YxStoreHotListService yxStoreHotListService; + + + @Autowired + private ApplicationEventPublisher publisher; + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") +// @PreAuthorize("@el.check('admin','yxStoreHotList:list')") + public void download(HttpServletResponse response, YxStoreHotListRecordQueryCriteria criteria) throws IOException { + yxStoreHotListRecordService.download(generator.convert(yxStoreHotListRecordService.queryAll(criteria), YxStoreHotListRecordDto.class), response); + } + + @GetMapping + @Log("查询榜单记录") + @ApiOperation("查询榜单记录") +// @PreAuthorize("@el.check('admin','yxStoreHotList:list')") + public ResponseEntity> getYxStoreHotLists(YxStoreHotListRecordQueryCriteria criteria, Pageable pageable){ + List storeHotLists= yxStoreHotListRecordService.lambdaQuery() + .eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .list(); + return new ResponseEntity<>(yxStoreHotListRecordService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增榜单记录") + @ApiOperation("新增榜单记录") +// @PreAuthorize("@el.check('admin','yxStoreHotList:add')") + public ResponseEntity create(@Validated @RequestBody YxStoreHotListRecord resources){ + return new ResponseEntity<>(yxStoreHotListRecordService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改榜单记录") + @ApiOperation("修改榜单记录") +// @PreAuthorize("@el.check('admin','yxStoreHotList:edit')") + public ResponseEntity update(@Validated @RequestBody YxStoreHotListRecord resources){ + yxStoreHotListRecordService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除榜单记录") + @ApiOperation("删除榜单记录") +// @PreAuthorize("@el.check('admin','yxStoreHotList:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + Arrays.asList(ids).forEach(id->{ + yxStoreHotListRecordService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListRecordService.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListRecordService.java new file mode 100644 index 00000000..c5fc76a2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListRecordService.java @@ -0,0 +1,52 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.domain.PageResult; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListRecordDto; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListRecordQueryCriteria; +import co.yixiang.modules.product.service.dto.YxStoreProductQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author sj +* @date 2022-11-03 +*/ +public interface YxStoreHotListRecordService extends BaseService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(YxStoreHotListRecordQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreHotListRecordQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java index 6e2acf75..899a7683 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java @@ -11,15 +11,19 @@ package co.yixiang.modules.hotList.service; import co.yixiang.common.service.BaseService; import co.yixiang.domain.PageResult; import co.yixiang.modules.hotList.domain.YxStoreHotList; +import co.yixiang.modules.hotList.param.YxStoreHotListRecordQueryParam; import co.yixiang.modules.hotList.service.dto.YxStoreHotListDto; import co.yixiang.modules.hotList.service.dto.YxStoreHotListQueryCriteria; import co.yixiang.modules.hotList.service.vo.YxStoreHotListVo; +import co.yixiang.modules.product.domain.YxStoreProduct; import co.yixiang.utils.HotListDTO; import org.springframework.data.domain.Pageable; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; +import java.util.Map; + /** * @author ssj * @date 2022-10-08 @@ -48,12 +52,14 @@ public interface YxStoreHotListService extends BaseService { * @throws IOException / */ void download(List all, HttpServletResponse response) throws IOException; + MapgetHotListDataList(); /** - * app根据月份获取列表 - * @param mouth 想要查的月份 + * app获取列表 + * @param QueryParam YxStoreHotListRecordQueryParam */ - List getList(String mouth); + List getList(YxStoreHotListRecordQueryParam QueryParam); List getList(); + } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListRecordDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListRecordDto.java new file mode 100644 index 00000000..6145a7b7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListRecordDto.java @@ -0,0 +1,59 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.dto; + +import lombok.Data; +import java.sql.Timestamp; +import java.math.BigDecimal; +import java.io.Serializable; + +/** +* @author hupeng +* @date 2022-11-03 +*/ +@Data +public class YxStoreHotListRecordDto implements Serializable { + + private Integer id; + + /** 商品id */ + private Integer productId; + private String productName; + /** 榜单id */ + private Integer hotListId; + /** 榜单名称 */ + private String hotListName; + + /** 入榜价格 */ + private BigDecimal price; + + /** 入榜时候销量 */ + private Integer hotSales; + + /** 商品分类id */ + private Integer cateId; + /** 商品分类id */ + private String cateName; + + /** 当前榜单所属时间月份 */ + private String mouth; + + /** 是否显示 */ + private Integer isShow; + + /** 添加时间 */ + private Timestamp createTime; + + private Timestamp updateTime; + + /** 删除状态 */ + private Integer isDel; + + private Long tenantId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListRecordQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListRecordQueryCriteria.java new file mode 100644 index 00000000..5f6c12a0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/dto/YxStoreHotListRecordQueryCriteria.java @@ -0,0 +1,28 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author sj +* @date 2022-11-03 +*/ +@Data +public class YxStoreHotListRecordQueryCriteria{ + + //榜单id + @Query + private Integer hotListId; + + @Query + private String mouth; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/TaskMsg.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/TaskMsg.java new file mode 100644 index 00000000..746c8660 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/TaskMsg.java @@ -0,0 +1,110 @@ +package co.yixiang.modules.hotList.service.impl; + +import cn.hutool.core.date.DateUtil; +import co.yixiang.enums.CommonEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.event.TemplateBean; +import co.yixiang.event.TemplateEvent; +import co.yixiang.event.TemplateListenEnum; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import co.yixiang.modules.hotList.service.YxStoreHotListRecordService; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.mapper.StoreProductMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; +@Slf4j +@Component +public class TaskMsg { + @Autowired + private YxStoreCouponUserMapper yxStoreCouponUserMapper; + + @Autowired + private ApplicationEventPublisher publisher; + + @Autowired + private StoreProductMapper storeProductMapper; + + @Autowired + private YxStoreHotListRecordService yxStoreHotListRecordService; + + @Autowired + private YxStoreHotListRecord yxStoreHotListRecord; + + //定时器,每天下午17点触发 + @Scheduled(cron = "0 0 17 * * ?") +// @Scheduled(cron = "0 50 17 * * ?") + public void scheduled(){ + log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); + log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); + //查出所有用户拥有的券使用时间小于24小时且未使用的券 + Date now=new Date(); + Date endTime = DateUtil.offsetDay(now,1); + List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); + storeCouponUsers.forEach(storeCouponUser->{ + //这里调用微信订阅模板发送消息 + TemplateBean templateBean = TemplateBean.builder() + .couponId(storeCouponUser.getCid()) + .uid(storeCouponUser.getUid()) + .templateType(TemplateListenEnum.TYPE_11.getValue()) + .time(DateUtil.formatTime(new Date())) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + }); + } + + @Scheduled(fixedRate = 20000) + public void execute() { + log.info("[execute][定时第 ({}) 次执行]", System.currentTimeMillis()); +// Date now=new Date(); +// Date endTime = DateUtil.offsetDay(now,1); +// List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); +// storeCouponUsers.forEach(storeCouponUser->{ +// //这里调用微信订阅模板发送消息 +// TemplateBean templateBean = TemplateBean.builder() +// .couponId(storeCouponUser.getCid()) +// .uid(storeCouponUser.getUid()) +// .templateType(TemplateListenEnum.TYPE_11.getValue()) +// .time(DateUtil.formatTime(new Date())) +// .build(); +// publisher.publishEvent(new TemplateEvent(this, templateBean)); +// }); + } + + + //每个月最后一天23:30生成该月的榜单 + @Scheduled(cron = "0 30 23 L * ?") + public void setYxStoreHotListRecord(){ + log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); + log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .eq(YxStoreProduct::getIsDel, CommonEnum.DEL_STATUS_0.getValue()) + .eq(YxStoreProduct::getIsHotList,ShopCommonEnum.SHOW_1.getValue()); + Calendar calender = Calendar.getInstance(); + int yearMonth = calender.get(Calendar.MONTH) + 1; //月份 + int year = calender.get(Calendar.YEAR); //年 + String mouth= year+"-"+ (yearMonth > 10 ? yearMonth : ('0' + yearMonth)); + //查询所有参与榜单评比的商品 + List list=storeProductMapper.selectList(wrapper); + list.forEach(yxStoreProduct -> { + yxStoreHotListRecord.setHotListId(yxStoreProduct.getHotListId()) //榜单id + .setProductId(yxStoreProduct.getId()) //商品id + .setPrice(yxStoreProduct.getPrice()) //入榜价格 + .setCateId(yxStoreProduct.getCateId()) //商品分类 + .setMouth(mouth) //当月月份 + .setHotSales(yxStoreProduct.getHotSales()==null?yxStoreProduct.getSales():yxStoreProduct.getHotSales()); //商品榜单虚拟销量,没填就使用真实销量 + //每个商品添加一条评比记录 + yxStoreHotListRecordService.save(yxStoreHotListRecord); + }); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListRecordServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListRecordServiceImpl.java new file mode 100644 index 00000000..63f6059c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListRecordServiceImpl.java @@ -0,0 +1,97 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.category.service.YxStoreCategoryService; +import co.yixiang.modules.category.service.mapper.StoreCategoryMapper; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import co.yixiang.modules.hotList.service.YxStoreHotListRecordService; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListRecordDto; +import co.yixiang.modules.hotList.service.dto.YxStoreHotListRecordQueryCriteria; +import co.yixiang.modules.hotList.service.mapper.YxStoreHotListMapper; +import co.yixiang.modules.hotList.service.mapper.YxStoreHotListRecordMapper; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +/** +* @author sj +* @date 2022-11-03 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxStoreHotListRecord") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreHotListRecordServiceImpl extends BaseServiceImpl implements YxStoreHotListRecordService { + + private final IGenerator generator; + private final YxStoreHotListMapper yxStoreHotListMapper; + private final YxStoreHotListRecordMapper yxStoreHotListRecordMapper; + private final StoreCategoryMapper storeCategoryMapper; + + private final YxStoreCategoryService storeCategoryService; + private final YxStoreProductService yxStoreProductService; + @Override + //@Cacheable + public PageResult queryAll(YxStoreHotListRecordQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + PageResult result=generator.convertPageInfo(page,YxStoreHotListRecordDto.class); + result.getContent().forEach(i->{ + i.setHotListName(yxStoreHotListMapper.selectById(i.getHotListId()).getListName()); + i.setCateName(storeCategoryMapper.selectById(i.getCateId()).getCateName()); + i.setProductName(yxStoreProductService.getById(i.getProductId()).getStoreName()); + }); + return result; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreHotListRecordQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreHotListRecord.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreHotListRecordDto yxStoreHotListRecord : all) { + Map map = new LinkedHashMap<>(); + map.put("商品id", yxStoreHotListRecord.getProductId()); + map.put("榜单id", yxStoreHotListRecord.getHotListId()); + map.put("入榜价格", yxStoreHotListRecord.getPrice()); + map.put("入榜时候销量", yxStoreHotListRecord.getHotSales()); + map.put("商品分类id", yxStoreHotListRecord.getCateId()); + map.put("当前榜单所属时间月份", yxStoreHotListRecord.getMouth()); + map.put("是否显示", yxStoreHotListRecord.getIsShow()); + map.put("添加时间", yxStoreHotListRecord.getCreateTime()); + map.put(" updateTime", yxStoreHotListRecord.getUpdateTime()); + map.put("删除状态", yxStoreHotListRecord.getIsDel()); + map.put(" tenantId", yxStoreHotListRecord.getTenantId()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java index 96b71315..9271c5dd 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java @@ -8,9 +8,28 @@ */ package co.yixiang.modules.hotList.service.impl; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; +import co.yixiang.enums.CommonEnum; +import co.yixiang.enums.SortEnum; +import co.yixiang.event.TemplateBean; +import co.yixiang.event.TemplateEvent; +import co.yixiang.event.TemplateListenEnum; import co.yixiang.exception.ErrorRequestException; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; +import co.yixiang.modules.cart.domain.YxStoreCart; +import co.yixiang.modules.category.service.mapper.StoreCategoryMapper; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import co.yixiang.modules.hotList.service.mapper.YxStoreHotListRecordMapper; import co.yixiang.modules.product.service.mapper.StoreProductMapper; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.utils.StringUtils; +import co.yixiang.utils.hotListDto.CateDto; +import co.yixiang.utils.hotListDto.HotListDataDto; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.SerializationUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.beans.BeanUtils; import cn.hutool.json.JSONUtil; import co.yixiang.common.service.impl.BaseServiceImpl; @@ -32,6 +51,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.github.pagehelper.PageInfo; import lombok.AllArgsConstructor; import lombok.SneakyThrows; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; @@ -39,10 +60,10 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; + +import co.yixiang.modules.hotList.param.YxStoreHotListRecordQueryParam; + /** * @author ssj @@ -58,6 +79,15 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl queryAll(YxStoreHotListQueryCriteria criteria){ + //查出所有用户拥有的券使用时间小于24小时且未使用的券 + Date now=new Date(); + Date endTime = DateUtil.offsetDay(now,1); + List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); + storeCouponUsers.forEach(storeCouponUser->{ + //这里调用微信订阅模板发送消息 + TemplateBean templateBean = TemplateBean.builder() + .couponId(storeCouponUser.getCid()) + .uid(storeCouponUser.getUid()) + .templateType(TemplateListenEnum.TYPE_11.getValue()) + .time(DateUtil.formatTime(new Date())) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + }); return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreHotList.class, criteria)); } @@ -110,41 +154,161 @@ public class YxStoreHotListServiceImpl extends BaseServiceImplgetHotListDataList(){ + Map map=new HashMap<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); + wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); + //获取所有评测列表(后期限制一年?) + List list=yxStoreHotListRecordMapper.selectList(wrapper); + //获取月份 + LinkedHashSet mouthList=new LinkedHashSet<>(); + list.forEach(yxStoreHotListRecord -> mouthList.add(yxStoreHotListRecord.getMouth())); + map.put("mouthList",mouthList); + mouthList.forEach(mouth->{ + LambdaQueryWrapper wrapper2= SerializationUtils.clone(wrapper); + //当前月份的所有榜单记录信息 + List recordList=yxStoreHotListRecordMapper.selectList(wrapper2.eq(YxStoreHotListRecord::getMouth,mouth)); + LinkedHashSet hotIdList=new LinkedHashSet<>(); + //获得不重复的榜单信息 + recordList.forEach(cate->{ + if(ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))){ + hotIdList.add(cate.getHotListId()); + } + }); + ArrayList hotListDTOS=new ArrayList<>(); + hotIdList.forEach(hotId->{ + LambdaQueryWrapper wrapper1= SerializationUtils.clone(wrapper); + //查出当前月份当前榜单的记录 + List recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth)); + LinkedHashSet cateIdList=new LinkedHashSet<>(); + //获得不重复的商品分类id + recordCateList.forEach(cate->{ + if(ObjectUtil.isNotNull(storeCategoryMapper.selectById(cate.getCateId()))) + cateIdList.add(cate.getCateId()); + }); + ArrayList cateDtos=new ArrayList<>(); + //把该榜单下的分类封为一个数组 + cateIdList.forEach(cateId->cateDtos.add(new CateDto().setCateId(Long.valueOf(cateId)).setCateName(storeCategoryMapper.selectById(cateId).getCateName()))); + hotListDTOS.add(new HotListDTO().setId(Math.toIntExact(hotId)).setListName(yxStoreHotListMapper.selectById(hotId).getListName()) + .setCateDtos(cateDtos) + .setListImage(yxStoreHotListMapper.selectById(hotId).getListImage())); + }); + map.put(mouth,new HotListDataDto().setHotListDTOS(hotListDTOS)); + //当前月份所有的商品分类 + }); + return map; + }; + /*** + *根据榜单,分类,时间等获取商品信息 + * ***/ @Override - public List getList(String mouth) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(YxStoreHotList::getIsShow, ShopCommonEnum.SHOW_1.getValue()) - .orderByAsc(YxStoreHotList::getSort) - .eq(YxStoreHotList::getMouth,mouth); - return getHotListDTOS(wrapper); + public List getList(YxStoreHotListRecordQueryParam queryParam) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); + wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); + //按照商品分类id + if (queryParam.getCateId()!=null){ + wrapper.eq(YxStoreHotListRecord::getCateId,queryParam.getCateId()); + } + //评测id + if (queryParam.getHotListId()!=null){ + wrapper.eq(YxStoreHotListRecord::getHotListId,queryParam.getHotListId()); + } + if (StringUtils.isNotBlank(queryParam.getMouth())){ + wrapper.eq(YxStoreHotListRecord::getMouth,queryParam.getMouth()); + } + //默认销量降序排序 + if (SortEnum.DESC.getValue().equals(queryParam.getSalesOrder())) { + wrapper.orderByDesc(YxStoreHotListRecord::getHotSales); + } else if (SortEnum.ASC.getValue().equals(queryParam.getSalesOrder())) { + wrapper.orderByAsc(YxStoreHotListRecord::getHotSales); + } + //价格排序 + if (SortEnum.DESC.getValue().equals(queryParam.getPriceOrder())) { + wrapper.orderByDesc(YxStoreHotListRecord::getPrice); + } else if (SortEnum.ASC.getValue().equals(queryParam.getPriceOrder())) { + wrapper.orderByAsc(YxStoreHotListRecord::getPrice); + } + Page pageModel = new Page<>(queryParam.getPage(), queryParam.getLimit()); + + IPage pageList = yxStoreHotListRecordMapper.selectPage(pageModel, wrapper); + List list =new ArrayList<>(); + pageList.getRecords().forEach(yxStoreHotListRecord -> { + YxStoreProduct yxStoreProduct=storeProductMapper.selectById(yxStoreHotListRecord.getProductId()); + if (ObjectUtil.isNotNull(yxStoreProduct)){ + list.add(yxStoreProduct); + } + }); + return list; } ; @Override public List getList() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(YxStoreHotList::getIsShow, ShopCommonEnum.SHOW_1.getValue()) - .orderByAsc(YxStoreHotList::getSort); - return getHotListDTOS(wrapper); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); + wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); + //获取所有评测列表(后期限制一年?) + List list=yxStoreHotListRecordMapper.selectList(wrapper); + //获取月份 + LinkedHashSet mouthList=new LinkedHashSet<>(); + list.forEach(yxStoreHotListRecord -> mouthList.add(yxStoreHotListRecord.getMouth())); + String mouth=Collections.max(mouthList); + List recordList=yxStoreHotListRecordMapper.selectList(wrapper.eq(YxStoreHotListRecord::getMouth,mouth)); + LinkedHashSet hotIdList=new LinkedHashSet<>(); + //获得不重复的榜单信息 + recordList.forEach(cate->{ + if(ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))){ + hotIdList.add(cate.getHotListId()); + } + }); + ArrayList hotListDTOS=new ArrayList<>(); + hotIdList.forEach(hotId->{ + LambdaQueryWrapper wrapper1= SerializationUtils.clone(wrapper); + //查出当前月份当前榜单的记录 + List recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth)); + //获得不重复的商品分类id + LinkedHashSet cateIdList=new LinkedHashSet<>(); + //当前榜单下的商品信息 + List productInfo=new ArrayList<>(); + //获得不重复的商品分类id + recordCateList.forEach(cate->{ + if(ObjectUtil.isNotNull(storeCategoryMapper.selectById(cate.getCateId()))){ + cateIdList.add(cate.getCateId()); + } + productInfo.add(storeProductMapper.selectById(cate.getProductId())); + }); + ArrayList cateDtos=new ArrayList<>(); + //把该榜单下的分类封为一个数组 + cateIdList.forEach(cateId->cateDtos.add(new CateDto().setCateId(Long.valueOf(cateId)).setCateName(storeCategoryMapper.selectById(cateId).getCateName()))); + hotListDTOS.add(new HotListDTO().setId(Math.toIntExact(hotId)).setListName(yxStoreHotListMapper.selectById(hotId).getListName()) + .setCateDtos(cateDtos) + .setProductInfo(productInfo) + .setListImage(yxStoreHotListMapper.selectById(hotId).getListImage())); + }); + return hotListDTOS; } - private List getHotListDTOS(LambdaQueryWrapper wrapper) { List list = generator.convert(baseMapper.selectList(wrapper),HotListDTO.class); - list.forEach(hotListDto->{ - List productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class); - List list1 =new ArrayList<>(); - productArr.forEach(productId->{ - LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); - wrapper1.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) - .eq(YxStoreProduct::getId, productId); - YxStoreProduct yxStoreProduct = storeProductMapper.selectOne(wrapper1); - //这里需要有一个非空判断,找不到这个商品就不加 - if (ObjectUtil.isNotNull(yxStoreProduct)){ - list1.add(yxStoreProduct); - } - }); - hotListDto.setProductInfo(list1); - }); +// list.forEach(hotListDto->{ +// List productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class); +// List list1 =new ArrayList<>(); +// productArr.forEach(productId->{ +// LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); +// wrapper1.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) +// .eq(YxStoreProduct::getId, productId); +// YxStoreProduct yxStoreProduct = storeProductMapper.selectOne(wrapper1); +// //这里需要有一个非空判断,找不到这个商品就不加 +// if (ObjectUtil.isNotNull(yxStoreProduct)){ +// list1.add(yxStoreProduct); +// } +// }); +// hotListDto.setProductInfo(list1); +// }); return list; } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/mapper/YxStoreHotListRecordMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/mapper/YxStoreHotListRecordMapper.java new file mode 100644 index 00000000..050dc788 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/mapper/YxStoreHotListRecordMapper.java @@ -0,0 +1,32 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.hotList.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.logging.domain.Log; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2022-11-03 +*/ +@Repository +public interface YxStoreHotListRecordMapper extends CoreMapper { + +// @Select("select l.id,l.create_time as createTime,l.description, l.request_ip as requestIp,l.address,u.nickname from log l " + +// " left join yx_user u on u.uid=l.uid where l.type=1 " + +// " and u.nickname LIKE CONCAT('%',#{nickname},'%') order by l.id desc") +// List list selectRecordList(); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java index 17092f93..8186941e 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java @@ -256,6 +256,14 @@ public class YxStoreProduct extends BaseDomain { @ApiModelProperty(value = "是否开启积分兑换") private Integer isIntegral; + @ApiModelProperty(value = "是否参与榜单评比") + private Integer isHotList; + + @ApiModelProperty(value = "所参与评比的榜单的id") + private Integer hotListId; + + @ApiModelProperty(value = "所参与评比的榜单的虚拟销量") + private Integer hotSales; //商品对应的分类 @TableField(exist = false) private YxStoreCategory storeCategory; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java index 6f4b7e38..af3786ac 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java @@ -143,8 +143,8 @@ public class StoreProductController { } Long count1 = yxStoreHotListMapper .selectCount(Wrappers.lambdaQuery() - .eq(YxStoreHotList::getIsShow,1) - .like(YxStoreHotList::getProductList,id)); + .eq(YxStoreHotList::getIsShow,1)); +// .like(YxStoreHotList::getProductList,id)); //此商品被热门榜单绑定,不能删除 if(count1 > 0) { //不能删除 @@ -212,6 +212,9 @@ public class StoreProductController { ProductDto productDto = new ProductDto(); productDto.setParameter(yxStoreProduct.getParameter()); productDto.setConfig(yxStoreProduct.getConfig()); + productDto.setIsHotList(yxStoreProduct.getIsHotList()); + productDto.setHotListId(yxStoreProduct.getHotListId()); + productDto.setHotSales(yxStoreProduct.getHotSales()); BeanUtil.copyProperties(yxStoreProduct,productDto,"sliderImage"); productDto.setSliderImage(Arrays.asList(yxStoreProduct.getSliderImage().split(","))); YxStoreProductAttrResult storeProductAttrResult = yxStoreProductAttrResultService @@ -230,7 +233,6 @@ public class StoreProductController { productDto.setAttrs(productFormatDtos); productDto.setItems(result.getObject("attr",ArrayList.class)); }else{ - productFromat(productDto, result); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java index bbee39d2..8148ca62 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java @@ -589,8 +589,8 @@ public class YxStoreProductServiceImpl extends BaseServiceImpllambdaQuery() - .eq(YxStoreHotList::getIsShow,1) - .like(YxStoreHotList::getProductList,id)); + .eq(YxStoreHotList::getIsShow,1)); +// .like(YxStoreHotList::getProductList,id)); //此商品被热门榜单绑定,不能下架 if(count1 > 0) { throw new YshopException("当前商品已绑定热门榜单,不能被下架"); @@ -622,6 +622,9 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl cateDtos; // /**商品信息数组**/ private List productInfo; diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java index 1861f068..72799285 100644 --- a/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java +++ b/zsw-bxg/src/main/java/co/yixiang/utils/WxbotMsgUtil.java @@ -3,17 +3,25 @@ package co.yixiang.utils; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.enums.CommonEnum; +import co.yixiang.enums.ShopCommonEnum; import co.yixiang.event.TemplateBean; import co.yixiang.event.TemplateEvent; import co.yixiang.event.TemplateListenEnum; import co.yixiang.modules.activity.domain.YxStoreCouponUser; import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; +import co.yixiang.modules.hotList.domain.YxStoreHotListRecord; +import co.yixiang.modules.hotList.service.YxStoreHotListRecordService; import co.yixiang.modules.order.service.YxStoreOrderService; import co.yixiang.modules.order.service.dto.YxStoreOrderDto; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.service.mapper.StoreProductMapper; import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.utils.WxTemplate.TemplateCard; import co.yixiang.utils.WxTemplate.dto.*; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpStatus; import org.apache.http.client.methods.CloseableHttpResponse; @@ -43,37 +51,6 @@ public class WxbotMsgUtil { @Autowired private YxSystemConfigService systemConfigService; - @Autowired - private YxStoreCouponUserMapper yxStoreCouponUserMapper; - - @Autowired - private ApplicationEventPublisher publisher; - - //定时器,每天下午17点触发 - @Scheduled(cron = "0 0 17 * * ?") - public void scheduled(){ - log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); - log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); - log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); - log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); - log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); - //查出所有用户拥有的券使用时间小于24小时且未使用的券 - Date now=new Date(); - Date endTime = DateUtil.offsetDay(now,1); - List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); - storeCouponUsers.forEach(storeCouponUser->{ - //这里调用微信订阅模板发送消息 - TemplateBean templateBean = TemplateBean.builder() - .couponId(storeCouponUser.getCid()) - .uid(storeCouponUser.getUid()) - .templateType(TemplateListenEnum.TYPE_10.getValue()) - .time(DateUtil.formatTime(new Date())) - .build(); - publisher.publishEvent(new TemplateEvent(this, templateBean)); - }); - } - - public void inform(long orderId, int type) throws IOException { CloseableHttpClient httpClient = HttpClients.createDefault();//实例化对象 diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/hotListDto/CateDto.java b/zsw-bxg/src/main/java/co/yixiang/utils/hotListDto/CateDto.java new file mode 100644 index 00000000..008826ef --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/hotListDto/CateDto.java @@ -0,0 +1,11 @@ +package co.yixiang.utils.hotListDto; + +import lombok.Data; + +@Data +public class CateDto { + //分类id + private Long cateId; + //分类名 + private String cateName; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/hotListDto/HotListDataDto.java b/zsw-bxg/src/main/java/co/yixiang/utils/hotListDto/HotListDataDto.java new file mode 100644 index 00000000..ece351bb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/hotListDto/HotListDataDto.java @@ -0,0 +1,15 @@ +package co.yixiang.utils.hotListDto; + +import co.yixiang.utils.HotListDTO; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; + +@Data +public class HotListDataDto implements Serializable { + + //当月的榜单信息 + private ArrayList hotListDTOS; + +}