This commit is contained in:
sxu 2025-01-27 13:13:10 +08:00
parent 8ce263c0d1
commit 99af3b25eb
4 changed files with 26 additions and 853 deletions

View File

@ -57,5 +57,6 @@ public class AesEncryptUtil {
public static void main(String[] args) {
System.out.println(aesEncrypt("123"));
System.out.println(aesDecode("Ko0muw9mxpn4mKcd40W0gw=="));
//System.out.println(aesDecode("$2a$10$WoMFC/Qwh/fgVeJoywyqZ.ua6OFU8wxdzaZj4SM14PYa6GimETwMe"));
}
}

View File

@ -11,7 +11,9 @@ import org.apache.ibatis.annotations.Select;
@Mapper
public interface CustInfoMapper extends BaseMapper<CustInfo> {
@Select({"select cust_id, cust_name, cust_num, cust_photo_url, mobile ,pwd from cust_info ${ew.customSqlSegment}"})
CustInfoAppIdLoginVO selectLoginInfo(@Param("ew") Wrapper<CustInfo> wrapper);
// @Select({"select cust_id, cust_name, cust_num, cust_photo_url, mobile ,pwd from cust_info ${ew.customSqlSegment}"})
// CustInfoAppIdLoginVO selectLoginInfo(@Param("ew") Wrapper<CustInfo> wrapper);
CustInfoAppIdLoginVO selectLoginInfo(CustInfo custInfo);
}

View File

