Pārlūkot izejas kodu

供应商首页数据

chao 3 gadi atpakaļ
vecāks
revīzija
de730fae57

+ 84 - 1
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -1,10 +1,14 @@
 package com.caimei365.user.controller;
 
 import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.dto.ShopBannerDto;
 import com.caimei365.user.model.dto.ShopUpdateDto;
+import com.caimei365.user.model.vo.ShopBannerVo;
+import com.caimei365.user.model.vo.ShopHomeVo;
 import com.caimei365.user.service.ShopService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -12,6 +16,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -85,7 +90,7 @@ public class ShopApi {
      */
     @ApiOperation("更新供应商资料")
     @PostMapping("/info/update")
-    public ResponseJson updateShopUserInfo(ShopUpdateDto shopUpdateDto) {
+    public ResponseJson<Void> updateShopUserInfo(ShopUpdateDto shopUpdateDto) {
         String operationLicence = shopUpdateDto.getOperationLicence();
         String hygienicLicense = shopUpdateDto.getHygienicLicense();
         String taxLicense = shopUpdateDto.getTaxLicense();
@@ -94,4 +99,82 @@ public class ShopApi {
         return shopService.updateShopUserInfo(shopUpdateDto, operationLicence, hygienicLicense, taxLicense, honorCertification, productCertification);
     }
 
+    /**
+     * 供应商首页数据
+     * @param shopId 供应商Id
+     */
+    @ApiOperation("供应商首页数据(旧:/supplier/home/detail(supplierId))")
+    @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id")
+    @GetMapping("/home/data")
+    public ResponseJson<ShopHomeVo> getShopHomeData(Integer shopId) {
+        if (null == shopId) {
+            return ResponseJson.error("参数异常:供应商Id不能为空!", null);
+        }
+        return shopService.getShopHomeData(shopId);
+    }
+
+    /**
+     * 供应商首页-轮播图片
+     * @param shopId 供应商Id
+     */
+    @ApiOperation("供应商首页-轮播图片(旧:/supplier/home/images(supplierId))")
+    @GetMapping("/home/images")
+    public ResponseJson<List<ShopBannerVo>> getShopHomeImages(Integer shopId) {
+        if (null == shopId) {
+            return ResponseJson.error("参数异常:供应商Id不能为空!", null);
+        }
+        return shopService.getShopHomeImages(shopId);
+    }
+
+    /**
+     * 供应商-更新轮播图片
+     * @param shopBannerDto {
+     *                      id      图片id
+     *                      shopId  供应商Id
+     *                      image   图片
+     *                      title   名称
+     *                      link    链接
+     *                      info    描述
+     * }
+     */
+    @ApiOperation("供应商-更新轮播图片(旧:/supplier/saveShopBanner)")
+    @PostMapping("/home/images/update")
+    public ResponseJson<Void> saveShopHomeImages(ShopBannerDto shopBannerDto) {
+        return shopService.saveShopHomeImages(shopBannerDto);
+    }
+
+    /**
+     * 供应商-删除轮播图片
+     * @param shopBannerDto { id  图片id}
+     */
+    @ApiOperation("供应商-更新轮播图片(旧:/supplier/deleteShopBanner)")
+    @PostMapping("/home/images/delete")
+    public ResponseJson<Void> deleteShopHomeImages(ShopBannerDto shopBannerDto) {
+        if (null == shopBannerDto.getId()) {
+            return ResponseJson.error("参数异常:图片Id不能为空!", null);
+        }
+        return shopService.deleteShopHomeImages(shopBannerDto.getId());
+    }
+
+    /**
+     * 供应商个人中心数据
+     * @param userId 用户Id
+     */
+    @ApiOperation("供应商个人中心数据(旧:/supplier/homePageData)")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/personal/data")
+    public ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId) {
+        if (null == userId) {
+            return ResponseJson.error("参数异常:用户Id不能为空!", null);
+        }
+        return shopService.getShopPersonalData(userId);
+    }
+
+
+
+    /**
+     * 【Y1】/supplier/saveShopBanner 供应商-添加,修改主页广告图
+     * 【Y1】/supplier/deleteShopBanner 供应商-删除主页广告图
+     */
+
 }

+ 17 - 0
src/main/java/com/caimei365/user/mapper/PersonalCenterMapper.java

@@ -0,0 +1,17 @@
+package com.caimei365.user.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/22
+ */
+@Mapper
+public interface PersonalCenterMapper {
+    /**
+     * 未读消息数量
+     */
+    Integer getUnReadMessageCount(Integer userId);
+}

+ 64 - 1
src/main/java/com/caimei365/user/mapper/ShopMapper.java

@@ -3,10 +3,12 @@ package com.caimei365.user.mapper;
 import com.caimei365.user.model.dto.ShopUpdateDto;
 import com.caimei365.user.model.po.ShopCertPo;
 import com.caimei365.user.model.po.UserPo;
-import com.caimei365.user.model.vo.ShopVo;
+import com.caimei365.user.model.vo.*;
+import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -54,4 +56,65 @@ public interface ShopMapper {
      * @param shopCert  资质证书数据
      */
     void insertShopCert(ShopCertPo shopCert);
+
+    /**
+     * 供应商首页数据
+     * @param shopId 供应商Id
+     */
+    ShopHomeVo getShopHomeData(Integer shopId);
+
+    /**
+     * 公司资质照片
+     */
+    List<String> getShopCertById(Integer shopId, int shopCertTypeId);
+
+    /**
+     * 供应商首页-轮播图片
+     */
+    List<ShopBannerVo> getShopHomeImages(Integer shopId);
+    /**
+     * 店铺促销活动
+     */
+    PromotionsVo getShopPromotionsByShopId(Integer shopId);
+    /**
+     * 促销赠品
+     */
+    List<ProductItemVo> getPromotionsGifts(Integer promotionsId);
+    /**
+     * 统计商品数量
+     *
+     * @param shopId    供应商id
+     * @param validFlag 商品状态
+     */
+    Integer getShopProductCount(Integer shopId, Integer validFlag);
+    /**
+     * 统计前五的商品销售信息
+     */
+    @MapKey("productId")
+    List<Map<String, Object>> getSalesRankingList(Integer shopId);
+    /**
+     * 获取商品信息
+     */
+    ProductItemVo getProductShown(Integer productId);
+    /**
+     * 销售统计
+     */
+    @MapKey("orderQuantity")
+    Map<String, Object> getSalesStatistics(Integer shopId, String startTime, String endTime);
+    /**
+     * 轮播图片数量
+     */
+    int getShopHomeImageCount(Integer shopId);
+    /**
+     * 新增轮播图
+     */
+    void insertShopHomeImage(ShopBannerVo shopBanner);
+    /**
+     * 更新轮播图
+     */
+    void updateShopHomeImage(ShopBannerVo shopBanner);
+    /**
+     * 删除轮播图
+     */
+    void deleteShopHomeImage(Integer id);
 }

+ 46 - 0
src/main/java/com/caimei365/user/model/dto/ShopBannerDto.java

@@ -0,0 +1,46 @@
+package com.caimei365.user.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/22
+ */
+@Data
+public class ShopBannerDto implements Serializable {
+    /**
+     * Id
+     */
+    @ApiModelProperty("Id")
+    private Integer id;
+    /**
+     * 供应商Id
+     */
+    @ApiModelProperty("供应商Id")
+    private Integer shopId;
+    /**
+     * 名称
+     */
+    @ApiModelProperty("名称")
+    private String title;
+    /**
+     * 链接
+     */
+    @ApiModelProperty("链接")
+    private String link;
+    /**
+     * 描述
+     */
+    @ApiModelProperty("描述")
+    private String info;
+    /**
+     * 图片
+     */
+    @ApiModelProperty("图片")
+    private String image;
+}

+ 28 - 0
src/main/java/com/caimei365/user/model/vo/ShopBannerVo.java

@@ -0,0 +1,28 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/22
+ */
+@Data
+public class ShopBannerVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+
+    private Integer shopId;
+
+    private String title;
+
+    private String link;
+
+    private String info;
+
+    private String image;
+}

