فهرست منبع

投票活动页

zhijiezhao 1 سال پیش
والد
کامیت
e803d6193b

+ 43 - 101
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -16,10 +16,12 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import jdk.nashorn.internal.ir.ReturnNode;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -41,6 +43,23 @@ public class ProductPageApi {
 
     private final PageService pageService;
 
+    @ApiOperation("投票页详情")
+    @GetMapping("/vote/list")
+    public ResponseJson<Map<String, Object>> voteList() {
+        return pageService.getVoteList();
+    }
+
+    @ApiOperation("按钮投票")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "id", value = "投票id"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = true, name = "voteType", value = "1供应商投票,2商品品类投票")
+    })
+    @PostMapping("/push/vote")
+    public ResponseJson vote(Integer id, Integer userId, Integer voteType, HttpServletRequest request) {
+        return pageService.vote(id, userId, voteType,request);
+    }
+
     @ApiOperation("删除sku")
     @ApiImplicitParam(required = true, name = "skuId", value = "skuId")
     @GetMapping("/del/sku")
@@ -55,11 +74,7 @@ public class ProductPageApi {
      * @param source   请求来源:www,crm
      */
     @ApiOperation("获取分类菜单(旧:/product/classify)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = true, name = "typeSort", value = "分类类型:1产品,2仪器,0全部"),
-            @ApiImplicitParam(required = false, name = "source", value = "请求来源:www,crm"),
-            @ApiImplicitParam(required = false, name = "mallType", value = "商城类型:1采美,2呵呵")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = true, name = "typeSort", value = "分类类型:1产品,2仪器,0全部"), @ApiImplicitParam(required = false, name = "source", value = "请求来源:www,crm"), @ApiImplicitParam(required = false, name = "mallType", value = "商城类型:1采美,2呵呵")})
     @GetMapping("/classify")
     public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source, Integer mallType) {
         return pageService.getClassify(typeSort, source, mallType);
@@ -73,11 +88,7 @@ public class ProductPageApi {
      * @param source 来源:1网站,2小程序
      */
     @ApiOperation("产品/仪器页面数据(旧:/home/instrumentData)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = true, name = "pageId", value = "页面信息id"),
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = true, name = "pageId", value = "页面信息id"), @ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")})
     @GetMapping("/classify/product")
     public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source) {
         if (pageId == null) {
@@ -93,10 +104,7 @@ public class ProductPageApi {
      * @param source 来源 : 1 网站 ; 2 小程序
      */
     @ApiOperation("首页楼层数据(旧:/home/data)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")})
     @IpSave(saveName = "首页楼层", saveParams = true)
     @GetMapping("/home/floor")
     public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source) {
@@ -110,18 +118,13 @@ public class ProductPageApi {
         return pageService.getNewFloorRecommend();
     }
 
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "brandID", value = "品牌id"),
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "brandID", value = "品牌id"),
 
     })
     @ApiOperation("新品橱窗列表")
     @IpSave(saveName = "新品橱窗商品列表", saveParams = false)
     @GetMapping("/home/NewFloorList")
