chao пре 4 година
родитељ
комит
5991c78e82

+ 0 - 1
src/main/java/com/caimei365/user/components/CommonService.java

@@ -2,7 +2,6 @@ package com.caimei365.user.components;
 
 import com.caimei365.user.mapper.BaseMapper;
 import com.caimei365.user.mapper.LoginMapper;
-import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.utils.ValidateUtil;
 import lombok.extern.slf4j.Slf4j;

+ 1 - 1
src/main/java/com/caimei365/user/config/JWTFilter.java

@@ -88,7 +88,7 @@ public class JWTFilter implements WebFilter {
                 // 需要验证的路径
                 if(Arrays.asList(PERMISSION_URLS).contains(url)) {
                     // Token失效
-                    log.error("Token失效,请重新登录!");
+                    log.error("Token失效,token:"+token+",cacheToken:"+cacheToken);
                     return tokenErrorResponse(response, "Token失效,请重新登录!");
                 }
             }

+ 16 - 0
src/main/java/com/caimei365/user/controller/ClubApi.java

@@ -79,5 +79,21 @@ public class ClubApi {
 		return clubService.updateClubUserInfo(club);
     }
 
+    /**
+     * 机构个人中心
+     *
+     * spi旧接口:/personalCenter/myCentre
+     *
+     * @param userId 用户Id
+     *
+     * @return Map(userPo,clubPo)
+     */
+    @ApiOperation("机构个人中心(小程序)")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/home")
+    public ResponseJson<Map<String, Object>> getClubHomeData(Integer userId) {
+        return clubService.getClubHomeData(userId);
+    }
+
 
 }

+ 0 - 2
src/main/java/com/caimei365/user/controller/RegisterApi.java

@@ -9,8 +9,6 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Map;
-
 
 /**
  * 注册Api

+ 6 - 0
src/main/java/com/caimei365/user/mapper/BaseMapper.java

@@ -93,4 +93,10 @@ public interface BaseMapper {
      */
     String getUserNameByUserId(Integer userId);
 
+    /**
+     * 获取采美售后电话
+     * @return
+     */
+    String getAfterSalesPhone();
+
 }

+ 8 - 0
src/main/java/com/caimei365/user/mapper/ClubMapper.java

@@ -3,6 +3,7 @@ package com.caimei365.user.mapper;
 import com.caimei365.user.model.dto.ClubUpdateDto;
 import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.ClubVo;
+import com.caimei365.user.model.vo.OrderCountVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -32,4 +33,11 @@ public interface ClubMapper {
      * @param club  机构数据
      */
     void updateClubByUpdateInfo(ClubUpdateDto club);
+
+    /**
+     * 获取订单数量
+     * @param userId
+     * @return
+     */
+    OrderCountVo getOrderCount(Integer userId);
 }

+ 39 - 0
src/main/java/com/caimei365/user/model/vo/OrderCountVo.java

@@ -0,0 +1,39 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/3/31
+ */
+@Data
+public class OrderCountVo implements Serializable {
+    /**
+     * 待确认数量
+     */
+    private Integer orderCount;
+    /**
+     * 待确认数量
+     */
+    private Integer confirmedCount;
+    /**
+     * 待付款数量
+     */
+    private Integer paymentCount;
+    /**
+     * 待发货数量
+     */
+    private Integer waitShipmentsCount;
+    /**
+     * 已发货数量
+     */
+    private Integer shipmentsCount;
+    /**
+     * 退货款数量
+     */
+    private Integer salesReturnCount;
+}

+ 8 - 0
src/main/java/com/caimei365/user/service/ClubService.java

@@ -50,4 +50,12 @@ public interface ClubService {
      * @return ClubUpdateDto
      */
     ResponseJson<ClubUpdateDto> updateClubUserInfo(ClubUpdateDto club);
+
+    /**
+     * 机构个人中心
+     *
+     * @param userId 用户Id
+     * @return Map(userPo,clubPo)
+     */
+    ResponseJson<Map<String, Object>> getClubHomeData(Integer userId);
 }

+ 41 - 0
src/main/java/com/caimei365/user/service/impl/ClubServiceImpl.java