@ -1,847 +1,25 @@
<?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="net.xnzn.core.customer.mapper.CustInfoMapper">
<!-- 用户基本信息(小程序使用),返回字段 -->
<sql id="baseInfoForApp">
cc.openid,
cc.source_type,
ci.cust_id,
ci.cust_third_id,
ci.cust_name,
ci.mobile,
ai.acc_bal,
ai.subsidy,
ai.red_envelope,
ai.scope
</sql>
<!-- 用户详细信息(小程序使用),返回字段 -->
<sql id="detailInfoForApp">
cc.openid,
ci.cust_third_id,
ci.pwd,
cc.source_type,
ci.cust_id,
ci.cust_name,
ci.mobile,
ci.email,
ci.sex,
ci.age,
ci.birthday,
ci.cust_photo_url,
ci.id_card,
ci.grade_name,
ci.home_addr,
ci.org_id,
ci.psn_type
</sql>
<!-- 用户详细信息,返回字段 -->
<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>
<update id="updateCustomersOrgNumAndOrgFullName">
UPDATE cust_info A
LEFT JOIN cust_org B ON A.org_id = B.org_id
set A.org_num = B.org_num, A.org_full_name = B.org_full_name
where A.org_id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<!-- 分页查询注销人员 -->
<select id="pageCancelCustInfo" resultType="net.xnzn.core.customer.vo.PageCancelCustInfoVO"
parameterType="net.xnzn.core.customer.dto.CustInfoParam">
SELECT ci.id,
ci.cust_id,
ci.cust_num,
ci.cust_name,
ci.mobile,
ci.org_id,
ci.org_full_name,
ci.cust_state,
ci.upby,
ci.uptime
FROM cust_info AS ci
<!--根据人员id集合获取人员信息-->
<select id="selectLoginInfo" resultType="net.xnzn.core.customer.vo.CustInfoAppIdLoginVO">
select cust_id, cust_name, cust_num, cust_photo_url, mobile, pwd
from cust_info
<where>
<if test="infoParam.keyword != null and infoParam.keyword != ''">
and (ci.cust_num LIKE CONCAT('%', #{infoParam.keyword},'%')
or ci.cust_name = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.cust_name_like LIKE CONCAT('%',#{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.CipherQueryLikeHandler},'%')
or ci.mobile = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.mobile_suffix = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
)
</if>
<if test="infoParam.custName != null and infoParam.custName != ''">
and ci.cust_name = #{infoParam.custName,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
</if>
<if test="infoParam.custNum != null and infoParam.custNum != ''">
and ci.cust_num = #{infoParam.custNum}
</if>
<if test="infoParam.orgIdList != null and infoParam.orgIdList.size > 0">
and ci.org_id in
<foreach collection="infoParam.orgIdList" item="orgId" separator="," open="(" close=")">
#{orgId}
</foreach>
</if>
<if test="infoParam.mobile != null and infoParam.mobile != ''">
and ci.mobile = #{infoParam.mobile,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
</if>
<if test="infoParam.custState != null">
and ci.cust_state = #{infoParam.custState}
</if>
</where>
order by ci.id desc
</select>
<select id="pageCustInfoPhoto" resultType="net.xnzn.core.customer.vo.PageCustInfoPhotoVO"
parameterType="net.xnzn.core.customer.dto.CustInfoParam">
SELECT
ci.id,
ci.cust_id,
ci.cust_num,
ci.cust_name,
ci.mobile,
ci.email,
ci.org_id,
co.org_full_name,
ci.cost_center_id,
A.name costCenterName,
ci.place_id,
place.place_full_name,
ci.sex,
B.job_name job,
ci.cust_third_id,
ci.home_addr,
ci.qq,
ci.wechat,
ci.psn_type,
ci.psn_type_name,
ci.dingtalk,
ci.cust_state,
ci.crtime,
-- ci.cust_type,
ci.birthday,
cp.photo_url,
cp.features_build_status,
cp.features_build_time,
cp.error_msg,
cp.expire_date,
ac.card_status cardStatus,
ac.serial_num serialNum,
ac.crtime openCardTime,
ci.cust_limit_id,
ci.extend_date,
ci.extend_date_time,
ci.extend_str1,
ci.extend_str2
FROM cust_info ci
LEFT JOIN (
SELECT cust_id,max(features_build_status) features_build_status ,MAX(features_build_time) features_build_time ,MAX(photo_url) photo_url,MAX(error_msg) error_msg ,MAX(expire_date) expire_date from cust_photo WHERE photo_type = 1 GROUP BY cust_id ) cp ON ci.cust_id = cp.cust_id
LEFT JOIN cust_org co ON co.org_id = ci.org_id
LEFT JOIN
(SELECT cust_id,
GROUP_CONCAT(serial_num SEPARATOR ', ') as serial_num,
GROUP_CONCAT(card_status SEPARATOR ', ') as card_status,
GROUP_CONCAT(DATE_FORMAT(crtime, '%Y-%m-%d %H:%i:%s') SEPARATOR ', ') as crtime
FROM acc_card where card_status in(1,4)
GROUP BY cust_id) ac ON ac.cust_id = ci.cust_id
LEFT JOIN cust_place place ON place.place_id = ci.place_id
LEFT JOIN cust_cost_center A ON A.cost_center_id = ci.cost_center_id
LEFT JOIN cust_job B ON B.job_code = ci.job AND B.job_type = 1
<where>
<if test="infoParam.custId != null">
and ci.cust_id = #{infoParam.custId}
</if>
<if test="infoParam.custName != null and infoParam.custName != ''">
and ci.cust_name_like LIKE CONCAT('%',#{infoParam.custName,typeHandler=net.xnzn.core.common.encrypt.CipherQueryLikeHandler},'%')
</if>
<if test="infoParam.custNum != null and infoParam.custNum != ''">
and ci.cust_num = #{infoParam.custNum}
</if>
<if test="infoParam.keyword != null and infoParam.keyword != ''">
and (ci.cust_num LIKE CONCAT('%', #{infoParam.keyword},'%')
or ci.cust_name = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.cust_name_like LIKE CONCAT('%',#{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.CipherQueryLikeHandler},'%')
or ci.mobile = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.mobile_suffix = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
)
</if>
<if test="infoParam.orgIdList != null and infoParam.orgIdList.size > 0">
and ci.org_id in
<foreach collection="infoParam.orgIdList" item="orgId" separator="," open="(" close=")">
#{orgId}
</foreach>
</if>
<if test="infoParam.placeIdList != null and infoParam.placeIdList.size > 0">
and ci.place_id in
<foreach collection="infoParam.placeIdList" item="placeId" separator="," open="(" close=")">
#{placeId}
</foreach>
</if>
<if test="infoParam.mobile != null and infoParam.mobile != ''">
and ci.mobile = #{infoParam.mobile,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
</if>
<if test="infoParam.sex != null">
and ci.sex = #{infoParam.sex}
</if>
<if test="infoParam.psnType != null and infoParam.psnType != -99">
and ci.psn_type = #{infoParam.psnType}
</if>
<if test="infoParam.psnType == -99">
and ci.psn_type is null
</if>
<if test="infoParam.psnTypeList != null and infoParam.psnTypeList.size > 0">
and ci.psn_type in
<foreach collection="infoParam.psnTypeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="infoParam.custState != null">
and ci.cust_state = #{infoParam.custState}
</if>
<if test="infoParam.featuresBuildStatus == 1">
and (cp.features_build_status is null or cp.features_build_status = 1)
</if>
<if test="infoParam.featuresBuildStatus == 2 or infoParam.featuresBuildStatus == 3">
and cp.features_build_status = #{infoParam.featuresBuildStatus}
</if>
<if test="infoParam.serialNum != null or (infoParam.cardStatusList != null and infoParam.cardStatusList.size > 0) or infoParam.beginOpenCardTime != null">
and EXISTS (SELECT 1 FROM acc_card acc
WHERE acc.cust_id = ci.cust_id and acc.card_status in(1,4)
<if test="infoParam.serialNum != null">
AND acc.serial_num like concat('%', #{infoParam.serialNum},'%')
</if>
<if test="infoParam.cardStatusList != null and infoParam.cardStatusList.size > 0">
and acc.card_status in
<foreach collection="infoParam.cardStatusList" item="cardStatus" separator="," open="(" close=")">
#{cardStatus}
</foreach>
</if>
<if test="infoParam.beginOpenCardTime != null">
<![CDATA[
and acc.crtime >= #{infoParam.beginOpenCardTime}
]]>
</if>
<if test="infoParam.endOpenCardTime != null">
<![CDATA[
and acc.crtime <= #{infoParam.endOpenCardTime}
]]>
</if>
)
</if>
<if test="infoParam.birthdayStartTime">
<![CDATA[
and ci.birthday >= #{infoParam.birthdayStartTime}
]]>
</if>
<if test="infoParam.birthdayEndTime != null">
<![CDATA[
and ci.birthday <= #{infoParam.birthdayEndTime}
]]>
</if>
<if test="infoParam.costCenterIds != null and infoParam.costCenterIds.size > 0">
and ci.cost_center_id in
<foreach collection="infoParam.costCenterIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
order by ci.id desc
</select>
<!-- 分页查询人员及职位信息 -->
<select id="pageCustJobInfo" resultType="net.xnzn.core.customer.vo.PageCustJobInfoVO"
parameterType="net.xnzn.core.customer.dto.CustJobInfoParam">
SELECT
t1.id, t1.cust_id, t1.cust_num, t1.cust_name, t1.mobile, t1.job, t2.org_full_name
FROM cust_info t1
LEFT JOIN cust_org t2 ON t1.org_id = t2.org_id
WHERE
t1.cust_state = 1
<if test="param.keyword != null and param.keyword != ''">
and (t1.cust_num LIKE CONCAT('%', #{param.keyword},'%')
or t1.cust_name = #{param.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or t1.cust_name_like LIKE CONCAT('%',#{param.keyword,typeHandler=net.xnzn.core.common.encrypt.CipherQueryLikeHandler},'%')
or t1.mobile = #{param.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or t1.mobile_suffix = #{param.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
)
</if>
<choose>
<when test="param.job != null and param.job != ''">
AND t1.job = #{param.job}
</when>
<when test="param.ifQueryJob == 1">
AND t1.job IS NOT NULL AND t1.job != ''
</when>
</choose>
order by t1.id desc
</select>
<select id="pageCustInfoDoorPwd" resultType="net.xnzn.core.device.door.dto.cust.PageCustInfoDoorPwdVO"
parameterType="net.xnzn.core.customer.dto.CustInfoParam">
select ci.cust_id as custId,
ci.sex as sex,
ci.job as job,
ci.org_id as orgId,
ci.cust_name as custName,
ci.cust_num as custNum,
ci.psn_type as psnType,
cpt.psn_type_name as psnTypeName,
co.org_name as orgName,
co.org_full_name as orgFullName,
ci.cust_photo_url as custPhotoUrl,
dcdp.is_valid as isValidDate
from cust_info ci
left join dc_cust_door_pwd dcdp on dcdp.cust_id = ci.cust_id
left join cust_org co on co.org_id = ci.org_id
LEFT JOIN cust_psn_type cpt ON cpt.psn_type = ci.psn_type
<where>
<if test="infoParam.custName != null and infoParam.custName != ''">
and ci.cust_name = #{infoParam.custName,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
</if>
<if test="infoParam.custNum != null and infoParam.custNum != ''">
and ci.cust_num = #{infoParam.custNum}
</if>
<if test="infoParam.keyword != null and infoParam.keyword != ''">
and (ci.cust_num LIKE CONCAT('%', #{infoParam.keyword},'%')
or ci.cust_name = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.cust_name_like LIKE CONCAT('%',#{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.CipherQueryLikeHandler},'%')
or ci.mobile = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or ci.mobile_suffix = #{infoParam.keyword,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler})
</if>
<if test="infoParam.orgIdList != null and infoParam.orgIdList.size > 0">
and ci.org_id in
<foreach collection="infoParam.orgIdList" item="orgId" separator="," open="(" close=")">
#{orgId}
</foreach>
</if>
<if test="infoParam.mobile != null and infoParam.mobile != ''">
and ci.mobile = #{infoParam.mobile}
</if>
<if test="infoParam.sex != null">
and ci.sex = #{infoParam.sex}
</if>
<if test="infoParam.psnType != null">
and ci.psn_type = #{infoParam.psnType}
</if>
<if test="infoParam.custState != null">
and ci.cust_state = #{infoParam.custState}
</if>
<if test="infoParam.birthdayStartTime">
<![CDATA[
and ci.birthday >= #{infoParam.birthdayStartTime}
]]>
</if>
<if test="infoParam.birthdayEndTime != null">
<![CDATA[
and ci.birthday <= #{infoParam.birthdayEndTime}
]]>
</if>
<if test="infoParam.doorStatus != null ">
AND
<if test="infoParam.doorStatus == 1">
EXISTS (select null from dc_cust_door dcdp where dcdp.cust_id = ci.cust_id) AND NOT
</if>
EXISTS (select null from dc_cust_door dcdp where dcdp.cust_id = ci.cust_id and dcdp.registry_result in (0,2))
</if>
</where>
order by ci.id desc
</select>
<!-- 查询用户详细信息 -->
<select id="queryCustInfoDetail" resultType="net.xnzn.core.customer.vo.CustInfoVo">
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
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
where ci.cust_id = #{info.custId}
and ci.cust_state = #{info.custState}
</select>
<!-- 查询人员和账户关联信息 -->
<select id="getAccCustInfo" resultType="net.xnzn.core.customer.dto.CustAccInfoModel"
parameterType="net.xnzn.core.customer.dto.CustInfoParam">
select ci.*
, ai.acc_id
, ai.wallet_bal
, ai.subsidy_bal
, ai.red_envelope
, ai.acc_bal
, ai.acc_pay_count
, ai.acc_status
, ai.month_full_reduce_amount
, ai.last_full_reduce_time
from cust_info ci
inner join acc_info ai
on ci.cust_id = ai.cust_id
<where>
<if test="custId != null">
and ci.cust_id = #{custId}
cust_status = 1 and (psn_type != 999 or psn_type is null)
<if test="custName != null and custName != ''">
and cust_name = #{custName}
</if>
<if test="custNum != null and custNum != ''">
and ci.cust_num = #{custNum}
and cust_num = #{custNum}
</if>
<if test="custLimitId != null">
and ci.cust_limit_id = #{custLimitId}
</if>
<if test="custState != null">
and ci.cust_state = #{custState}
</if>
</where>
limit 1
</select>
<!-- 根据openid和来源查询人员信息 -->
<select id="queryCustInfoByOpenid" resultType="net.xnzn.core.customer.vo.CustInfoVo">
select ci.*,
cc.openid,
cc.source_type
from cust_casual cc
inner join cust_info ci on cc.cust_id = ci.cust_id and ci.cust_state = #{infoModel.custState}
where cc.openid = #{infoModel.openid}
and cc.source_type = #{infoModel.sourceType}
</select>
<!-- 根据一堆条件获取人员id集合(and条件) -->
<select id="selectCustIdByCondition" resultType="java.lang.Long">
select cust_id
from cust_info
<where>
cust_state = 1
<if test="orgIdList != null and orgIdList.size() > 0">
and org_id in
<foreach close=")" collection="orgIdList" item="orgId" open="(" separator=",">
#{orgId}
</foreach>
</if>
<if test="psnTypeList != null and psnTypeList.size() > 0">
and psn_type in
<foreach close=")" collection="psnTypeList" item="psnType" open="(" separator=",">
#{psnType}
</foreach>
</if>
<if test="crtime != null">
<![CDATA[
and crtime <= #{crtime}
]]>
</if>
</where>
</select>
<!-- 根据一堆条件获取人员id集合(or条件) -->
<select id="selectCustIdOrCondition" resultType="java.lang.Long">
select cust_id
from cust_info
<where>
<if test="orgIdList != null and orgIdList.size() > 0">
or org_id in
<foreach close=")" collection="orgIdList" item="orgId" open="(" separator=",">
#{orgId}
</foreach>
</if>
<if test="psnTypeList != null and psnTypeList.size() > 0">
or psn_type in
<foreach close=")" collection="psnTypeList" item="psnType" open="(" separator=",">
#{psnType}
</foreach>
</if>
and cust_state = 1
</where>
</select>
<!--根据人员id集合获取人员信息-->
<select id="selectListByCustIdList" resultType="net.xnzn.core.customer.dto.InformUserInfoVO">
SELECT ci.cust_id,
ci.cust_num,
ci.cust_name,
ci.mobile,
ci.org_id,
ci.psn_type,
cc.openid,
ai.acc_bal,
cc.source_type
FROM cust_info ci
LEFT JOIN cust_casual cc ON ci.cust_id = cc.cust_id
LEFT JOIN acc_info ai ON ai.cust_id = ci.cust_id
<where>
ci.cust_state = 1
<if test="custIdList != null and custIdList.size() > 0">
and ci.cust_id in
<foreach collection="custIdList" item="custId" separator="," open="(" close=")">
#{custId}
</foreach>
</if>
</where>
</select>
<!-- 查询人员及账户余额信息 shihao.li -->
<select id="queryCustAccBal" parameterType="net.xnzn.core.customer.dto.CustInfoParam"
resultType="net.xnzn.core.customer.vo.CustAccBalVO">
select ci.cust_id,
ci.cust_num,
ci.cust_name,
ci.cust_photo_url,
ci.org_full_name,
ai.wallet_bal,
ai.subsidy_bal,
ai.acc_bal,
ai.balance2,
ai.red_envelope,
ai.scope
from cust_info ci
inner join acc_info ai on ci.cust_id = ai.cust_id
inner join acc_card ac on ai.acc_id = ac.acc_id and ac.card_status in(1,4)
where ac.serial_num = #{serialNum}
and ci.cust_state = #{custState}
</select>
<!-- 根据人员id以及部门id获取人员信息 -->
<select id="selectCancelCustInfo" resultType="net.xnzn.core.customer.vo.BatchCancelCustInfoVO">
select distinct ci.cust_id,
ci.cust_limit_id,
ci.cust_num,
ci.cust_name,
ci.org_id,
ci.org_full_name,
ai.acc_id
from cust_info ci
left join acc_info ai on ci.cust_id = ai.cust_id
where ci.cust_state = 1
<choose>
<when test="selectType == 1">
and (
ci.cust_id in
<foreach collection="custIdList" item="custId" separator="," open="(" close=")">
#{custId}
</foreach>
or ci.org_id in
<foreach collection="orgIdList" item="orgId" separator="," open="(" close=")">
#{orgId}
</foreach>
)
</when>
<when test="selectType == 2">
and ci.cust_id in
<foreach collection="custIdList" item="custId" separator="," open="(" close=")">
#{custId}
</foreach>
</when>
<when test="selectType == 3">
and ci.org_id in
<foreach collection="orgIdList" item="orgId" separator="," open="(" close=")">
#{orgId}
</foreach>
</when>
</choose>
</select>
<select id="queryCustInfoByCustIdList" resultType="net.xnzn.core.customer.model.CustInfo">
select *
from cust_info
where cust_state = 1
and cust_id in
<foreach collection="custIdList" item="custId" separator="," open="(" close=")">
#{custId}
</foreach>
</select>
<select id="getCustPayVO" resultType="net.xnzn.core.customer.vo.CustPayVO">
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="queryCustInfo" resultType="net.xnzn.core.customer.vo.CustInfoVo">
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>
<!-- 根据人员编号查询人员基本信息-->
<select id="getCustInfoForRechargeByCustNum" resultType="net.xnzn.core.customer.vo.CustInfoForRechargeVO">
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>
<select id="queryCustNoticeInfoList" resultType="net.xnzn.core.customer.vo.CustNoticeInfoVO">
SELECT A.cust_id,
A.cust_num,
A.cust_name,
A.org_id,
A.org_full_name
<choose>
<when test="queryDTO.recipientType != null and (queryDTO.recipientType == 1 or queryDTO.recipientType == 999)">
,A.mobile recipient
</when>
<otherwise>
,B.openid recipient
</otherwise>
</choose>
FROM cust_info A
<if test="queryDTO.recipientType != null and queryDTO.recipientType == 2">
LEFT JOIN cust_casual B ON A.cust_id = B.cust_id AND B.source_type = 2
</if>
<if test="queryDTO.recipientType != null and queryDTO.recipientType == 3">
LEFT JOIN cust_casual B ON A.cust_id = B.cust_id AND B.source_type = 1
</if>
<if test="queryDTO.recipientType != null and queryDTO.recipientType == 4">
LEFT JOIN cust_casual B ON A.cust_id = B.cust_id AND B.source_type = 9
</if>
<if test="queryDTO.recipientType != null and queryDTO.recipientType == 5">
LEFT JOIN cust_casual B ON A.cust_id = B.cust_id AND B.source_type = 3
</if>
<where>
A.cust_state = 1
<if test="queryDTO.startOrderTime != null">
AND A.order_time <![CDATA[ >= ]]> #{queryDTO.startOrderTime}
</if>
<if test="queryDTO.endOrderTime != null">
AND A.order_time <![CDATA[ <= ]]> #{queryDTO.endOrderTime}
</if>
<if test="queryDTO.endOrderTime != null">
AND A.order_time <![CDATA[ <= ]]> #{queryDTO.endOrderTime}
</if>
<if test="queryDTO.keywords != null and queryDTO.keywords != ''">
and (A.cust_num LIKE CONCAT('%', #{queryDTO.keywords},'%')
or A.cust_name = #{queryDTO.keywords,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or A.cust_name_like LIKE CONCAT('%',#{queryDTO.keywords,typeHandler=net.xnzn.core.common.encrypt.CipherQueryLikeHandler},'%')
or A.mobile = #{queryDTO.keywords,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler}
or A.mobile_suffix = #{queryDTO.keywords,typeHandler=net.xnzn.core.common.encrypt.SM4EncDecHandler})
</if>
<if test="queryDTO.orgIdList != null and queryDTO.orgIdList.size() > 0">
AND A.org_id in
<foreach collection="queryDTO.orgIdList" item="orgId" separator="," open="(" close=")">
#{orgId}
</foreach>
</if>
<choose>
<when test="queryDTO.recipientType != null and queryDTO.recipientType == 1">
AND A.mobile IS NOT NULL
</when>
<when test="queryDTO.recipientType != null and queryDTO.recipientType == 999">
</when>
<otherwise>
AND B.openid IS NOT NULL
</otherwise>
</choose>
</where>
</select>
<select id="existsCustomerByCustIdAndPsnType" resultType="java.lang.Integer">
SELECT 1
FROM cust_info
<where>
cust_id = #{custId}
AND psn_type = #{psnType}
AND cust_state = 1
LIMIT 1
</where>
</select>
<!-- 根据人员编号集合查询人员基本信息-->
<select id="listCustInfoForRechargeByCustNums" resultType="net.xnzn.core.customer.vo.CustInfoForRechargeVO">
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="getCustIdAndStateByCustThirdId"
resultType="net.xnzn.core.customer.openapi.vo.CustIdAndStateVO">
SELECT cust_id, cust_state
FROM cust_info
WHERE cust_third_id = #{custThirdId}
</select>
<select id="getCustomerNumByOrgIdList" resultType="net.xnzn.core.customer.po.CustomerNumByOrgIdMapperPO">
SELECT
org_id,
COUNT(*) customerNum
FROM
cust_info
<where>
cust_state = 1
<if test="orgIdList != null and orgIdList.size() > 0">
AND org_id in
<foreach collection="orgIdList" item="orgId" separator="," open="(" close=")">
#{orgId}
</foreach>
</if>
</where>
GROUP BY org_id
</select>
<select id="getCustInfoByMobile" resultType="net.xnzn.core.customer.model.CustInfo">
SELECT ci.cust_id,
ci.cust_num,
ci.cust_name,
ci.mobile
FROM cust_info AS ci
WHERE cust_state = 1
<if test="mobile != null and mobile != ''">
and mobile = #{mobile}
</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>
<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}
</if>
<if test="idCard != null and idCard != ''">
and id_card = #{idCard}
</if>
</where>
</select>
</mapper>

View File

@ -51,26 +51,21 @@ public class CustInfoBusinessImpl implements CustInfoBusiness {
Integer loginType = content.getLoginType();
if (loginType != null && CustLoginTypeEnum.contains(loginType)) {
Long merchantId = 1L;
// Long merchantId = (Long)Executors.readInSystem(() -> {
// return this.allocMerchantApi.getMerchantIdByAppid(LoginSourceTypeEnum.getAppIdKey(sourceType), content.getAppId());
// });
if (ObjectUtil.isEmpty(merchantId)) {
throw new ServiceException("商户appId不存在");
} else {
//TenantContextHolder.setTenantId(merchantId);
if (CharSequenceUtil.isNotBlank(content.getMobile())) {
content.setMobile(this.aesEncryptUtil.aesDecode(content.getMobile()));
}
LambdaQueryWrapper<CustInfo> custInfoWrapper = (LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(CustInfo.class).eq(CustInfo::getCustState, PersonalStatusEnum.NORMAL.getKey())).and((wrapper) -> {
((LambdaQueryWrapper)((LambdaQueryWrapper)wrapper.ne(CustInfo::getPsnType, CustConstant.TEMPORARY_PSN_TYPE)).or()).isNull(CustInfo::getPsnType);
});
CustInfo custInfo = new CustInfo();
if (CustLoginTypeEnum.NAME_PWD.key().equals(content.getLoginType())) {
custInfoWrapper.eq(CustInfo::getCustName, SM4EncryptUtils.sm4Encryptbyconfig(content.getCustName()));
custInfo.setCustName(SM4EncryptUtils.sm4Encryptbyconfig(content.getCustName()));
} else if (CustLoginTypeEnum.NAME_CUST_NUM_PWD.key().equals(content.getLoginType())) {
((LambdaQueryWrapper)custInfoWrapper.eq(CustInfo::getCustName, SM4EncryptUtils.sm4Encryptbyconfig(content.getCustName()))).eq(CustInfo::getCustNum, content.getCustNum());
custInfo.setCustName(SM4EncryptUtils.sm4Encryptbyconfig(content.getCustName()));
custInfo.setCustNum(content.getCustNum());
} else if (CustLoginTypeEnum.TEL_PWD.key().equals(content.getLoginType())) {
custInfoWrapper.eq(CustInfo::getMobile, SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile()));
custInfo.setMobile(SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile()));
} else if (CustLoginTypeEnum.TEL_CODE.key().equals(content.getLoginType())) {
SmsCodeVerifyDTO smsCodeVerifyDTO = new SmsCodeVerifyDTO();
smsCodeVerifyDTO.setCode(content.getCode());
@ -79,17 +74,14 @@ public class CustInfoBusinessImpl implements CustInfoBusiness {
if (!flag) {
throw new ServiceException("验证码错误");
}
custInfoWrapper.eq(CustInfo::getMobile, SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile()));
custInfo.setMobile(SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile()));
} else {
if (!CustLoginTypeEnum.ID_CARD_PWD.key().equals(content.getLoginType())) {
throw new ServiceException("参数错误");
}
custInfoWrapper.eq(CustInfo::getIdCard, SM4EncryptUtils.sm4Encryptbyconfig(content.getIdCard()));
custInfo.setIdCard(SM4EncryptUtils.sm4Encryptbyconfig(content.getIdCard()));
}
CustInfoAppIdLoginVO result = this.custInfoMapper.selectLoginInfo(custInfoWrapper);
CustInfoAppIdLoginVO result = this.custInfoMapper.selectLoginInfo(custInfo);
if (ObjectUtil.isEmpty(result)) {
throw new ServiceException("未找到用户");
} else {
@ -127,7 +119,7 @@ public class CustInfoBusinessImpl implements CustInfoBusiness {
openid = custCasual.getOpenid();
if (StringUtils.isBlank(openid)) {
openid = IdUtil.simpleUUID();
this.custCasualMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(CustCasual.class).eq(CustCasual::getCasualId, custCasual.getCasualId())).set(CustCasual::getOpenid, openid));
//this.custCasualMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(CustCasual.class).eq(CustCasual::getCasualId, custCasual.getCasualId())).set(CustCasual::getOpenid, openid));
}
}