tj
6 天以前 b428226d0cf78bbb843fa17bffb1e338230fae6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.mzl.flower.mapper.customer;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.dto.request.customer.QueryCustomerDTO;
import com.mzl.flower.dto.response.customer.CustomerDTO;
import com.mzl.flower.dto.response.customer.InviteDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.customer.Customer;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
 
import java.util.List;
 
@Repository
public interface CustomerMapper extends BaseMapper<Customer> {
    List<CustomerDTO> queryCustomer(@Param("dto") QueryCustomerDTO dto, Page page);
 
    CustomerDTO getCurrentCustomer(@Param("userId") String userId);
 
    void bindPartner(@Param("id") Long id, @Param("partnerId")Long partnerId, @Param("userId")String userId);
 
    @Select("select count(1) from t_customer_info where level_id = #{levelId} and deleted = '0' ")
    Integer getByLevelId(@Param("levelId") String levelId);
 
    @Update("UPDATE t_customer_info c " +
            "JOIN ( " +
            "    SELECT user_id, " +
            "           SUM(growth) as sumgrowthvalue " +
            "    FROM t_member_growth_record " +
            "    WHERE deleted = '0' " +
            "    GROUP BY user_id " +
            "    HAVING SUM(growth) > 0 " +
            ") t1 ON c.user_id = t1.user_id " +
            "SET c.level_id = #{levelId} " +
            "WHERE t1.sumgrowthvalue BETWEEN #{startPoint} AND #{endPoint} ")
    Boolean updateMemberLevelByPoint(@Param("levelId") Long levelId, @Param("startPoint") int startPoint, @Param("endPoint") int endPoint);
 
 
 
    @Select("select * from t_customer_info where  user_id  = ( select id from t_user where tel =#{phone} and type = 'customer')")
    CustomerDTO findCustomerByPhone(String phone);
 
    @Select("select * from t_customer_info where  intervialcode  =#{code}")
    Customer findCustomerByInvitationCode(@Param("code") String code);
 
    @Select("select count(1) from t_customer_info where reintervialcode = #{code}")
    Integer getInvitatCountByCode(@Param("code") String code);
 
    @Select("SELECT " +
            "    c.user_id as userId," +
            "    c.name as userName," +
            "    CASE " +
            "        WHEN t1.reward < 3 THEN '获得了3天会员' " +
            "        WHEN t1.reward >= 3 AND t1.reward < 5 THEN '获得了15天会员' " +
            "        WHEN t1.reward >=5 THEN '获得了30天会员' " +
            "        ELSE '' " +
            "    END AS reward ," +
            "    '已注册' as status " +
            "FROM " +
            "    t_customer_info c " +
            "    INNER JOIN (" +
            "        SELECT " +
            "            reintervialcode, " +
            "            COUNT(DISTINCT id) AS reward" +
            "        FROM " +
            "            t_customer_info " +
            "        WHERE " +
            "            reintervialcode IS NOT NULL " +
            "            AND reintervialcode <> '' " +
            "        GROUP BY " +
            "            reintervialcode " +
            "    ) t1 ON c.intervialcode = t1.reintervialcode")
    List<InviteDTO> getReward();
 
    @Select("SELECT " +
            "c.user_id AS userId, " +
            "c.NAME AS userName, " +
            "'' AS reward, " +
            "'已注册' AS STATUS , c.cover  " +
            "FROM " +
            "t_customer_info c " +
            "WHERE " +
            "reintervialcode IN ( SELECT intervialcode FROM t_customer_info WHERE user_id = #{userid} )")
    List<InviteDTO> getMyReward(String userid);
    void checkVipExpireTime();
}