@@ -140,4 +140,45 @@ public class ClubServiceImpl implements ClubService {
         clubMapper.updateClubByUpdateInfo(club);
         return ResponseJson.success("修改机构资料成功", club);
     }
+
+    /**
+     * 机构个人中心
+     *
+     * @param userId 用户Id
+     * @return Map(userPo, clubPo)
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getClubHomeData(Integer userId) {
+        if (null == userId) {
+            return ResponseJson.error("参数异常", null);
+        }
+        // 用户信息
+        UserVo user = baseMapper.getUserByUserId(userId);
+        if (user == null) {
+            return ResponseJson.error("用户信息不存在", null);
+        }
+        ClubVo club = clubMapper.getClubById(user.getClubId());
+        if (club == null) {
+            return ResponseJson.error("机构信息不存在", null);
+        }
+        Map<String, Object> map = new HashMap();
+        map.put("user", user);
+        map.put("club", club);
+        OrderCountVo countVo = clubMapper.getOrderCount(userId);
+        //待确认数量
+        map.put("confirmedCount", countVo.getConfirmedCount());
+        //待付款数量
+        map.put("paymentCount", countVo.getPaymentCount());
+        //待发货数量
+        map.put("waitShipmentsCount", countVo.getWaitShipmentsCount());
+        //已发货数量
+        map.put("shipmentsCount", countVo.getShipmentsCount());
+        //退货款数量
+        map.put("salesReturnCount", countVo.getSalesReturnCount());
+        //联系电话
+        String contactNumber = baseMapper.getAfterSalesPhone();
+        map.put("contactNumber", contactNumber);
+
+        return ResponseJson.success(map);
+    }
 }

+ 3 - 0
src/main/java/com/caimei365/user/service/impl/SellerServiceImpl.java

@@ -53,7 +53,10 @@ public class SellerServiceImpl implements SellerService {
         if (null == seller || !Md5Util.md5(password).equals(seller.getPassword())) {
             return ResponseJson.error("密码和账户名不匹配" ,null);
         }
+        // 生成token
         String token = JwtUtil.createToken(seller.getUserId());
+        // 为了过期续签,将token存入redis,并设置超时时间
+        redisService.set(token, token, JwtUtil.getExpireTime());
         seller.setToken(token);
         Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
         String openId = (String) infoData.get(WeChatService.Keys.OPEN_ID);

+ 4 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -69,6 +69,7 @@
                agreeFlag,
                registerTime,
                registerIP as registerIp,
+               guideFlag,
                validFlag
         from user
         where userID = #{userId}
@@ -76,4 +77,7 @@
     <select id="getUserNameByUserId" resultType="java.lang.String">
         select userName from user where userID = #{userId}
     </select>
+    <select id="getAfterSalesPhone" resultType="java.lang.String">
+        select contactNumber from cm_mall_organize where id = 0 and delFlag = '0'
+    </select>
 </mapper>

+ 12 - 0
src/main/resources/mapper/ClubMapper.xml

@@ -62,4 +62,16 @@
         from club
         where clubID = #{clubId}
     </select>
+    <select id="getOrderCount" resultType="com.caimei365.user.model.vo.OrderCountVo">
+        select userID as userId,
+        (select COUNT(*) from cm_order where  userID = #{userId} and delFlag = '0') as orderCount,
+        (select COUNT(*) from cm_order where  userID = #{userId} and delFlag = '0' and status = '0') as confirmedCount,
+        (select COUNT(*) from cm_order where  userID = #{userId} and delFlag = '0' and status in(11,12,13,21,22,23)) as paymentCount,
+        (select COUNT(*) from cm_order where  userID = #{userId} and delFlag = '0' and status in(11,12,21,22,31,32)) as waitShipmentsCount,
+        (select COUNT(*) from cm_order where  userID = #{userId} and delFlag = '0' and status in(12,13,22,23,32,33)) as shipmentsCount,
+        (select COUNT(*) from cm_order where  userID = #{userId} and delFlag = '0' and status in(1,2)) as salesReturnCount
+        from cm_order
+        where  userID = #{userId} and delFlag = '0'
+        limit 1
+    </select>
 </mapper>