release: APP添加门店访问次数记录

release-2024-04-25
huangyw 3 months ago
parent b396f8a1a4
commit f713dd0f61

@ -61,6 +61,13 @@ public class StoreController {
return Result.success(storeService.getOne(id)); return Result.success(storeService.getOne(id));
} }
@GetMapping("/app/get")
@GlobalInterceptor(checkAppUserLogin = true)
@ApiOperation(value = "获取门店详情(APP)", notes = "获取门店详情")
public Result<StoreAppVO> getStoreForApp(String id) {
return Result.success(storeService.getStoreForApp(id));
}
@PostMapping("/add") @PostMapping("/add")
@GlobalInterceptor(checkAdminLogin = true) @GlobalInterceptor(checkAdminLogin = true)
@ApiOperation(value = "添加门店(PC)", notes = "添加门店") @ApiOperation(value = "添加门店(PC)", notes = "添加门店")

@ -3,7 +3,13 @@ package com.luoo.user.dao;
import com.luoo.user.pojo.Store; import com.luoo.user.pojo.Store;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
public interface StoreDao extends JpaRepository<Store, String> , JpaSpecificationExecutor<Store> { public interface StoreDao extends JpaRepository<Store, String>, JpaSpecificationExecutor<Store> {
@Modifying
@Query(value = "update tb_store set visit_count = visit_count + 1 where id = ?1", nativeQuery = true)
public void addVisitCount(String id);
} }

@ -0,0 +1,29 @@
package com.luoo.user.listener;
import com.luoo.user.service.StoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @program: luoo_parent
* @description:
* @author: yawei.huang
* @create: 2024-08-22 08:43
**/
@Component
@RabbitListener(queues = "store_visit")
@Slf4j
public class StoreVisitCountListener {
@Autowired
private StoreService storeService;
@RabbitHandler
public void executeDraw(String id) {
log.info("store_visit-id:{}", id);
storeService.addVisitCount(id);
}
}

@ -79,4 +79,8 @@ public class Store extends JPABasePojo {
@Column(name = "status") @Column(name = "status")
@ApiModelProperty(value = "门店状态 1-合作中 2-停止合作") @ApiModelProperty(value = "门店状态 1-合作中 2-停止合作")
private Integer status; private Integer status;
@Column(name = "visit_count")
@ApiModelProperty(value = "门店访问量")
private Integer visitCount;
} }

@ -16,6 +16,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
import enums.StoreEnums; import enums.StoreEnums;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Distance; import org.springframework.data.geo.Distance;
@ -51,12 +52,15 @@ public class StoreService {
private final UserInfoService userInfoService; private final UserInfoService userInfoService;
public StoreService(StoreDao storeDao, JPAQueryFactory jpaQueryFactory, RegionService regionService, RedisTemplate redisTemplate, UserInfoService userInfoService) { private final RabbitTemplate rabbitTemplate;
public StoreService(StoreDao storeDao, JPAQueryFactory jpaQueryFactory, RegionService regionService, RedisTemplate redisTemplate, UserInfoService userInfoService, RabbitTemplate rabbitTemplate) {
this.storeDao = storeDao; this.storeDao = storeDao;
this.jpaQueryFactory = jpaQueryFactory; this.jpaQueryFactory = jpaQueryFactory;
this.regionService = regionService; this.regionService = regionService;
this.redisTemplate = redisTemplate; this.redisTemplate = redisTemplate;
this.userInfoService = userInfoService; this.userInfoService = userInfoService;
this.rabbitTemplate = rabbitTemplate;
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -94,6 +98,39 @@ public class StoreService {
return storeDao.findById(id).orElse(null); return storeDao.findById(id).orElse(null);
} }
public StoreAppVO getStoreForApp(String id) {
QStore qStore = QStore.store;
rabbitTemplate.convertAndSend("store_visit", id);
// 只显示合作中的门店
return jpaQueryFactory.select(Projections.constructor(StoreAppVO.class,
qStore.id,
qStore.name,
qStore.regionId,
qStore.address,
qStore.lng,
qStore.lat,
qStore.contact,
qStore.phone,
qStore.tel,
qStore.openingHours,
qStore.background,
qStore.description,
qStore.visitCount
)).from(qStore)
.where(
(qStore.id.eq(id))
.and(qStore.status.eq(StoreEnums.STORE_STATUS_COOPERATION.getCode())))
.fetchOne();
}
@Transactional(rollbackFor = Exception.class)
public void addVisitCount(String id) {
storeDao.addVisitCount(id);
}
// 列表页-PC // 列表页-PC
public PageResult<StorePCVO> getList(StoreSearchDto storeSearchDto, Integer page, Integer size) { public PageResult<StorePCVO> getList(StoreSearchDto storeSearchDto, Integer page, Integer size) {
BooleanBuilder booleanBuilder = new BooleanBuilder(); BooleanBuilder booleanBuilder = new BooleanBuilder();

@ -69,10 +69,13 @@ public class StoreAppVO implements Serializable {
@ApiModelProperty(value = "距离") @ApiModelProperty(value = "距离")
private Double distance; private Double distance;
@ApiModelProperty(value = "门店访问量")
private Integer visitCount;
public StoreAppVO() { public StoreAppVO() {
} }
public StoreAppVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description) { public StoreAppVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description, Integer visitCount) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.regionId = regionId; this.regionId = regionId;
@ -85,5 +88,6 @@ public class StoreAppVO implements Serializable {
this.openingHours = openingHours; this.openingHours = openingHours;
this.background = background; this.background = background;
this.description = description; this.description = description;
this.visitCount = visitCount;
} }
} }

@ -68,6 +68,9 @@ public class StorePCVO implements Serializable {
@ApiModelProperty(value = "门店状态 1-合作中 2-停止合作") @ApiModelProperty(value = "门店状态 1-合作中 2-停止合作")
private Integer status; private Integer status;
@ApiModelProperty(value = "门店访问量")
private Integer visitCount;
@Transient @Transient
Region region; Region region;
@ -75,7 +78,7 @@ public class StorePCVO implements Serializable {
public StorePCVO() { public StorePCVO() {
} }
public StorePCVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description, LocalDateTime createTime, Integer status) { public StorePCVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description, LocalDateTime createTime, Integer status, Integer visitCount) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.regionId = regionId; this.regionId = regionId;
@ -90,5 +93,6 @@ public class StorePCVO implements Serializable {
this.description = description; this.description = description;
this.createTime = createTime; this.createTime = createTime;
this.status = status; this.status = status;
this.visitCount = visitCount;
} }
} }

@ -2,4 +2,11 @@ alter table tb_task_point
add action varchar(50) null comment 'APP动作'; add action varchar(50) null comment 'APP动作';
alter table tb_task_point alter table tb_task_point
add task_point_id varchar(20) null comment 'tb_task_point表id'; add task_point_id varchar(20) null comment 'tb_task_point表id';
alter table tb_store
add visit_count int null comment '浏览次数';
alter table tb_store
alter column visit_count set default 0;

Loading…
Cancel
Save