+ 89 - 0
src/main/java/com/caimei365/user/model/vo/ShopHomeVo.java

@@ -0,0 +1,89 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/22
+ */
+@Data
+public class ShopHomeVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 对应的userId
+     */
+    private Integer userId;
+    /**
+     * 供应商名称
+     */
+    private String name;
+    /**
+     * 供应商公司简称
+     */
+    private String abbr;
+    /**
+     * 公司LOGO
+     */
+    private String logo;
+    /**
+     * 所在地区
+     */
+    private String address;
+    /**
+     * 经营范围
+     */
+    private String businessScope;
+    private String[] businessScopeArr;
+    /**
+     * 营业执照
+     */
+    private String businessLicense;
+    /**
+     * 税务登记证
+     */
+    private String taxCertificate;
+    /**
+     * 供应商授权采美代理证书
+     */
+    private String certificate;
+    /**
+     * 介绍
+     */
+    private String info;
+    /**
+     * 主打产品说明
+     */
+    private String productDesc;
+    /**
+     * 网站
+     */
+    private String site;
+    /**
+     * 上架商品数量
+     */
+    private Integer normalNum;
+    /**
+     * 公司资质照片1
+     */
+    private String medicalPracticeLicenseImg1;
+    /**
+     * 公司资质照片2
+     */
+    private String medicalPracticeLicenseImg2;
+    /**
+     * 公司资质照片3
+     */
+    private String medicalPracticeLicenseImg3;
+    /**
+     * 授权牌照
+     */
+    private String authorizationCertificateImage;
+}

