zjh
2025-05-30 b7d7d80a8a9e9ac145a05b5e1d545b6b61fc0cc4
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.ltkj.hosp.mapper;
 
import java.sql.ResultSet;
import java.util.List;
import java.util.Map;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ltkj.hosp.domain.TjCustomer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
 
/**
 * 客户信息Mapper接口
 *
 * @author ltkj
 * @date 2022-11-17
 */
@Mapper
public interface TjCustomerMapper extends BaseMapper<TjCustomer> {
    /**
     * 查询客户信息
     *
     * @param cusId 客户信息主键
     * @return 客户信息
     */
    public TjCustomer selectTjCustomerByCusId(Long cusId);
 
    /**
     * 查询客户信息列表
     *
     * @param tjCustomer 客户信息
     * @return 客户信息集合
     */
    public List<TjCustomer> selectTjCustomerList(TjCustomer tjCustomer);
 
    /**
     * 新增客户信息
     *
     * @param tjCustomer 客户信息
     * @return 结果
     */
    public int insertTjCustomer(TjCustomer tjCustomer);
 
    /**
     * 修改客户信息
     *
     * @param tjCustomer 客户信息
     * @return 结果
     */
    public int updateTjCustomer(TjCustomer tjCustomer);
 
    /**
     * 删除客户信息
     *
     * @param cusId 客户信息主键
     * @return 结果
     */
    public int deleteTjCustomerByCusId(Long cusId);
 
    /**
     * 批量删除客户信息
     *
     * @param cusIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTjCustomerByCusIds(Long[] cusIds);
 
 
    @Select("SELECT * FROM tj_customer WHERE cus_name like concat('%',#{name},'%') AND deleted=0 ")
    List<TjCustomer> getTjCustomerList(String name);
 
 
    @Select("SELECT * FROM tj_customer WHERE cus_idcard = #{cusIdCard} and deleted=0")
    TjCustomer getTjCustomerByCusIdCard(String cusIdCard);
 
 
    @Select("SELECT * FROM tj_customer WHERE cus_idcard = #{cusIdCard} deleted=0")
    ResultSet getJsonParseCustomerList(String deptId, Integer page, Integer pageSize, String cusName, String tjNumber);
 
    @Select("SELECT IFNULL(b.cn_name,'无')  FROM (\n" +
            "\n" +
            "SELECT a.firm_id cid FROM tj_order a WHERE a.user_id=#{cusId} ORDER BY a.order_id DESC LIMIT 1)" +
            " aa LEFT JOIN dict_comp b ON aa.cid=b.drug_manufacturer_id")
    String getCompNameByCusId(String cusId);
 
 
    @Update("update tj_customer set card_id=#{cardId} where cus_id=#{cusId}")
    void  updateCardId(@Param("cusId") Long cusId,@Param("cardId") String cardId);
 
 
//    @Select({"<script> select  * from  v_customer where 1=1 "+
//            " <when test='name !=null'>" +
//            "  AND xm like '%'+#{name}+'%'" +
//            "</when>" +
//            " <when test='sjh !=null'>" +
//            "  AND sjh like '%'+#{sjh}+'%' " +
//            "</when>" +
//            " <when test='sfzh !=null'>" +
//            "  AND sfzh = #{sfzh}" +
//            "</when>" +
//            "</script>"})
    List<Map<String, Object>> vcustomerlist(@Param("name")String name, @Param("sjh")String sjh, @Param("sfzh") String sfzh);
 
    List<TjCustomer> getcusList(TjCustomer tjCustomer);
 
    List<Map<String ,Object >> getCusInfoList(String card);
 
    List<Map<String ,Object >> getCusInfoListByCardAndName(@Param("card") String card,@Param("name") String name);
 
 
    @Select("SELECT IF(b.cus_sex=0,'男','女') xb FROM tj_order a JOIN tj_customer b ON b.cus_id=a.user_id \n" +
            "WHERE a.tj_number=#{tjNumber}")
    String getSexByTjh(String tjNumber);
}