-    public ResponseJson<PaginationVo<ProductItemVo>> getNewFloorList(Integer source,
-                                                                     Integer userId,
-                                                                     @RequestParam(value = "brandID", required = false) List<String> brandID,
-                                                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                     @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+    public ResponseJson<PaginationVo<ProductItemVo>> getNewFloorList(Integer source, Integer userId, @RequestParam(value = "brandID", required = false) List<String> brandID, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
 
         return pageService.getNewFloorList(source, userId, brandID, pageNum, pageSize);
     }
@@ -148,8 +151,7 @@ public class ProductPageApi {
     @ApiOperation("公告展示列表")
     @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
     @GetMapping("/home/title")
-    ResponseJson<PaginationVo<AnnouncementPo>> getannlist(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                          @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+    ResponseJson<PaginationVo<AnnouncementPo>> getannlist(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         return pageService.getannlist(pageNum, pageSize);
     }
 
@@ -200,10 +202,7 @@ public class ProductPageApi {
      * @param source 来源 : 1 网站 ; 2 小程序
      */
     @ApiOperation("二级专题页楼层数据(旧:/page/topic, /page/topic/info)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "pageId", value = "页面id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "pageId", value = "页面id"), @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")})
     @GetMapping("/page/floor")
     public ResponseJson<Map<String, Object>> getPageFloors(Integer pageId, Integer source) {
         return pageService.getPageFloors(pageId, source);
@@ -217,11 +216,7 @@ public class ProductPageApi {
      * @param source 来源 : 1 网站 ; 2 小程序
      */
     @ApiOperation("活动专题楼层数据(美博会)(旧:/home/activity/data)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "pageId", value = "页面id"),
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "pageId", value = "页面id"), @ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")})
     @GetMapping("/page/beauty")
     public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source) {
         return pageService.getPageBeautyData(pageId, userId, source);
@@ -235,11 +230,7 @@ public class ProductPageApi {
      * @param source  来源 : 1 网站 ; 2 小程序
      */
     @ApiOperation("楼层详情(旧:/home/floorContentDetails)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "floorId", value = "楼层id"),
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "floorId", value = "楼层id"), @ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")})
     @GetMapping("/page/floor/details")
     public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source) {
         return pageService.getPageFloorData(floorId, userId, source);
@@ -253,11 +244,7 @@ public class ProductPageApi {
      * @param source   来源 : 1 网站 ; 2 小程序
      */
     @ApiOperation("分页详情楼层详情(旧:/home/pageFloorDetails)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "centreId", value = "分页详情楼层id"),
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "centreId", value = "分页详情楼层id"), @ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")})
     @GetMapping("/page/floor/centre")
     public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source) {
         return pageService.getPageCentreData(centreId, userId, source);
@@ -271,10 +258,7 @@ public class ProductPageApi {
      *                  Statistics统计存入Redis的hash => prefix + ":" + field + ":" + date("yyyyMMdd");
      */
     @ApiOperation("商品详情页(旧:/product/details)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "productId", value = "商品Id")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "productId", value = "商品Id")})
     @IpSave(saveName = "商品详情", saveParams = true)
     @Statistics(prefix = "statistics_details", field = "productId")
     @GetMapping("/product/details")
@@ -290,10 +274,7 @@ public class ProductPageApi {
      *                  Statistics统计存入Redis的hash => prefix + ":" + field + ":" + date("yyyyMMdd");
      */
     @ApiOperation("商品详情页(旧:/product/details)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "productId", value = "商品Id")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "productId", value = "商品Id")})
     @GetMapping("/product/organizeDetails")
     public ResponseJson<ProductDetailVo> getProductOrganizeDetails(Integer productId, Integer userId) {
         return pageService.getProductOrganizeDetails(productId, userId);
@@ -305,15 +286,9 @@ public class ProductPageApi {
      * @param userId 用户Id
      */
     @ApiOperation("再次购买商品列表(旧:/repeat/buyAgain)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
-            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户Id"), @ApiImplicitParam(required = false, name = "pageNum", value = "页码"), @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")})
     @GetMapping("/product/repeat")
-    public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId,
-                                                                         @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                         @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+    public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
         return pageService.getBuyAgainProducts(userId, pageNum, pageSize);
     }
 
@@ -322,10 +297,7 @@ public class ProductPageApi {
      * 项目仪器详情页
      */
     @ApiOperation("项目仪器详情页(旧:/equipment/recommend)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "equipmentId", value = "项目仪器Id")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "equipmentId", value = "项目仪器Id")})
     @GetMapping("/equipment/details")
     @ResponseBody
     public ResponseJson<PageDetailVo> getEquipmentDetails(Integer equipmentId, Integer userId) {
@@ -365,11 +337,7 @@ public class ProductPageApi {
      * @param userId        用户Id
      */
     @ApiOperation("商品详情-相关推荐(旧:/product/detail/recommend)")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "productId", value = "商品Id"),
-            @ApiImplicitParam(required = false, name = "recommendType", value = "相关推荐类型: 0自动选择, 1手动推荐"),
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "productId", value = "商品Id"), @ApiImplicitParam(required = false, name = "recommendType", value = "相关推荐类型: 0自动选择, 1手动推荐"), @ApiImplicitParam(required = false, name = "userId", value = "用户id")})
     @GetMapping("/detail/recommend")
     public ResponseJson<List<ProductListVo>> getProductDetailRecommends(Integer productId, Integer recommendType, Integer userId) {
         return pageService.getProductDetailRecommends(productId, recommendType, userId);
@@ -392,19 +360,10 @@ public class ProductPageApi {
      * 商品资料列表
      */
     @ApiOperation("商品资料列表")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键词"),
-            @ApiImplicitParam(required = false, name = "productType", value = "商品属性:1产品,2仪器"),
-            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "keyword", value = "搜索关键词"), @ApiImplicitParam(required = false, name = "productType", value = "商品属性:1产品,2仪器"), @ApiImplicitParam(required = false, name = "pageNum", value = "页码"), @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")})
     @IpSave(saveName = "美业资料搜索", saveParams = true)
     @GetMapping("/product/archive")
-    public ResponseJson<PaginationVo<ArchiveVo>> getProductArchive(String keyword, Integer productType,
-                                                                   @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                   @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
-                                                                   @RequestParam(value = "productFlag", defaultValue = "1") int productFlag,
-                                                                   @RequestParam(value = "linkageFlag", defaultValue = "0") int linkageFlag) {
+    public ResponseJson<PaginationVo<ArchiveVo>> getProductArchive(String keyword, Integer productType, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, @RequestParam(value = "productFlag", defaultValue = "1") int productFlag, @RequestParam(value = "linkageFlag", defaultValue = "0") int linkageFlag) {
         return pageService.getProductArchive(keyword, productType, pageNum, pageSize);
     }
 
@@ -412,10 +371,7 @@ public class ProductPageApi {
      * 商品资料详情
      */
     @ApiOperation("商品资料详情")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "archiveId", value = "资料id"),
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "archiveId", value = "资料id"), @ApiImplicitParam(required = false, name = "userId", value = "用户id"),})
     @GetMapping("/product/archive/detail")
     public ResponseJson<ArchiveDetailVo> getArchiveDetail(Integer archiveId, Integer userId) {
         if (null == archiveId || null == userId) {
@@ -432,16 +388,9 @@ public class ProductPageApi {
      * @return
      */
     @ApiOperation("超级会员优惠商品页面")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源 : 1 网站 ; 2 小程序"),
-            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = false, name = "userId", value = "用户id"), @ApiImplicitParam(required = false, name = "source", value = "来源 : 1 网站 ; 2 小程序"), @ApiImplicitParam(required = false, name = "pageNum", value = "页码"), @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")})
     @GetMapping("/svip/product/page")
-    public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source,
-                                                                @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+    public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         if (null == userId || source == null) {
             return ResponseJson.error("参数错误", null);
         }
@@ -491,15 +440,9 @@ public class ProductPageApi {
      * 采美百科产品仪器分类数据
      */
     @ApiOperation("采美百科产品仪器分类数据")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = true, name = "typeId", value = "分类id"),
-            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
-    })
+    @ApiImplicitParams({@ApiImplicitParam(required = true, name = "typeId", value = "分类id"), @ApiImplicitParam(required = false, name = "pageNum", value = "页码"), @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),})
     @GetMapping("/baike/type")
-    public ResponseJson<PaginationVo<BaikeProductVo>> getBaikeTypeData(Integer typeId,
-                                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                       @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+    public ResponseJson<PaginationVo<BaikeProductVo>> getBaikeTypeData(Integer typeId, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         if (null == typeId) {
             return ResponseJson.error("参数异常", null);
         }
@@ -519,8 +462,7 @@ public class ProductPageApi {
      * @return
      */
     @GetMapping("/get/authuser/list")
-    public ResponseJson<PaginationVo<BaikeProductVo>> getAuthUserList(Integer id, String name, Integer typeId, Integer auditStatus, Integer onlineStatus, Integer status, Integer shopId, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                      @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+    public ResponseJson<PaginationVo<BaikeProductVo>> getAuthUserList(Integer id, String name, Integer typeId, Integer auditStatus, Integer onlineStatus, Integer status, Integer shopId, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         BaikeProductVo baikeProductVo = new BaikeProductVo();
         baikeProductVo.setProductId(id);
         baikeProductVo.setName(name);

+ 8 - 0
src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -499,4 +499,12 @@ public interface PageMapper {
     List<String> findLabels(String labelIds);
 
     String findKeyWordId(String labelId);
+
+    List<VotePageVo> findVoteList();
+
+    List<CategoryVoteVo> findCategoryVote();
+
+    void updateVote(Integer id, Integer voteType);
+
+    void insertVote(String ip, Integer userId, Integer id, Integer voteType);
 }

+ 21 - 0
src/main/java/com/caimei365/commodity/model/vo/CategoryVoteVo.java

@@ -0,0 +1,21 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+@Data
+public class CategoryVoteVo {
+
+    private Integer id;
+    /**
+     * 品类名称
+     */
+    private String name;
+    /**
+     * 得票数
+     */
+    private Integer voteNum;
+    /**
+     * 得票排行
+     */
+    private Integer rank;
+}

+ 35 - 0
src/main/java/com/caimei365/commodity/model/vo/VotePageVo.java

@@ -0,0 +1,35 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+@Data
+public class VotePageVo {
+
+    private Integer id;
+    private Integer shopId;
+    private String shopName;
+    /**
+     * 跳转商品Id
+     */
+    private Integer productId;
+    /**
+     * 供应商logo,默认从shop表中取
+     */
+    private String shopLogo;
+    /**
+     * 供应商介绍,如果未提供则从shop表取
+     */
+    private String shopIntroduction;
+    /**
+     *  得票数量
+     */
+    private Integer voteNum;
+    /**
+     * 供应商官网网址,未提供则从shop取
+     */
+    private String shopWebsite;
+    /**
+     * 得票排名
+     */
+    private Integer rank;
+}

+ 4 - 0
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -7,6 +7,7 @@ import com.caimei365.commodity.model.po.ProductPo;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 import java.util.Map;
 
@@ -349,4 +350,7 @@ public interface PageService {
      */
     ResponseJson insertEntryInfo(BaikeProductVo baikeProductVo);
 
+    ResponseJson<Map<String,Object>> getVoteList();
+
+    ResponseJson vote(Integer id, Integer userId,  Integer voteType,HttpServletRequest request);
 }

+ 58 - 9
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -3,6 +3,7 @@ package com.caimei365.commodity.service.impl;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.caimei365.commodity.components.PriceUtilService;
+import com.caimei365.commodity.components.RedisService;
 import com.caimei365.commodity.mapper.*;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.dto.Sku;
@@ -24,8 +25,12 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -62,6 +67,8 @@ public class PageServiceImpl implements PageService {
     private CmDistributionMapper cmDistributionMapper;
     @Resource
     private CmDistributionProductMapper cmDistributionProductMapper;
+    @Resource
+    private RedisService redisService;
     @Value("${spring.cloud.config.profile}")
     private String active;
 
@@ -572,7 +579,7 @@ public class PageServiceImpl implements PageService {
      */
     @Override
     public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId) {
-        Integer identity =0;
+        Integer identity = 0;
         if (null != userId && userId > 0) {
             // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
             identity = priceMapper.getIdentityByUserId(userId);
@@ -1251,7 +1258,7 @@ public class PageServiceImpl implements PageService {
             return ResponseJson.error("商品资料不存在", null);
         }
         // 判断该用户是否拥有访问该资料的权限
-        int permission = checkArchivePermission(archive.getProductId(),archive.getProductClassify(), userId);
+        int permission = checkArchivePermission(archive.getProductId(), archive.getProductClassify(), userId);
         List<ArchiveContentVo> imageArchiveList = pageMapper.getImageArchiveList(archiveId);
         List<ArchiveContentVo> videoArchiveList = pageMapper.getVideoArchiveList(archiveId);
         List<ArchiveContentVo> fileArchiveList = pageMapper.getFileArchiveList(archiveId);
@@ -1277,7 +1284,7 @@ public class PageServiceImpl implements PageService {
             if (0 == finalPermission && null != archiveFile) {
                 String fileUrl = generateFileUrl(archiveFile);
                 videoArchive.setFileUrl(fileUrl);
-            } else if (3 == finalPermission  && null != archiveFile) {
+            } else if (3 == finalPermission && null != archiveFile) {
                 String fileUrl = generateFileUrl(archiveFile);
                 videoArchive.setFileUrl(fileUrl);
             }
@@ -1322,7 +1329,7 @@ public class PageServiceImpl implements PageService {
         return ResponseJson.success(archiveDetail);
     }
 
-    private Integer checkArchivePermission(Integer productId,Integer productClassify, Integer userId) {
+    private Integer checkArchivePermission(Integer productId, Integer productClassify, Integer userId) {
         // 根据用户Id查询用户身份
         Integer identity = priceMapper.getIdentityByUserId(userId);
         // 1生美机构,2医美机构
@@ -1339,10 +1346,7 @@ public class PageServiceImpl implements PageService {
                 if (!byCmDistribution.parentId().equals("0")) {
                     byCmDistribution.id(String.valueOf(byCmDistribution.parentId()));
                 }
-                int productCount = cmDistributionProductMapper.getCmDistributionTeamProductCount(new CmDistributionTeamProduct()
-                        .distributionId(Integer.valueOf(byCmDistribution.id()))
-                        .productId(productId)
-                );
+                int productCount = cmDistributionProductMapper.getCmDistributionTeamProductCount(new CmDistributionTeamProduct().distributionId(Integer.valueOf(byCmDistribution.id())).productId(productId));
                 // 商品团队不存在该商品的访问权限
                 if (productCount == 0) {
                     return 5;
@@ -1377,7 +1381,7 @@ public class PageServiceImpl implements PageService {
         } catch (ParseException e) {
             log.info("格式化时间错误", e);
         }
-        String url = ossClient.generatePresignedUrl(bucketName,  ossName, expiration).toString();
+        String url = ossClient.generatePresignedUrl(bucketName, ossName, expiration).toString();
         ossClient.shutdown();
         return AesEncryptUtil.encrypt(url);
     }
@@ -1830,4 +1834,49 @@ public class PageServiceImpl implements PageService {
         }
         return ResponseJson.success();
     }
+
+    @Override
+    public ResponseJson<Map<String, Object>> getVoteList() {
+        Map<String, Object> map = new HashMap<>();
+        List<VotePageVo> voteList = pageMapper.findVoteList();
+        List<CategoryVoteVo> categoryVoteList = pageMapper.findCategoryVote();
+        map.put("voteList", voteList);
+        map.put("categoryList", categoryVoteList);
+        return ResponseJson.success(map);
+    }
+
+    @Override
+    public ResponseJson vote(Integer id, Integer userId, Integer voteType, HttpServletRequest request) {
+        String ip = "";
+        String unknown = "unknown";
+        ip = request.getHeader("x-forwarded-for");
+        if (StringUtils.isBlank(ip)) {
+            ip = request.getHeader("X-Real-IP");
+        }
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+        }
+        String key = id + "-" + voteType + ip;
+        boolean exists = redisService.exists(key);
+        if (exists) {
+            String word = 1 == voteType ? "您今天已经为该供应商投过票" : "您今天已经为该品类投过票";
+            return ResponseJson.error(word);
+        } else {
+            LocalDateTime now = LocalDateTime.now();
+            LocalDateTime expirationTime = now.with(LocalTime.of(23, 59, 59));
+            long durationUntilExpiration = ChronoUnit.SECONDS.between(now, expirationTime);
+            redisService.set(key, userId, durationUntilExpiration);
+            pageMapper.updateVote(id, voteType);
+            pageMapper.insertVote(ip, userId, id, voteType);
+        }
+        return ResponseJson.success("投票成功!");
+    }
 }

+ 207 - 109
src/main/resources/mapper/PageMapper.xml

@@ -120,7 +120,8 @@
     </select>
     <select id="getFloorImageByCentreId" resultType="com.caimei365.commodity.model.vo.FloorImageVo">
         select
-        id, floorId, centreId, productId, name, link, image, appletsImage,adsImage, label,content, pcStatus, appletsStatus, sort,displaySort, createDate
+        id, floorId, centreId, productId, name, link, image, appletsImage,adsImage, label,content, pcStatus,
+        appletsStatus, sort,displaySort, createDate
         from new_page_floor_image
         where centreId = #{id}
         <if test="source == 1">
@@ -135,51 +136,65 @@
         </if>
     </select>
     <select id="getProductItemById" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
-        select p.productID                                                                          as productId,
+        select p.productID         as productId,
                p.actStatus,
                p.name,
                p.aliasName,
-               p.mainImage                                                                          as image,
-               p.productCode                                                                        as code,
+               p.mainImage         as image,
+               p.productCode       as code,
                p.priceFlag,
-               (select unit from cm_sku where productID = #{productId} and organizeId = 0 order by price asc LIMIT 1)  as unit,
-               (select price from cm_sku where productID = #{productId} and organizeId = 0 order by price asc LIMIT 1) as price,
+               (select unit
+                from cm_sku
+                where productID = #{productId}
+                  and organizeId = 0
+                order by price asc
+                LIMIT 1)           as unit,
+               (select price
+                from cm_sku
+                where productID = #{productId}
+                  and organizeId = 0
+                order by price asc
+                LIMIT 1)           as price,
                (select price
                 from cm_sku
-                where productID = #{productId} and organizeId = 0
+                where productID = #{productId}
+                  and organizeId = 0
                 order by price asc
-                LIMIT 1)                                                                            as originalPrice,
-               p.shopID                                                                             as shopId,
-               p.searchKey                                                                          as keyword,
+                LIMIT 1)           as originalPrice,
+               p.shopID            as shopId,
+               p.searchKey         as keyword,
                (select minBuyNumber
                 from cm_sku
-                where productID = #{productId} and organizeId = 0
+                where productID = #{productId}
+                  and organizeId = 0
                 order by price asc
-                LIMIT 1)                                                                            as minBuyNumber,
+                LIMIT 1)           as minBuyNumber,
                (select ladderPriceFlag
                 from cm_sku
-                where productID = #{productId} and organizeId = 0
+                where productID = #{productId}
+                  and organizeId = 0
                 order by price asc
-                LIMIT 1)                                                                            as ladderPriceFlag,
+                LIMIT 1)           as ladderPriceFlag,
                (select normalPrice
                 from cm_sku
-                where productID = #{productId} and organizeId = 0
+                where productID = #{productId}
+                  and organizeId = 0
                 order by price asc
-                LIMIT 1)                                                                            as normalPrice,
+                LIMIT 1)           as normalPrice,
                p.step,
-               p.shopID                                                                             as shopId,
-               p.taxPoint                                                                           as taxRate,
+               p.shopID            as shopId,
+               p.taxPoint          as taxRate,
                p.includedTax,
                p.invoiceType,
-               p.productCategory                                                                    as productCategory,
+               p.productCategory   as productCategory,
                copi.validFlag,
                p.featuredFlag,
                p.commodityType,
-               p.bigTypeID                                                                          as bigTypeId,
-               p.smallTypeID                                                                        as smallTypeId,
-               p.tinyTypeID                                                                         as tinyTypeId,
-               p.visibility                                                                         as visibility,
-               cshd.detailTalkFlag                                                                  as detailTalkFlag,
+               p.bigTypeID         as bigTypeId,
+               p.smallTypeID       as smallTypeId,
+               p.tinyTypeID        as tinyTypeId,
+               p.visibility        as visibility,
+               cshd.detailTalkFlag as detailTalkFlag,
                p.productType
         from product p
                  left join cm_second_hand_detail cshd on p.productID = cshd.productID
@@ -210,35 +225,50 @@
         order by - sort desc,createDate desc
     </select>
     <select id="getOrganizeId" resultType="java.lang.Integer">
-        SELECT userOrganizeID FROM USER WHERE userId = #{userId}
+        SELECT userOrganizeID
+        FROM USER
+        WHERE userId = #{userId}
     </select>
     <select id="getProductDetails" resultType="com.caimei365.commodity.model.vo.ProductDetailVo">
-        select p.productID                                                                                     as productId,
-               p.shopID                                                                                        as shopId,
+        select p.productID         as productId,
+               p.shopID            as shopId,
                (select normalPrice
                 from cm_sku
-                where productId = #{productId} and organizeId = 0
+                where productId = #{productId}
+                  and organizeId = 0
                 order by price asc
-                limit 1)                                                                                       as normalPrice,
-               ifnull((select stock from cm_sku where productId = #{productId} and organizeId = 0 order by price asc limit 1), 0) as stock,
+                limit 1)           as normalPrice,
+               ifnull((select stock
+                       from cm_sku
+                       where productId = #{productId}
+                         and organizeId = 0
+                       order by price asc
+                       limit 1),
+                      0)           as stock,
                (select minBuyNumber
                 from cm_sku
-                where productId = #{productId} and organizeId = 0
+                where productId = #{productId}
+                  and organizeId = 0
+                order by price asc
+                limit 1)           as minBuyNumber,
+               (select unit
+                from cm_sku
+                where productId = #{productId}
+                  and organizeId = 0
                 order by price asc
-                limit 1)                                                                                       as minBuyNumber,
-               (select unit from cm_sku where productId = #{productId} and organizeId = 0 order by price asc limit 1)             as unit,
+                limit 1)           as unit,
                p.name,
                p.aliasName,
                p.commodityType,
                p.mainImage,
                p.invoiceType,
-               p.bigTypeID                                                                                     as bigTypeId,
-               p.smallTypeID                                                                                   as smallTypeId,
-               p.tinyTypeID                                                                                    as tinyTypeId,
+               p.bigTypeID         as bigTypeId,
+               p.smallTypeID       as smallTypeId,
+               p.tinyTypeID        as tinyTypeId,
                p.searchKey,
                p.visibility,
                p.commodityDetailsFlag,
-               p.brandID                                                                                       as brandId,
+               p.brandID           as brandId,
                p.productType,
                p.tags,
                p.includedTax,
@@ -257,7 +287,8 @@
                p.machineType,
                p.productCode,
                p.updateTime,
-               IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
+               IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 0),
+                      999)         AS validFlag,
                p.searchKey,
                p.allAreaFlag,
                p.step,
@@ -267,12 +298,12 @@
                p.trainingType,
                p.trainingFee,
                p.productRemarks,
-               p.productDetail                                                                                 as productDetailChose,
-               s.shopType                                                                                      as shopType,
-               p.qualificationNo                                                                               as qualificationNo,
-               p.productName                                                                                   as productName,
-               p.qualificationTime                                                                             as qualificationTime,
-               p.qualificationLink                                                                             as qualificationLink,
+               p.productDetail     as productDetailChose,
+               s.shopType          as shopType,
+               p.qualificationNo   as qualificationNo,
+               p.productName       as productName,
+               p.qualificationTime as qualificationTime,
+               p.qualificationLink as qualificationLink,
                p.returnGoodsStutas,
                P.relatedLabels
         from product p
@@ -280,27 +311,32 @@
         where p.productID = #{productId}
     </select>
     <select id="getProductOrganizeDetails" resultType="com.caimei365.commodity.model.vo.ProductDetailVo">
-        select p.productID                                                                                     as productId,
-               p.shopID                                                                                        as shopId,
+        select p.productID         as productId,
+               p.shopID            as shopId,
                (select minBuyNumber
                 from cm_sku
-                where productId = #{productId} and organizeId = 4
+                where productId = #{productId}
+                  and organizeId = 4
+                order by price asc
+                limit 1)           as minBuyNumber,
+               (select unit
+                from cm_sku
+                where productId = #{productId}
+                  and organizeId = 4
                 order by price asc
-                limit 1)                                                                                       as minBuyNumber,
-               (select unit from cm_sku
-               where productId = #{productId} and organizeId = 4 order by price asc limit 1)             as unit,
+                limit 1)           as unit,
                p.name,
                p.aliasName,
                p.commodityType,
                p.mainImage,
                p.invoiceType,
-               p.bigTypeID                                                                                     as bigTypeId,
-               p.smallTypeID                                                                                   as smallTypeId,
-               p.tinyTypeID                                                                                    as tinyTypeId,
+               p.bigTypeID         as bigTypeId,
+               p.smallTypeID       as smallTypeId,
+               p.tinyTypeID        as tinyTypeId,
                p.searchKey,
                p.visibility,
                p.commodityDetailsFlag,
-               p.brandID                                                                                       as brandId,
+               p.brandID           as brandId,
                p.productType,
                p.tags,
                p.includedTax,
@@ -319,7 +355,8 @@
                p.machineType,
                p.productCode,
                p.updateTime,
-               IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 4), 999) AS validFlag,
+               IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 4),
+                      999)         AS validFlag,
                p.searchKey,
                p.allAreaFlag,
                p.step,
@@ -329,12 +366,12 @@
                p.trainingType,
                p.trainingFee,
                p.productRemarks,
-               p.productDetail                                                                                 as productDetailChose,
-               s.shopType                                                                                      as shopType,
-               p.qualificationNo                                                                               as qualificationNo,
-               p.productName                                                                                   as productName,
-               p.qualificationTime                                                                             as qualificationTime,
-               p.qualificationLink                                                                             as qualificationLink,
+               p.productDetail     as productDetailChose,
+               s.shopType          as shopType,
+               p.qualificationNo   as qualificationNo,
+               p.productName       as productName,
+               p.qualificationTime as qualificationTime,
+               p.qualificationLink as qualificationLink,
                p.returnGoodsStutas,
                P.relatedLabels
         from product p
@@ -342,35 +379,38 @@
         where p.productID = #{productId}
     </select>
     <select id="getBuyAgainProducts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
-        select p.productID                 as productId,
+        select p.productID                                   as productId,
                p.actStatus,
                p.name,
                p.aliasName,
-               p.mainImage                 as image,
+               p.mainImage                                   as image,
                rpp.skuId,
                cs.unit,
-               p.productCode               as code,
+               p.productCode                                 as code,
                p.priceFlag,
                cs.price,
                cs.costPrice,
-               ifnull((SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ), 1) as costCheckFlag,
-               p.searchKey                 as keyword,
-               cs.minBuyNumber             as minBuyNumber,
+               ifnull((SELECT costCheckFlag
+                       FROM cm_organize_product_info
+                       WHERE productId = cs.productId
+                         AND organizeId = cs.organizeId), 1) as costCheckFlag,
+               p.searchKey                                   as keyword,
+               cs.minBuyNumber                               as minBuyNumber,
                cs.ladderPriceFlag,
                cs.normalPrice,
                p.step,
-               p.shopID                    as shopId,
-               p.taxPoint                  as taxRate,
+               p.shopID                                      as shopId,
+               p.taxPoint                                    as taxRate,
                p.includedTax,
                p.invoiceType,
-               p.productCategory           as productCategory,
+               p.productCategory                             as productCategory,
                copi.validFlag,
                p.featuredFlag,
                p.commodityType,
-               p.bigTypeID                 as bigTypeId,
-               p.smallTypeID               as smallTypeId,
-               p.tinyTypeID                as tinyTypeId,
-               rpp.currentPrice            as discountPrice,
+               p.bigTypeID                                   as bigTypeId,
+               p.smallTypeID                                 as smallTypeId,
+               p.tinyTypeID                                  as tinyTypeId,
+               rpp.currentPrice                              as discountPrice,
                p.productType
         from repeat_purchase_price rpp
                  left join product p on rpp.productId = p.productID
@@ -663,7 +703,7 @@
     </select>
 
     <select id="getFileArchiveList" resultType="com.caimei365.commodity.model.vo.ArchiveContentVo">
-        select id as archiveContentId, title,content, addTime
+        select id as archiveContentId, title, content, addTime
         from cm_product_archive_content
         where productArchiveId = #{archiveId}
           and type = 3
@@ -692,7 +732,9 @@
                if(cpa.productId is not null, ifnull(p.commodityType, cpa.productType),
                   cpa.productType)                                          AS "productType",
                cpa.productClassify                                          AS "productClassify",
-               (SELECT  GROUP_CONCAT(cpac.labelIds) from cm_product_archive_content cpac WHERE cpac.productArchiveId=cpa.id)  AS "labelIds"
+               (SELECT GROUP_CONCAT(cpac.labelIds)
+                from cm_product_archive_content cpac
+                WHERE cpac.productArchiveId = cpa.id)                       AS "labelIds"
         from cm_product_archive cpa
                  left join product p on cpa.productId = p.productID
                  left join shop s on p.shopID = s.shopID
@@ -716,7 +758,8 @@
         select id
         from cm_product_archive
         where productId = #{productId}
-        order by addTime desc limit 1
+        order by addTime desc
+        limit 1
     </select>
 
     <select id="findBeansHistoryByArchiveId" resultType="java.lang.Integer">
@@ -733,45 +776,58 @@
     </select>
 
     <select id="getSvipProductList" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
-        select p.productID                                                                           as productId,
+        select p.productID       as productId,
                p.actStatus,
                p.name,
                p.aliasName,
-               p.mainImage                                                                           as image,
-               (select unit from cm_sku where productId = csp.productId and organizeId = 0 order by price asc limit 1)  as unit,
-               p.productCode                                                                         as code,
+               p.mainImage       as image,
+               (select unit
+                from cm_sku
+                where productId = csp.productId
+                  and organizeId = 0
+                order by price asc
+                limit 1)         as unit,
+               p.productCode     as code,
                p.priceFlag,
-               (select price from cm_sku where productId = csp.productId and organizeId = 0 order by price asc limit 1) as price,
-               p.shopID                                                                              as shopId,
-               p.searchKey                                                                           as keyword,
+               (select price
+                from cm_sku
+                where productId = csp.productId
+                  and organizeId = 0
+                order by price asc
+                limit 1)         as price,
+               p.shopID          as shopId,
+               p.searchKey       as keyword,
                (select minBuyNumber
                 from cm_sku
-                where productId = csp.productId and organizeId = 0
+                where productId = csp.productId
+                  and organizeId = 0
                 order by price asc
-                limit 1)                                                                             as minBuyNumber,
+                limit 1)         as minBuyNumber,
                (select ladderPriceFlag
                 from cm_sku
-                where productId = csp.productId and organizeId = 0
+                where productId = csp.productId
+                  and organizeId = 0
                 order by price asc
-                limit 1)                                                                             as ladderPriceFlag,
+                limit 1)         as ladderPriceFlag,
                (select normalPrice
                 from cm_sku
-                where productId = csp.productId and organizeId = 0
+                where productId = csp.productId
+                  and organizeId = 0
                 order by price asc
-                limit 1)                                                                             as normalPrice,
+                limit 1)         as normalPrice,
                p.step,
-               p.shopID                                                                              as shopId,
-               p.taxPoint                                                                            as taxRate,
+               p.shopID          as shopId,
+               p.taxPoint        as taxRate,
                p.includedTax,
                p.invoiceType,
-               p.productCategory                                                                     as productCategory,
+               p.productCategory as productCategory,
                copi.validFlag,
                p.featuredFlag,
                p.commodityType,
-               p.bigTypeID                                                                           as bigTypeId,
-               p.smallTypeID                                                                         as smallTypeId,
-               p.tinyTypeID                                                                          as tinyTypeId,
-               p.visibility                                                                          as visibility
+               p.bigTypeID       as bigTypeId,
+               p.smallTypeID     as smallTypeId,
+               p.tinyTypeID      as tinyTypeId,
+               p.visibility      as visibility
         from cm_svip_product csp
                  left join product p on p.productID = csp.productId
                  left join cm_organize_product_info copi on copi.productId = csp.productId
@@ -1045,9 +1101,12 @@
         p.priceFlag,
         p.shopID as shopId,
         p.searchKey as keyword,
-        (select minBuyNumber from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as ladderPriceFlag,
-        (select normalPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
+        (select minBuyNumber from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as
+        minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as
+        ladderPriceFlag,
+        (select normalPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as
+        normalPrice,
         p.step,
         p.taxPoint as taxRate,
         p.includedTax,
@@ -1081,9 +1140,12 @@
         SELECT DISTINCT
         (select price from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as price,
         (select unit from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as unit,
-        (select normalPrice from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
-        (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as ladderPriceFlag,
+        (select normalPrice from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as
+        normalPrice,
+        (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as
+        minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as
+        ladderPriceFlag,
         p.productID,
         p.actStatus,
         p.name,
@@ -1143,9 +1205,12 @@
         (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as price,
         p.shopID as shopId,
         p.searchKey as keyword,
-        (select minBuyNumber from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as ladderPriceFlag,
-        (select normalPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
+        (select minBuyNumber from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as
+        minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as
+        ladderPriceFlag,
+        (select normalPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as
+        normalPrice,
         p.step,
         p.taxPoint as taxRate,
         p.includedTax,
@@ -1391,7 +1456,7 @@
     </update>
     <insert id="insertReferenceInfo">
         insert into cm_baike_reference_info(referenceType, website, articleName, websiteName, publishTime,
-                                                acitationTime, author, workName, publicationPlace, press, publicationYear,
+                                            acitationTime, author, workName, publicationPlace, press, publicationYear,
                                             acitationWeb, referenceDescription, imageDescription, imageUrl, productId,
                                             productType, ctrlId)
         values (#{referenceType}, #{website}, #{articleName}, #{websiteName}, #{publishTimeStr}, #{acitationTimeStr},
@@ -1420,11 +1485,22 @@
             relatedLabels = #{labelStrs}
         where id = #{id}
     </update>
+    <update id="updateVote">
+        update
+        <if test="1 ==voteType">
+            cm_vote_page
+        </if>
+        <if test="2 == voteType">
+            cm_category_vote
+        </if>
+        set voteNum = voteNum + 1
+        where id = #{id}
+    </update>
 
     <insert id="insertEntryInfo" useGeneratedKeys="true" keyProperty="id">
         insert into cm_baike_product
         (commodityType, name, discription, typeId, actualPv, auditStatus, onlineStatus, status, publishTime, addTime,
-         alias,banner, image, seoKeyword, publishSource, shopId, labelIds, relatedLabels)
+         alias, banner, image, seoKeyword, publishSource, shopId, labelIds, relatedLabels)
         values (#{commodityType}, #{name}, #{discription}, #{typeId}, 0, 1, 1, #{status}, #{publishTime}, NOW(),
                 #{alias}, #{banner}, #{image}, #{seoKeyword}, #{publishSource}, #{shopId}, #{labelIds}, #{labelStrs})
     </insert>
@@ -1460,7 +1536,7 @@
     </delete>
 
     <insert id="insertImage">
-        insert into cm_baike_product_image(productId, image,type )
+        insert into cm_baike_product_image(productId, image, type)
         values (#{entryId}, #{image}, #{type})
     </insert>
 
@@ -1522,6 +1598,10 @@
             <if test="ctrlId != null and ctrlId != ''">#{ctrlId},</if>
         </trim>
     </insert>
+    <insert id="insertVote">
+        insert into cm_vote_num(ip, voteDate, userId, voteId, voteType)
+        values (#{ip}, now(), #{userId}, #{id}, #{voteType})
+    </insert>
 
     <select id="getShopid" resultType="java.lang.Integer">
         select cmShopId
@@ -1545,4 +1625,22 @@
         from cm_user_search_frequency
         where id = #{id}
     </select>
+    <select id="findVoteList" resultType="com.caimei365.commodity.model.vo.VotePageVo">
+        SELECT id,
+               shopId,
+               shopName,
+               productId,
+               shopLogo,
+               shopIntroduction,
+               voteNum,
+               shopWebsite,
+               ROW_NUMBER() OVER (ORDER BY voteNum DESC) as 'rank'
+        FROM cm_vote_page
+        order by voteNum desc
+    </select>
+    <select id="findCategoryVote" resultType="com.caimei365.commodity.model.vo.CategoryVoteVo">
+        select id, categoryName as name, voteNum, ROW_NUMBER() OVER (ORDER BY voteNum DESC) as 'rank'
+        from cm_category_vote
+        order by voteNum desc
+    </select>
 </mapper>