Commit 7b44128e authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/base-modify' into base-modify

parents 6d050e4b d4d4491d
...@@ -91,13 +91,13 @@ ...@@ -91,13 +91,13 @@
<dependency> <dependency>
<groupId>tk.mybatis</groupId> <groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId> <artifactId>mapper-spring-boot-starter</artifactId>
<version>1.1.2</version> <version>2.1.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId> <artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version> <version>1.2.10</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -15,7 +15,7 @@ spring: ...@@ -15,7 +15,7 @@ spring:
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
#共用配置,暂定一个 #共用配置,暂定一个
#shared-dataids: common-dev.yaml shared-dataids: common-dev.yaml
--- ---
spring: spring:
profiles: pro profiles: pro
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<dependency> <dependency>
<groupId>tk.mybatis</groupId> <groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId> <artifactId>mapper</artifactId>
<version>3.4.0</version> <version>4.1.5</version>
</dependency> </dependency>
<!-- <dependency> <!-- <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId> <artifactId>pagehelper</artifactId>
<version>5.0.3</version> <version>5.1.8</version>
</dependency> </dependency>
<!-- <dependency> <!-- <dependency>
......
...@@ -74,16 +74,15 @@ public abstract class BaseBiz<M extends Mapper<T>, T> { ...@@ -74,16 +74,15 @@ public abstract class BaseBiz<M extends Mapper<T>, T> {
} }
public void updateById(T entity) { public int updateById(T entity) {
EntityUtils.setUpdatedInfo(entity); EntityUtils.setUpdatedInfo(entity);
mapper.updateByPrimaryKey(entity); return mapper.updateByPrimaryKey(entity);
} }
public void updateSelectiveById(T entity) { public int updateSelectiveById(T entity) {
EntityUtils.setUpdatedInfo(entity); EntityUtils.setUpdatedInfo(entity);
mapper.updateByPrimaryKeySelective(entity); return mapper.updateByPrimaryKeySelective(entity);
} }
public List<T> selectByExample(Object example) { public List<T> selectByExample(Object example) {
...@@ -107,7 +106,4 @@ public abstract class BaseBiz<M extends Mapper<T>, T> { ...@@ -107,7 +106,4 @@ public abstract class BaseBiz<M extends Mapper<T>, T> {
List<T> list = mapper.selectByExample(example); List<T> list = mapper.selectByExample(example);
return new TableResultResponse<T>(result.getTotal(), list); return new TableResultResponse<T>(result.getTotal(), list);
} }
} }
package com.github.wxiaoqi.security.common.mapper;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import tk.mybatis.mapper.common.Mapper;
public interface VersionMapper<T> extends Mapper<T> {
default int deleteWithVersion(T t) {
int result = delete(t);
if(result == 0) {
throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
}
return result;
}
default int updateByPrimaryKeyWithVersion(T t){
int result = updateByPrimaryKey(t);
if(result == 0) {
throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
}
return result;
}
}
...@@ -21,6 +21,8 @@ public class ResultCode { ...@@ -21,6 +21,8 @@ public class ResultCode {
public static int RSTOKEN_EXPIRED_CODE = Integer.valueOf(SystemProperty.getResultConfig("RSTOKEN_EXPIRED_CODE")); public static int RSTOKEN_EXPIRED_CODE = Integer.valueOf(SystemProperty.getResultConfig("RSTOKEN_EXPIRED_CODE"));
// rstoken不合法 // rstoken不合法
public static int RSTOKEN_NULL_CODE = Integer.valueOf(SystemProperty.getResultConfig("RSTOKEN_NULL_CODE")); public static int RSTOKEN_NULL_CODE = Integer.valueOf(SystemProperty.getResultConfig("RSTOKEN_NULL_CODE"));
// 数据库操作失败
public static int DB_OPERATION_FAIL_CODE = Integer.valueOf(SystemProperty.getResultConfig("DB_OPERATION_FAIL_CODE"));
// 请求微信接口错误 // 请求微信接口错误
public static int WXAPI_CODE = Integer.valueOf(SystemProperty.getResultConfig("WXAPI_CODE")); public static int WXAPI_CODE = Integer.valueOf(SystemProperty.getResultConfig("WXAPI_CODE"));
// 微信用户不存在 // 微信用户不存在
......
...@@ -27,6 +27,11 @@ RSTOKEN_EXPIRED_CODE=1006 ...@@ -27,6 +27,11 @@ RSTOKEN_EXPIRED_CODE=1006
#rstoken为空 #rstoken为空
RSTOKEN_NULL_CODE=1007 RSTOKEN_NULL_CODE=1007
1007=rstoken为空 1007=rstoken为空
#数据库操作失败
DB_OPERATION_FAIL_CODE=1008
1008=数据库操作失败
#请求微信接口失败 #请求微信接口失败
WXAPI_CODE=2001 WXAPI_CODE=2001
#微信用不不存在 #微信用不不存在
......
...@@ -19,6 +19,11 @@ import java.util.List; ...@@ -19,6 +19,11 @@ import java.util.List;
*/ */
@FeignClient(value = "ace-admin") @FeignClient(value = "ace-admin")
public interface UserFeign { public interface UserFeign {
public static final int MEMBER_DAYS_LOCK = 1;
public static final int MEMBER_DAYS_CONFIRM = 2;
public static final int MEMBER_DAYS_WITHDRAW = 3;
@RequestMapping(value = "/public/userinfo-by-token") @RequestMapping(value = "/public/userinfo-by-token")
public ObjectRestResponse<UserDTO> userinfoByToken(@RequestParam("token") String token); public ObjectRestResponse<UserDTO> userinfoByToken(@RequestParam("token") String token);
...@@ -71,7 +76,7 @@ public interface UserFeign { ...@@ -71,7 +76,7 @@ public interface UserFeign {
* @throws Exception * @throws Exception
*/ */
@RequestMapping(value = "/member/user/buyMember", method = RequestMethod.POST) @RequestMapping(value = "/member/user/buyMember", method = RequestMethod.POST)
public ObjectRestResponse buyMember(@RequestBody UserMemberDTO userMemberDTO) throws Exception; public ObjectRestResponse buyMember(@RequestBody UserMemberDTO userMemberDTO);
/** /**
* 订单更改会员 * 订单更改会员
...@@ -86,7 +91,7 @@ public interface UserFeign { ...@@ -86,7 +91,7 @@ public interface UserFeign {
@RequestParam(value = "userId",defaultValue = "0")Integer userId, @RequestParam(value = "userId",defaultValue = "0")Integer userId,
@RequestParam(value = "days",defaultValue = "0")Integer days, @RequestParam(value = "days",defaultValue = "0")Integer days,
@RequestParam(value = "type",defaultValue = "1")Integer type @RequestParam(value = "type",defaultValue = "1")Integer type
) throws Exception; );
} }
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
</targetResourcesProject> </targetResourcesProject>
<targetXMLPackage>mapper</targetXMLPackage> <targetXMLPackage>mapper</targetXMLPackage>
<!-- 依赖版本 --> <!-- 依赖版本 -->
<mapper.version>3.4.0</mapper.version> <mapper.version>4.1.5</mapper.version>
<mybatis.version>3.3.1</mybatis.version> <mybatis.version>3.4.6</mybatis.version>
<mybatis.spring.version>1.2.4</mybatis.spring.version> <mybatis.spring.version>1.3.2</mybatis.spring.version>
<pagehelper.version>4.1.1</pagehelper.version> <pagehelper.version>5.1.8</pagehelper.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -139,13 +139,13 @@ ...@@ -139,13 +139,13 @@
<dependency> <dependency>
<groupId>tk.mybatis</groupId> <groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId> <artifactId>mapper-spring-boot-starter</artifactId>
<version>1.1.2</version> <version>2.1.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId> <artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version> <version>1.2.10</version>
</dependency> </dependency>
<!-- swagger --> <!-- swagger -->
......
...@@ -17,7 +17,7 @@ spring: ...@@ -17,7 +17,7 @@ spring:
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
#共用配置,暂定一个 #共用配置,暂定一个
#shared-dataids: common-dev.yaml shared-dataids: common-dev.yaml
--- ---
spring: spring:
......
...@@ -117,7 +117,7 @@ public class CampsiteShopAdminDTO { ...@@ -117,7 +117,7 @@ public class CampsiteShopAdminDTO {
* 具体地址 * 具体地址
*/ */
@ApiModelProperty(value = "具体地址") @ApiModelProperty(value = "具体地址")
private String adress; private String address;
/** /**
* 客服电话 * 客服电话
......
...@@ -53,6 +53,12 @@ public class CampsiteShopAdminPageDTO implements Serializable { ...@@ -53,6 +53,12 @@ public class CampsiteShopAdminPageDTO implements Serializable {
@ApiModelProperty(value = "创建时间", hidden = true) @ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime; private Long crtTime;
/**
* 开业时间
*/
@ApiModelProperty(value = "开业时间")
private Long shopStartTime;
/** /**
* 上下架状态 0-创建状态 1-上架 2-下架 * 上下架状态 0-创建状态 1-上架 2-下架
*/ */
......
...@@ -20,6 +20,8 @@ import lombok.NoArgsConstructor; ...@@ -20,6 +20,8 @@ import lombok.NoArgsConstructor;
@Api("轮播图详细列表") @Api("轮播图详细列表")
public class CampsiteShopCarouselDetailDTO { public class CampsiteShopCarouselDetailDTO {
private Integer id;
/** /**
* 图片地址 * 图片地址
*/ */
......
...@@ -119,7 +119,7 @@ public class CampsiteShopDTO implements Serializable { ...@@ -119,7 +119,7 @@ public class CampsiteShopDTO implements Serializable {
* 具体地址 * 具体地址
*/ */
@ApiModelProperty(value = "具体地址") @ApiModelProperty(value = "具体地址")
private String adress; private String address;
/** /**
* 客服电话 * 客服电话
......
...@@ -22,7 +22,7 @@ public class CampsiteShopTagDTO implements Serializable { ...@@ -22,7 +22,7 @@ public class CampsiteShopTagDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id; private Integer id;
/** /**
* 店铺id * 店铺id
*/ */
...@@ -39,7 +39,7 @@ public class CampsiteShopTagDTO implements Serializable { ...@@ -39,7 +39,7 @@ public class CampsiteShopTagDTO implements Serializable {
* 类型名称 * 类型名称
*/ */
@ApiModelProperty(value = "类型名称") @ApiModelProperty(value = "类型名称")
private String tagName; private String name;
/** /**
* 创建时间 * 创建时间
......
...@@ -143,9 +143,9 @@ public class CampsiteShop implements Serializable { ...@@ -143,9 +143,9 @@ public class CampsiteShop implements Serializable {
/** /**
* 具体地址 * 具体地址
*/ */
@Column(name = "adress") @Column(name = "address")
@ApiModelProperty(value = "具体地址") @ApiModelProperty(value = "具体地址")
private String adress; private String address;
/** /**
* 客服电话 * 客服电话
......
...@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor; ...@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -41,7 +42,7 @@ public class CampsiteShopAdminPageVo implements Serializable { ...@@ -41,7 +42,7 @@ public class CampsiteShopAdminPageVo implements Serializable {
* 店铺类型名称 * 店铺类型名称
*/ */
@ApiModelProperty(value = "店铺类型名称") @ApiModelProperty(value = "店铺类型名称")
private List<String> storeTypeName; private List<String> storeTypeName = new ArrayList<>();
/** /**
* 热度值 * 热度值
*/ */
...@@ -54,6 +55,11 @@ public class CampsiteShopAdminPageVo implements Serializable { ...@@ -54,6 +55,11 @@ public class CampsiteShopAdminPageVo implements Serializable {
@ApiModelProperty(value = "创建时间", hidden = true) @ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime; private Long crtTime;
/**
* 开业时间
*/
@ApiModelProperty(value = "开业时间 ")
private Long shopStartTime;
/** /**
* 上下架状态 0-创建状态 1-上架 2-下架 * 上下架状态 0-创建状态 1-上架 2-下架
*/ */
......
package com.xxfc.platform.campsite.vo;
import com.xxfc.platform.campsite.dto.CampsiteShopCarouselDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description TODO
* @data 2019/6/19 18:07
*/
@Data
public class CampsiteShopAdminVO {
/**
* 主键id
*/
@ApiModelProperty("主键id")
private Integer id;
/**
* 店铺名称
*/
@ApiModelProperty(value = "店铺名称")
private String name;
/**
* 店铺logo
*/
@ApiModelProperty(value = "店铺logo")
private String logo;
/**
* 店铺介绍
*/
@ApiModelProperty(value = "店铺介绍")
private String intro;
/**
* 店铺URL
*/
@ApiModelProperty(value = "店铺URL")
private String url;
/**
* 主要联系人
*/
@ApiModelProperty(value = "主要联系人")
private String concat;
/**
* 联系人身份证号
*/
@ApiModelProperty(value = "联系人身份证号")
private String idNumber;
/**
* 联系人电话
*/
@ApiModelProperty(value = "联系人电话")
private String phone;
/**
* 公司id
*/
@ApiModelProperty(value = "公司id")
private Integer companyId;
/**
* 公司名称
*/
@ApiModelProperty(value = "公司名称")
private String companyName;
/**
* 开店时间
*/
@ApiModelProperty(value = "开店时间")
private Long startTime;
/**
* 地址-省/直辖市(编码)
*/
@ApiModelProperty(value = "地址-省/直辖市(编码)")
private Integer province;
/**
* 地址-省/直辖市(名称)
*/
@ApiModelProperty(value = "地址-省/直辖市(名称)")
private String provinceName;
/**
* 地址-市
*/
@ApiModelProperty(value = "地址-市")
private Integer city;
/**
* 地址-市(名称)
*/
@ApiModelProperty(value = "地址-市(名称)")
private String cityName;
/**
* 经度
*/
@ApiModelProperty(value = "经度")
private Double longitude;
/**
* 纬度
*/
@ApiModelProperty(value = "纬度")
private Double latitude;
/**
* 具体地址
*/
@ApiModelProperty(value = "具体地址")
private String address;
/**
* 客服电话
*/
@ApiModelProperty(value = "客服电话")
private String servicePhone;
/**
* 配套设施&收费
*/
@ApiModelProperty(value = "配套设施&收费")
private String configure;
/**
* 店铺详情
*/
@ApiModelProperty(value = "店铺详情")
private String content;
/**
* 店铺状态:0-未开业;1-已开业
*/
@ApiModelProperty(value = "店铺状态:0-未开业;1-已开业")
private Integer status;
/**
* 热度值
*/
@ApiModelProperty(value = "热度值")
private Integer hot;
/**
* 上下架状态 0-创建状态 1-上架 2-下架
*/
@ApiModelProperty(value = "上下架状态 0-创建状态 1-上架 2-下架")
private Integer saleState;
/**
* 轮播图
*/
private List<CampsiteShopCarouselVo> carouse;
/**
* 营地类型
*/
private List<CampsiteTagListVo> campsiteTagListVos;
}
package com.xxfc.platform.campsite.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author libin
* @version 1.0
* @description TODO
* @data 2019/6/17 18:23
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Api("轮播图详细列表")
public class CampsiteShopCarouselAdminDetailVo {
private Integer id;
/**
* 商家id
*/
@ApiModelProperty(value = "商家id")
private Integer shopId;
/**
* 访问链接
*/
@ApiModelProperty(value = "访问链接")
private String url;
/**
* 轮播图片链接
*/
@ApiModelProperty(value = "轮播图片链接")
private String imgUrl;
}
...@@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.dto.*; import com.xxfc.platform.campsite.dto.*;
import com.xxfc.platform.campsite.vo.CampsiteShopAdminPageVo; import com.xxfc.platform.campsite.vo.*;
import com.xxfc.platform.campsite.vo.CampsiteShopCarouselDetailVo; import jdk.nashorn.internal.ir.LiteralNode;
import com.xxfc.platform.campsite.vo.CampsiteShopDetailVo;
import com.xxfc.platform.campsite.vo.CampsiteShopPageVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -72,7 +70,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -72,7 +70,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
BeanUtils.copyProperties(campsiteShopPageDTO,campsiteShopPageVo); BeanUtils.copyProperties(campsiteShopPageDTO,campsiteShopPageVo);
campsiteShopPageVoList.add(campsiteShopPageVo); campsiteShopPageVoList.add(campsiteShopPageVo);
} }
campsiteShopPageVoList.stream().sorted(Comparator.comparing(CampsiteShopPageVo::getHot).reversed().thenComparing(CampsiteShopPageVo::getCrtTime).reversed()); campsiteShopPageVoList.sort(Comparator.comparing(CampsiteShopPageVo::getHot).reversed().thenComparing(CampsiteShopPageVo::getCrtTime).reversed());
campsiteShopPageDataVO.setData(campsiteShopPageVoList); campsiteShopPageDataVO.setData(campsiteShopPageVoList);
return campsiteShopPageDataVO; return campsiteShopPageDataVO;
} }
...@@ -98,18 +96,20 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -98,18 +96,20 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
log.debug("根据店铺id=【{}】查询出店铺轮播图信息:【{}】",id,campsiteShopCarouselDTOS); log.debug("根据店铺id=【{}】查询出店铺轮播图信息:【{}】",id,campsiteShopCarouselDTOS);
} }
List<CampsiteShopCarouselDetailVo> campsiteShopCarouselDetailVos = new ArrayList<>(); List<CampsiteShopCarouselDetailVo> campsiteShopCarouselDetailVos = new ArrayList<>();
if (CollectionUtils.isNotEmpty(campsiteShopCarouselDTOS)) {
campsiteShopCarouselDTOS.forEach(campsiteShopCarouselDetailDTO -> { campsiteShopCarouselDTOS.forEach(campsiteShopCarouselDetailDTO -> {
CampsiteShopCarouselDetailVo carouselDetailVo = new CampsiteShopCarouselDetailVo(); CampsiteShopCarouselDetailVo carouselDetailVo = new CampsiteShopCarouselDetailVo();
BeanUtils.copyProperties(campsiteShopCarouselDetailDTO,carouselDetailVo); BeanUtils.copyProperties(campsiteShopCarouselDetailDTO, carouselDetailVo);
campsiteShopCarouselDetailVos.add(carouselDetailVo); campsiteShopCarouselDetailVos.add(carouselDetailVo);
}); });
}
campsiteShopDetailVo.setCampsiteShopCarouselDetailVos(campsiteShopCarouselDetailVos); campsiteShopDetailVo.setCampsiteShopCarouselDetailVos(campsiteShopCarouselDetailVos);
//从店铺类型表根据店铺id查询 -->类型列表拼接 //从店铺类型表根据店铺id查询 -->类型列表拼接
List<String> typeNameList = campsiteShopTagBiz.findByCampsiteShopId(id); List<CampsiteShopTagDTO> shopTagDTOS = campsiteShopTagBiz.findByCampsiteShopId(id);
if (log.isDebugEnabled()){ if (log.isDebugEnabled()){
log.debug("根据店铺id=【{}】查询出店铺类型:【{}】",id,typeNameList); log.debug("根据店铺id=【{}】查询出店铺类型:【{}】",id,shopTagDTOS);
} }
campsiteShopDetailVo.setTypeNames(typeNameList); campsiteShopDetailVo.setTypeNames(shopTagDTOS==null?Collections.EMPTY_LIST:shopTagDTOS.stream().map(CampsiteShopTagDTO::getName).collect(Collectors.toList()));
//根据经纬度算距离 //根据经纬度算距离
double distance = getDistance(campsiteShopDetailDTO.getLongitude(),campsiteShopDetailDTO.getLatitude(),longitude,latitude); double distance = getDistance(campsiteShopDetailDTO.getLongitude(),campsiteShopDetailDTO.getLatitude(),longitude,latitude);
if (log.isDebugEnabled()){ if (log.isDebugEnabled()){
...@@ -128,6 +128,20 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -128,6 +128,20 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
if (log.isDebugEnabled()){ if (log.isDebugEnabled()){
log.debug("查询条件:【{}】",campsiteShopAdminFindDTO); log.debug("查询条件:【{}】",campsiteShopAdminFindDTO);
} }
//筛选时间处理
/* Long startTime = campsiteShopAdminFindDTO.getStartTime();
Long endTime = campsiteShopAdminFindDTO.getEndTime();
if (startTime==null || endTime ==null){
Long processTime = startTime!=null?startTime:(endTime!=null?endTime:null);
if (processTime!=null){
campsiteShopAdminFindDTO.setStartTime(processStartTime(processTime));
campsiteShopAdminFindDTO.setEndTime(processEndTime(processTime));
}
}else {
campsiteShopAdminFindDTO.setStartTime(processStartTime(startTime));
campsiteShopAdminFindDTO.setEndTime(processEndTime(endTime));
}*/
PageDataVO<CampsiteShopAdminPageDTO> campsiteShopAdminpageDTOPageDataVO = PageDataVO.pageInfo(campsiteShopAdminFindDTO.getPage(),campsiteShopAdminFindDTO.getLimit(),()->mapper.findCampsiteShops(campsiteShopAdminFindDTO)); PageDataVO<CampsiteShopAdminPageDTO> campsiteShopAdminpageDTOPageDataVO = PageDataVO.pageInfo(campsiteShopAdminFindDTO.getPage(),campsiteShopAdminFindDTO.getLimit(),()->mapper.findCampsiteShops(campsiteShopAdminFindDTO));
List<CampsiteShopAdminPageDTO> campsiteShopAdminPageDTOS = campsiteShopAdminpageDTOPageDataVO.getData(); List<CampsiteShopAdminPageDTO> campsiteShopAdminPageDTOS = campsiteShopAdminpageDTOPageDataVO.getData();
if (log.isDebugEnabled()){ if (log.isDebugEnabled()){
...@@ -144,8 +158,12 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -144,8 +158,12 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
if (log.isDebugEnabled()){ if (log.isDebugEnabled()){
log.debug("营地id为:【{}】的类型【{}】",campsiteShopIds,shopTagsMap); log.debug("营地id为:【{}】的类型【{}】",campsiteShopIds,shopTagsMap);
} }
campsiteShopAdminPageDTOS.stream().peek(campsiteShopAdminPageDTO -> campsiteShopAdminPageDTO.setStoreTypeName(shopTagsMap.get(campsiteShopAdminPageDTO.getId()))) campsiteShopAdminPageDTOS = campsiteShopAdminPageDTOS.stream().peek(campsiteShopAdminPageDTO -> {
.sorted(Comparator.comparing(CampsiteShopAdminPageDTO::getHot).reversed().thenComparing(CampsiteShopAdminPageDTO::getCrtTime).reversed()); if (Objects.nonNull(shopTagsMap)) {
List<String> tagNames = shopTagsMap.get(campsiteShopAdminPageDTO.getId());
campsiteShopAdminPageDTO.setStoreTypeName(tagNames == null ? new ArrayList<String>() : tagNames);
}
}).sorted(Comparator.comparing(CampsiteShopAdminPageDTO::getHot).reversed().thenComparing(CampsiteShopAdminPageDTO::getCrtTime).reversed()).collect(Collectors.toList());
//组装数据 //组装数据
campsiteShopAdminPageDataVos.setTotalPage(campsiteShopAdminpageDTOPageDataVO.getTotalPage()); campsiteShopAdminPageDataVos.setTotalPage(campsiteShopAdminpageDTOPageDataVO.getTotalPage());
campsiteShopAdminPageDataVos.setTotalCount(campsiteShopAdminpageDTOPageDataVO.getTotalCount()); campsiteShopAdminPageDataVos.setTotalCount(campsiteShopAdminpageDTOPageDataVO.getTotalCount());
...@@ -163,6 +181,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -163,6 +181,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
public int saveCampsiteShop(CampsiteShopAdminDTO campsiteShopAdminDTO) { public int saveCampsiteShop(CampsiteShopAdminDTO campsiteShopAdminDTO) {
CampsiteShop campsiteShop = new CampsiteShop(); CampsiteShop campsiteShop = new CampsiteShop();
campsiteShopAdminDTO.setName(campsiteShopAdminDTO.getName()==null?null:campsiteShopAdminDTO.getName().trim());
BeanUtils.copyProperties(campsiteShopAdminDTO,campsiteShop); BeanUtils.copyProperties(campsiteShopAdminDTO,campsiteShop);
int effectRows = 0; int effectRows = 0;
if (Objects.nonNull(campsiteShopAdminDTO.getId())){ if (Objects.nonNull(campsiteShopAdminDTO.getId())){
...@@ -194,6 +213,44 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -194,6 +213,44 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
return effectRows; return effectRows;
} }
/**
* 编辑查询
* @param id
* @return
*/
public CampsiteShopAdminVO findByCampsiteId(Integer id) {
CampsiteShopAdminVO campsiteShopAdminVO = new CampsiteShopAdminVO();
CampsiteShop campsiteShop = new CampsiteShop();
campsiteShop.setId(id);
CampsiteShop shop = mapper.selectOne(campsiteShop);
BeanUtils.copyProperties(shop, campsiteShopAdminVO);
//根据营地id查询轮播
List<CampsiteShopCarouselDetailDTO> shopCarouselDetailDTOS = campsiteShopCarouselBiz.findByCampsiteShopId(id);
List<CampsiteShopCarouselVo> campsiteShopCarouselVos = new ArrayList<>();
if (CollectionUtils.isNotEmpty(shopCarouselDetailDTOS)) {
shopCarouselDetailDTOS.forEach(campsiteShopCarouselDetailDTO -> {
CampsiteShopCarouselVo campsiteShopCarouselVo = new CampsiteShopCarouselVo();
BeanUtils.copyProperties(campsiteShopCarouselDetailDTO, campsiteShopCarouselVo);
campsiteShopCarouselVos.add(campsiteShopCarouselVo);
});
}
campsiteShopAdminVO.setCarouse(campsiteShopCarouselVos);
//根据营地id查询营地类型
List<CampsiteShopTagDTO> shopTagDTOS = campsiteShopTagBiz.findByCampsiteShopId(id);
List<CampsiteTagListVo> shopTagVos = new ArrayList<>();
if (CollectionUtils.isNotEmpty(shopTagDTOS)) {
shopTagDTOS.forEach(campsiteShopTagDTO -> {
CampsiteTagListVo campsiteTagListVo = new CampsiteTagListVo();
BeanUtils.copyProperties(campsiteShopTagDTO, campsiteTagListVo);
shopTagVos.add(campsiteTagListVo);
});
campsiteShopAdminVO.setCampsiteTagListVos(shopTagVos);
}
campsiteShopAdminVO.setCarouse(campsiteShopAdminVO.getCarouse()==null?new ArrayList<CampsiteShopCarouselVo>():campsiteShopAdminVO.getCarouse());
campsiteShopAdminVO.setCampsiteTagListVos(campsiteShopAdminVO.getCampsiteTagListVos()==null?new ArrayList<CampsiteTagListVo>():campsiteShopAdminVO.getCampsiteTagListVos());
return campsiteShopAdminVO;
}
/** /**
* 逻辑删除 * 逻辑删除
* @param id * @param id
...@@ -212,6 +269,46 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -212,6 +269,46 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
public int updateCampsiteSaleStatus(Integer id, Integer status) { public int updateCampsiteSaleStatus(Integer id, Integer status) {
return mapper.updateCampsiteSaleStatus(id,status); return mapper.updateCampsiteSaleStatus(id,status);
} }
/**
* 检验营地名称是否存在
* @param id
* @param name
* @return
*/
public Boolean campsiteNameExist(Integer id, String name) {
int count = mapper.checkNameExist(id,name);
if (count == 0) {
return false;
}
return true;
}
/**
* 处理开始时间
* @param time
* @return
*/
private long processStartTime(Long time){
Date processStartDate = new Date(time);
processStartDate.setHours(0);
processStartDate.setMinutes(0);
processStartDate.setSeconds(0);
return processStartDate.getTime();
}
/**
* 处理结束时间
* @param time
* @return
*/
private long processEndTime(Long time){
Date processEndDate = new Date(time);
processEndDate.setHours(23);
processEndDate.setMinutes(59);
processEndDate.setSeconds(59);
return processEndDate.getTime();
}
/** /**
* 根据经纬度,计算两点间的距离 * 根据经纬度,计算两点间的距离
* *
...@@ -240,4 +337,6 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> { ...@@ -240,4 +337,6 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
return s; return s;
} }
} }
\ No newline at end of file
...@@ -34,7 +34,7 @@ public class CampsiteShopTagBiz extends BaseBiz<CampsiteShopTagMapper,CampsiteSh ...@@ -34,7 +34,7 @@ public class CampsiteShopTagBiz extends BaseBiz<CampsiteShopTagMapper,CampsiteSh
* @param id * @param id
* @return * @return
*/ */
public List<String> findByCampsiteShopId(Integer id) { public List<CampsiteShopTagDTO> findByCampsiteShopId(Integer id) {
return mapper.findByCampsiteShopId(id); return mapper.findByCampsiteShopId(id);
} }
...@@ -49,7 +49,7 @@ public class CampsiteShopTagBiz extends BaseBiz<CampsiteShopTagMapper,CampsiteSh ...@@ -49,7 +49,7 @@ public class CampsiteShopTagBiz extends BaseBiz<CampsiteShopTagMapper,CampsiteSh
return null; return null;
} }
Map<Integer, List<String>> shopOfTagsMap = campsiteShopTagDTOS.stream() Map<Integer, List<String>> shopOfTagsMap = campsiteShopTagDTOS.stream()
.collect(Collectors.groupingBy(CampsiteShopTagDTO::getShopId,Collectors.mapping(CampsiteShopTagDTO::getTagName,Collectors.toList()))); .collect(Collectors.groupingBy(CampsiteShopTagDTO::getShopId,Collectors.mapping(CampsiteShopTagDTO::getName,Collectors.toList())));
return shopOfTagsMap; return shopOfTagsMap;
} }
......
...@@ -3,6 +3,7 @@ package com.xxfc.platform.campsite.biz; ...@@ -3,6 +3,7 @@ package com.xxfc.platform.campsite.biz;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.sun.org.apache.regexp.internal.RE;
import com.xxfc.platform.campsite.dto.CampsiteTagListDTO; import com.xxfc.platform.campsite.dto.CampsiteTagListDTO;
import com.xxfc.platform.campsite.vo.CampsiteTagListVo; import com.xxfc.platform.campsite.vo.CampsiteTagListVo;
import com.xxfc.platform.campsite.vo.CampsiteTagVo; import com.xxfc.platform.campsite.vo.CampsiteTagVo;
...@@ -62,6 +63,31 @@ public class CampsiteTagBiz extends BaseBiz<CampsiteTagMapper,CampsiteTag> { ...@@ -62,6 +63,31 @@ public class CampsiteTagBiz extends BaseBiz<CampsiteTagMapper,CampsiteTag> {
return tagVoPageDataVO; return tagVoPageDataVO;
} }
tagVoPageDataVO = JSONObject.parseObject(JSONObject.toJSONString(pageDataVO),new TypeReference<PageDataVO<CampsiteTagVo>>(){}); tagVoPageDataVO = JSONObject.parseObject(JSONObject.toJSONString(pageDataVO),new TypeReference<PageDataVO<CampsiteTagVo>>(){});
tagVoPageDataVO.getData().sort(Comparator.comparing(CampsiteTagVo::getRank).reversed().thenComparing(Comparator.comparing(CampsiteTagVo::getCtrTime).reversed()));
return tagVoPageDataVO; return tagVoPageDataVO;
} }
/**
* 更改是否作为筛选条件
* @param id
* @param status
* @return
*/
public int updateCampsiteTagIsSearchStatus(Integer id, Integer status) {
return mapper.updateCampsiteTagIsearchStatus(id,status);
}
/**
* 营地类型名检验
* @param id
* @param name
* @return
*/
public Boolean checkTagNameExist(Integer id, String name) {
int count = mapper.checkTagNameExist(id,name);
if (count == 0){
return false;
}
return true;
}
} }
\ No newline at end of file
...@@ -55,4 +55,12 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> { ...@@ -55,4 +55,12 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> {
* @return * @return
*/ */
int updateCampsiteSaleStatus(@Param("id") Integer id, @Param("status") Integer status); int updateCampsiteSaleStatus(@Param("id") Integer id, @Param("status") Integer status);
/**
* 检验营地名称
* @param id
* @param name
* @return
*/
int checkNameExist(@Param("id") Integer id,@Param("name") String name);
} }
...@@ -23,8 +23,7 @@ public interface CampsiteShopTagMapper extends Mapper<CampsiteShopTag> { ...@@ -23,8 +23,7 @@ public interface CampsiteShopTagMapper extends Mapper<CampsiteShopTag> {
* @param shopId * @param shopId
* @return * @return
*/ */
@Select("select `name` from campsite_shop_tag as `cst` left join campsite_tag as `ct` on cst.tag_id=ct.id where `shop_id`=#{shopId}") List<CampsiteShopTagDTO> findByCampsiteShopId(Integer shopId);
List<String> findByCampsiteShopId(Integer shopId);
/** /**
* 根据店铺ids查询 * 根据店铺ids查询
......
...@@ -36,4 +36,21 @@ public interface CampsiteTagMapper extends Mapper<CampsiteTag> { ...@@ -36,4 +36,21 @@ public interface CampsiteTagMapper extends Mapper<CampsiteTag> {
List<CampsiteTagDTO> finCampsiteTagsAll(); List<CampsiteTagDTO> finCampsiteTagsAll();
/**
* 更改筛选条件状态
* @param id
* @param status
* @return
*/
int updateCampsiteTagIsearchStatus(@Param("id") Integer id, @Param("status") Integer status);
/**
* 检验营地类型名
* @param id
* @param name
* @return
*/
int checkTagNameExist(@Param("id") Integer id,@Param("name") String name);
} }
...@@ -8,6 +8,7 @@ import com.xxfc.platform.campsite.dto.CampsiteShopAdminDTO; ...@@ -8,6 +8,7 @@ import com.xxfc.platform.campsite.dto.CampsiteShopAdminDTO;
import com.xxfc.platform.campsite.dto.CampsiteShopAdminFindDTO; import com.xxfc.platform.campsite.dto.CampsiteShopAdminFindDTO;
import com.xxfc.platform.campsite.entity.CampsiteShop; import com.xxfc.platform.campsite.entity.CampsiteShop;
import com.xxfc.platform.campsite.vo.CampsiteShopAdminPageVo; import com.xxfc.platform.campsite.vo.CampsiteShopAdminPageVo;
import com.xxfc.platform.campsite.vo.CampsiteShopAdminVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -29,8 +30,8 @@ public class CampsiteShopAdminController extends BaseController<CampsiteShopBiz, ...@@ -29,8 +30,8 @@ public class CampsiteShopAdminController extends BaseController<CampsiteShopBiz,
* @return * @return
*/ */
@ApiOperation(value = "营地列表") @ApiOperation(value = "营地列表")
@GetMapping("/pages") @PostMapping("/pages")
public ObjectRestResponse<PageDataVO<CampsiteShopAdminPageVo>> findCampsiteShopPage(CampsiteShopAdminFindDTO campsiteShopAdminFindDTO){ public ObjectRestResponse<PageDataVO<CampsiteShopAdminPageVo>> findCampsiteShopPage(@RequestBody CampsiteShopAdminFindDTO campsiteShopAdminFindDTO){
PageDataVO<CampsiteShopAdminPageVo> pageVoPageDataVO = getBaseBiz().findCampsiteShopPage(campsiteShopAdminFindDTO); PageDataVO<CampsiteShopAdminPageVo> pageVoPageDataVO = getBaseBiz().findCampsiteShopPage(campsiteShopAdminFindDTO);
return ObjectRestResponse.succ(pageVoPageDataVO); return ObjectRestResponse.succ(pageVoPageDataVO);
} }
...@@ -78,4 +79,16 @@ public class CampsiteShopAdminController extends BaseController<CampsiteShopBiz, ...@@ -78,4 +79,16 @@ public class CampsiteShopAdminController extends BaseController<CampsiteShopBiz,
} }
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
@GetMapping("/exist")
public ObjectRestResponse<Boolean> checkCampsiteNameExist(@RequestParam(value = "id",required = false) Integer id,@RequestParam("name") String name){
Boolean exist = getBaseBiz().campsiteNameExist(id,name==null?"":name.trim());
return ObjectRestResponse.succ(exist);
}
@GetMapping("/campsite/{id}")
public ObjectRestResponse<CampsiteShopAdminVO> findByCampsiteId(@PathVariable("id") Integer id){
CampsiteShopAdminVO campsiteShopAdminVO = getBaseBiz().findByCampsiteId(id);
return ObjectRestResponse.succ(campsiteShopAdminVO);
}
} }
\ No newline at end of file
...@@ -43,4 +43,19 @@ public class CampsiteTagAdminController extends BaseController<CampsiteTagBiz,Ca ...@@ -43,4 +43,19 @@ public class CampsiteTagAdminController extends BaseController<CampsiteTagBiz,Ca
return ObjectRestResponse.succ(tagVoPageDataVO); return ObjectRestResponse.succ(tagVoPageDataVO);
} }
@PutMapping("/searchStatus")
public ObjectRestResponse<Void> updateIsSearchStatus(@RequestParam("id") Integer id,@RequestParam("status") Integer status){
int effectRows = getBaseBiz().updateCampsiteTagIsSearchStatus(id,status);
if (effectRows>0){
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
@GetMapping("/exist")
public ObjectRestResponse<Boolean> checkTagNameExist(@RequestParam(value = "id",required = false) Integer id,@RequestParam("name") String name){
Boolean exist = getBaseBiz().checkTagNameExist(id,name==null?"":name.trim());
return ObjectRestResponse.succ(exist);
}
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</resultMap> </resultMap>
<select id="findCarousesByShopId" resultType="com.xxfc.platform.campsite.dto.CampsiteShopCarouselDetailDTO"> <select id="findCarousesByShopId" resultType="com.xxfc.platform.campsite.dto.CampsiteShopCarouselDetailDTO">
select `img_url`as `imgUrl`,`url`as `url` from `campsite_shop_carousel` where shop_id=#{shopId} select `id` as `id`,`img_url`as `imgUrl`,`url`as `url` from `campsite_shop_carousel` where shop_id=#{shopId} and `is_del`=0;
</select> </select>
<update id="updateCarouseStatus"> <update id="updateCarouseStatus">
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<result property="cityName" column="city_name"/> <result property="cityName" column="city_name"/>
<result property="longitude" column="longitude"/> <result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/> <result property="latitude" column="latitude"/>
<result property="adress" column="adress"/> <result property="address" column="address"/>
<result property="servicePhone" column="service_phone"/> <result property="servicePhone" column="service_phone"/>
<result property="configure" column="configure"/> <result property="configure" column="configure"/>
<result property="content" column="content"/> <result property="content" column="content"/>
...@@ -47,32 +47,27 @@ ...@@ -47,32 +47,27 @@
</select> </select>
<select id="findCampsiteShopDetailById" resultType="com.xxfc.platform.campsite.dto.CampsiteShopDetailDTO"> <select id="findCampsiteShopDetailById" resultType="com.xxfc.platform.campsite.dto.CampsiteShopDetailDTO">
select `name` as `name`,`province_name` as `provinceName`,`city_name` as `cityName`,`adress` as `address`, select `name` as `name`,`province_name` as `provinceName`,`city_name` as `cityName`,`address` as `address`,
`content` as `content`,`configure` as `configure`,`longitude` as `longitude`,`latitude` as `latitude` from `campsite_shop` where `id`=#{id} `content` as `content`,`configure` as `configure`,`longitude` as `longitude`,`latitude` as `latitude` from `campsite_shop` where `id`=#{id}
</select> </select>
<select id="findCampsiteShops" parameterType="com.xxfc.platform.campsite.dto.CampsiteShopAdminFindDTO" resultType="com.xxfc.platform.campsite.dto.CampsiteShopAdminPageDTO"> <select id="findCampsiteShops" parameterType="com.xxfc.platform.campsite.dto.CampsiteShopAdminFindDTO" resultType="com.xxfc.platform.campsite.dto.CampsiteShopAdminPageDTO">
SELECT `id`,`name`,`hot`,`crt_time` as `crtTime`,`sale_state` as SELECT `id`,`name`,`hot`,`crt_time` as `crtTime`,`start_time` as `shopStartTime`,`sale_state` as
`saleState` FROM `campsite_shop` `saleState` FROM `campsite_shop`
where `is_del`=0 where `is_del`=0
<if test="startTime != null || endTime!=null"> <if test="startTime != null and endTime!=null">
<choose> and start_time between #{startTime} and #{endTime}
<when test="startTime!=null and endTime!=null">
and crt_time between #{startTime} and #{endTime}
</when>
<otherwise>
<if test="startTime!=null">
and crt_time=#{startTime}
</if> </if>
<if test="endTime != null"> <if test="startTime != null and endTime==null">
and crt_time=#{endTime} and <![CDATA[ start_time >= #{startTime} ]]>
</if> </if>
</otherwise> <if test="endTime != null and startTime==null">
</choose> and <![CDATA[ start_time <= #{endTime} ]]>
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and `name` like concat('%',#{name},'%') and `name` like concat('%',#{name},'%')
</if> </if>
</select> </select>
<update id="updateCampsiteStatus"> <update id="updateCampsiteStatus">
...@@ -82,4 +77,11 @@ ...@@ -82,4 +77,11 @@
<update id="updateCampsiteSaleStatus"> <update id="updateCampsiteSaleStatus">
update `campsite_shop` set `sale_state`=#{status} where `id`=#{id} update `campsite_shop` set `sale_state`=#{status} where `id`=#{id}
</update> </update>
<select id="checkNameExist" resultType="int">
select count(`id`) from `campsite_shop` where `name`=#{name}
<if test="id != null">
and `id`!=#{id}
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -14,13 +14,17 @@ ...@@ -14,13 +14,17 @@
</resultMap> </resultMap>
<select id="findByCampsiteShopIds" resultType="com.xxfc.platform.campsite.dto.CampsiteShopTagDTO"> <select id="findByCampsiteShopIds" resultType="com.xxfc.platform.campsite.dto.CampsiteShopTagDTO">
select cst.shop_id as `shopId`,cst.tag_id as `tagId`,ct.name as `tagName` from `campsite_shop_tag` as `cst` inner join `campsite_tag` as `ct` on cst.tag_id=ct.id where cst.is_del=0 select cst.shop_id as `shopId`,cst.tag_id as `tagId`,ct.name as `name` from `campsite_shop_tag` as `cst` inner join `campsite_tag` as `ct` on cst.tag_id=ct.id where cst.is_del=0
and cst.tag_id in and cst.shop_id in
<foreach collection="cspIds" item="tagId" separator="," open="(" close=")"> <foreach collection="cspIds" item="spid" separator="," open="(" close=")">
#{tagId} #{spid}
</foreach> </foreach>
</select> </select>
<select id="findByCampsiteShopId" resultType="com.xxfc.platform.campsite.dto.CampsiteShopTagDTO">
select ct.id as `id`,ct.name as `name` from campsite_shop_tag as `cst` left join campsite_tag as `ct` on cst.tag_id=ct.id where `shop_id`=#{shopId}
</select>
<update id="updateCampsiteTagStatus"> <update id="updateCampsiteTagStatus">
update `campsite_shop_tag` set `is_del`=#{status} where `shop_id`=#{shopId} update `campsite_shop_tag` set `is_del`=#{status} where `shop_id`=#{shopId}
<if test="ids != null and ids.size() != 0"> <if test="ids != null and ids.size() != 0">
...@@ -42,4 +46,5 @@ ...@@ -42,4 +46,5 @@
delete from `campsite_shop_tag` where `shop_id`=#{shopId} ; delete from `campsite_shop_tag` where `shop_id`=#{shopId} ;
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
...@@ -35,4 +35,15 @@ ...@@ -35,4 +35,15 @@
<select id="finCampsiteTagsAll" resultMap="campsiteTagDTOMap"> <select id="finCampsiteTagsAll" resultMap="campsiteTagDTOMap">
select * from `campsite_tag` where `is_del`=0 select * from `campsite_tag` where `is_del`=0
</select> </select>
<update id="updateCampsiteTagIsearchStatus">
update `campsite_tag` set `is_search`=#{status} where `id`=#{id}
</update>
<select id="checkTagNameExist" resultType="int">
select count(`id`) from `campsite_tag` where `name`=#{name}
<if test="id != null">
and `id`!=#{id}
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -57,7 +57,7 @@ public class CampsiteShopBizTest { ...@@ -57,7 +57,7 @@ public class CampsiteShopBizTest {
campsiteShopAdminDTO.setProvinceName("浙江省"); campsiteShopAdminDTO.setProvinceName("浙江省");
campsiteShopAdminDTO.setCity(2342342); campsiteShopAdminDTO.setCity(2342342);
campsiteShopAdminDTO.setCityName("台州市"); campsiteShopAdminDTO.setCityName("台州市");
campsiteShopAdminDTO.setAdress("胡同路23号"); campsiteShopAdminDTO.setAddress("胡同路23号");
campsiteShopAdminDTO.setConcat("zhangsan"); campsiteShopAdminDTO.setConcat("zhangsan");
campsiteShopAdminDTO.setConfigure("dsaasdfasdfa"); campsiteShopAdminDTO.setConfigure("dsaasdfasdfa");
campsiteShopAdminDTO.setContent("sadfasdfasdfasd"); campsiteShopAdminDTO.setContent("sadfasdfasdfasd");
......
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
<groupId>com.github.wxiaoqi</groupId> <groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-common</artifactId> <artifactId>ace-common</artifactId>
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
<exclusions> <!-- <exclusions>-->
<exclusion> <!-- <exclusion>-->
<groupId>tk.mybatis</groupId> <!-- <groupId>tk.mybatis</groupId>-->
<artifactId>mapper</artifactId> <!-- <artifactId>mapper</artifactId>-->
</exclusion> <!-- </exclusion>-->
</exclusions> <!-- </exclusions>-->
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.persistence</groupId> <groupId>javax.persistence</groupId>
......
...@@ -203,4 +203,10 @@ public class BaseOrder implements Serializable { ...@@ -203,4 +203,10 @@ public class BaseOrder implements Serializable {
@ApiModelProperty(value = "是否已支付") @ApiModelProperty(value = "是否已支付")
private Integer hasPay; private Integer hasPay;
/**
* 乐观锁,修改版本号
*/
@Version
@ApiModelProperty(value = "乐观锁,修改版本号")
private Integer version;
} }
...@@ -33,6 +33,11 @@ ...@@ -33,6 +33,11 @@
<version>2.0.2</version> <version>2.0.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -87,6 +87,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -87,6 +87,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
}}); }});
} }
/**
* 取消订单
* @param baseOrder
*/
public void cancel(BaseOrder baseOrder) { public void cancel(BaseOrder baseOrder) {
if(cancelAble.get(baseOrder.getType()).contains(baseOrder.getStatus())) { if(cancelAble.get(baseOrder.getType()).contains(baseOrder.getStatus())) {
this.updateSelectiveById(new BaseOrder(){{ this.updateSelectiveById(new BaseOrder(){{
...@@ -138,8 +142,19 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -138,8 +142,19 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//处理取消流程 //处理取消流程
if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) { if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) {
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId());
}});
//取消租车预定 //取消租车预定
//取消租车免费天数使用
if(null != orvd.getFreeDays() && orvd.getFreeDays() > 0) {
int result = userFeign.memberDays(baseOrder.getUserId(), orvd.getFreeDays(), UserFeign.MEMBER_DAYS_WITHDRAW);
if(result < 0) {
throw new BaseException(ResultCode.FAILED_CODE);
}
}
}else if(OrderTypeEnum.TOUR.getCode().equals(baseOrder.getType())) { }else if(OrderTypeEnum.TOUR.getCode().equals(baseOrder.getType())) {
OrderTourDetail otd = orderTourDetailBiz.selectOne(new OrderTourDetail(){{ OrderTourDetail otd = orderTourDetailBiz.selectOne(new OrderTourDetail(){{
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
...@@ -153,6 +168,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -153,6 +168,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
} }
} }
/**
* 支付回调处理
* @param orderNo
* @param tradeNo
*/
public void payNotifyHandle(String orderNo, String tradeNo) { public void payNotifyHandle(String orderNo, String tradeNo) {
BaseOrder baseOrder = this.selectOne(new BaseOrder() {{ BaseOrder baseOrder = this.selectOne(new BaseOrder() {{
setNo(orderNo); setNo(orderNo);
...@@ -173,7 +193,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -173,7 +193,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
OrderMemberDetail omd = orderMemberDetailBiz.selectOne(new OrderMemberDetail(){{ OrderMemberDetail omd = orderMemberDetailBiz.selectOne(new OrderMemberDetail(){{
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
try {
//触发会员效益
userFeign.buyMember(new UserMemberDTO() {{ userFeign.buyMember(new UserMemberDTO() {{
setUserId(baseOrder.getUserId()); setUserId(baseOrder.getUserId());
setDiscount(omd.getRebate()); setDiscount(omd.getRebate());
...@@ -181,13 +202,18 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -181,13 +202,18 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
setMemberLevel(omd.getMemberLevel()); setMemberLevel(omd.getMemberLevel());
setRentFreeDays(omd.getRentFreeNum()); setRentFreeDays(omd.getRentFreeNum());
}}); }});
}catch (Exception e){
log.error(e.getMessage(), e);
}
}else if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) { }else if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) {
updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode()); updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode());
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId());
}});
//车辆预定审核通过 //车辆预定审核通过
//确认免费天数
if(orvd.getFreeDays() > 0) {
userFeign.memberDays(baseOrder.getUserId(), orvd.getFreeDays(), UserFeign.MEMBER_DAYS_CONFIRM);
}
}else if(OrderTypeEnum.TOUR.getCode().equals(baseOrder.getType())) { }else if(OrderTypeEnum.TOUR.getCode().equals(baseOrder.getType())) {
updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode()); updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode());
//暂无处理 //暂无处理
......
package com.xxfc.platform.order.config;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
/**
* rabbitmq配置类
* 过期订单取消延时队列
* @author zhanghang
* @date 2019/1/7
*/
@Configuration
public class RabbitUserConfig {
/**
* 延时队列交换机
* 注意这里的交换机类型:CustomExchange
* @return
*/
@Bean
public CustomExchange delayExchange(){
Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "direct");
return new CustomExchange("delay_exchange","x-delayed-message",true, false,args);
}
/**
* 延时队列
* @return
*/
@Bean
public Queue delayQueue(){
return new Queue("delay_queue",true);
}
/**
* 给延时队列绑定交换机
* @return
*/
@Bean
public Binding cfgDelayBinding(Queue cfgDelayQueue, CustomExchange cfgUserDelayExchange){
return BindingBuilder.bind(cfgDelayQueue).to(cfgUserDelayExchange).with("delay_key").noargs();
}
}
...@@ -3,9 +3,12 @@ package com.xxfc.platform.order.service; ...@@ -3,9 +3,12 @@ package com.xxfc.platform.order.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Dict; import cn.hutool.core.lang.Dict;
import com.github.wxiaoqi.security.admin.constant.enumerate.MemberEnum; import com.github.wxiaoqi.security.admin.constant.enumerate.MemberEnum;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.context.BaseContextHandler; import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.biz.OrderCostDetailBiz; import com.xxfc.platform.order.biz.OrderCostDetailBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz; import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.OrderTemplateBiz; import com.xxfc.platform.order.biz.OrderTemplateBiz;
...@@ -51,6 +54,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -51,6 +54,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
@Autowired @Autowired
OrderTemplateBiz orderTemplateBiz; OrderTemplateBiz orderTemplateBiz;
@Autowired
UserFeign userFeign;
@PostConstruct @PostConstruct
public void init(){ public void init(){
this.orderTypeEnum = OrderTypeEnum.RentVehicle; this.orderTypeEnum = OrderTypeEnum.RentVehicle;
...@@ -75,6 +81,14 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -75,6 +81,14 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
//设置订单名称 //设置订单名称
bo.getOrder().setName(bo.getVehicleModel().getName()); bo.getOrder().setName(bo.getVehicleModel().getName());
//扣减免费天数
if(null != bo.getFreeDays() && bo.getFreeDays() > 0) {
int result = userFeign.memberDays(bo.getAppUserDTO().getUserid(), bo.getFreeDays(), UserFeign.MEMBER_DAYS_LOCK);
if(result < 0) {
throw new BaseException(ResultCode.FAILED_CODE);
}
}
super.handleDetail(bo); super.handleDetail(bo);
} }
......
package com.xxfc.platform.order;
import cn.hutool.extra.template.Template;
import cn.hutool.extra.template.TemplateConfig;
import cn.hutool.extra.template.TemplateEngine;
import cn.hutool.extra.template.TemplateUtil;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.HashMap;
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes={OrderApplication.class})
public class OrderTest {
@Autowired
BaseOrderBiz baseOrderBiz;
@Test
public void test() {
BaseOrder baseOrder =baseOrderBiz.selectById(93);
baseOrder.setRefundTime(System.currentTimeMillis());
baseOrder.setVersion(baseOrder.getVersion() - 1);
baseOrderBiz.updateSelectiveById(baseOrder);
log.info("success");
}
}
package com.xxfc.platform.order;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes={OrderApplication.class})
public class RabbitmqTest {
static final String exchangeName = "test_exchange";
static final String queueName = "test_queue";
static final String routingKey = "test_queue";
@Test
public void test() throws IOException, TimeoutException {
//建立连接,创建通道
ConnectionFactory fc = new ConnectionFactory();
fc.setHost("10.5.52.3");
fc.setPort(5672);
fc.setUsername("guest");
fc.setPassword("guest");
fc.setVirtualHost("my_vhost");
Connection conn = fc.newConnection();
Channel channel = conn.createChannel();
channel.exchangeDelete(exchangeName); //删除路由
Map<String, Object> map = new HashMap<>();
map.put("x-delayed-type", "direct");
channel.exchangeDeclare(exchangeName, "x-delayed-message",false, false,map); //创建路由
channel.queueDelete(queueName); //删除队列
channel.queueDeclare(queueName, true, false, false, null); //创建队列
channel.queueBind(queueName, exchangeName, routingKey); //绑定路由、队列
channel.close();
conn.close();
// String msg = "测试延时de消息|"+ LocalDateTime.now();
//
// rabbitTemplate.convertAndSend(exchangeName, routingKey, msg, (message) ->{
// message.getMessageProperties().setHeader("x-delay", 9000); //延迟9秒
// return message;
// });
}
}
package com.xxfc.platform.order;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes={OrderApplication.class})
public class RabbitmqTest2 {
@Autowired
private RabbitTemplate rabbitTemplate;
@Test
public void test() throws IOException, TimeoutException {
List<Integer> list = new ArrayList<Integer>(){{
add(1);add(2);add(3);add(4);add(5);add(6);
}};
//这里的消息可以是任意对象,无需额外配置,直接传即可
log.info("===============延时队列生产消息====================");
log.info("发送时间:{},发送内容:{}", LocalDateTime.now(), list.toString());
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
rabbitTemplate.convertAndSend(
"test_exchange",
"test_queue",
list,
message -> {
//注意这里时间可以使long,而且是设置header
message.getMessageProperties().setHeader("x-delay",60000);
return message;
}
);
log.info("{}ms后执行", 60000);
}
}
package com.xxfc.platform.order;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException;
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes={OrderApplication.class})
public class RabbitmqTest3 {
@Autowired
private RabbitTemplate rabbitTemplate;
// @Bean
// @RabbitListener(queues = "delay_queue")
// public
@Test
public void test() throws IOException, TimeoutException {
;
}
}
...@@ -4,9 +4,11 @@ import cn.hutool.extra.template.Template; ...@@ -4,9 +4,11 @@ import cn.hutool.extra.template.Template;
import cn.hutool.extra.template.TemplateConfig; import cn.hutool.extra.template.TemplateConfig;
import cn.hutool.extra.template.TemplateEngine; import cn.hutool.extra.template.TemplateEngine;
import cn.hutool.extra.template.TemplateUtil; import cn.hutool.extra.template.TemplateUtil;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
...@@ -18,6 +20,8 @@ import java.util.HashMap; ...@@ -18,6 +20,8 @@ import java.util.HashMap;
public class RegionTest { public class RegionTest {
// @Autowired
// BaseOrderBiz baseOrderBiz;
@Test @Test
public void test() { public void test() {
...@@ -49,6 +53,9 @@ public class RegionTest { ...@@ -49,6 +53,9 @@ public class RegionTest {
// .driverAmount(new BigDecimal("1800")) // .driverAmount(new BigDecimal("1800"))
// .deposit(new BigDecimal("20000")).build() // .deposit(new BigDecimal("20000")).build()
//输出:Hello Hutool //输出:Hello Hutool
log.info(result); log.info(result);
} }
} }
package com.xxfc.platform.tour.dto;
import com.xxfc.platform.vehicle.constant.VehicleScoreType;
import lombok.Data;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
/**
* @author libin
* @version 1.0
* @description TODO
* @data 2019/6/18 15:45
*/
@Data
public class ScoreTypeDTO {
/**
* 评分类型
*/
@Enumerated(EnumType.STRING)
private VehicleScoreType vehicleScoreType;
/**
* 评分
*/
private int score;
}
package com.xxfc.platform.tour.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description 商品评分
* @data 2019/6/18 15:15
*/
@Data
public class TourUserScoreDTO {
@ApiModelProperty("主键id")
private Integer id;
/**
* 订单id
*/
@ApiModelProperty(value = "订单id")
@NotNull(message = "订单id不能为空")
private Integer orderId;
/**
* 商品id
*/
@ApiModelProperty(value = "商品id")
@NotNull(message = "商品id不能为空")
private Integer modelId;
/**
* 评分类型
*/
@ApiModelProperty(value = "评分类型")
private Integer type;
/**
* 评价分
*/
@ApiModelProperty(value = "评价分")
private Integer aveScore;
/**
* 评分明细
*/
@ApiModelProperty(value = "评分明细")
private String scores;
/**
* 是否匿名;0-否;1-是
*/
@ApiModelProperty(value = "是否匿名;0-否;1-是")
private Integer isAnony;
/**
* 评价
*/
@ApiModelProperty(value = "评价")
private String comment;
/**
* 图片
*/
@ApiModelProperty(value = "图片")
private String imgs;
/**
* 状态:0-未审核;1-已审核;2-审核不通过
*/
@ApiModelProperty(value = "状态:0-未审核;1-已审核;2-审核不通过")
private Integer status;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
/**
* 是否删除;0-正常;1-删除
*/
@ApiModelProperty(value = "是否删除;0-正常;1-删除")
private Integer isDel;
/**
* 服务类型评分
*/
@ApiModelProperty(value = "服务类型评分")
private List<ScoreTypeDTO> scoretype;
}
\ No newline at end of file
package com.xxfc.platform.tour.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description 商品评分
* @data 2019/6/18 15:15
*/
@Data
public class TourUserScoreDetailDTO {
/**
* 用户id
*/
@ApiModelProperty("用户id")
private Integer userId;
/**
* 评价分
*/
@ApiModelProperty(value = "评价分")
private Integer aveScore;
/**
* 评价
*/
@ApiModelProperty(value = "评价")
private String comment;
/**
* 图片
*/
@ApiModelProperty(value = "图片")
private String imgs;
/**
* 商品名称
*/
@ApiModelProperty(value ="商品名称")
private String name;
/**
* 商品描述
*/
@ApiModelProperty(value = "商品描述")
private String describes;
/**
* 商品封面
*/
@ApiModelProperty(value = "商品封面")
private String cover;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 评分明细
*/
@ApiModelProperty(value = "评分明细")
private String scores;
}
\ No newline at end of file
package com.xxfc.platform.tour.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description 商品评分
* @data 2019/6/18 15:15
*/
@Data
public class TourUserScoreListDTO {
/**
* 用户id
*/
@ApiModelProperty(value = "用户id")
private Integer userId;
/**
* 评价分
*/
@ApiModelProperty(value = "评价分")
private Integer aveScore;
/**
* 是否匿名;0-否;1-是
*/
@ApiModelProperty(value = "是否匿名;0-否;1-是")
private Integer isAnony;
/**
* 评价
*/
@ApiModelProperty(value = "评价")
private String comment;
/**
* 图片
*/
@ApiModelProperty(value = "图片")
private String imgs;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
}
\ No newline at end of file
package com.xxfc.platform.tour.entity;
import java.io.Serializable;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 用户评分表
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 20:27:43
*/
@Data
@Table(name = "tour_user_score")
public class TourUserScore implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
private Integer id;
/**
* 用户id
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户id")
private Integer userId;
/**
* 订单id
*/
@Column(name = "order_id")
@ApiModelProperty(value = "订单id")
private Integer orderId;
/**
* 商品id
*/
@Column(name = "model_id")
@ApiModelProperty(value = "商品id")
private Integer modelId;
/**
* 评分类型
*/
@Column(name = "type")
@ApiModelProperty(value = "评分类型")
private Integer type;
/**
* 评价分
*/
@Column(name = "ave_score")
@ApiModelProperty(value = "评价分")
private Integer aveScore;
/**
* 评分明细
*/
@Column(name = "scores")
@ApiModelProperty(value = "评分明细")
private String scores;
/**
* 是否匿名;0-否;1-是
*/
@Column(name = "is_anony")
@ApiModelProperty(value = "是否匿名;0-否;1-是")
private Integer isAnony;
/**
* 评价
*/
@Column(name = "comment")
@ApiModelProperty(value = "评价")
private String comment;
/**
* 图片
*/
@Column(name = "imgs")
@ApiModelProperty(value = "图片")
private String imgs;
/**
* 状态:0-未审核;1-已审核;2-审核不通过
*/
@Column(name = "status")
@ApiModelProperty(value = "状态:0-未审核;1-已审核;2-审核不通过")
private Integer status;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
/**
* 是否删除;0-正常;1-删除
*/
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除;0-正常;1-删除")
private Integer isDel;
}
package com.xxfc.platform.tour.vo;
import com.xxfc.platform.vehicle.constant.VehicleScoreType;
import lombok.Data;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
/**
* @author libin
* @version 1.0
* @description TODO
* @data 2019/6/18 15:45
*/
@Data
public class ScoreTypeVo {
/**
* 评分类型
*/
@Enumerated(EnumType.STRING)
private VehicleScoreType vehicleScoreType;
/**
* 评分
*/
private int score;
}
package com.xxfc.platform.tour.vo;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description 订单评价vo
* @data 2019/6/18 15:26
*/
@Data
public class TourUserScoreVo {
/**
* 主键id
*/
@ApiModelProperty("主键id")
private Integer id;
/**
* 用户id
*/
@ApiModelProperty("用户id")
private String userId;
/**
* 用户名
*/
@ApiModelProperty(value = "用户名")
private String userName;
/**
* 用户头像地址
*/
@ApiModelProperty(value = "用户头像地址")
private String headUrl;
/**
* 评分类型
*/
@ApiModelProperty(value = "评分类型")
private Integer type;
/**
* 评价分
*/
@ApiModelProperty(value = "评价分")
private Integer aveScore;
/**
* 是否匿名;0-否;1-是
*/
@ApiModelProperty(value = "是否匿名;0-否;1-是")
private Integer isAnony;
/**
* 评价
*/
@ApiModelProperty(value = "评价")
private String comment;
/**
* 图片
*/
@ApiModelProperty(value = "图片")
private String imgs;
/**
* 商品名称
*/
@ApiModelProperty(value ="商品名称")
private String name;
/**
* 商品封面
*/
@ApiModelProperty(value = "商品封面")
private String cover;
/**
* 商品描述
*/
@ApiModelProperty(value = "商品描述")
private String describes;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 类型-评分
*/
private List<ScoreTypeVo> scoreTypeVos;
}
...@@ -159,9 +159,11 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> { ...@@ -159,9 +159,11 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> {
if (effectRows==0){ if (effectRows==0){
return effectRows; return effectRows;
} }
if (CollectionUtils.isNotEmpty(tourTagBannerDTOS)) {
//保存标签轮播图 //保存标签轮播图
tourTagBannerDTOS.stream().peek(tourTagBannerDTO -> tourTagBannerDTO.setTagId(tourTagDTO.getId())).count(); tourTagBannerDTOS.stream().peek(tourTagBannerDTO -> tourTagBannerDTO.setTagId(tourTagDTO.getId())).count();
tourTagBannerBiz.saveBatch(tourTagBannerDTOS,userDTO); tourTagBannerBiz.saveBatch(tourTagBannerDTOS, userDTO);
}
return effectRows; return effectRows;
} }
...@@ -205,7 +207,9 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> { ...@@ -205,7 +207,9 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> {
if (log.isDebugEnabled()){ if (log.isDebugEnabled()){
log.debug("更改标签对应的轮播图信息:[{}]",tourTagBannerDTOS); log.debug("更改标签对应的轮播图信息:[{}]",tourTagBannerDTOS);
} }
if (CollectionUtils.isNotEmpty(tourTagBannerDTOS)){
tourTagBannerDTOS.stream().filter(tourTagBannerDTO -> Objects.isNull(tourTagBannerDTO.getTagId())).peek(tourTagBannerDTO -> tourTagBannerDTO.setTagId(tourTagDTO.getId())).count(); tourTagBannerDTOS.stream().filter(tourTagBannerDTO -> Objects.isNull(tourTagBannerDTO.getTagId())).peek(tourTagBannerDTO -> tourTagBannerDTO.setTagId(tourTagDTO.getId())).count();
}
tourTagBannerBiz.updateTourBannerByBatch(tourTagBannerDTOS,userDTO); tourTagBannerBiz.updateTourBannerByBatch(tourTagBannerDTOS,userDTO);
return effrows; return effrows;
} }
......
package com.xxfc.platform.tour.biz;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.tour.dto.ScoreTypeDTO;
import com.xxfc.platform.tour.dto.TourUserScoreDTO;
import com.xxfc.platform.tour.dto.TourUserScoreDetailDTO;
import com.xxfc.platform.tour.dto.TourUserScoreListDTO;
import com.xxfc.platform.tour.vo.ScoreTypeVo;
import com.xxfc.platform.tour.vo.TourUserScoreVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.xxfc.platform.tour.entity.TourUserScore;
import com.xxfc.platform.tour.mapper.TourUserScoreMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import javax.annotation.Resource;
import java.time.Instant;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 用户评分表
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 20:27:43
*/
@Service
@Slf4j
public class TourUserScoreBiz extends BaseBiz<TourUserScoreMapper,TourUserScore> {
@Resource
private UserFeign userFeign;
/**
* 根据商品id查询
* @param goodId
* @return
*/
public PageDataVO<TourUserScoreVo> findTourUserScorePageByGoodId(Integer goodId, Integer pageNo, Integer pageSize) {
PageDataVO<TourUserScoreVo> pageDataVO = new PageDataVO<>();
//根据模型id查找
PageDataVO<TourUserScoreListDTO> tourUserScoreDTOPageDataVO = PageDataVO.pageInfo(pageNo,pageSize,()->mapper.findyByGoodIdAndApproved(goodId,1));
List<TourUserScoreListDTO> dataVOData = tourUserScoreDTOPageDataVO.getData();
if (CollectionUtils.isEmpty(dataVOData)){
return pageDataVO;
}
if (log.isDebugEnabled()){
log.debug("根据商品id查找出的评价:【{}】",dataVOData);
}
//设置用户信息
List<Integer> userIds = dataVOData.stream().map(TourUserScoreListDTO::getUserId).distinct().collect(Collectors.toList());
List<AppUserVo> appUserVos = userFeign.getByUserIds(userIds).getData();
if (log.isDebugEnabled()){
log.debug("根据用户ids查询出用户信息:【{}】",appUserVos);
}
Map<Integer, AppUserVo> userMap = appUserVos.stream().collect(Collectors.toMap(AppUserVo::getUserid, Function.identity()));
List<TourUserScoreVo> tourUserScoreVos = dataVOData.stream().map(vehicleUserScoreListDTO -> {
TourUserScoreVo tourUserScoreVo = new TourUserScoreVo();
BeanUtils.copyProperties(vehicleUserScoreListDTO, tourUserScoreVo);
tourUserScoreVo.setUserName(userMap.get(vehicleUserScoreListDTO.getUserId()).getNickname());
tourUserScoreVo.setHeadUrl(userMap.get(vehicleUserScoreListDTO.getUserId()).getHeadimgurl());
return tourUserScoreVo;
}).sorted(Comparator.comparing(TourUserScoreVo::getCrtTime).reversed()).collect(Collectors.toList());
//组装数据
pageDataVO.setPageNum(tourUserScoreDTOPageDataVO.getPageNum());
pageDataVO.setPageSize(tourUserScoreDTOPageDataVO.getPageSize());
pageDataVO.setTotalCount(tourUserScoreDTOPageDataVO.getTotalCount());
pageDataVO.setTotalPage(tourUserScoreDTOPageDataVO.getTotalPage());
pageDataVO.setData(tourUserScoreVos);
return pageDataVO;
}
/**
* 保存评分
* @param tourUserScoreDTO
* @return
*/
public int saveTourUserScore(TourUserScoreDTO tourUserScoreDTO, AppUserDTO appUserDTO) {
if (log.isDebugEnabled()){
log.debug("用户:【{}】,评分的数据:【{}】",appUserDTO.getNickname(),tourUserScoreDTO);
}
tourUserScoreDTO.setCrtTime(Instant.now().toEpochMilli());
List<ScoreTypeDTO> scoretype = tourUserScoreDTO.getScoretype();
int avgScore =0;
if (CollectionUtils.isNotEmpty(scoretype)) {
//评分明细
tourUserScoreDTO.setScores(JSONObject.toJSONString(scoretype));
//计算平均分值
double avgScored = scoretype.stream().mapToInt(ScoreTypeDTO::getScore).average().getAsDouble();
avgScore = Long.valueOf(Math.round(avgScored)).intValue();
//更改商品的评分
/* if (0 != avgScore) {
tourGoodBiz.updateScoreByModelIdAndavgScore(tourUserScoreDTO.getGoodId(), avgScore);
}*/
}
TourUserScore trourUserScore = new TourUserScore();
BeanUtils.copyProperties(tourUserScoreDTO,trourUserScore);
trourUserScore.setAveScore(avgScore);
trourUserScore.setUserId(appUserDTO.getUserid());
trourUserScore.setUpdTime(Instant.now().toEpochMilli());
return mapper.insertSelective(trourUserScore);
}
/**
* 根据订单id查询订单评价
* @param orderId
* @return
*/
public TourUserScoreVo findTourUserScoreDetailByOrderId(Integer orderId) {
TourUserScoreVo toureUserScoreVo = new TourUserScoreVo();
//根据订单id查询
TourUserScoreDetailDTO tourUserScoreDetailDTO = mapper.findTourUserScoreDetailByOrderId(orderId);
if (log.isDebugEnabled()){
log.debug("根据订单id:【{}】查询到的订单评价内容:【{}】",orderId,tourUserScoreDetailDTO);
}
BeanUtils.copyProperties(tourUserScoreDetailDTO,toureUserScoreVo);
//评分明细数据转换
String scores = tourUserScoreDetailDTO.getScores();
if (StringUtils.isNotEmpty(scores)){
List<ScoreTypeVo> typeVos = JSONObject.parseObject(scores, new TypeReference<List<ScoreTypeVo>>() {});
toureUserScoreVo.setScoreTypeVos(typeVos);
}
//根据用户id查询用户信息
ObjectRestResponse<List<AppUserVo>> appuserResponse = userFeign.getByUserIds(Arrays.asList(tourUserScoreDetailDTO.getUserId()));
if (log.isDebugEnabled()){
log.debug("根据用户id:【{}】查询到的用户信息:【{}】",tourUserScoreDetailDTO.getUserId(),appuserResponse.getData());
}
AppUserVo appUserVo = appuserResponse.getData().get(0);
toureUserScoreVo.setUserName(appUserVo.getNickname());
toureUserScoreVo.setHeadUrl(appUserVo.getHeadimgurl());
return toureUserScoreVo;
}
}
\ No newline at end of file
package com.xxfc.platform.tour.mapper;
import com.xxfc.platform.tour.dto.TourUserScoreDetailDTO;
import com.xxfc.platform.tour.dto.TourUserScoreListDTO;
import com.xxfc.platform.tour.entity.TourUserScore;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 用户评分表
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 20:27:43
*/
public interface TourUserScoreMapper extends Mapper<TourUserScore> {
/**
* 根据审核状态和车型id查询评论
* @param goodId
* @param status
* @return
*/
@Select("select `user_id` as `userId`,`comment` as `comment`,`ave_score` as `aveScore`,`is_anony` as `isAnony`,`imgs` as `imgs`,`crt_time` as `crtTime` from `tour_user_score` where `model_id`=#{goodId}")
List<TourUserScoreListDTO> findyByGoodIdAndApproved(@Param("goodId") Integer goodId, @Param("status") Integer status);
/**
* 根据订单查询评价
* @param orderId
* @return
*/
TourUserScoreDetailDTO findTourUserScoreDetailByOrderId(Integer orderId);
}
package com.xxfc.platform.tour.rest;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.annotation.BeanValid;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.tour.biz.TourUserScoreBiz;
import com.xxfc.platform.tour.dto.TourUserScoreDTO;
import com.xxfc.platform.tour.entity.TourUserScore;
import com.xxfc.platform.tour.vo.TourUserScoreVo;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("tourUserScore")
public class TourUserScoreController extends BaseController<TourUserScoreBiz,TourUserScore> {
/**
* 保存评论
* @param tourUserScoreDTO
* @param appUserDTO
* @return
*/
@PostMapping("/score")
public ObjectRestResponse<Void> saveTourUserScore(@RequestBody @BeanValid TourUserScoreDTO tourUserScoreDTO, AppUserDTO appUserDTO){
int effectRows = getBaseBiz().saveTourUserScore(tourUserScoreDTO,appUserDTO);
if (effectRows>0){
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
/**
* 根据车型查询评论列表 根据评分时间排序
*
* @param modelId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/app/unauth/scores")
public ObjectRestResponse<PageDataVO<TourUserScoreVo>> findVehicleUserScorePageByModelId(@RequestParam("modelId") Integer modelId,
@RequestParam(value = "pageNo",required = false,defaultValue = "1")Integer pageNo,
@RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize) {
PageDataVO<TourUserScoreVo> pageDataVO = getBaseBiz().findTourUserScorePageByGoodId(modelId,pageNo,pageSize);
return ObjectRestResponse.succ(pageDataVO);
}
/**
* 根据订单id查询评价详情
* @param orderId
* @return
*/
@GetMapping("/score/order/{orderId}")
public ObjectRestResponse findVehicleUserScoreDetailByOrderId(@PathVariable("orderId") Integer orderId){
TourUserScoreVo vehicleUserScoreVo = getBaseBiz().findTourUserScoreDetailByOrderId(orderId);
return ObjectRestResponse.succ(vehicleUserScoreVo);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.tour.mapper.TourUserScoreMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.tour.entity.TourUserScore" id="tourUserScoreMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="orderId" column="order_id"/>
<result property="modelId" column="model_id"/>
<result property="type" column="type"/>
<result property="aveScore" column="ave_score"/>
<result property="scores" column="scores"/>
<result property="isAnony" column="is_anony"/>
<result property="comment" column="comment"/>
<result property="imgs" column="imgs"/>
<result property="status" column="status"/>
<result property="crtTime" column="crt_time"/>
<result property="updTime" column="upd_time"/>
<result property="isDel" column="is_del"/>
</resultMap>
<select id="findTourUserScoreDetailByOrderId"
resultType="com.xxfc.platform.tour.dto.TourUserScoreDetailDTO">
SELECT tus.user_id as `userId`,tus.ave_score as `aveScore`,tus.comment as `comment`, tus.imgs as `imgs`,tus.crt_time as `crtTime`,tus.scores as `scores`,tg.name as `name`,tg.describes as `describes`,tg.cover as `cover`
FROM `tour_user_score` as `tus` left JOIN `tour_good` as `tg` on tus.model_id=tg.id WHERE tus.order_id=#{orderId} ;
</select>
</mapper>
...@@ -24,7 +24,7 @@ public interface VehicleUserScoreMapper extends Mapper<VehicleUserScore> { ...@@ -24,7 +24,7 @@ public interface VehicleUserScoreMapper extends Mapper<VehicleUserScore> {
* @param status * @param status
* @return * @return
*/ */
@Select("select `user_id` as `userId`,`comment` as `comment`,`ave_score` as `aveScore`,`is_anony` as `isAnony`,`imgs` as `imgs`,`crt_time` as `crtTime` from `vehicle_user_score` where `model_id`=#{modelId} and `status`=#{status}") @Select("select `user_id` as `userId`,`comment` as `comment`,`ave_score` as `aveScore`,`is_anony` as `isAnony`,`imgs` as `imgs`,`crt_time` as `crtTime` from `vehicle_user_score` where `model_id`=#{modelId}")
List<VehicleUserScoreListDTO> findyByModelIdAndApproved(@Param("modelId") Integer modelId, @Param("status") Integer status); List<VehicleUserScoreListDTO> findyByModelIdAndApproved(@Param("modelId") Integer modelId, @Param("status") Integer status);
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment