java-retail-app/bd-business/bd-business-member/src/main/resources/mapper/member/base/CuMemberMapper.xml

2660 lines
104 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="com.hzs.member.base.mapper.CuMemberMapper">
<!-- 查询登录会员以及状态 -->
<resultMap id="MemberResultMap" type="com.hzs.common.domain.member.ext.CuMemberExt">
<id column="PK_ID" property="pkId"/>
<result column="MEMBER_CODE" property="memberCode"/>
<result column="MEMBER_NAME" property="memberName"/>
<result column="CUSTOMER_TYPE" property="customerType"/>
<result column="PHONE" property="phone"/>
<result column="ID_CARD" property="idCard"/>
<result column="SEX" property="sex"/>
<result column="BIRTH_DATE" property="birthDate"/>
<result column="PK_COUNTRY" property="pkCountry"/>
<result column="PK_SETTLE_COUNTRY" property="pkSettleCountry"/>
<result column="PARENT" property="parent"/>
<result column="PK_PARENT" property="pkParent"/>
<result column="PK_PLACE_PARENT" property="pkPlaceParent"/>
<result column="PLACE_DEPT" property="placeDept"/>
<result column="PK_TEAM_CODE" property="pkTeamCode"/>
<result column="PK_CENTER_CODE" property="pkCenterCode"/>
<result column="SOURCE" property="source"/>
<result column="PK_REGISTER_GRADE" property="pkRegisterGrade"/>
<result column="PK_SETTLE_GRADE" property="pkSettleGrade"/>
<result column="PK_AWARDS" property="pkAwards"/>
<result column="PK_MAX_AWARDS" property="pkMaxAwards"/>
<result column="CONSUME_MONEY" property="consumeMoney"/>
<result column="CONSUME_ACHIEVE" property="consumeAchieve"/>
<result column="PURCHASE_STATUS" property="purchaseStatus"/>
<result column="SHARE_STATUS" property="shareStatus"/>
<result column="PAY_TIME" property="payTime"/>
<result column="PAY_STATUS" property="payStatus"/>
<result column="LOGIN_PWD" property="loginPwd"/>
<result column="PAY_PWD" property="payPwd"/>
<result column="LOGIN_PASSWORD" property="loginPassword"/>
<result column="PAY_PASSWORD" property="payPassword"/>
<result column="EDIT_NUMBER" property="editNumber"/>
<result column="PK_CREATOR" property="pkCreator"/>
<result column="CREATION_TIME" property="creationTime"/>
<result column="PK_MODIFIED" property="pkModified"/>
<result column="MODIFIED_TIME" property="modifiedTime"/>
<result column="REGISTER_AUTHORITY" property="registerAuthority"/>
<result column="PK_VERTEX" property="pkVertex"/>
<result column="ACCOUNT_STATUS" property="accountStatus"/>
<result column="PAY_STATUS" property="payStatus"/>
<result column="CATEGORY" property="category"/>
<result column="EMAIL" property="email"/>
<result column="ORDER_SOURCE" property="orderSource"/>
<result column="IS_REAL_NAME" property="isRealName"/>
<result column="IS_BUS_LICENSE" property="isBusLicense"/>
<result column="IS_MAKER_SPACE" property="isMakerSpace"/>
<result column="CHANGE_NUMBER" property="changeNumber"/>
<result column="WECHAT" property="wechat"/>
<result column="CARD_TYPE" property="cardType"/>
<result column="NICK_NAME" property="nickName"/>
<result column="HEAD_PATH" property="headPath"/>
<result column="DIRECT_PUSH_NUMBER" property="directPushNumber"/>
<result column="IS_DEALER" property="isDealer"/>
<result column="SYSTEM_LEVEL" property="systemLevel"/>
<result column="LECTURER_LEVEL" property="lecturerLevel"/>
<result column="SUPER_STUDIO" property="superStudio"/>
<result column="ID_FRONT" property="idFront"/>
<result column="ID_BACK" property="idBack"/>
<result column="PK_PROVINCE" property="pkProvince"/>
<result column="PK_CITY" property="pkCity"/>
<result column="PK_COUNTY" property="pkCounty"/>
<result column="ADDRESS" property="address"/>
<result column="BANK_NAME" property="bankName"/>
<result column="SUB_BANK_NAME" property="subBankName"/>
<result column="ACCOUNT_NAME" property="accountName"/>
<result column="reservedPhone" property="reservedPhone"/>
<result column="CARD_NUMBER" property="cardNumber"/>
<result column="certificationTime" property="certificationTime"/>
<result column="directPushNumber" property="directPushNumber"/>
<result column="ID_TYPE" property="idType"/>
<result column="GLOBAL_CODE" property="globalCode"/>
<result column="COUNTRY_CODE" property="countryCode"/>
<result column="recommendedOrderNumber" property="recommendedOrderNumber"/>
<result column="GLOBAL_CODE" property="globalCode"/>
<result column="COUNTRY_CODE" property="countryCode"/>
<result column="GRADE_VALUE" property="gradeValue"/>
<result column="REGISTER_GRADEVAL" property="registerGradeVal"/>
<result column="AWARDS_VAL" property="awardsVal"/>
<result column="TEAM_CODE" property="teamCode"/>
<result column="TEAM_NAME" property="teamName"/>
<result column="SERVICE_AGREEMENT" property="serviceAgreement"/>
<result column="EXPIRE_DATE" property="expireDate"/>
<result column="STOP_DATE" property="stopDate"/>
<result column="EXPIRE_STATUS" property="expireStatus"/>
<result column="SERVICE_CODE" property="serviceCode"/>
<result column="SYSTEM_TYPE" property="systemType"/>
<result column="IS_REGION" property="isRegion"/>
<result column="IS_ACTIVATE" property="isActivate"/>
</resultMap>
<resultMap id="MemberVO" type="com.hzs.member.base.vo.CuMemberVO">
<id column="PK_ID" property="pkId"/>
<result column="MEMBER_CODE" property="memberCode"/>
<result column="MEMBER_NAME" property="memberName"/>
<result column="NICK_NAME" property="nickName"/>
<result column="CUSTOMER_TYPE" property="customerType"/>
<result column="PHONE" property="phone"/>
<result column="ID_CARD" property="idCard"/>
<result column="SEX" property="sex"/>
<result column="BIRTH_DATE" property="birthDate"/>
<result column="PK_COUNTRY" property="pkCountry"/>
<result column="PK_SETTLE_COUNTRY" property="pkSettleCountry"/>
<result column="PAR_MEMBER_CODE" property="parMemberCode"/>
<result column="PAR_MEMBER_NAME" property="parMemberName"/>
<result column="PLACE_MEMBER_CODE" property="placeMemberCode"/>
<result column="PLACE_MEMBER_NAME" property="placeMemberName"/>
<result column="PLACE_DEPT" property="placeDept"/>
<result column="CENTER_MEMBER_CODE" property="centerMemberCode"/>
<result column="CENTER_MEMBER_NAME" property="centerMemberName"/>
<result column="SOURCE" property="source"/>
<result column="PK_REGISTER_GRADE" property="pkRegisterGrade"/>
<result column="PK_SETTLE_GRADE" property="pkSettleGrade"/>
<result column="PK_AWARDS" property="pkAwards"/>
<result column="CONSUME_MONEY" property="consumeMoney"/>
<result column="CONSUME_ACHIEVE" property="consumeAchieve"/>
<result column="PURCHASE_STATUS" property="purchaseStatus"/>
<result column="SHARE_STATUS" property="shareStatus"/>
<result column="PAY_TIME" property="payTime"/>
<result column="PAY_STATUS" property="payStatus"/>
<result column="EDIT_NUMBER" property="editNumber"/>
<result column="CREATION_TIME" property="creationTime"/>
<result column="REGISTER_AUTHORITY" property="registerAuthority"/>
<result column="TOP_MEMBER_CODE" property="topMemberCode"/>
<result column="TOP_MEMBER_NAME" property="topMemberName"/>
<result column="ACCOUNT_STATUS" property="accountStatus"/>
<result column="WALLET_STATUS" property="walletStatus"/>
<result column="PAY_STATUS" property="payStatus"/>
<result column="CATEGORY" property="category"/>
<result column="EMAIL" property="email"/>
<result column="INCOME_STATUS" property="incomeStatus"/>
<result column="ORDER_SOURCE" property="orderSource"/>
<result column="IS_REAL_NAME" property="isRealName"/>
<result column="IS_BUS_LICENSE" property="isBusLicense"/>
<result column="IS_MAKER_SPACE" property="isMakerSpace"/>
<result column="CHANGE_NUMBER" property="changeNumber"/>
<result column="WECHAT" property="wechat"/>
<result column="CARD_TYPE" property="cardType"/>
<result column="ID_CARD_JUST" property="idCardJust"/>
<result column="ID_CARD_BACK" property="idCardBack"/>
<result column="GIFT_PROVINCE" property="giftProvince"/>
<result column="GIFT_CITY" property="giftCity"/>
<result column="GIFT_COUNTY" property="giftCounty"/>
<result column="GIFT_ADDRESS" property="giftAddress"/>
<result column="BANK_NAME" property="bankName"/>
<result column="SUB_BANK_NAME" property="subBankName"/>
<result column="ACCOUNT_NAME" property="accountName"/>
<result column="PHONE" property="reservePhone"/>
<result column="CARD_NUMBER" property="cardNumber"/>
<result column="NICK_NAME" property="nickName"/>
<result column="HEAD_PATH" property="headPath"/>
<result column="agent_grade" property="agentGrade"/>
<result column="DIRECT_PUSH_NUMBER" property="directPushNumber"/>
<result column="IS_DEALER" property="isDealer"/>
<result column="SYSTEM_LEVEL" property="systemLevel"/>
<result column="LECTURER_LEVEL" property="lecturerLevel"/>
<result column="SUPER_STUDIO" property="superStudio"/>
<result column="STORE_LEVEL" property="storeLevel"/>
<result column="SERVICE_CODE" property="serviceCode"/>
</resultMap>
<sql id="CuMember_Column">
select cm.pk_id,
cm.member_code,
cm.member_name,
cm.phone,
cm.pk_settle_country,
cm.pk_parent,
cm.pk_place_parent,
cm.place_dept,
cm.pk_team_code,
cm.pk_center_code,
cm.category,
cm.pk_settle_grade,
cm.pk_awards,
cm.purchase_status,
cm.order_source,
cm.is_real_name,
cm.is_bus_license,
cm.is_maker_space,
cm.share_status,
cm.pay_pwd,
cm.register_authority,
cm.nick_name,
cm.pk_vertex,
cm.service_code
from cu_member cm
where cm.del_flag = 0
</sql>
<!-- 保存会员信息 -->
<insert id="insertCuMember" parameterType="com.hzs.common.domain.member.base.CuMember">
INSERT INTO CU_MEMBER (PK_ID, MEMBER_CODE, MEMBER_NAME, CATEGORY, CUSTOMER_TYPE, PHONE, EMAIL, ID_CARD, PK_SETTLE_COUNTRY,
PK_PARENT, PK_PLACE_PARENT, PLACE_DEPT, PK_TEAM_CODE, PK_CENTER_CODE, SOURCE, PK_REGISTER_GRADE,
PK_SETTLE_GRADE, PK_AWARDS, CONSUME_MONEY, CONSUME_ACHIEVE, PAY_STATUS, LOGIN_PWD, PAY_PWD, LOGIN_PASSWORD, PAY_PASSWORD,
PK_VERTEX, ACCOUNT_STATUS, ORDER_SOURCE, PK_CREATOR, CREATION_TIME, PK_COUNTRY, PAY_TIME, GLOBAL_CODE, COUNTRY_CODE, REGISTER_AUTHORITY,
EXPIRE_DATE, STOP_DATE, IS_MAKER_GIFT, MAKER_GIFT_TIME, NICK_NAME
<if test="systemType != null">
,SYSTEM_TYPE
</if>
<if test="isActivate != null">
,IS_ACTIVATE
</if>
)
VALUES (#{pkId,jdbcType=INTEGER}, #{memberCode}, #{memberName}, #{category}, #{customerType}, #{phone}, #{email, jdbcType=VARCHAR}, #{idCard, jdbcType=VARCHAR}, #{pkSettleCountry},
#{pkParent}, #{pkPlaceParent,jdbcType=NUMERIC}, #{placeDept,jdbcType=INTEGER}, #{pkTeamCode,jdbcType=INTEGER}, #{pkCenterCode,jdbcType=INTEGER}, #{source}, #{pkRegisterGrade},
#{pkSettleGrade}, #{pkAwards}, #{consumeMoney,jdbcType=NUMERIC}, #{consumeAchieve,jdbcType=NUMERIC}, #{payStatus}, #{loginPwd}, #{payPwd},
#{loginPassword}, #{payPassword}, #{pkVertex,jdbcType=INTEGER}, #{accountStatus}, #{orderSource},
#{pkCreator,jdbcType=INTEGER}, #{creationTime, jdbcType=TIMESTAMP}, #{pkCountry}, #{payTime, jdbcType=TIMESTAMP},
#{globalCode, jdbcType=VARCHAR}, #{countryCode, jdbcType=VARCHAR}, #{registerAuthority,jdbcType=INTEGER},
#{expireDate, jdbcType=DATE}, #{stopDate, jdbcType=DATE}, #{isMakerGift,jdbcType=INTEGER}, #{makerGiftTime,jdbcType=TIMESTAMP}, #{nickName, jdbcType=VARCHAR}
<if test="systemType != null">
,#{systemType}
</if>
<if test="isActivate != null">
,#{isActivate}
</if>
)
</insert>
<!-- 批量保存会员信息 -->
<insert id="insertBatchCuMember">
insert ALL
<foreach collection="memberList" item="item" separator=" ">
into CU_MEMBER (
PK_ID, MEMBER_CODE, MEMBER_NAME, NICK_NAME, CUSTOMER_TYPE,
PHONE, PK_PARENT,
PK_COUNTRY, PK_SETTLE_COUNTRY, SOURCE,
PK_REGISTER_GRADE, PK_SETTLE_GRADE, PK_AWARDS,
LOGIN_PWD, PAY_PWD, LOGIN_PASSWORD, PAY_PASSWORD,
PK_CREATOR, CREATION_TIME,
PK_TEAM_CODE, PK_VERTEX, ORDER_SOURCE, CONSUME_ACHIEVE,
GLOBAL_CODE, COUNTRY_CODE, EXPIRE_DATE, STOP_DATE, SYSTEM_TYPE, IS_ACTIVATE
)
values (
#{item.pkId}, #{item.memberCode}, #{item.memberName}, #{item.nickName}, #{item.customerType},
#{item.phone}, #{item.pkParent},
#{item.pkCountry}, #{item.pkSettleCountry}, #{item.source},
#{item.pkRegisterGrade}, #{item.pkSettleGrade}, #{item.pkAwards},
#{item.loginPwd}, #{item.payPwd}, #{item.loginPassword}, #{item.payPassword},
#{item.pkCreator}, #{item.creationTime},
#{item.pkTeamCode, jdbcType=NUMERIC}, #{item.pkVertex, jdbcType=NUMERIC}, #{item.orderSource}, #{item.consumeAchieve},
#{item.globalCode, jdbcType=VARCHAR}, #{item.countryCode, jdbcType=VARCHAR},
#{item.expireDate, jdbcType=DATE}, #{item.stopDate, jdbcType=DATE}, #{item.systemType}, #{item.isActivate}
)
</foreach>
SELECT 1 FROM dual
</insert>
<!-- 通用查询映射结果 -->
<select id="queryLoginMember" resultMap="MemberResultMap">
select cm.*
from cu_member cm
where cm.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and cm.member_code = #{memberCode}
</if>
<if test="pkMember != null">
and cm.pk_id = #{pkMember}
</if>
</select>
<!-- 根据服务编号登录用户2024.07.09 兼容海外临时需求) -->
<select id="queryTmpLoginMember" resultMap="MemberResultMap">
select cm.*
from cu_member cm
where cm.del_flag = 0
<if test="serviceCode != null and serviceCode != ''">
and cm.SERVICE_CODE = #{serviceCode}
</if>
</select>
<!--and cm.PAY_STATUS=1-->
<select id="queryMemberInfoByCondition" resultMap="MemberResultMap">
<include refid="CuMember_Column"/>
<choose>
<when test="category != 10">
and cm.category = 0
</when>
</choose>
<if test="pkSettleCountry != null">
and cm.pk_settle_country=#{pkSettleCountry}
</if>
<if test="payStatus != null">
and cm.pay_status=#{payStatus}
</if>
<if test="pkId != null ">
and cm.pk_id = #{pkId}
</if>
<if test="memberCode != null and memberCode != ''">
and cm.member_code = #{memberCode}
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name = #{memberName}
</if>
<if test="phone != null and phone != ''">
and cm.phone = #{phone}
</if>
<if test="pkParent != null and pkParent != ''">
and cm.pk_parent = #{pkParent}
</if>
<if test="pkPlaceParent != null and pkPlaceParent != ''">
and cm.pk_place_parent = #{pkPlaceParent}
</if>
<if test="placeDept != null and placeDept != ''">
and cm.place_dept = #{placeDept}
</if>
<if test="pkSettleGrade != null and pkSettleCountry != null">
<choose>
<when test="pkSettleGrade == 20 and pkSettleCountry == 1">
and cm.pk_settle_grade = 1
</when>
<otherwise>
and cm.pk_settle_grade > 1
</otherwise>
</choose>
</if>
</select>
<select id="selectPlaceSponsorOnUmbrella" resultMap="MemberResultMap">
select t.pk_id, t.member_code, t.member_name, t.phone, t.pk_place_parent
from cu_member t
where t.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and member_code = #{memberCode}
</if>
<if test="phone != null and phone != ''">
and t.phone=#{phone}
</if>
start with t.pk_id = #{memberId}
connect by t.pk_id = prior t.pk_place_parent
order by level desc
</select>
<select id="selectPlaceSponsorUnderUmbrella" resultMap="MemberResultMap">
select t.pk_id,
t.member_code,
t.member_name,
t.phone,
t.pk_place_parent,
t.pk_parent,
t.pk_center_code,
t.PLACE_DEPT
from cu_member t
where t.del_flag = 0 start
with t.pk_place_parent = #{memberId}
connect by t.pk_place_parent = prior t.pk_id
order by level
</select>
<select id="selectPlaceSponsorUnderUmbrellaByCondition" resultMap="MemberResultMap">
select * from (
select t.pk_id,
t.member_code,
t.member_name,
t.phone,
t.pk_place_parent,
t.pk_parent,
t.pk_center_code,
t.PLACE_DEPT
from cu_member t
where t.del_flag = 0 start
with t.pk_place_parent = #{memberId}
connect by t.pk_place_parent = prior t.pk_id
union
select t.pk_id,
t.member_code,
t.member_name,
t.phone,
t.pk_place_parent,
t.pk_parent,
t.pk_center_code,
t.PLACE_DEPT
from cu_member t
where t.del_flag = 0 and t.pk_id = #{memberId}
) a
where a.pk_id in
<foreach collection="cuMemberExtList" item="item" open="(" close=")" separator=",">
#{item.pkId}
</foreach>
</select>
<select id="selectPlaceSponsorLastLeft" resultMap="MemberResultMap">
select *
from (select t.pk_id, t.member_code, t.member_name, t.pk_vertex, t.nick_name, t.service_code
from cu_member t
where t.del_flag = 0
and t.place_dept = 1 start
with t.pk_id = (select u.pk_id
from cu_member u
where u.del_flag=0 and u.pk_place_parent = #{memberId}
and u.place_dept = #{placeDept, jdbcType=INTEGER})
connect by prior
t.pk_id = (select u.pk_place_parent
from cu_member u
where u.pk_id = t.pk_id
and u.place_dept = 1)
order by level desc) n
where rownum = 1
</select>
<select id="selectBloodKinshipOnUmbrella" resultMap="MemberResultMap">
select t.pk_id, t.member_code, t.member_name, t.phone, t.pk_parent
from cu_member t
where t.del_flag = 0 start
with t.pk_id = #{memberId}
connect by t.pk_id = prior t.pk_parent
order by level
</select>
<!-- 查找血缘伞下,推荐人 -->
<select id="selectBloodKinshipUnderUmbrella" resultMap="MemberResultMap">
select t.pk_id, t.member_code, t.member_name, t.phone, t.pk_parent
from cu_member t
where t.del_flag = 0 start
with t.pk_id = #{memberId}
connect by t.pk_parent = prior t.pk_id
order by level
</select>
<select id="createMemberId" resultType="java.lang.Long">
SELECT CU_MEMBER_SEQ.NEXTVAL
FROM DUAL
</select>
<!--会员真实信息列表-->
<select id="realCuMemberByCondition" parameterType="com.hzs.member.base.vo.CuMemberVO" resultMap="MemberVO">
SELECT
cm.PK_ID,
gr.GRADE_NAME as registerName,
grr.GRADE_NAME as settleName,
awa.AWARDS_NAME awardsName,
cm.member_code,
cm.SEX,
cm.BIRTH_DATE,
cm.member_name,
cm.phone,
cm.CARD_TYPE,
cm.ID_CARD,
cmg.ID_CARD_JUST,
cmg.ID_CARD_BACK,
province.name GIFT_PROVINCE,
city.name GIFT_CITY,
county.name GIFT_COUNTY,
cmg.GIFT_ADDRESS,
cmb.BANK_NAME,
cmb.SUB_BANK_NAME,
cmb.ACCOUNT_NAME,
cmb.PHONE,
cmb.CARD_NUMBER,
cm.EMAIL,
cm.WECHAT,
cmg.CREATION_TIME as attestationTime,
cm.PAY_TIME,
cm.creation_time
FROM
cu_member cm
left join bd_awards awa on awa.pk_id= cm.PK_AWARDS
left join bd_grade gr on gr.pk_id=cm.PK_REGISTER_GRADE
left join bd_grade grr on grr.pk_id=cm.PK_REGISTER_GRADE
left join cu_member_bank cmb on cmb.PK_MEMBER=cm.PK_ID
left join CU_MEMBER_GIFT cmg on cmg.PK_MEMBER=cm.PK_ID
left join bd_area province on province.PK_ID=cmg.GIFT_PROVINCE
left join bd_area city on city.PK_ID=cmg.GIFT_CITY
left join bd_area county on county.PK_ID=cmg.GIFT_COUNTY
WHERE
cm.del_flag = 0
and cm.pk_settle_country=#{pkCountry}
<if test="memberCode != null and memberCode != ''">
and cm.member_code=#{memberCode}
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name=#{memberName}
</if>
<if test="phone != null and phone != ''">
and cm.phone=#{phone}
</if>
<if test="pkRegisterGrade != null ">
and cm.pk_register_grade =#{pkRegisterGrade}
</if>
<if test="pkSettleGrade != null ">
and cm.PK_SETTLE_GRADE =#{pkSettleGrade}
</if>
<if test="pkAwards != null">
and cm.pk_awards=#{pkAwards}
</if>
<if test="cardType != null">
and cm.CARD_TYPE=#{cardType}
</if>
<if test="birthDate != null">
and cm.BIRTH_DATE=#{birthDate}
</if>
<if test="giftProvince != null">
and cmg.GIFT_PROVINCE=#{giftProvince}
</if>
<if test="giftCity != null">
and cmg.GIFT_CITY=#{giftCity}
</if>
<if test="giftCounty != null">
and cmg.GIFT_COUNTY=#{giftCounty}
</if>
<if test="sex != null">
and cm.SEX=#{sex}
</if>
<if test="pkBdBank != null">
and cmb.PK_BD_BANK=#{pkBdBank}
</if>
<if test="subBankName != null and subBankName != ''">
and cmb.SUB_BANK_NAME=#{subBankName}
</if>
<if test="cardNumber != null and cardNumber != ''">
and cmb.CARD_NUMBER=#{cardNumber}
</if>
<if test="email != null and email != ''">
and cm.EMAIL=#{email}
</if>
<if test="wechat != null and wechat != ''">
and cm.WECHAT=#{wechat}
</if>
<if test="startDate != null and startDate !='' ">
and cm.CREATION_TIME &gt;= to_date(#{startDate}, 'yyyy-mm-dd')
</if>
<if test="endDate != null and endDate !='' ">
and cm.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="startDatePay != null and startDatePay != ''">
and cm.PAY_TIME &gt;= to_date(#{startDatePay}, 'yyyy-mm-dd')
</if>
<if test="endDatePay != null and endDatePay != ''">
and cm.PAY_TIME &lt;= to_date(#{endDatePay} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="startAttestationTime != null">
and cmg.creation_time &gt;= to_date(#{startAttestationTime}, 'yyyy-mm-dd')
</if>
<if test="endAttestationTime != null">
and cmg.creation_time &lt;= to_date(#{endAttestationTime} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
</select>
<select id="findMemberByMembercodesAndPkcountry" resultMap="MemberResultMap">
select m.member_code,m.pk_id, m.member_name,m.pk_settle_country
from cu_member m
where m.del_flag = 0
and m.category = 0
<if test="pkCountry != null">
and m.pk_settle_country = #{pkCountry}
</if>
and m.member_code in
<foreach collection="memberCodes" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<!-- 根据会员ID列表查询会员 -->
<select id="findMemberByMemberId" resultMap="MemberResultMap">
select cm.pk_id,
cm.member_code,
cm.MEMBER_NAME,
cm.phone,
cm.pk_settle_country
from cu_member cm
where cm.del_flag = 0
<if test="pkCountry != null">
and cm.pk_settle_country = #{pkCountry}
</if>
and cm.pk_id in
<foreach collection="pkMemberList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<!--特殊配置-修改会员编号列表-->
<select id="puCodeList" parameterType="com.hzs.member.base.vo.UpdateCodeVO"
resultType="com.hzs.member.base.vo.UpdateCodeVO">
select cm.pk_ID as pkId,
cm.MEMBER_CODE as memberCode,
cm.member_name as memberName,
cm.PHONE as phone,
cm.PK_SETTLE_GRADE pkSettleGrade,
cm.PK_AWARDS pkAwards,
cmp.PK_ID as serviceLogId,
cmp.NEW_VALUE as newValue,
cmp.OLD_VALUE as oldValue,
cmp.changeNumber as changeNumber,
cmp.CREATION_TIME as creationTime,
cmp.APPROVE_STATUS as approveStatus,
cmp.BUSINESS_NO as businessNo,
cmp.SINGLE_AMOUNT as cost
from cu_member cm
INNER JOIN (
select b.PK_ID,b.pk_member,
b.OLD_VALUE,
b.NEW_VALUE,
b.creation_time,
b.APPROVE_STATUS,
b.BUSINESS_NO,
b.SINGLE_AMOUNT,
b.APPROVE_NUMBER changeNumber
from CU_MEMBER_SERVICE_LOG b where b.EDIT_TYPE=109
) cmp on cm.pk_ID=cmp.pk_member
where cm.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and(cm.member_code like #{memberCode} || '%'
or cmp.OLD_VALUE like #{memberCode} || '%'
or cmp.NEW_VALUE like #{memberCode} || '%')
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name like #{memberName} || '%'
</if>
<if test="businessNo != null and businessNo != ''">
and cmp.BUSINESS_NO=#{businessNo}
</if>
<if test="approveStatus != null">
and cmp.APPROVE_STATUS=#{approveStatus}
</if>
<if test="approveStatus == null">
and cmp.APPROVE_STATUS=5
</if>
<if test="phone != null and phone != ''">
and cm.phone like #{phone} || '%'
</if>
<if test="pkCountry != null">
and cm.PK_SETTLE_COUNTRY=#{pkCountry}
</if>
<if test="pkAwards != null">
and cm.pk_awards=#{pkAwards}
</if>
<if test="pkSettleGrade != null">
and cm.PK_SETTLE_GRADE=#{pkSettleGrade}
</if>
ORDER BY cmp.CREATION_TIME DESC
</select>
<!-- 零元撤单列表-->
<select id="zeroList" parameterType="com.hzs.member.base.vo.ZeroElementRevokeVO"
resultType="com.hzs.member.base.vo.ZeroElementRevokeVO">
select cm.pk_ID as pkId,
cm.MEMBER_CODE as memberCode,
cm.member_name as memberName,
cm.PHONE as phone,
grr.grade_name pkSettleGradeVal,
awa.awards_name pkAwardsVal,
ver.VERTEX_NAME as vertexName,
ct.TEAM_NAME as teamName,
par.member_code parMemberCode,
par.member_name parMemberName,
cm.CREATION_TIME creationTime
from cu_member cm
left JOIN cu_member_team ct
ON ct.pk_id = cm.pk_team_code
left join bd_vertex ver
on ver.pk_id = cm.PK_VERTEX
and ver.del_flag = 0
left join bd_awards awa
on awa.pk_id = cm.pk_awards
and awa.del_flag = 0
left join bd_grade grr
on grr.pk_id = cm.pk_settle_grade
and grr.del_flag = 0
left JOIN cu_member par
ON par.pk_id = cm.pk_parent
where cm.del_flag = 0
and cm.CATEGORY = 0
and cm.CONSUME_MONEY = 0
and cm.CONSUME_ACHIEVE = 0
and grr.GRADE_VALUE = 20
<if test="memberCode != null and memberCode != ''">
and(cm.member_code like #{memberCode} || '%')
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name like #{memberName} || '%'
</if>
<if test="vertexId != null">
and cm.PK_VERTEX = #{vertexId}
</if>
<if test="teamId != null">
and cm.pk_team_code = #{teamId}
</if>
<if test="phone != null and phone != ''">
and cm.phone like #{phone} || '%'
</if>
<if test="pkCountry != null">
and cm.PK_SETTLE_COUNTRY = #{pkCountry}
</if>
<if test="pkAwards != null">
and cm.pk_awards = #{pkAwards}
</if>
<if test="parMemberCode != null and parMemberCode != ''">
and par.member_code like #{parMemberCode} || '%'
</if>
<if test="parMemberName != null and parMemberName != ''">
and par.member_name like #{parMemberName} || '%'
</if>
<if test="pkSettleGrade != null">
and cm.pk_settle_grade = #{pkSettleGrade}
</if>
ORDER BY cm.CREATION_TIME DESC
</select>
<!-- 查询全部修改过会员编号的会员记录-->
<select id="puCodeAllList" parameterType="com.hzs.member.base.vo.UpdateCodeVO"
resultType="com.hzs.member.base.vo.UpdateCodeVO">
select cm.pk_ID as pkId,
cm.MEMBER_CODE as memberCode,
cm.member_name as memberName,
cm.PHONE as phone,
cm.PK_SETTLE_GRADE pkSettleGrade,
cm.PK_AWARDS pkAwards,
cmp.PK_ID as serviceLogId,
cmp.NEW_VALUE as newValue,
cmp.OLD_VALUE as oldValue,
cmp.changeNumber as changeNumber,
cmp.CREATION_TIME as creationTime,
cmp.APPROVE_STATUS as approveStatus,
cmp.BUSINESS_NO as businessNo,
cmp.SINGLE_AMOUNT as cost
from cu_member cm
INNER JOIN (
select b.PK_ID,b.pk_member,
b.OLD_VALUE,
b.NEW_VALUE,
b.creation_time,
b.APPROVE_STATUS,
b.BUSINESS_NO,
b.SINGLE_AMOUNT,
b.APPROVE_NUMBER changeNumber
from CU_MEMBER_SERVICE_LOG b where b.EDIT_TYPE=109
) cmp on cm.pk_ID=cmp.pk_member
where cm.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and(cm.member_code like #{memberCode} || '%'
or cmp.OLD_VALUE like #{memberCode} || '%'
or cmp.NEW_VALUE like #{memberCode} || '%')
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name like #{memberName} || '%'
</if>
<if test="businessNo != null and businessNo != ''">
and cmp.BUSINESS_NO=#{businessNo}
</if>
<if test="phone != null and phone != ''">
and cm.phone like #{phone} || '%'
</if>
<if test="pkCountry != null">
and cm.PK_COUNTRY=#{pkCountry}
</if>
<if test="pkAwards != null">
and cm.pk_awards=#{pkAwards}
</if>
<if test="approveStatus != null">
and cmp.APPROVE_STATUS=#{approveStatus}
</if>
<if test="pkSettleGrade != null">
and cm.PK_SETTLE_GRADE=#{pkSettleGrade}
</if>
ORDER BY cmp.CREATION_TIME DESC
</select>
<!--查询会员变更前信息-->
<select id="specialBusinessQuery" parameterType="com.hzs.member.base.vo.UpdateCodeVO"
resultType="com.hzs.member.base.vo.UpdateCodeVO">
select cm.pk_ID as pkId,
cm.MEMBER_CODE as memberCode,
cm.member_name as memberName,
cm.PK_SETTLE_COUNTRY as pkSettleCountry,
bc.SHORT_NAME as shortName,
cm.PHONE as phone,
cm.PK_SETTLE_GRADE pkSettleGrade,
cm.PK_AWARDS pkAwards,
cm.PLACE_DEPT as placeDept,
par.member_code parMemberCode,
par.member_name parMemberName,
place.member_code placeMemberCode,
place.member_name placeMemberName
from cu_member cm
INNER JOIN cu_member par
ON par.pk_id = cm.pk_parent
left JOIN cu_member place
ON place.pk_id = cm.pk_place_parent
left JOIN BD_COUNTRY bc on bc.pk_id=cm.PK_SETTLE_COUNTRY
where cm.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and cm.member_code=#{memberCode}
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name=#{memberName}
</if>
<if test="pkCountry != null">
and cm.PK_COUNTRY=#{pkCountry}
</if>
</select>
<update id="batchUpdateMemberNameAndMobileByPkmember">
MERGE INTO cu_member m
USING
(
<foreach collection="businessMemberList" item="item" index="index" separator="union">
select #{item.pkMember} pk_member,
<if test='businessType == "100"'>
#{item.newValue} member_name
</if>
<if test='businessType == "101"'>
#{item.newValue} phone
</if>
FROM DUAL
</foreach>
) t
ON ( t.pk_member=m.pk_id and m.pk_id in
<foreach collection="businessMemberList" item="item" open="(" close=")" separator=",">
#{item.pkMember}
</foreach>)
WHEN MATCHED THEN
UPDATE SET
<if test='businessType == "100"'>
m.member_name = t.member_name,
</if>
<if test='businessType == "101"'>
m.member_name = DECODE(m.system_type,1,t.phone,m.member_name),
m.phone = t.phone,
</if>
m.MODIFIED_TIME = sysdate,
m.pk_modified = #{updatePkMember}
</update>
<update id="batchUpdateMemberByBusinessType" parameterType="com.hzs.member.handlebusiness.vo.HandleBusinessVO">
update cu_member
<set>
<foreach collection="handleBusinessList" item="item" index="index" separator=",">
<if test='item.businessType == "102"'>
<foreach collection="item.businessValueList" index="index" item="value">
is_real_name = #{value}
</foreach>
</if>
<if test='item.businessType == "103"'>
<foreach collection="item.businessValueList" index="index" item="value">
<if test='value == "3"'>
login_pwd = #{loginPwd},login_password = #{loginPassword},
pay_pwd = #{payPwd},pay_password = #{payPassword}
</if>
<if test='value == "1"'>
login_pwd = #{loginPwd},login_password = #{loginPassword}
</if>
<if test='value == "2"'>
pay_pwd = #{payPwd},pay_password = #{payPassword}
</if>
</foreach>
</if>
<if test='item.businessType == "106"'>
<foreach collection="item.businessValueList" index="index" item="value">
pk_register_grade = #{value}
</foreach>
</if>
<if test='item.businessType == "113"'>
<foreach collection="item.businessValueList" index="index" item="value">
pk_settle_grade = #{value}
</foreach>
</if>
<if test='item.businessType == "107"'>
<foreach collection="item.businessValueList" index="index" item="value">
pk_awards = #{value}
</foreach>
</if>
<if test='item.businessType == "115"'>
<foreach collection="item.businessValueList" index="index" item="value">
pk_country = #{value}
</foreach>
</if>
<if test='item.businessType == "116"'>
<foreach collection="item.businessValueList" index="index" item="value">
account_status = #{value}
</foreach>
</if>
<if test='item.businessType == "117"'>
<foreach collection="item.businessValueList" index="index" item="value">
income_status = #{value}
</foreach>
</if>
<if test='item.businessType == "119 "'>
<foreach collection="item.businessValueList" index="index" item="value" separator=",">
<if test='value == "1"'>
purchase_status = 0
</if>
<if test='value == "2"'>
share_status = 0
</if>
<if test='value == "3"'>
purchase_status = 1
</if>
<if test='value == "4"'>
share_status = 1
</if>
</foreach>
</if>
<if test='item.businessType == "120"'>
<foreach collection="item.businessValueList" index="index" item="value">
register_authority = #{value}
</foreach>
</if>
<if test='item.businessType == "122"'>
<foreach collection="item.businessValueList" index="index" item="value">
is_maker_space = #{value}
</foreach>
</if>
<if test='item.businessType == "142"'>
<foreach collection="item.businessValueList" index="index" item="value">
super_studio = #{value}
</foreach>
</if>
<if test='item.businessType == "143"'>
<foreach collection="item.businessValueList" index="index" item="value">
is_dealer = #{value}
</foreach>
</if>
<if test='item.businessType == "148"'>
<foreach collection="item.businessValueList" index="index" item="value">
LECTURER_LEVEL = #{value}
</foreach>
</if>
<if test='item.businessType == "149"'>
<foreach collection="item.businessValueList" index="index" item="value">
SYSTEM_LEVEL = #{value}
</foreach>
</if>
<if test='item.businessType == "166"'>
<foreach collection="item.businessValueList" index="index" item="value">
pk_max_awards = #{value}
</foreach>
</if>
<if test='item.businessType == "136"'>
<foreach collection="item.businessValueList" index="index" item="value">
IS_REGION = #{value}
</foreach>
</if>
<if test='item.businessType == "137"'>
<foreach collection="item.businessValueList" index="index" item="value">
IS_ACTIVATE = #{value}
</foreach>
</if>
</foreach>
,MODIFIED_TIME = sysdate,
PK_MODIFIED = #{updatePkMember}
</set>
where pk_id in
<foreach collection="businessMemberList" item="item" open="(" close=")" separator=",">
#{item.pkMember}
</foreach>
</update>
<select id="selectBiddingList" resultType="com.hzs.member.marketnews.vo.UserInvestmentVo">
select
cm.MEMBER_CODE memberCode,cm.MEMBER_NAME memberName,cm.PK_REGISTER_GRADE pkRegisterGrade,cm.CREATION_TIME
creationTime,
cm.PK_PARENT pkParent,cm.PK_PLACE_PARENT pkPlaceParent,
(select nvl(sum(so.ORDER_AMOUNT),0) from SA_ORDER so where so.PK_MEMBER = cm.PK_ID
and so.ORDER_TYPE = 1
and so.ORDER_STATUS = 1
and so.DEL_FLAG = 0
) regMoney,
(select nvl(sum(so.ORDER_ACHIEVE),0) from SA_ORDER so where so.PK_MEMBER = cm.PK_ID
and so.ORDER_TYPE = 1
and so.ORDER_STATUS = 1
and so.DEL_FLAG = 0
) regPv,
(mbp.ROUND+1) round,
mbp.SECOND second,
so.ORDER_TYPE orderType,cm.PAY_TIME payTime,cm.PLACE_DEPT placeDept
from CU_MEMBER_BONUS_PUSH mbp
left join cu_member_bonus mb on mbp.PK_BONUS = mb.PK_ID
left join cu_member cm on cm.PK_ID = mb.PK_MEMBER
left join SA_ORDER so on so.PK_ID = mbp.PK_ORDER
where cm.DEL_FLAG = 0
and cm.PAY_STATUS = 1
<if test="memberInfo != null and memberInfo != ''">
and (cm.member_code=#{memberInfo} or cm.member_name=#{memberInfo})
</if>
<if test="memberCode != null and memberCode != ''">
and cm.member_code=#{memberCode}
</if>
<if test="pkCountry != null">
and cm.PK_COUNTRY=#{pkCountry}
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name=#{memberName}
</if>
<if test="startCreationTime != null">
and cm.creation_time >= #{startCreationTime}
</if>
<if test="endCreationTime != null">
and cm.creation_time &lt; #{endCreationTime}
</if>
order by mbp.ROUND asc ,mbp.SECOND asc
</select>
<!--特殊配置-修改结算国列表-->
<select id="upseCountryList" parameterType="com.hzs.member.base.vo.UpdateSettleCountryVO"
resultType="com.hzs.member.base.vo.UpdateSettleCountryVO">
select cm.pk_ID as pkId,
cm.MEMBER_CODE as memberCode,
cm.member_name as memberName,
cmp.PK_ID as serviceLogId,
cmp.APPROVE_NUMBER as changeNumber,
cmp.creation_time as creationTime,
cm.PK_SETTLE_COUNTRY as pkSettleCountry,
bc.SHORT_NAME as oldValue,
bcc.SHORT_NAME as newValue,
cmp.NEW_VALUE as newSettleCountry,
cmp.SINGLE_AMOUNT as cost
from cu_member cm
INNER JOIN (
select a.PK_ID,a.pk_member, a.NEW_VALUE, a.APPROVE_NUMBER,
a.creation_time,a.APPROVE_STATUS,a.BUSINESS_NO,
a.SINGLE_AMOUNT
from CU_MEMBER_SERVICE_LOG a
where a.EDIT_TYPE=124
<if test="businessNo != null and businessNo != ''">
and a.BUSINESS_NO=#{businessNo}
</if>
) cmp on cm.pk_ID=cmp.pk_member
LEFT JOIN BD_COUNTRY bc on bc.PK_ID=cm.PK_SETTLE_COUNTRY
LEFT JOIN BD_COUNTRY bcc on bcc.PK_ID=cmp.NEW_VALUE
where cm.del_flag = 0
<if test="memberName != null and memberName != ''">
and cm.member_name like #{memberName} || '%'
</if>
<if test="memberCode != null and memberCode != ''">
and cm.member_code like #{memberCode} || '%'
</if>
<if test="pkCountry != null">
and cm.PK_COUNTRY=#{pkCountry}
</if>
<if test="approveStatus != null">
and cmp.APPROVE_STATUS=#{approveStatus}
</if>
ORDER BY cmp.CREATION_TIME DESC
</select>
<!--特殊配置 修改结算国列表-->
<select id="upsettleCountryList" parameterType="com.hzs.member.base.vo.UpdateSettleCountryVO"
resultType="com.hzs.member.base.vo.UpdateSettleCountryVO">
select
cm.MEMBER_CODE as memberCode,
cm.member_name as memberName,
cm.PHONE phone,
cmp.PK_ID pkId,
cmp.PK_MEMBER pkMember,
cmp.APPROVE_NUMBER changeNumber,
cmp.CREATION_TIME creationTime,
cmp.APPROVE_STATUS approveStatus,
bc.SHORT_NAME as oldValue,
bcc.SHORT_NAME as newValue,
aw.PK_TRANSACTION pkAwards ,
ver.VERTEX_NAME as vertexName,
ct.TEAM_NAME as teamName
from CU_MEMBER_SERVICE_LOG cmp
LEFT JOIN CU_SETTLE_COUNTRY_DETAILED b on cmp.PK_ID=b.PK_SERVICE_LOG
INNER JOIN cu_member cm on cm.pk_ID=cmp.pk_member
LEFT JOIN BD_COUNTRY bc on bc.PK_ID=cmp.OLD_VALUE
LEFT JOIN BD_COUNTRY bcc on bcc.PK_ID=cmp.NEW_VALUE
LEFT JOIN BD_AWARDS aw on aw.PK_ID=cm.PK_AWARDS
LEFT JOIN cu_member_team ct ON ct.pk_id = cm.pk_team_code
left join bd_vertex ver on ver.pk_id=ct.PK_BD_VERTEX
where cmp.EDIT_TYPE = 124 and cm.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and cm.member_code like #{memberCode} || '%'
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name like #{memberName} || '%'
</if>
<if test="businessNo != null and businessNo != ''">
and cm.BUSINESS_NO=#{businessNo}
</if>
<if test="pkCountry != null and approveStatus==5">
and b.PK_COUNTRY=#{pkCountry}
</if>
<if test="approveStatus != null">
and cmp.APPROVE_STATUS=#{approveStatus}
</if>
ORDER BY cmp.CREATION_TIME DESC
</select>
<!--修改政策币列表-->
<select id="upPolicyCurrencyList" parameterType="com.hzs.member.base.vo.UpPolicyCurrencyVO"
resultType="com.hzs.member.base.vo.UpPolicyCurrencyVO">
select
cm.MEMBER_CODE as memberCode,
cm.member_name as memberName,
cm.PHONE phone,
cmp.PK_ID pkId,
cmp.PK_MEMBER pkMember,
cmp.APPROVE_NUMBER changeNumber,
cmp.CREATION_TIME creationTime,
cmp.OLD_VALUE oldValue,
cmp.NEW_VALUE newValue,
cmp.BUSINESS_SCOPE businessScope,
aw.PK_TRANSACTION pkAwards ,
ver.VERTEX_NAME as vertexName,
ct.TEAM_NAME as teamName
from CU_MEMBER_SERVICE_LOG cmp
LEFT JOIN cu_member cm on cm.pk_ID=cmp.pk_member
LEFT JOIN BD_AWARDS aw on aw.PK_ID=cm.PK_AWARDS
LEFT JOIN cu_member_team ct ON ct.pk_id = cm.pk_team_code
left join bd_vertex ver on ver.pk_id=cm.pk_vertex
where cmp.EDIT_TYPE = 125 and cm.del_flag = 0
and cmp.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and cm.member_code like #{memberCode} || '%'
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name like #{memberName} || '%'
</if>
<if test="businessNo != null and businessNo != ''">
and cm.BUSINESS_NO=#{businessNo}
</if>
<if test="pkBdVertex != null">
and cm.PK_VERTEX=#{pkBdVertex}
</if>
<if test="pkAwards != null">
and cm.PK_AWARDS=#{pkAwards}
</if>
<if test="pkTeamCode != null">
and cm.pk_team_code=#{pkTeamCode}
</if>
<if test="pkCountry != null">
and cmp.PK_COUNTRY=#{pkCountry}
</if>
<if test="approveStatus != null">
and cmp.APPROVE_STATUS=#{approveStatus}
</if>
<if test="startDate != null and endDate != null">
and cmp.creation_time between #{startDate, jdbcType=TIMESTAMP} and #{endDate, jdbcType=TIMESTAMP}
</if>
<if test="pkIdList != null and pkIdList.size > 0">
and cmp.pk_id in
<foreach collection="pkIdList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
ORDER BY cmp.CREATION_TIME DESC
</select>
<select id="checkCecharge" parameterType="java.lang.Long"
resultType="java.lang.Integer">
select count(1)
from cu_member_recharge
where APPROVE_STATE in (0, 1)
and PK_MEMBER = #{pkMember}
and DEL_FLAG = 0
</select>
<select id="checkWithdraw" parameterType="java.lang.Long"
resultType="java.lang.Integer">
select count(1)
from cu_member_withdraw
where PK_MEMBER = #{pkMember}
and APPROVE_STATE not in (4, 5, 6)
and STATUS = 0
and DEL_FLAG = 0
</select>
<select id="checkAccount" parameterType="java.lang.Long"
resultType="java.lang.Integer">
select count(1)
from cu_member_account
where (ACCOUNT1 > 0 or
ACCOUNT2 > 0 or
ACCOUNT3 > 0 or
ACCOUNT4 > 0 or
ACCOUNT5 > 0 or
ACCOUNT7 > 0 or
ACCOUNT8 > 0 or
ACCOUNT9 > 0 or
ACCOUNT10 > 0)
and PK_MEMBER = #{pkMember}
</select>
<!--查询会员是否存在未完成基础业务办理-->
<select id="checkmsLogCount"
resultType="java.lang.Integer">
select count(1)
from CU_MEMBER_SERVICE_LOG
where (APPROVE_STATUS = 1 or
APPROVE_STATUS = 2 or
APPROVE_STATUS = 3)
<if test="pkMember!= null ">
and PK_MEMBER = #{pkMember}
</if>
<if test="editType!= null ">
and EDIT_TYPE = #{editType}
</if>
</select>
<!--查询会员是否存在未完成注水业绩业务-->
<select id="checkMemberAchieveCount" parameterType="java.lang.Long"
resultType="java.lang.Integer">
select count(1)
from CU_MEMBER_ACHIEVE_LOG
where (APPROVE_STATUS = 1 or APPROVE_STATUS = 2 or APPROVE_STATUS = 3)
and PK_MEMBER = #{pkMember}
</select>
<!-- 查询选择会员列表 -->
<select id="queryMemberSelect" resultType="com.hzs.common.domain.member.ext.CuMemberExt">
select cm.pk_id,
cm.member_code,
cm.member_name,
cm.phone,
cm.pk_register_grade,
bdr.pk_transaction register_grade_key,
cm.pk_settle_grade,
bds.pk_transaction settle_grade_key,
cm.pk_awards,
ba.pk_transaction awards_key
from cu_member cm
inner join bd_grade bdr
on bdr.pk_id = cm.pk_register_grade
inner join bd_grade bds
on bds.pk_id = cm.pk_settle_grade
inner join bd_awards ba
on ba.pk_id = cm.pk_awards
where cm.del_flag = 0
and cm.pk_settle_country = #{pkCountry}
<if test="param.memberCode != null and param.memberCode != ''">
and cm.member_code like #{param.memberCode} || '%'
</if>
<if test="param.memberName != null and param.memberName != ''">
and cm.member_name like #{param.memberName} || '%'
</if>
<if test="param.phone != null and param.phone != ''">
and cm.phone = #{param.phone}
</if>
<if test="param.pkRegisterGrade != null and param.pkRegisterGrade.size > 0">
and cm.pk_register_grade in
<foreach collection="param.pkRegisterGrade" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="param.pkSettleGrade != null and param.pkSettleGrade.size > 0">
and cm.pk_settle_grade in
<foreach collection="param.pkSettleGrade" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="param.pkAwards != null and param.pkAwards.size > 0">
and cm.pk_awards in
<foreach collection="param.pkAwards" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="param.memberCodeList != null and param.memberCodeList.size > 0">
and cm.member_code in
<foreach collection="param.memberCodeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
order by cm.creation_time desc
</select>
<select id="queryCuMemberLastPlaceParent" resultMap="MemberResultMap">
select cu.place_dept,
cu.pk_id,
cu.member_code,
cu.member_name,
cu.phone,
cu.category,
cu.pk_settle_grade,
bg.grade_value,
nick_name,
service_code,
pk_vertex
from (
select *
from (select 1 place_dept,
t.pk_id,
t.member_code,
t.member_name,
t.phone,
t.category,
t.pk_settle_grade,
level lev,
t.nick_name,
t.service_code,
t.pk_vertex
from (select *
from cu_member start with pk_id=#{pkMember}
connect by prior pk_id = pk_place_parent) t
where t.place_dept = 1
and t.del_flag = 0
start
with t.pk_id = (select u.pk_id
from cu_member u
where u.del_flag=0 and u.pk_place_parent=#{pkMember}
and place_dept = 1)
connect by prior
t.pk_id = (select u.pk_place_parent
from cu_member u
where u.del_flag=0
and u.pk_id = t.pk_id
and u.place_dept = 1)
order by lev desc) n
where rownum = 1
union
select *
from (
select 2 place_dept,
t.pk_id,
t.member_code,
t.member_name,
t.phone,
t.category,
t.pk_settle_grade,
level lev,
t.nick_name,
t.service_code,
t.pk_vertex
from (select *
from cu_member start with pk_id=#{pkMember}
connect by prior pk_id = pk_place_parent) t
where t.place_dept = 1
and t.del_flag = 0
start
with t.pk_id = (select u.pk_id
from cu_member u
where u.del_flag=0 and u.pk_place_parent=#{pkMember}
and place_dept = 2)
connect by prior
t.pk_id = (select u.pk_place_parent
from cu_member u
where u.del_flag=0
and u.pk_id = t.pk_id
and u.place_dept = 1)
union
select t.place_dept, t.pk_id, t.member_code, t.member_name, t.phone, t.category, t.pk_settle_grade, 0 lev, t.nick_name, t.service_code, t.pk_vertex
from cu_member t
where t.place_dept = 2 and t.del_flag = 0 and t.pk_place_parent=#{pkMember}
union
select 2, t.pk_id, t.member_code, t.member_name, t.phone, t.category, t.pk_settle_grade, -1 lev, t.nick_name, t.service_code, t.pk_vertex
from cu_member t
where t.del_flag = 0 and t.pk_id=#{pkMember}
order by lev desc) n
where rownum = 1) cu
left join bd_grade bg
on cu.pk_settle_grade = bg.pk_id
</select>
<select id="selectByMemberRealInfo" resultType="com.hzs.member.base.vo.MemberRealInfoVO">
select
cm.MEMBER_CODE as memberCode,
cm.MEMBER_NAME memberName,
cm.PHONE phone,
bg.PK_TRANSACTION as pkRegisterGrade,
bgg.PK_TRANSACTION as pkSettleGrade,
ba.PK_TRANSACTION as pkAwards,
bamax.PK_TRANSACTION as pkMaxAwards,
ma.SEX as sex,
cm.birth_date birthDate,
ma.ID_TYPE idType,
ma.ID_CARD idCard,
ma.ID_FRONT idFront,
ma.ID_BACK idBack,
ma.PK_PROVINCE pkProvince,
ma.PK_CITY pkCity,
ma.PK_COUNTY pkCounty,
ma.ADDRESS address,
bb.BANK_NAME bankName,
ma.SUB_BANK_NAME subBankName,
ma.ACCOUNT_NAME accountName,
ma.PHONE reservedPhone,
ma.CARD_NUMBER cardNumber,
cm.EMAIL email,
ma.CREATION_TIME certificationTime,
cm.CREATION_TIME creationTime,
cm.PAY_TIME payTime,
cm.DIRECT_PUSH_NUMBER directPushNumber
from CU_MEMBER cm
left join CU_MEMBER_AUTHENTICATION ma on ma.PK_MEMBER = cm.PK_ID and ma.del_flag = 0
left join BD_BANK bb on bb.PK_ID = ma.pk_bank
left join BD_GRADE bg on bg.pk_id=cm.PK_REGISTER_GRADE
left join BD_GRADE bgg on bgg.pk_id=cm.PK_SETTLE_GRADE
left join BD_AWARDS ba on ba.pk_id=cm.PK_AWARDS
left join BD_AWARDS baMax on baMax.pk_id=cm.PK_MAX_AWARDS
left join bd_vertex ver on cm.pk_vertex = ver.pk_id
LEFT JOIN cu_member_team ct ON ct.pk_id = cm.pk_team_code
where cm.del_flag = 0
<if test="pkCountry != null">
and cm.PK_SETTLE_COUNTRY = #{pkCountry}
</if>
<if test="systemType != null">
and cm.system_type = #{systemType}
</if>
<if test="memberCode != null and memberCode != ''">
and cm.MEMBER_CODE like #{memberCode} ||'%'
</if>
<if test="memberName != null and memberName != ''">
and cm.MEMBER_NAME like #{memberName} ||'%'
</if>
<if test="birthDate != null and birthDate != ''">
and ma.ID_CARD like '%' || #{birthDate} ||'%'
</if>
<if test="phone != null and phone != ''">
and cm.PHONE = #{phone}
</if>
<if test="pkRegisterGrade != null">
and cm.PK_REGISTER_GRADE = #{pkRegisterGrade}
</if>
<if test="pkAwards != null">
and cm.PK_AWARDS = #{pkAwards}
</if>
<if test="pkSettleGrade != null">
and cm.PK_SETTLE_GRADE = #{pkSettleGrade}
</if>
<if test="idType != null">
and ma.ID_TYPE = #{idType}
</if>
<if test="idCard != null and idCard != ''">
and ma.ID_CARD = #{idCard}
</if>
<if test="pkProvince != null">
and ma.PK_PROVINCE = #{pkProvince}
</if>
<if test="pkCity != null">
and ma.PK_CITY = #{pkCity}
</if>
<if test="pkCounty != null">
and ma.PK_COUNTY = #{pkCounty}
</if>
<if test="address != null and address != ''">
and ma.ADDRESS like #{address} ||'%'
</if>
<if test="sex != null">
and ma.SEX = #{sex}
</if>
<if test="bankName != null and bankName != ''">
and bb.BANK_NAME like #{bankName}||'%'
</if>
<if test="subBankName != null and subBankName != ''">
and ma.SUB_BANK_NAME like #{subBankName}||'%'
</if>
<if test="cardNumber != null and cardNumber != ''">
and ma.CARD_NUMBER like #{cardNumber}||'%'
</if>
<if test="email != null and email != ''">
and cm.EMAIL like #{email}||'%'
</if>
<if test="startCertificationTime != null">
and ma.CREATION_TIME &gt;= to_date(#{startCertificationTime}, 'yyyy-mm-dd')
</if>
<if test="endCertificationTime != null">
and ma.CREATION_TIME &lt;= to_date(#{endCertificationTime} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="startCreationTime != null">
and cm.CREATION_TIME &gt;= to_date(#{startCreationTime}, 'yyyy-mm-dd')
</if>
<if test="endCreationTime != null">
and cm.CREATION_TIME &lt;= to_date(#{endCreationTime} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="startPayTime != null">
and cm.PAY_TIME &gt;= to_date(#{startPayTime}, 'yyyy-mm-dd')
</if>
<if test="endPayTime != null">
and cm.PAY_TIME &lt;= to_date(#{endPayTime} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
<!-- 体系权限处理 -->
<if test="vertexList != null and vertexList.size > 0">
and ver.pk_member in
<foreach collection="vertexList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<!--团队权限 -->
<if test="teamList != null and teamList.size > 0">
and ct.pk_member in
<foreach collection="teamList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
order by cm.CREATION_TIME desc
</select>
<select id="selectRegList" resultType="com.hzs.member.marketnews.vo.UserInvestmentVo">
select
cm.MEMBER_CODE memberCode,
cm.MEMBER_NAME memberName,
cm.PK_REGISTER_GRADE pkRegisterGrade,
cm.CREATION_TIME creationTime,
cm.PK_PARENT pkParent,
cm.PK_PLACE_PARENT pkPlaceParent,
nvl(a.regMoney, 0) regMoney,
nvl(a.regPv, 0) regPv,
cm.PAY_TIME payTime,
cm.PLACE_DEPT placeDept,
pm.MEMBER_NAME placeParentName,
pm.MEMBER_CODE placeParentCode,
pm.pk_vertex place_pk_vertex,
pm.service_code place_service_code,
pm.nick_name place_nick_name,
pp.MEMBER_NAME parentName,
pp.MEMBER_CODE parentCode,
pp.pk_vertex parent_pk_vertex,
pp.service_code parent_service_code,
pp.nick_name parent_nick_name,
cm.pk_vertex,
cm.service_code,
cm.nick_name
from cu_member cm
left join (
select nvl(sum(so.ORDER_AMOUNT),0) regMoney ,nvl(sum(so.ORDER_ACHIEVE),0) regPv,so.PK_MEMBER from SA_ORDER so where
so.ORDER_TYPE = 1
and so.ORDER_STATUS in (1,7,24)
and so.DEL_FLAG = 0
group by so.PK_MEMBER
)a on a.PK_MEMBER = cm.PK_ID
left join cu_member pm on pm.pk_id = cm.PK_PLACE_PARENT
left join cu_member pp on pp.pk_id = cm.PK_PARENT
where cm.DEL_FLAG = 0
and cm.PAY_STATUS = 1
and cm.CATEGORY = 0
<if test="memberInfo != null and memberInfo != ''">
and (cm.member_code=#{memberInfo} or cm.member_name=#{memberInfo})
</if>
<if test="memberCode != null and memberCode != ''">
and (cm.member_code=#{memberCode} or cm.SERVICE_CODE = #{memberCode})
</if>
<if test="memberName != null and memberName != ''">
and (cm.member_name=#{memberName} or cm.nick_name = #{memberName})
</if>
<if test="pkRegisterGrade != null">
and cm.PK_REGISTER_GRADE=#{pkRegisterGrade}
</if>
<if test="pkCountry != null">
and cm.PK_COUNTRY=#{pkCountry}
</if>
<if test="pkCreator != null">
and cm.PK_CREATOR=#{pkCreator}
</if>
<if test="startCreationTime != null">
and cm.creation_time >= #{startCreationTime}
</if>
<if test="endCreationTime != null">
and cm.creation_time &lt; #{endCreationTime}
</if>
order by cm.CREATION_TIME desc
</select>
<select id="queryMemberByCondition" resultType="com.hzs.common.domain.member.ext.CuMemberExt">
select cm.pk_id,cm.member_code,cm.member_name,cm.phone,cm.pk_settle_country,cm.pk_parent,
cm.pk_place_parent,cm.place_dept,cm.pk_team_code,cm.pk_center_code,cm.category,cm.pk_settle_grade,
cm.pk_awards,cm.purchase_status,cm.order_source,cm.is_real_name,cm.is_bus_license,cm.is_maker_space,
cm.share_status,cm.pay_pwd,cm.register_authority,cm.nick_name,bg.grade_value,
cm.pk_vertex,
cm.nick_name,
cm.service_code
from cu_member cm
left join bd_grade bg
on cm.pk_settle_grade = bg.pk_id
where cm.del_flag=0
<if test="pkSettleCountry != null">
and cm.pk_settle_country=#{pkSettleCountry}
</if>
<if test="pkId != null ">
and cm.pk_id = #{pkId}
</if>
<if test="memberCode != null and memberCode != ''">
and cm.member_code = #{memberCode}
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name = #{memberName}
</if>
<if test="phone != null and phone != ''">
and cm.phone = #{phone}
</if>
<if test="pkParent != null and pkParent != ''">
and cm.pk_parent = #{pkParent}
</if>
<if test="pkPlaceParent != null and pkPlaceParent != ''">
and cm.pk_place_parent = #{pkPlaceParent}
</if>
<if test="placeDept != null and placeDept != ''">
and cm.place_dept = #{placeDept}
</if>
</select>
<select id="parentList" resultType="com.hzs.member.base.vo.ParentMemberVo">
select a.* from ( select cm.CONSUME_MONEY consumeMoney,cm.CONSUME_ACHIEVE consumeAchieve,cm.member_code memberCode,cm.member_name memberName,cm.PK_REGISTER_GRADE pkRegisterGrade,
cm.PK_SETTLE_GRADE pkSettleGrade,
cm.CREATION_TIME creationTime,
cm.pk_vertex,
cm.nick_name,
cm.service_code
from CU_MEMBER cm
where 1 = 1 and cm.DEL_FLAG = 0 and cm.pay_status=1 and cm.PK_SETTLE_GRADE != 1
<if test="memberInfo != null and memberInfo != ''">
and (cm.member_code=#{memberInfo} or cm.member_name=#{memberInfo})
</if>
<if test="pkParent != null">
and cm.PK_PARENT = #{pkParent}
</if>
<if test="memberCode != null and memberCode != ''">
and (cm.member_code = #{memberCode} or cm.SERVICE_CODE = #{memberCode})
</if>
<if test="memberName != null and memberName != ''">
and (cm.member_name = #{memberName} or cm.NICK_NAME = #{memberName})
</if>
<if test="startCreateTime != null">
and cm.CREATION_TIME >= #{startCreateTime}
</if>
<if test="endCreateTime != null">
and cm.CREATION_TIME &lt;= #{endCreateTime}
</if>
union all
select cm.CONSUME_MONEY consumeMoney,cm.CONSUME_ACHIEVE consumeAchieve,cm.member_code memberCode,cm.member_name memberName,cm.PK_REGISTER_GRADE pkRegisterGrade,
cm.PK_SETTLE_GRADE pkSettleGrade,
cm.CREATION_TIME creationTime,
cm.pk_vertex,
cm.nick_name,
cm.service_code
from CU_MEMBER cm
where 1 = 1 and cm.DEL_FLAG = 0 and cm.pay_status=1 and cm.PK_SETTLE_GRADE = 1
and (
(select count(so.PK_ID) from sa_order so where so.PK_MEMBER = cm.pk_id and so.DEL_FLAG = 0 and so.ORDER_STATUS = 1) > 0
or
(select count(sto.PK_ID) from sa_t_order sto where sto.PK_MEMBER = cm.pk_id and sto.DEL_FLAG = 0 and sto.ORDER_STATUS = 1) > 0
)
<if test="memberInfo != null and memberInfo != ''">
and (cm.member_code=#{memberInfo} or cm.member_name=#{memberInfo})
</if>
<if test="pkParent != null">
and cm.PK_PARENT = #{pkParent}
</if>
<if test="memberCode != null and memberCode != ''">
and (cm.member_code = #{memberCode} or cm.SERVICE_CODE = #{memberCode})
</if>
<if test="memberName != null and memberName != ''">
and (cm.member_name = #{memberName} or cm.NICK_NAME = #{memberName})
</if>
<if test="startCreateTime != null">
and cm.CREATION_TIME >= #{startCreateTime}
</if>
<if test="endCreateTime != null">
and cm.CREATION_TIME &lt;= #{endCreateTime}
</if>
) a order by a.creationTime desc
</select>
<!-- 校验是否血缘关系 -->
<select id="checkParent" resultType="int">
select count(1)
from cu_member cm
where cm.member_code = #{topCode} start
with cm.pk_id = #{pkMember}
connect by cm.pk_id = prior cm.pk_parent
</select>
<!-- 校验会员编号是否存在 -->
<select id="checkMemberCodeExist" resultType="com.hzs.member.base.dto.MemberCountDTO">
select tmp.member_code, count(tmp.member_code) member_count
from (
select cm.member_code
from cu_member cm
where cm.del_flag = 0
and (cm.member_code in ('0'
<foreach collection="codeList" item="item" close=")" index="index">
<choose>
<when test="index % 500 == 0">) or cm.member_code in (#{item}</when>
<otherwise>, #{item}</otherwise>
</choose>
</foreach>
)
<if test="checkEmpty != null and checkEmpty">
<!-- 需要校验批量空单数据 -->
union all
select cmed.member_code
from CU_MEMBER_EMPTY_DETAIL cmed
inner join CU_MEMBER_EMPTY cme
on cme.pk_id = cmed.pk_member_empty
and cme.status in (1, 2, 4)
and cme.del_flag = 0
where cmed.del_flag = 0
<if test="excludeMemberEmpty != null">
and cmed.pk_member_empty != #{excludeMemberEmpty}
</if>
and (cmed.member_code in ('0'
<foreach collection="codeList" item="item" close=")" index="index">
<choose>
<when test="index % 500 == 0">) or cmed.member_code in (#{item}</when>
<otherwise>, #{item}</otherwise>
</choose>
</foreach>
)
</if>
) tmp
group by tmp.member_code
</select>
<!-- 校验会员联系方式是否存在 -->
<select id="checkMemberPhoneExist" resultType="com.hzs.member.base.dto.MemberCountDTO">
select tmp.phone, count(tmp.phone) member_count
from (
select cm.phone
from cu_member cm
where cm.del_flag = 0
and cm.system_type = #{systemType}
and (cm.phone in ('0'
<foreach collection="phoneList" item="item" close=")" index="index">
<choose>
<when test="index % 500 == 0">) or cm.phone in (#{item}</when>
<otherwise>, #{item}</otherwise>
</choose>
</foreach>
)
<if test="checkEmpty != null and checkEmpty">
<!-- 需要校验批量空单数据 -->
union all
select cmed.phone
from CU_MEMBER_EMPTY_DETAIL cmed
inner join CU_MEMBER_EMPTY cme
on cme.pk_id = cmed.pk_member_empty
and cme.status in (1, 2, 4)
and cme.del_flag = 0
and cme.system_type = #{systemType}
where cmed.del_flag = 0
<if test="excludeMemberEmpty != null">
and cmed.pk_member_empty != #{excludeMemberEmpty}
</if>
and (cmed.phone in ('0'
<foreach collection="phoneList" item="item" close=")" index="index">
<choose>
<when test="index % 500 == 0">) or cmed.phone in (#{item}</when>
<otherwise>, #{item}</otherwise>
</choose>
</foreach>
)
</if>
) tmp
group by tmp.phone
</select>
<select id="findAll" resultMap="MemberResultMap">
select *
from cu_member
</select>
<select id="selectByDeptNumberCount" resultType="long">
select count(t.pk_id)
from CU_MEMBER t
where t.CATEGORY = 0
and t.del_flag = 0
start
with t.PK_PLACE_PARENT = #{pkMember} and t.PLACE_DEPT = #{placeDept}
connect by t.PK_PLACE_PARENT = prior t.PK_ID
</select>
<select id="selectPlaceSponsorUnderUmbrellaByCode" resultMap="MemberResultMap">
select *
from (select t.pk_id,
t.member_code,
t.member_name,
t.phone,
t.pk_place_parent,
t.pk_parent,
t.pk_center_code,
t.PLACE_DEPT,
t.service_code
from cu_member t
where t.del_flag = 0 start
with t.pk_place_parent = #{memberId}
connect by t.pk_place_parent = prior t.pk_id) a
where (a.member_code = #{placeParentCode} or a.service_code = #{placeParentCode})
</select>
<!--根据用户编号、用户用户名查询用户信息-->
<select id="selectMemberByMemberCode" resultMap="MemberResultMap">
select m.member_code, m.member_name
from cu_member m
where m.del_flag = 0
and m.category = 0
and m.pk_settle_country = #{pkCountry}
<if test="memberCode != null and memberCode != ''">
and m.member_code=#{memberCode}
</if>
<if test="memberName != null and memberName != ''">
and m.member_name=#{memberName}
</if>
ORDER BY m.CREATION_TIME DESC
</select>
<!-- 查询最末安置人(根据会员编号) -->
<select id="queryLastPlaceByMemberCode" resultMap="MemberResultMap">
select *
from (select level, cm.*
from cu_member cm
where cm.del_flag = 0
and cm.place_dept = 1
start
with (cm.pk_place_parent =
(select pk_id
from cu_member
where member_code = #{memberCode}) and
cm.place_dept = #{placeDept})
connect by cm.pk_place_parent = prior cm.pk_id
order by level desc) tmp
where rownum = 1
</select>
<!-- 查询指定数量会员SEQ -->
<select id="querySeqList" resultType="long">
SELECT CU_MEMBER_SEQ.nextval
FROM (select level from dual connect by #{param} >= level)
</select>
<!-- 根据会员编号批量查询会员信息 -->
<select id="queryMemberListByCode" resultType="com.hzs.common.domain.member.base.CuMember">
select cm.*
from cu_member cm
where cm.del_flag = 0
and (cm.member_code in (''
<foreach collection="memberCodeList" item="item" close=")" index="index">
<choose>
<when test="index % 500 == 0">) or cm.member_code in (#{item}</when>
<otherwise>, #{item}</otherwise>
</choose>
</foreach>
)
order by cm.pk_id
</select>
<select id="selectBloodKinshipUnderUmbrellaByMemberIds" resultType="com.hzs.member.base.vo.MemberTeamInfoVo">
<foreach collection="memberIds" item="memberId" separator="union">
select count(t.pk_id) numberCount, sum(t.CONSUME_ACHIEVE) numberAchieve, #{memberId} pkMember
from cu_member t
where t.del_flag = 0 start
with t.pk_id = #{memberId}
connect by t.pk_parent = prior t.pk_id
</foreach>
</select>
<select id="queryMemberLeftRightCount" resultType="com.hzs.common.domain.member.base.CuMember">
select 1 placeDept, count(t.pk_id) pkId
from cu_member t
where t.del_flag = 0 start
with t.pk_place_parent = #{pkMember} and place_dept=1
connect by t.pk_place_parent = prior t.pk_id
union
select 2 placeDept, count(t.pk_id) pkId
from cu_member t
where t.del_flag = 0 start
with t.pk_place_parent = #{pkMember} and place_dept=2
connect by t.pk_place_parent = prior t.pk_id
order by placeDept
</select>
<update id="updateParentById">
update CU_MEMBER
set PK_PARENT = #{pkParent},
DIRECT_PUSH_NUMBER = #{directPushNumber}
where PK_ID = #{pkMember}
</update>
<update id="updatePlaceParentAndPlaceDeptById">
update CU_MEMBER
set PK_PLACE_PARENT = #{pkPlaceParent},
PLACE_DEPT = #{placeDept}
where PK_ID = #{pkMember}
</update>
<!-- 校验会员编号是否存在 -->
<select id="checkCodeExist" resultType="string">
select member_code
from cu_member cm
where 1 = 1
and (cm.member_code in ('0'
<foreach collection="memberCodeList" item="item" close=")" index="index">
<choose>
<when test="index % 500 == 0">) or cm.member_code in (#{item}</when>
<otherwise>, #{item}</otherwise>
</choose>
</foreach>
)
union
select member_code
from cu_member_empty_code cmec
where cmec.del_flag = 0
and (cmec.member_code in ('0'
<foreach collection="memberCodeList" item="item" close=")" index="index">
<choose>
<when test="index % 500 == 0">) or cmec.member_code in (#{item}</when>
<otherwise>, #{item}</otherwise>
</choose>
</foreach>
)
</select>
<!-- 查询注册订单信息 -->
<select id="queryRegisterOrder" resultMap="MemberResultMap">
select cm.member_code,
cm.member_name,
cm.phone,
cm.login_password,
cm.pay_password
from sa_order so
inner join cu_member cm
on cm.pk_id = so.pk_member
where so.del_flag = 0
and so.order_type in (1, 7, 24)
and so.order_code = #{orderCode}
and so.pk_creator = #{pkMember}
</select>
<select id="checkPlaceDeptAndMemberCode" resultType="java.lang.Long">
select count(c.pk_id)
from cu_member c
where c.PLACE_DEPT = #{placeDept}
and c.del_flag = 0
and c.PK_PLACE_PARENT = (select cm.pk_id from cu_member cm where cm.MEMBER_CODE = #{placeDeptMemberCode} and cm.del_flag = 0)
</select>
<select id="checkMemberParent" resultType="long">
select count(t.pk_id)
from cu_member t
where t.del_flag = 0
and t.member_code = #{memberCode} start
with t.pk_id = #{pkMember}
connect by t.pk_parent = prior t.pk_id
</select>
<update id="updateMemberEditNumber">
update cu_member m
set m.change_number = nvl(m.change_number,0) + 1,
m.modified_time = sysdate,
m.pk_modified = #{updatePkMember}
where m.pk_id in
<foreach collection="pkMemberList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<select id="checkPlaceMemberList" resultType="long">
select count(t.PK_ID)
from cu_member t
where t.member_code = #{editNewPlaceMemberCode} start
with t.PK_ID = #{pkMember}
connect by t.PK_PLACE_PARENT = prior t.pk_id
</select>
<!-- 查询安置会员列表 -->
<select id="queryPlaceMemberList" resultMap="MemberResultMap">
select cm.*
from cu_member cm
where cm.del_flag = 0
and cm.pk_settle_country = #{pkCountry}
and cm.pk_place_parent =
(select cm.pk_id
from cu_member cm
where cm.member_code = #{memberCode})
order by cm.pk_id
</select>
<!-- 查询血缘上所属体系 -->
<select id="queryParentVertex" resultMap="MemberResultMap">
select *
from (select cm.*
from cu_member cm
where cm.pk_vertex is not null
and cm.del_flag = 0
start
with cm.pk_id = #{pkMember}
connect by cm.pk_id = prior cm.pk_parent
order by level)
where rownum = 1
</select>
<select id="getMemberConsumptionStat" resultType="com.hzs.member.base.vo.MemberConsumptionStatVo">
select
cm.MEMBER_CODE memberCode,
cm.MEMBER_NAME memberName,
so.orderAmount orderAmount ,
so.orderAchieve orderAchieve
from cu_member cm
left join (
select so.PK_CREATOR,
nvl(sum(oi.PRICE * oi.QUANTITY),0) orderAmount,
nvl(sum(oi.ACHIEVEMENT * oi.QUANTITY),0) orderAchieve
from SA_ORDER_ITEMS oi
left join sa_order so on so.PK_ID = oi.PK_ORDER
left join BD_WARES bw on bw.PK_ID = oi.PK_WARES
where so.del_flag = 0
and oi.del_flag = 0
and so.ORDER_STATUS = 1
<if test="specialArea != null">
and bw.SPECIAL_AREA = #{specialArea}
</if>
<if test="pkProductList != null and pkProductList.size > 0">
and oi.pk_wares in
<foreach collection="pkProductList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="startPayTime != null">
and so.PAY_TIME &gt;= #{startPayTime}
</if>
<if test="endPayTime != null">
and so.PAY_TIME &lt;= #{endPayTime}
</if>
group by so.PK_CREATOR
)so on so.PK_CREATOR = cm.PK_ID
where cm.DEL_FLAG = 0
and cm.PAY_STATUS = 1
and so.orderAmount > 0
<if test="pkCountry != null">
and cm.PK_SETTLE_COUNTRY = #{pkCountry}
</if>
<if test="memberCode != null and memberCode != ''">
and cm.member_code=#{memberCode}
</if>
group by cm.MEMBER_CODE ,cm.MEMBER_NAME ,orderAmount ,orderAchieve
order by orderAmount desc
</select>
<!-- 查询表是否存在-->
<select id="selectExistTable" resultType="Integer">
select count(1)
from user_tables t
where t.table_name = upper('${achieveTable}')
</select>
<select id="queryBloodKinshipUnderUmbrella" resultType="long">
<foreach collection="paramList" item="item" separator=" union ">
select ${item.pkMember}
from cu_member cm
where cm.del_flag = 0
and cm.pk_id = #{item.pkMember}
start with cm.pk_id = #{item.loginMember}
connect by cm.pk_id = prior cm.pk_parent
</foreach>
</select>
<select id="queryPlaceSponsorUnderUmbrella" resultType="long">
<foreach collection="paramList" item="item" separator=" union ">
select ${item.pkMember}
from cu_member cm
where cm.del_flag = 0
and cm.pk_id = #{item.pkMember}
start with cm.pk_id = #{item.loginMember}
connect by cm.pk_id = prior cm.pk_place_parent
</foreach>
</select>
<!-- 查询菜单用户 -->
<select id="getMenuMember" resultType="com.hzs.common.domain.member.ext.CuMemberExt">
select cm.*,
case
when tmp1.pk_member is null then
1
else
0
end experience_center_show,
case
when tmp2.pk_member is null then
1
else
0
end special_registration,
case
when tmp10.store_level = 2 then
0
else
1
end wholesale_show,
case
when tmp10.store_level = 1 or tmp10.store_level = 0 then
0
else
1
end maker_space_show
from cu_member cm
left join (select distinct cmsc.pk_member
from cu_authority_control cmsc
where cmsc.pk_member = #{pkMember}
and cmsc.control_type = 1
and cmsc.del_flag = 0) tmp1
on tmp1.pk_member = cm.pk_id
left join (select distinct cmsc.pk_member
from cu_authority_control cmsc
where cmsc.pk_member = #{pkMember}
and cmsc.control_type = 2
and cmsc.del_flag = 0) tmp2
on tmp2.pk_member = cm.pk_id
left join (select cms.pk_member, cms.store_level
from cu_maker_space cms
where cms.del_flag = 0
and cms.store_type = 1
and cms.pk_member = #{pkMember}
and cms.APPROVE_STATUS = 5
and cms.APPLY_STATUS = 5) tmp10
on tmp10.pk_member = cm.pk_id
where cm.pk_id = #{pkMember}
and cm.del_flag = 0
</select>
<select id="queryMemberServiceCodeList" resultType="com.hzs.member.base.vo.MemberServiceCodeVo">
select cm.SERVICE_CODE serviceCode,cm.MEMBER_CODE memberCode,cm.MEMBER_NAME memberName,cm.NICK_NAME nickName,
bg.GRADE_NAME gradeName ,ba.AWARDS_NAME awardsName,bv.VERTEX_NAME vertexName,cm.CREATION_TIME creationTime
from CU_MEMBER cm
left join bd_grade bg
on bg.pk_id = cm.pk_settle_grade
left join bd_awards ba on ba.pk_id = cm.PK_AWARDS
left join bd_vertex bv
on bv.pk_id = cm.PK_VERTEX
where cm.del_flag = 0 and cm.SERVICE_CODE is not null
<if test="pkCountry != null">
and cm.PK_SETTLE_COUNTRY = #{pkCountry}
</if>
<if test="serviceCode != null and serviceCode != ''">
and cm.SERVICE_CODE = #{serviceCode}
</if>
<if test="memberCode != null and memberCode != ''">
and cm.MEMBER_CODE = #{memberCode}
</if>
<if test="startDate != null and startDate !='' ">
and cm.CREATION_TIME &gt;= to_date(#{startDate}, 'yyyy-mm-dd')
</if>
<if test="endDate != null and endDate !='' ">
and cm.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
order by cm.SERVICE_CODE desc
</select>
<update id="updateMemberCodeByServiceCodeBlack">
update CU_MEMBER
set SERVICE_CODE = null
where MEMBER_CODE = #{memberCode}
</update>
<select id="getMaxServiceCode" resultType="java.lang.String">
select max(t.SERVICE_CODE)
from CU_MEMBER t
where t.PK_COUNTRY = #{pkCountry}
</select>
<!-- 根据会员编号获取推荐人信息 -->
<select id="getParentMember" resultType="com.hzs.common.domain.member.base.CuMember">
select cmp.*
from cu_member cm
left join cu_member cmp
on cmp.pk_id = cm.pk_parent
where cm.member_code = #{memberCode}
</select>
<!-- 查询同名同手机号最早注册的会员是否升级-->
<select id="sameNamePhone" resultType="com.hzs.common.domain.member.base.CuMember">
select *
from CU_MEMBER cmm
where cmm.MEMBER_NAME = #{memberName}
and cmm.PHONE = #{phone}
and cmm.PAY_TIME = (
select PAY_TIME
from (
SELECT cm.MEMBER_NAME,
cm.PHONE,
MIN(cm.PAY_TIME) PAY_TIME
FROM CU_MEMBER cm
WHERE cm.MEMBER_NAME = #{memberName}
AND cm.PHONE = #{phone}
and cm.DEL_FLAG = 0
and cm.CATEGORY = 0
and cm.PK_SETTLE_GRADE >= #{grade}
GROUP BY cm.MEMBER_NAME, cm.PHONE
HAVING COUNT(1) >= #{memberPoint}
)
)
and cmm.PK_SETTLE_GRADE &lt; #{giveGrade}
</select>
<!-- 查询会员奖衔列表 -->
<select id="listMemberAwards" resultType="com.hzs.member.base.vo.MemberAwardsQueryVO">
select cm.member_code,
cm.member_name,
cm.phone,
cmsa.pk_awards,
ba.awards_name,
cm.pk_max_awards,
bam.awards_name max_awards_name,
bha.awards_name history_awards_name,
bv.vertex_name,
bg.grade_name,
cmsa.new_pv,
cmsp.settle_date
from cu_member_settle_awards cmsa
left join cu_member cm
on cmsa.pk_member = cm.pk_id
left join cu_member_histroy_awards cmha
on cmha.pk_member = cm.pk_id
left join bd_histroy_awards bha
on bha.pk_id = cmha.pk_awards
left join bd_awards ba
on ba.pk_id = cmsa.pk_awards
left join bd_awards bam
on bam.pk_id = cm.pk_max_awards
left join bd_vertex bv
on bv.pk_id = cm.pk_vertex
left join bd_grade bg
on bg.pk_id = cm.pk_settle_grade
left join CU_MEMBER_SETTLE_PERIOD cmsp
on cmsp.pk_id = cmsa.period
where cm.del_flag = 0
and cm.pk_settle_country = #{pkCountry}
and cm.category = 0
<if test="param.memberCode != null and param.memberCode != ''">
and cm.member_code like #{param.memberCode} || '%'
</if>
<if test="param.pkGrade != null">
and cm.pk_settle_grade = #{param.pkGrade}
</if>
<if test="param.pkAwards != null">
and cmsa.pk_awards = #{param.pkAwards}
</if>
<if test="param.pkVertex != null">
and cm.pk_vertex = #{param.pkVertex}
</if>
<if test="param.startDate != null">
and cmsp.settle_date >= #{param.startDate}
</if>
<if test="param.endDate != null">
and #{param.endDate} >= cmsp.settle_date
</if>
order by cmsp.settle_date desc
</select>
<!-- 查询同姓名同手机号指定等级会员数量 -->
<select id="countGradeMemberPoint" resultType="int">
select count(1)
from cu_member cm
where cm.del_flag = 0
and cm.pk_country = #{pkCountry}
and cm.category = 0
and cm.pk_settle_grade = #{pkGrade}
and cm.member_name = #{memberName}
and cm.phone = #{phone}
</select>
<select id="querySponsorOnUmbrella" resultType="com.hzs.common.domain.member.ext.CuMemberExt">
select * from(
<foreach collection="memberCodeList" item="item" index="index" separator="union">
select t.pk_id, t.member_code, t.member_name, t.phone, t.pk_place_parent,level num
from cu_member t
where t.del_flag = 0 and member_code = #{item}
start with t.pk_id = #{memberId}
connect by t.pk_id = prior t.pk_place_parent
</foreach>)
order by num desc
</select>
<!-- 查询新零售会员信息-->
<select id="retailMemberList" resultType="com.hzs.member.base.vo.RetailMemberVO">
SELECT cm.pk_id pkId,
cm.member_code memberCode,
cm.nick_name nickName,
cm.pay_time payTime,
cm.change_number changeNumber,
cm.creation_time creationTime,
cm.income_status incomeStatus,
cm.is_real_name isRealName,
cm.account_status accountStatus,
cm.member_name memberName,
cm.phone,
cm.system_type systemType,
cm.customer_type customerType,
cm.category as category,
cm.purchase_status purchaseStatus,
cm.share_status shareStatus,
cm.source,
cm.consume_achieve consumeAchieve,
cm.pay_status payStatus,
cm.register_authority registerAuthority,
cm.order_source orderSource,
cm.edit_number editNumber,
cm.consume_money consumeMoney,
cm.direct_push_number directPushNumber,
cm.is_activate,
cma.is_transfer as istransfer,
cma.is_withdraw as iswithdraw,
cma.is_consume as isconsume,
cma.transfer_status as transferstatus,
ver.vertex_name as vertexName,
cmt.team_name as teamName,
gr.GRADE_NAME as pkRegisterGradeVal,
grr.GRADE_NAME as pkSettleGradeVal,
awa.AWARDS_NAME as pkAwardsVal,
awar.AWARDS_NAME as pkRangeAwardsVal,
par.member_code parMemberCode,
par.member_name parMemberName,
pr.NAME giftProvince,
cty.NAME giftCity,
con.NAME giftCounty
FROM cu_member cm
inner join CU_MEMBER_ACCOUNT cma
on cm.pk_id = cma.PK_MEMBER
left join cu_member par
ON par.pk_id = cm.pk_parent
left join bd_awards awa
on awa.pk_id = cm.PK_AWARDS
left join bd_awards awar
on awar.pk_id = cm.PK_RANGE_AWARDS
left join bd_grade gr
on gr.pk_id = cm.PK_REGISTER_GRADE
left join bd_grade grr
on grr.pk_id = cm.PK_SETTLE_GRADE
left join bd_vertex ver
on cm.pk_vertex = ver.pk_id
left join cu_member_team cmt
on cmt.pk_id = cm.pk_team_code
left join CU_MEMBER_RETAIL_REGION cmrr
on cm.pk_id = cmrr.PK_MEMBER and cmrr.EFFECTIVE=0 and cmrr.del_flag = 0
left join BD_AREA pr
on pr.pk_id = cmrr.PROVINCE
left join BD_AREA cty
on cty.pk_id = cmrr.CITY
left join BD_AREA con
on con.pk_id = cmrr.COUNTY
WHERE cm.del_flag = 0 and cm.pk_id in
(
SELECT cm.PK_ID
FROM cu_member cm
inner join CU_MEMBER_ACCOUNT cma
on cm.pk_id = cma.PK_MEMBER
left join cu_member par
ON par.pk_id = cm.pk_parent
left join bd_awards awa
on awa.pk_id = cm.PK_AWARDS
left join bd_grade gr
on gr.pk_id = cm.PK_REGISTER_GRADE
left join bd_grade grr
on grr.pk_id = cm.PK_SETTLE_GRADE
left join bd_vertex ver
on cm.pk_vertex = ver.pk_id
left join cu_member_team cmt
on cmt.pk_id = cm.pk_team_code
left join CU_MEMBER_RETAIL_REGION cmrr
on cm.pk_id = cmrr.PK_MEMBER and cmrr.EFFECTIVE=0 and cmrr.del_flag = 0
WHERE cm.del_flag = 0
<if test="isActivate != null">
and cm.IS_ACTIVATE = #{isActivate}
</if>
<if test="pkCountry != null">
and cm.pk_settle_country = #{pkCountry}
</if>
<if test="memberCode != null and memberCode != ''">
and cm.member_code like #{memberCode}||'%'
</if>
<if test="memberCodeList != null and memberCodeList.size > 0">
and
(cm.member_code in
<foreach collection="memberCodeList" item="item" index="index" open="(" close=")">
<if test="index != 0">
<choose>
<when test="index % 500 == 0">) or cm.member_code IN (</when>
<otherwise>,</otherwise>
</choose>
</if>
#{item}
</foreach>
)
</if>
<if test="changeNumber != null">
and cm.CHANGE_NUMBER=#{changeNumber}
</if>
<if test="isTransfer != null">
and cma.IS_TRANSFER=#{isTransfer}
</if>
<if test="walletStatus != null">
and cma.IS_WITHDRAW=#{walletStatus}
</if>
<if test="isConsume != null">
and cma.IS_CONSUME=#{isConsume}
</if>
<if test="transferStatus != null">
and cma.TRANSFER_STATUS=#{transferStatus}
</if>
<if test="vertexId != null">
and ver.PK_ID=#{vertexId}
</if>
<if test="teamId != null">
and cmt.PK_ID=#{teamId}
</if>
<if test="registerAuthority != null">
and cm.REGISTER_AUTHORITY=#{registerAuthority}
</if>
<if test="accountStatus != null">
and cm.ACCOUNT_STATUS=#{accountStatus}
</if>
<if test="isRealName != null">
and cm.IS_REAL_NAME=#{isRealName}
</if>
<if test="orderSource != null">
and cm.order_source=#{orderSource}
</if>
<if test="parMemberCode != null and parMemberCode != ''">
and par.member_code like #{parMemberCode}||'%'
</if>
<if test="parMemberName != null and parMemberName != ''">
and par.member_name like #{parMemberName}||'%'
</if>
<if test="memberName != null and memberName != ''">
and cm.member_name like #{memberName}||'%'
</if>
<if test="phone != null and phone != ''">
and cm.phone=#{phone}
</if>
<if test="pkRegisterGrade != null ">
and cm.pk_register_grade =#{pkRegisterGrade}
</if>
<if test="pkSettleGrade != null ">
and cm.PK_SETTLE_GRADE =#{pkSettleGrade}
</if>
<if test="pkAwards != null">
and cm.pk_awards=#{pkAwards}
</if>
<if test="pkRangeAwards != null">
and cm.pk_range_awards=#{pkRangeAwards}
</if>
<if test="directPushNumber != null">
and cm.DIRECT_PUSH_NUMBER=#{directPushNumber}
</if>
<if test="startDate != null and startDate !='' ">
and cm.CREATION_TIME &gt;= to_date(#{startDate}, 'yyyy-mm-dd')
</if>
<if test="endDate != null and endDate !='' ">
and cm.CREATION_TIME &lt;= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="startDatePay != null and startDatePay != ''">
and cm.PAY_TIME &gt;= to_date(#{startDatePay}, 'yyyy-mm-dd')
</if>
<if test="endDatePay != null and endDatePay != ''">
and cm.PAY_TIME &lt;= to_date(#{endDatePay} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="isTransfer != null ">
and cma.IS_TRANSFER=#{isTransfer}
</if>
<if test="isWithdraw != null ">
and cma.IS_WITHDRAW=#{isWithdraw}
</if>
<if test="isConsume != null ">
and cma.IS_CONSUME=#{isConsume}
</if>
<if test="province != null">
and cmrr.PROVINCE=#{province}
</if>
<if test="city != null">
and cmrr.CITY=#{city}
</if>
<if test="county != null">
and cmrr.COUNTY=#{county}
</if>
<!-- 体系权限处理 -->
<if test="vertexList != null and vertexList.size > 0">
and ver.pk_member in
<foreach collection="vertexList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
)
order by cm.CREATION_TIME desc
</select>
<!-- 查询新零售登录会员 -->
<select id="queryRetailLoginMember" resultMap="MemberResultMap">
select cm.*
from cu_member cm
where cm.del_flag = 0
<if test="memberCode != null and memberCode != ''">
and cm.member_code = #{memberCode}
</if>
<if test="pkMember != null">
and cm.pk_id = #{pkMember}
</if>
</select>
<!-- 查询新零售登录会员列表 -->
<select id="listRetailLoginMember" resultMap="MemberResultMap">
select cm.*
from cu_member cm
where cm.del_flag = 0
<if test="memberCodeList != null and memberCodeList.size > 0">
and cm.member_code in
<foreach collection="memberCodeList" item="items" open="(" close=")" separator=",">
#{items}
</foreach>
</if>
<if test="pkMemberList != null and pkMemberList.size > 0">
and cm.pk_id in
<foreach collection="pkMemberList" item="items" open="(" close=")" separator=",">
#{items}
</foreach>
</if>
</select>
<!-- 新零售查询会员血缘伞上 -->
<select id="getRetailTopMember" resultType="com.hzs.common.domain.member.base.CuMember">
select cm.*
from cu_member cm
where cm.del_flag = 0
<if test="topPkMember != null">
and cm.pk_id = #{topPkMember}
</if>
<if test="topMemberCode = null and topMemberCode != ''">
and cm.member_code = #{topMemberCode}
</if>
start
with
<choose>
<when test="pkMember != null">
cm.pk_id = #{pkMember}
</when>
<otherwise>
cm.member_code = #{memberCode}
</otherwise>
</choose>
connect by cm.pk_id = prior cm.pk_parent
</select>
<!-- 添加等级升级记录 -->
<insert id="saveMemberGrade">
INSERT into cu_member_grade (PK_ID, PK_MEMBER, PERIOD,
UP_TYPE, OLD_LEVEL, NEW_LEVEL, PK_CREATOR, pk_Country)
values (CU_MEMBER_GRADE_SEQ.nextval, #{pkMember}, #{period},
2, #{oldLevel}, #{newLevel}, #{pkCreator}, #{pkCountry})
</insert>
<!-- 根据手机号查询会员 -->
<select id="listMemberByPhone" resultType="com.hzs.common.domain.member.ext.CuMemberExt">
select *
from cu_member cm
where cm.del_flag = 0
and cm.category = 0
and cm.phone = #{phone}
order by cm.creation_time desc
</select>
<!-- 推荐列表 -->
<select id="listRecommend" resultType="com.hzs.common.domain.member.ext.CuMemberExt">
select cm.member_code,
cm.member_name,
cm.nick_name,
cm.creation_time,
cm.phone,
bg.grade_name settle_grade_val
from cu_member cm
left join bd_grade bg
on bg.pk_id = cm.pk_settle_grade
where cm.del_flag = 0
and cm.category = 0
and cm.pk_parent = #{pkMember}
order by cm.creation_time desc
</select>
<!-- 查询分享或空单并且没有订单会员列表 -->
<select id="listRetailMemberNotOrder" resultType="com.hzs.common.domain.member.ext.CuMemberExt">
select cm.*,
bg.grade_name settle_grade_val,
ba.awards_name awards_val,
cmp.member_code parent,
cmp.member_name parent_name
from cu_member cm
left join cu_member cmp
on cmp.pk_id = cm.pk_parent
left join bd_grade bg
on bg.pk_id = cm.pk_settle_grade
left join bd_awards ba
on ba.pk_id = cm.pk_awards
where cm.pk_id in (select cm.pk_id
from cu_member cm
left join sa_order so
on so.pk_member = cm.pk_id
and so.del_flag = 0
and so.order_status = 1
where cm.del_flag = 0
and cm.customer_type in (1, 4)
<if test="param.memberCode != null and param.memberCode != ''">
and cm.member_code = #{param.memberCode}
</if>
<if test="param.pkCountry != null">
and cm.PK_SETTLE_COUNTRY = #{param.pkCountry}
</if>
<if test="param.systemType != null">
and cm.system_type = #{param.systemType}
</if>
group by cm.pk_id
having count(so.pk_id) = 0)
order by cm.creation_time desc
</select>
<!-- 校验有订单的会员 -->
<select id="checkMemberOrder" resultType="Long">
select distinct pk_member
from (select distinct so.pk_member
from sa_order so
where so.del_flag = 0
and so.order_status = 1
and so.pk_member in
<foreach collection="pkMemberList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
union all
select distinct so.pk_creator
from sa_order so
where so.del_flag = 0
and so.order_status = 1
and so.pk_creator in
<foreach collection="pkMemberList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
)
</select>
<select id="selectMemberByUnderBlood" resultType="com.hzs.common.domain.system.config.BdTradeWhiteConfig">
SELECT pk_id pkId,
withdrawal_state withdrawalState,
transfer_state transferState
FROM (SELECT t0.pk_id, t0.ls, t1.withdrawal_state, t1.transfer_state
FROM (select m.pk_id,
m.del_flag,
m.system_type,
m.category,
level ls
from cu_member m
where m.del_flag = 0
start
with m.pk_id = #{pkMember}
connect by m.pk_id = prior m.pk_parent) t0,
(SELECT wc.pk_member, wc.withdrawal_state, wc.transfer_state
FROM bd_trade_white_config wc
where wc.del_flag = 0
and wc.member_type = #{memberType}) t1
where t0.pk_id = t1.pk_member
and t0.del_flag = 0
and t0.category = 0)
where rownum = 1
</select>
</mapper>