+ 0 - 1
src/main/java/com/caimei365/user/model/vo/ShopVo.java

@@ -103,7 +103,6 @@ public class ShopVo implements Serializable {
      * 省市区地址
      */
     private String provincialAddress;
-
     /**
      * 荣誉证书
      */

+ 42 - 1
src/main/java/com/caimei365/user/service/ShopService.java

@@ -2,8 +2,12 @@ package com.caimei365.user.service;
 
 
 import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.dto.ShopBannerDto;
 import com.caimei365.user.model.dto.ShopUpdateDto;
+import com.caimei365.user.model.vo.ShopBannerVo;
+import com.caimei365.user.model.vo.ShopHomeVo;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -60,5 +64,42 @@ public interface ShopService {
      * @param productCertification      产品证书
      * @return ClubUpdateDto
      */
-    ResponseJson updateShopUserInfo(ShopUpdateDto shopUpdateDto, String operationLicence, String hygienicLicense, String taxLicense, String honorCertification, String productCertification);
+    ResponseJson<Void> updateShopUserInfo(ShopUpdateDto shopUpdateDto, String operationLicence, String hygienicLicense, String taxLicense, String honorCertification, String productCertification);
+
+    /**
+     * 供应商首页数据
+     * @param shopId 供应商Id
+     */
+    ResponseJson<ShopHomeVo> getShopHomeData(Integer shopId);
+
+    /**
+     * 供应商首页-轮播图片
+     * @param shopId 供应商Id
+     */
+    ResponseJson<List<ShopBannerVo>> getShopHomeImages(Integer shopId);
+
+    /**
+     * 供应商个人中心数据
+     * @param userId 用户Id
+     */
+    ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId);
+
+    /**
+     * 供应商-更新轮播图片
+     * @param shopBannerDto {
+     *                      id      图片id
+     *                      shopId  供应商Id
+     *                      image   图片
+     *                      title   名称
+     *                      link    链接
+     *                      info    描述
+     * }
+     */
+    ResponseJson<Void> saveShopHomeImages(ShopBannerDto shopBannerDto);
+
+    /**
+     * 供应商-删除轮播图片
+     * @param id  图片id
+     */
+    ResponseJson<Void> deleteShopHomeImages(Integer id);
 }

+ 190 - 2
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -2,15 +2,21 @@ package com.caimei365.user.service.impl;
 
 import com.caimei365.user.components.RedisService;
 import com.caimei365.user.mapper.BaseMapper;
+import com.caimei365.user.mapper.PersonalCenterMapper;
 import com.caimei365.user.mapper.ShopMapper;
 import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.dto.ShopBannerDto;
 import com.caimei365.user.model.dto.ShopUpdateDto;
 import com.caimei365.user.model.po.ShopCertPo;
 import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.ShopService;
