Bonus-Cloud-Houqin/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/customer/CustInfoMapper.xml

289 lines
8.0 KiB
XML
Raw Normal View History

2025-02-27 13:36:55 +08:00
<?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" >
2025-02-27 13:46:27 +08:00
<mapper namespace="com.bonus.canteen.core.customer.mapper.CustInfoMapper">
2025-02-27 13:36:55 +08:00
<!--根据人员id集合获取人员信息-->
2025-02-27 13:46:27 +08:00
<select id="selectOne" resultType="com.bonus.canteen.core.customer.model.CustInfo">
2025-02-27 13:36:55 +08:00
select cust_id, cust_name, cust_num, cust_photo_url, mobile, pwd
from cust_info
<where>
cust_state = 1
<if test="custId != null">
and cust_id = #{custId}
</if>
<if test="custName != null and custName != ''">
and cust_name = #{custName}
</if>
<if test="custNum != null and custNum != ''">
and cust_num = #{custNum}
</if>
<if test="mobile != null and mobile != ''">
and mobile = #{mobile}
</if>
<if test="idCard != null and idCard != ''">
and id_card = #{idCard}
</if>
</where>
</select>
<update id="updateById">
update cust_info
set cust_name = #{custName}, cust_num = #{custNum}, mobile = #{mobile}, id_card = #{idCard}, pwd = #{pwd}
where cust_id = #{custId}
</update>
<!-- 用户详细信息,返回字段 -->
<sql id="detailInfo">
ci.cust_id,
ci.cust_num,
ci.cust_name,
ci.mobile,
ci.email,
ci.sex,
-- ci.age,
ci.id_card,
ci.birthday,
ci.cust_photo_url,
ci.org_id,
ci.cust_third_id,
ci.org_num,
ci.org_full_name,
ci.place_id,
place.place_num,
place.place_full_name,
ci.psn_type,
ci.psn_type_name,
ci.home_addr,
ci.qq,
ci.wechat,
ci.company_wechat,
ci.dingtalk,
ci.emer_contact_person,
ci.emer_contact_num,
ci.emer_contact_card,
ci.job,
ci.job_rank,
ci.job_level,
ci.job_title,
ci.job_title_rank,
ci.auth_strength,
ci.entry_date,
ci.signing_date,
ci.expiry_date,
-- ci.cust_type,
ci.birthday,
cd.label_ids,
cd.label_names,
cd.taste_ids,
cd.taste_names,
ai.end_date accEndDate,
ci.doctor_num,
ci.hospital_num
</sql>
2025-02-27 13:46:27 +08:00
<select id="queryCustInfoDetail" resultType="com.bonus.canteen.core.customer.vo.CustInfoVo">
2025-02-27 13:36:55 +08:00
select
<include refid="detailInfo"/>
,
ci.marital_status,
ci.cost_center_id,
A.name costCenterName,
ci.ethnicity_code,
ci.native_place,
ci.position,
ci.bank_card_num,
ci.head_portrait_url,
ci.extend_date,
ci.extend_date_time,
ci.extend_str1,
ci.extend_str2,
cc.openid
from cust_info ci
left join cust_diet_like cd on ci.cust_id = cd.cust_id and cd.if_del = 2
left join acc_info ai on ci.cust_id = ai.cust_id
LEFT JOIN cust_place place ON ci.place_id = place.place_id
LEFT JOIN cust_cost_center A ON A.cost_center_id = ci.cost_center_id
LEFT JOIN cust_casual cc on ci.cust_id = cc.cust_id
where ci.cust_id = #{info.custId}
and ci.cust_state = #{info.custState}
</select>
<!-- 查询用户详细信息 -->
2025-02-27 13:46:27 +08:00
<select id="queryCustInfo" resultType="com.bonus.canteen.core.customer.vo.CustInfoVo">
2025-02-27 13:36:55 +08:00
select ci.cust_limit_id,
<if test="info.serialNum != null and info.serialNum != ''">
ac.serial_num,
ac.card_status,
</if>
ci.alipay_contract_num,
<include refid="detailInfo"/>
from cust_info ci
left join cust_diet_like cd on ci.cust_id = cd.cust_id and cd.if_del = 2
left join acc_info ai on ci.cust_id = ai.cust_id
<if test="info.serialNum != null and info.serialNum != ''">
left join acc_card ac on ci.cust_id = ac.cust_id and ac.card_status in(1,4)
</if>
LEFT JOIN cust_place place ON ci.place_id = place.place_id
where 1 = 1
<if test="info.custId != null">
and ci.cust_id = #{info.custId}
</if>
<if test="info.custLimitId != null">
and ci.cust_limit_id = #{info.custLimitId}
</if>
<if test="info.serialNum != null and info.serialNum != ''">
and ac.serial_num = #{info.serialNum}
</if>
<if test="info.custState != null">
and ci.cust_state = #{info.custState}
</if>
</select>
2025-02-27 13:46:27 +08:00
<select id="getCustInfoForRechargeByCustNum" resultType="com.bonus.canteen.core.customer.vo.CustInfoForRechargeVO">
2025-02-27 13:36:55 +08:00
SELECT ci.cust_id,
ci.cust_num,
ci.cust_name,
ci.mobile,
ci.cust_third_id,
ci.org_full_name,
co.org_num
FROM cust_info AS ci
INNER JOIN cust_org AS co ON ci.org_id = co.org_id
where ci.cust_num = #{custNum}
and ci.cust_state = #{custState}
</select>
2025-02-27 13:46:27 +08:00
<select id="listCustInfoForRechargeByCustNums" resultType="com.bonus.canteen.core.customer.vo.CustInfoForRechargeVO">
2025-02-27 13:36:55 +08:00
SELECT
ci.cust_id,
ci.cust_third_id,
ci.cust_num,
ci.cust_name,
ci.mobile,
co.org_num,
co.org_name,
co.org_full_name
FROM
cust_info AS ci
LEFT JOIN cust_org AS co ON ci.org_id = co.org_id
where ci.cust_num in
<foreach collection="custNumList" item="custNum" separator="," open="(" close=")">
#{custNum}
</foreach>
and ci.cust_state = #{custState}
</select>
<select id="queryOrgManagerCustIdByCustId" resultType="java.lang.Long">
SELECT t2.org_head_id
FROM cust_org t2
INNER JOIN cust_info t1 ON t1.org_id = t2.org_id
WHERE t1.cust_id = #{custId}
</select>
<select id="getOrgManagerCustIdByCustId" resultType="java.lang.Long">
SELECT t2.org_head_id
FROM cust_org t2
WHERE EXISTS(
SELECT 1
FROM cust_info t1
WHERE t1.cust_id = #{custId}
AND t1.org_id = t2.org_id
)
</select>
2025-02-27 13:46:27 +08:00
<select id="getCustPayVO" resultType="com.bonus.canteen.core.customer.vo.CustPayVO">
2025-02-27 13:36:55 +08:00
SELECT a.cust_id,
a.psn_type,
a.psn_type_name,
a.org_id,
a.org_num,
a.cust_third_id,
a.alipay_contract_num,
a.cust_state,
a.cust_num,
a.cust_name,
a.org_full_name,
a.cust_photo_url,
a.head_portrait_url,
a.mobile,
b.serial_num,
b.third_serial_num,
b.card_status,
b.validity_date
FROM
cust_info a
LEFT JOIN acc_card b ON b.cust_id = a.cust_id and b.card_status in (1, 4)
<if test="custPayDTO.openid != null and custPayDTO.openid != ''">
LEFT JOIN cust_casual c ON c.cust_id = a.cust_id
</if>
<where>
<if test="custPayDTO.serialNum != null and custPayDTO.serialNum != ''">
AND b.serial_num = #{custPayDTO.serialNum}
</if>
<if test="custPayDTO.openid != null and custPayDTO.openid != ''">
AND c.openid = #{custPayDTO.openid}
</if>
<if test="custPayDTO.custId != null">
AND a.cust_id = #{custPayDTO.custId}
</if>
</where>
</select>
<select id="selectCustCasualByCustId" resultType="com.bonus.domain.CustCasual">
select casual_id, openid from cust_casual where cust_id = #{custId} and source_type = #{sourceType} and if_del = 2
</select>
<insert id="addCustCasual">
insert into cust_casual (casual_id, casual_name, cust_id, mobile, openid, source_type)
values (#{casualId}, #{casualName}, #{custId}, #{mobile}, #{openid}, #{sourceType})
</insert>
<update id="updateCustCasual">
update cust_casual
set openid = #{openid}, mobile = #{mobile}
where casual_id = #{casualId}
</update>
</mapper>