+import com.caimei365.user.utils.DateUtil;
+import com.caimei365.user.utils.ImageUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -25,13 +31,16 @@ import java.util.*;
 @Slf4j
 @Service
 public class ShopServiceImpl implements ShopService {
-
+    @Value("${caimei.wwwDomain}")
+    private String wwwDomain;
     @Resource
     private RedisService redisService;
     @Resource
     private BaseMapper baseMapper;
     @Resource
     private ShopMapper shopMapper;
+    @Resource
+    private PersonalCenterMapper personalCenterMapper;
 
 
     /**
@@ -139,7 +148,7 @@ public class ShopServiceImpl implements ShopService {
      * @return ClubUpdateDto
      */
     @Override
-    public ResponseJson updateShopUserInfo(ShopUpdateDto shopUpdateDto, String operationLicence, String hygienicLicense, String taxLicense, String honorCertification, String productCertification) {
+    public ResponseJson<Void> updateShopUserInfo(ShopUpdateDto shopUpdateDto, String operationLicence, String hygienicLicense, String taxLicense, String honorCertification, String productCertification) {
         // 参数校验
         if (null == shopUpdateDto.getUserId()) {
             return ResponseJson.error("参数异常:用户Id不能为空!");
@@ -212,4 +221,183 @@ public class ShopServiceImpl implements ShopService {
         }
         return ResponseJson.success("修改供应商资料成功", null);
     }
+
+    /**
+     * 供应商首页数据
+     *
+     * @param shopId 供应商Id
+     */
+    @Override
+    public ResponseJson<ShopHomeVo> getShopHomeData(Integer shopId) {
+        ShopHomeVo supplier = shopMapper.getShopHomeData(shopId);
+        if (supplier != null && supplier.getBusinessScope() != null) {
+            String[] businessScope = supplier.getBusinessScope().split("/");
+            supplier.setBusinessScopeArr(businessScope);
+            supplier.setLogo(ImageUtils.getImageURL("shopLogo", supplier.getLogo(), 0, wwwDomain));
+        }
+        //公司资质照片
+        List<String> productionLicence = shopMapper.getShopCertById(shopId, 2);
+        if (null != productionLicence && productionLicence.size() > 0) {
+            supplier.setMedicalPracticeLicenseImg1(productionLicence.get(0));
+        }
+        List<String> hygienicLicense = shopMapper.getShopCertById(shopId, 5);
+        if (null != hygienicLicense && hygienicLicense.size() > 0) {
+            supplier.setMedicalPracticeLicenseImg2(hygienicLicense.get(0));
+        }
+        List<String> taxLicense = shopMapper.getShopCertById(shopId, 6);
+        if (null != taxLicense && taxLicense.size() > 0) {
+            supplier.setMedicalPracticeLicenseImg3(taxLicense.get(0));
+        }
+        return ResponseJson.success(supplier);
+    }
+
+    /**
+     * 供应商首页-轮播图片
+     *
+     * @param shopId 供应商Id
+     */
+    @Override
+    public ResponseJson<List<ShopBannerVo>> getShopHomeImages(Integer shopId) {
+        List<ShopBannerVo> images = shopMapper.getShopHomeImages(shopId);
+        return ResponseJson.success(images);
+    }
+
+    /**
+     * 供应商-更新轮播图片
+     *
+     * @param shopBannerDto {
+     *                      id      图片id
+     *                      shopId  供应商Id
+     *                      image   图片
+     *                      title   名称
+     *                      link    链接
+     *                      info    描述
+     *                      }
+     */
+    @Override
+    public ResponseJson<Void> saveShopHomeImages(ShopBannerDto shopBannerDto) {
+        ShopBannerVo shopBanner = new ShopBannerVo();
+        BeanUtils.copyProperties(shopBannerDto, shopBanner);
+        if (null != shopBannerDto.getId()){
+            // 更新
+            shopBanner.setId(shopBannerDto.getId());
+            shopMapper.updateShopHomeImage(shopBanner);
+        } else {
+            // 新增
+            int count = shopMapper.getShopHomeImageCount(shopBannerDto.getShopId());
+            if (count >= 4) {
+                return ResponseJson.error("主页广告图的上限是4张图!", null);
+            }
+            shopMapper.insertShopHomeImage(shopBanner);
+        }
+        return ResponseJson.success(null);
+    }
+
+    /**
+     * 供应商-删除轮播图片
+     *
+     * @param id  图片id
+     */
+    @Override
+    public ResponseJson<Void> deleteShopHomeImages(Integer id) {
+        shopMapper.deleteShopHomeImage(id);
+        return ResponseJson.success(null);
+    }
+
+    /**
+     * 供应商个人中心数据
+     *
+     * @param userId 用户Id
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId) {
+        Map<String, Object> result = new HashMap<>(11);
+        // 1.用户信息
+        UserVo user = baseMapper.getUserByUserId(userId);
+        if (user == null) {
+            return ResponseJson.error("用户信息不存在", null);
+        }
+        result.put("user", user);
+        // 2.供应商信息
+        ShopVo shop = shopMapper.getShopById(user.getShopId());
+        if (shop == null) {
+            return ResponseJson.error("供应商信息不存在", null);
+        }
+        shop.setLogo(ImageUtils.getImageURL("shopLogo", shop.getLogo(), 0, wwwDomain));
+        result.put("shop", shop);
+        // 3.资料完整度
+        List<String> productCertification = shopMapper.getShopCertById(user.getShopId(), 3);
+        List<String> certificateHonor = shopMapper.getShopCertById(user.getShopId(), 1);
+        // 4.是否有荣誉证书与产品证书
+        boolean b = productCertification != null && productCertification.size() > 0 && certificateHonor != null && certificateHonor.size() > 0;
+        if (StringUtils.isNotBlank(user.getEmail()) && StringUtils.isNotBlank(shop.getLegalPerson()) && StringUtils.isNotBlank(shop.getShopDesc())
+                && StringUtils.isNotBlank(shop.getLogo()) && b) {
+            result.put("dataIntegrity", "100%");
+        } else if (StringUtils.isNotBlank(shop.getLegalPerson()) && StringUtils.isNotBlank(shop.getShopDesc()) && StringUtils.isNotBlank(shop.getLogo())) {
+            result.put("dataIntegrity", "90%");
+        } else {
+            result.put("dataIntegrity", "70%");
+        }
+        // 5.店铺促销活动
+        PromotionsVo promotions = shopMapper.getShopPromotionsByShopId(user.getShopId());
+        if (null != promotions && 3 == promotions.getMode()) {
+            List<ProductItemVo> productGifts = shopMapper.getPromotionsGifts(promotions.getId());
+            productGifts.forEach(p -> {
+                p.setImage(ImageUtils.getImageURL("product", p.getImage(), 0, wwwDomain));
+            });
+            promotions.setGiftList(productGifts);
+        }
+        result.put("promotions", promotions);
+        // 6.未读消息数量
+        Integer unReadMessageCount = personalCenterMapper.getUnReadMessageCount(userId);
+        result.put("unReadMessageCount", unReadMessageCount);
+        // 7.商品数量统计,validFlag 商品状态,见ProductStatus,0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已冻结'
+        Integer allNum = shopMapper.getShopProductCount(user.getShopId(), null);
+        result.put("allNum", allNum);
+        // 8.已上架数量
+        Integer upNum = shopMapper.getShopProductCount(user.getShopId(), 2);
+        result.put("upNum", upNum);
+        // 9.已下架数量
+        Integer downNum = shopMapper.getShopProductCount(user.getShopId(), 3);
+        result.put("downNum", downNum);
+        // 10.单品销售排名
+        List<Map<String, Object>> salesRankingList = shopMapper.getSalesRankingList(user.getShopId());
+        if (salesRankingList != null && salesRankingList.size() > 0) {
+            salesRankingList.forEach(map -> {
+                ProductItemVo product = shopMapper.getProductShown((Integer) map.get("productId"));
+                if (product != null) {
+                    map.put("name", product.getName());
+                    map.put("image", ImageUtils.getImageURL("product", product.getImage(), 0, wwwDomain));
+                }
+            });
+        }
+        result.put("salesRankingList", salesRankingList);
+        // 11.销售情况统计
+        List<Map<String, Object>> salesStatisticsList = new ArrayList<>();
+        Date endDayOfDay = DateUtil.getDayEnd();
+        // 近一个月销售情况统计
+        Date beginDayOfYesterday = DateUtil.addMonth(endDayOfDay, -1);
+        Map<String, Object> m1 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfYesterday), DateUtil.formatDateTime(endDayOfDay));
+        m1.put("time", "近一月");
+        salesStatisticsList.add(m1);
+        // 近三个月销售情况统计
+        Date beginDayOfLastWeek = DateUtil.addMonth(endDayOfDay, -3);
+        Map<String, Object> m2 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfLastWeek), DateUtil.formatDateTime(endDayOfDay));
+        m2.put("time", "近三月");
+        salesStatisticsList.add(m2);
+        // 近半年销售情况统计
+        Date beginDayOfLastMonth = DateUtil.addMonth(endDayOfDay, -6);
+        Map<String, Object> m3 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfLastMonth), DateUtil.formatDateTime(endDayOfDay));
+        m3.put("time", "近半年");
+        salesStatisticsList.add(m3);
+        // 近一年销售情况统计
+        Date beginDayOfLastYear = DateUtil.addMonth(endDayOfDay, -12);
+        Map<String, Object> m4 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfLastYear), DateUtil.formatDateTime(endDayOfDay));
+        m4.put("time", "近一年");
+        salesStatisticsList.add(m4);
+        result.put("salesStatisticsList", salesStatisticsList);
+
+        return ResponseJson.success(result);
+    }
+
 }

+ 108 - 14
src/main/java/com/caimei365/user/utils/DateUtil.java

@@ -4,14 +4,20 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.GregorianCalendar;
 
+/**
+ * @author Administrator
+ */
 public class DateUtil {
-    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
     private static Calendar calendar = Calendar.getInstance();
 
-    /*
-    输入日期字符串比如201703,返回当月第一天的Date
-    */
+    /**
+     * 输入日期字符串比如201703,返回当月第一天的Date
+     * @param month
+     * @return
+     */
     public static Date getMinDay(String month) {
         try {
             Date nowDate = sdf.parse(month);
@@ -25,9 +31,11 @@ public class DateUtil {
         return null;
     }
 
-    /*
-    输入日期字符串,返回下个月1号0点
-    */
+    /**
+     * 输入日期字符串,返回下个月1号0点
+     * @param month
+     * @return
+     */
     public static Date getMaxDay(String month) {
         try {
             Date nowDate = sdf.parse(month);
@@ -44,25 +52,111 @@ public class DateUtil {
 
     /**
      * 返回现在时间yyyy-mm格式
-     *
      * @return
      */
     public static String getNowMonth() {
-        Date date = new Date();
-        String format = new SimpleDateFormat("yyyy-MM").format(date);
-        return format;
+        return new SimpleDateFormat("yyyy-MM").format(new Date());
     }
 
-
     /**
      * 获取现在时间的00:00
+     */
+    public static Date getNowZeroTime() {
+        Calendar cal = Calendar.getInstance();
+        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
+        return cal.getTime();
+    }
+    /**
+     * 判断当前时间在时间区间内
+     *
+     * @param nowTime   当前时间
+     * @param startTime 开始时间
+     * @param endTime   结束时间
+     * @return
+     */
+    public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
+        if (nowTime.getTime() == startTime.getTime()
+                || nowTime.getTime() == endTime.getTime()) {
+            return true;
+        }
+        Calendar date = Calendar.getInstance();
+        date.setTime(nowTime);
+        Calendar begin = Calendar.getInstance();
+        begin.setTime(startTime);
+        Calendar end = Calendar.getInstance();
+        end.setTime(endTime);
+        if (date.after(begin) && date.before(end)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 获取当天的结束时间
+     */
+    public static Date getDayEnd() {
+        Calendar cal = new GregorianCalendar();
+        cal.set(Calendar.HOUR_OF_DAY, 23);
+        cal.set(Calendar.MINUTE, 59);
+        cal.set(Calendar.SECOND, 59);
+        return cal.getTime();
+    }
+
+    /**
+     * 在日期上增加数个整月
      *
+     * @param date 日期
+     * @param n    要增加的月数
      * @return
      */
-    public static Date getNowTime() {
+    public static Date addMonth(Date date, int n) {
         Calendar cal = Calendar.getInstance();
-        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
+        cal.setTime(date);
+        cal.add(Calendar.MONTH, n);
         return cal.getTime();
     }
 
+    /**
+     * 得到日期时间字符串,转换格式(yyyy-MM-dd HH:mm:ss)
+     */
+    public static String formatDateTime(Date date) {
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
+    }
+
+    /**
+     * date2比date1多的天数
+     *
+     * @param date1
+     * @param date2
+     * @return
+     */
+    public static int differentDays(Date date1, Date date2) {
+        Calendar cal1 = Calendar.getInstance();
+        cal1.setTime(date1);
+        Calendar cal2 = Calendar.getInstance();
+        cal2.setTime(date2);
+        int day1 = cal1.get(Calendar.DAY_OF_YEAR);
+        int day2 = cal2.get(Calendar.DAY_OF_YEAR);
+        int year1 = cal1.get(Calendar.YEAR);
+        int year2 = cal2.get(Calendar.YEAR);
+        if (year1 != year2) {
+            //同一年
+            int timeDistance = 0;
+            for (int i = year1; i < year2; i++) {
+                if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
+                    //闰年
+                    timeDistance += 366;
+                } else {
+                    //不是闰年
+                    timeDistance += 365;
+                }
+            }
+            return timeDistance + (day2 - day1);
+        } else {
+            //不同年
+            System.out.println("判断day2 - day1 : " + (day2 - day1));
+            return day2 - day1;
+        }
+    }
 }

+ 115 - 0
src/main/java/com/caimei365/user/utils/ImageUtils.java

@@ -0,0 +1,115 @@
+package com.caimei365.user.utils;
+
+import org.springframework.util.StringUtils;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2020/3/16
+ */
+public class ImageUtils {
+
+	public static String getImageURL(String dirName, String src, String domain) {
+		return getImageURL(dirName, src, 0,domain);
+	}
+
+	/***
+	 * 获取图片地址
+	 *
+	 * @param src
+	 *            保存在数据库中的图片文件名
+	 * @param type
+	 *            图片的前缀 (如 type = 200 那么则获取的图片是 200_XXX的图片)
+	 * @param dirName
+	 *            图片保存的文件夹名 如 (league)
+	 * @param domain
+	 * 			   加上域名拼成完整路径
+	 * @return
+	 */
+	public static String getImageURL(String dirName, String src, int type, String domain) {
+
+
+		//正式环境 域名 http --- https处理
+		if (domain != null && !"".equals(domain) && domain.startsWith("http:") && domain.toLowerCase().lastIndexOf("config/beta")== -1 && domain.toLowerCase().lastIndexOf("localhost")== -1) {
+			domain = domain.replace("http:", "https:");
+		}
+
+		//正式环境 图片地址 http --- https处理
+		if(src != null && src.startsWith("https:")){
+			//非正式环境 使用http
+			if (domain !=null && !"".equals(domain) && domain.toLowerCase().lastIndexOf("config/beta")>-1 || domain.toLowerCase().lastIndexOf("localhost")>-1){
+				src = src.replace("https:","http:");
+			}
+			return src;
+		}
+
+		//正式环境 图片地址  http --- https处理
+		if(src != null && src.startsWith("http:")){
+			//非正式环境 使用http
+			if (domain !=null && !"".equals(domain) && domain.toLowerCase().lastIndexOf("config/beta")==-1 && domain.toLowerCase().lastIndexOf("localhost")==-1){
+				src = src.replace("http:","https:");
+			}
+			return src;
+		}
+		type = 0 ;
+		dirName = dirName.trim();
+		if (dirName == null) {dirName = "";}
+		if(src == null || src.equalsIgnoreCase("null")) {src = "";}
+		if (src.indexOf(",") > 0) {
+			String tmp = src;
+			src = tmp.substring(0, tmp.indexOf(","));
+		}
+		String image = "/img/default/none.jpg";
+		if (dirName.equals("user")) {
+			image = "/img/default/HeaderImg.png";
+		} else if (dirName.equals("club")) {
+			image = "/img/default/default_club.jpg";
+		} else if (dirName.equals("shopLogo")) {
+			image = "/img/default/suppliver.jpg";
+		}else if (dirName.equals("caiMeiImage")) {
+			image = "/img/default/caiMeiImage.jpg";
+		}else {
+			image = "/img/default/none.jpg";
+		}
+		if (src != null && !src.equals("")) {
+			if (type != 0 || dirName.equals("product")) {
+				src = src.replace("\\", "/");
+				String srcActual = src;
+				String subDirName = "";
+				int index = src.lastIndexOf("/");
+
+				if (index != -1) {
+					subDirName = src.substring(0, index + 1);
+					srcActual = src.substring(index + 1);
+				}
+				boolean b = src.startsWith("/uploadFile");
+				if(b){
+					image = src;
+				}else{
+					image = "/uploadFile/" + dirName + "/" + subDirName
+							+ (type == 0 ? "" : type + "_") + srcActual;
+				}
+			} else {
+				boolean b = src.startsWith("/uploadFile");
+				if(b){
+					image = src;
+				}else{
+					image = "/uploadFile/" + dirName + "/" + src;
+				}
+			}
+		}else {
+			if(StringUtils.isEmpty(image)) {
+				image = "/img/default/none.jpg";
+			}
+		}
+		return domain + image;
+	}
+
+	public static String getProductImageURL(String image, int type, String domain) {
+		if (image == null) {
+			return getImageURL("product", "", type, domain);
+		}
+		return getImageURL("product", image, type, domain);
+	}
+}

+ 7 - 0
src/main/resources/mapper/PersonalCenterMapper.xml

@@ -0,0 +1,7 @@
+<?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.caimei365.user.mapper.PersonalCenterMapper">
+    <select id="getUnReadMessageCount" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM message WHERE toUserID = #{userId} AND readFlag='0'
+    </select>
+</mapper>

+ 123 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -96,4 +96,127 @@
                businessScope, logo, addTime, status, contractPhone, validFlag, website, wxOfficialAccount, wxApplets
         from shop where shopID = #{shopId}
     </select>
+    <select id="getShopHomeData" resultType="com.caimei365.user.model.vo.ShopHomeVo">
+        select
+            s.shopID as id,
+            s.userID as userId,
+            s.name,
+            s.sname as abbr,
+            s.logo,
+            s.address,
+            s.businessScope,
+            s.businessLicenseImage as businessLicense,
+            s.taxCertificateImage as taxCertificate,
+            s.authorizationCertificateImage as certificate,
+            s.info,
+            s.productDesc,
+            s.site,
+            count(*) as normalNum
+        from shop s
+        where s.shopID = #{supplierId}
+        group by s.shopID
+    </select>
+    <select id="getShopCertById" resultType="java.lang.String">
+        SELECT image FROM shopcert WHERE shopID = #{shopId} AND shopCertTypeID = #{shopCertTypeId}
+    </select>
+    <select id="getShopHomeImages" resultType="com.caimei365.user.model.vo.ShopBannerVo">
+        select shopBannerID AS id, shopID AS shopId, image, link, title, info
+        from shopbanner where shopID = #{shopId}
+    </select>
+    <select id="getShopPromotionsByShopId" resultType="com.caimei365.user.model.vo.PromotionsVo">
+        select  pr.id,
+                pr.name,
+                pr.description,
+                pr.type,
+                pr.mode,
+                pr.touchPrice,
+                pr.reducedPrice,
+                pr.beginTime,
+                pr.endTime,
+                pr.status,
+                prp.productId,
+                prp.supplierId
+        from cm_promotions pr
+        left join cm_promotions_product prp on pr.id = prp.promotionsId
+        where prp.supplierId = #{shopId}
+          and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
+          and pr.type=3
+          and pr.delFlag not in (1,2)
+        order by pr.type desc
+        limit 1
+    </select>
+    <select id="getPromotionsGifts" resultType="com.caimei365.user.model.vo.ProductItemVo">
+        select
+            cpg.id as id,
+            p.productID as productId,
+            p.shopID as shopId,
+            p.`name` as `name`,
+            p.mainImage as image,
+            cpg.number as number,
+            0 as price,
+            2 as productType,
+            p.price1 as originalPrice,
+            p.unit as unit,
+            p.validFlag as validFlag,
+            p.stock as stock
+        from product p
+        left join cm_promotions_gift cpg on cpg.productId = p.productID
+        where cpg.promotionsId = #{promotionsId}
+        order by cpg.addTime desc
+    </select>
+    <select id="getShopProductCount" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM product
+        WHERE shopID = #{shopId}
+        <if test="validFlag != null">
+            AND validFlag = #{validFlag}
+        </if>
+    </select>
+    <select id="getSalesRankingList" resultType="java.util.Map">
+        SELECT cop.productID AS productId, SUM(cop.num) AS total
+        FROM cm_order_product cop JOIN cm_order co ON co.orderID = cop.orderID
+        WHERE cop.shopID = #{shopId}
+          AND co.STATUS NOT IN ('0', '6', '7')
+          AND co.delFlag = '0'
+          AND co.secondHandOrderFlag != '1'
+        GROUP BY productID
+        ORDER BY total DESC
+        LIMIT 5
+    </select>
+    <select id="getProductShown" resultType="com.caimei365.user.model.vo.ProductItemVo">
+        SELECT name, mainImage AS image
+        FROM product
+        WHERE  productId = #{productId}
+    </select>
+    <select id="getSalesStatistics" resultType="java.util.Map">
+        SELECT COUNT(DISTINCT so.shopOrderID) AS orderQuantity,
+        IFNULL(SUM(o.productTotalFee),0) AS orderAmount
+        FROM cm_order o
+        JOIN cm_shop_order so ON o.orderID = so.orderID
+        WHERE o.status NOT IN('0', '6', '7')
+        AND o.delFlag = '0'
+        AND so.delFlag = '0'
+        AND so.shopID = #{shopId}
+        AND o.secondHandOrderFlag != '1'
+        <if test="startTime != null and startTime != ''">
+            AND o.orderTime <![CDATA[  >=  ]]> #{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            AND o.orderTime <![CDATA[   <=  ]]> #{endTime}
+        </if>
+    </select>
+    <select id="getShopHomeImageCount" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM shopbanner WHERE shopID = #{shopId}
+    </select>
+    <insert id="insertShopHomeImage">
+        INSERT INTO shopbanner (shopID,title,link,info,image)
+        VALUES (#{shopId},#{title},#{link},#{info},#{image})
+    </insert>
+    <update id="updateShopHomeImage">
+        UPDATE shopbanner
+        SET title = #{title}, link = #{link}, info = #{info}, image = #{image}
+        WHERE shopBannerID = #{id}
+    </update>
+    <delete id="deleteShopHomeImage">
+        DELETE FROM shopbanner WHERE shopBannerID = #{id}
+    </delete>
 </mapper>