| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  | <?xml version="1.0" encoding="UTF-8"?> | 
					
						
							|  |  |  | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
					
						
							|  |  |  | <mapper namespace="com.hzs.bonus.achieve.mapper.CuMemberTreeMapper" | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | > | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <!-- 通用查询映射结果 --> | 
					
						
							|  |  |  |     <resultMap id="CuMemberSettleExt" type="com.hzs.common.domain.member.ext.CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <id column="PK_ID" property="pkId"/> | 
					
						
							|  |  |  |         <result column="PERIOD" property="period"/> | 
					
						
							|  |  |  |         <result column="PK_MEMBER" property="pkMember"/> | 
					
						
							|  |  |  |         <result column="PK_PARENT" property="pkParent"/> | 
					
						
							|  |  |  |         <result column="PK_PLACE_PARENT" property="pkPlaceParent"/> | 
					
						
							|  |  |  |         <result column="PLACE_DEPT" property="placeDept"/> | 
					
						
							|  |  |  |         <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="PK_GRADE" property="pkGrade"/> | 
					
						
							|  |  |  |         <result column="PK_ORI_AWARDS" property="pkOriAwards"/> | 
					
						
							|  |  |  |         <result column="PK_AWARDS" property="pkAwards"/> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <result column="ACCOUNT_STATUS" property="accountStatus"/> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <result column="PAY_STATUS" property="payStatus"/> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <result column="REGISTER_AUTHORITY" property="registerAuthority"/> | 
					
						
							|  |  |  |         <result column="CATEGORY" property="category"/> | 
					
						
							|  |  |  |         <result column="PURCHASE_TYPE" property="purchaseType"/> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <result column="PURCHASE_STATUS" property="purchaseStatus"/> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <result column="SHARE_STATUS" property="shareStatus"/> | 
					
						
							|  |  |  |         <result column="INCOME_STATUS" property="incomeStatus"/> | 
					
						
							|  |  |  |         <result column="PK_TEAM_CODE" property="pkTeamCode"/> | 
					
						
							|  |  |  |         <result column="PK_CENTER_CODE" property="pkCenterCode"/> | 
					
						
							|  |  |  |         <result column="PK_VERTEX" property="pkVertex"/> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <result column="PK_SETTLE_COUNTRY" property="pkSettleCountry"/> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <result column="IS_REAL_NAME" property="isRealName"/> | 
					
						
							|  |  |  |         <result column="IS_BUS_LICENSE" property="isBusLicense"/> | 
					
						
							|  |  |  |         <result column="IS_MAKER_SPACE" property="isMakerSpace"/> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <result column="PK_COUNTRY" property="pkCountry"/> | 
					
						
							|  |  |  |         <result column="PK_RATE" property="pkRate"/> | 
					
						
							|  |  |  |         <result column="A_BALANCE" property="aBalance"/> | 
					
						
							|  |  |  |         <result column="B_BALANCE" property="bBalance"/> | 
					
						
							|  |  |  |         <result column="R_A_BALANCE" property="rABalance"/> | 
					
						
							|  |  |  |         <result column="R_B_BALANCE" property="rBBalance"/> | 
					
						
							|  |  |  |         <result column="A_SUM_AMOUNT" property="aSumAmount"/> | 
					
						
							|  |  |  |         <result column="B_SUM_AMOUNT" property="bSumAmount"/> | 
					
						
							|  |  |  |         <result column="A_SUM_PV" property="aSumPv"/> | 
					
						
							|  |  |  |         <result column="B_SUM_PV" property="bSumPv"/> | 
					
						
							|  |  |  |         <result column="A_NEW_AMOUNT" property="aNewAmount"/> | 
					
						
							|  |  |  |         <result column="B_NEW_AMOUNT" property="bNewAmount"/> | 
					
						
							|  |  |  |         <result column="A_NEW_PV" property="aNewPv"/> | 
					
						
							|  |  |  |         <result column="B_NEW_PV" property="bNewPv"/> | 
					
						
							|  |  |  |         <result column="A_SUM_REAL_AMOUNT" property="aSumRealAmount"/> | 
					
						
							|  |  |  |         <result column="B_SUM_REAL_AMOUNT" property="bSumRealAmount"/> | 
					
						
							|  |  |  |         <result column="A_SUM_REAL_PV" property="aSumRealPv"/> | 
					
						
							|  |  |  |         <result column="B_SUM_REAL_PV" property="bSumRealPv"/> | 
					
						
							|  |  |  |         <result column="REP_A_BALANCE" property="repABalance"/> | 
					
						
							|  |  |  |         <result column="REP_B_BALANCE" property="repBBalance"/> | 
					
						
							|  |  |  |         <result column="R_REP_A_BALANCE" property="rRepABalance"/> | 
					
						
							|  |  |  |         <result column="R_REP_B_BALANCE" property="rRepBBalance"/> | 
					
						
							|  |  |  |         <result column="REP_A_NEW_AMOUNT" property="repANewAmount"/> | 
					
						
							|  |  |  |         <result column="REP_B_NEW_AMOUNT" property="repBNewAmount"/> | 
					
						
							|  |  |  |         <result column="REP_A_NEW_PV" property="repANewPv"/> | 
					
						
							|  |  |  |         <result column="REP_B_NEW_PV" property="repBNewPv"/> | 
					
						
							|  |  |  |         <result column="REP_A_SUM_AMOUNT" property="repASumAmount"/> | 
					
						
							|  |  |  |         <result column="REP_B_SUM_AMOUNT" property="repBSumAmount"/> | 
					
						
							|  |  |  |         <result column="REP_A_SUM_PV" property="repASumPv"/> | 
					
						
							|  |  |  |         <result column="REP_B_SUM_PV" property="repBSumPv"/> | 
					
						
							|  |  |  |         <result column="REGISTER_AMOUNT" property="registerAmount"/> | 
					
						
							|  |  |  |         <result column="REGISTER_PV" property="registerPv"/> | 
					
						
							|  |  |  |         <result column="REGISTER_NEW_PV" property="registerNewPv"/> | 
					
						
							|  |  |  |         <result column="UPGRADE_AMOUNT" property="upgradeAmount"/> | 
					
						
							|  |  |  |         <result column="UPGRADE_PV" property="upgradePv"/> | 
					
						
							|  |  |  |         <result column="UPGRADE_NEW_PV" property="upgradeNewPv"/> | 
					
						
							|  |  |  |         <result column="REPURCHASE_AMOUNT" property="repurchaseAmount"/> | 
					
						
							|  |  |  |         <result column="REPURCHASE_PV" property="repurchasePv"/> | 
					
						
							|  |  |  |         <result column="REPURCHASE_NEW_PV" property="repurchaseNewPv"/> | 
					
						
							|  |  |  |         <result column="HI_FUN_AMOUNT" property="hiFunAmount"/> | 
					
						
							|  |  |  |         <result column="HI_FUN_PV" property="hiFunPv"/> | 
					
						
							|  |  |  |         <result column="HI_FUN_NEW_PV" property="hiFunNewPv"/> | 
					
						
							|  |  |  |         <result column="MALL_AMOUNT" property="mallAmount"/> | 
					
						
							|  |  |  |         <result column="MALL_PV" property="mallPv"/> | 
					
						
							|  |  |  |         <result column="MALL_NEW_PV" property="mallNewPv"/> | 
					
						
							|  |  |  |         <result column="MIN_ACHIEVE" property="minAchieve"/> | 
					
						
							|  |  |  |         <result column="REGISTER_Blo_NEW_PV" property="registerBloNewPv"/> | 
					
						
							|  |  |  |         <result column="UPGRADE_Blo_NEW_PV" property="upgradeBloNewPv"/> | 
					
						
							|  |  |  |         <result column="REPURCHASE_Blo_NEW_PV" property="repurchaseBloNewPv"/> | 
					
						
							|  |  |  |         <result column="HI_FUN_Blo_NEW_PV" property="hiFunBloNewPv"/> | 
					
						
							|  |  |  |         <result column="MALL_Blo_NEW_PV" property="mallBloNewPv"/> | 
					
						
							|  |  |  |         <result column="ROUND" property="round"/> | 
					
						
							|  |  |  |         <result column="SECOND" property="second"/> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <result column="ASSESS_TYPE" property="assessType"/> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <result column="PK_ORDER" property="pkOrder"/> | 
					
						
							|  |  |  |         <result column="LEVEL" property="level"/> | 
					
						
							|  |  |  |         <result column="GRADE_VALUE" property="gradeValue"/> | 
					
						
							|  |  |  |         <result column="parentMemberCode" property="parentMemberCode"/> | 
					
						
							|  |  |  |         <result column="AP_PK_ID" property="apPkId"/> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <result column="USABLE_QUANTITY" property="usableQuantity"/> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <result column="RETAIL_PRICE" property="retailPrice"/> | 
					
						
							|  |  |  |         <result column="PK_DATA_ID" property="pkDataId"/> | 
					
						
							|  |  |  |         <result column="directPushNumber" property="directPushNumber"/> | 
					
						
							|  |  |  |         <result column="historyPerformancePv" property="historyPerformancePv"/> | 
					
						
							|  |  |  |         <result column="STORE_LEVEL" property="storeLevel"/> | 
					
						
							|  |  |  |         <result column="IS_MAKER_GIFT" property="isMakerGift"/> | 
					
						
							|  |  |  |         <result column="EXPIRE_STATUS" property="expireStatus"/> | 
					
						
							|  |  |  |         <result column="IS_PAY_REG" property="isPayReg"/> | 
					
						
							| 
									
										
										
										
											2025-04-17 09:27:05 +08:00
										 |  |  |         <result column="UN_GRANT_INCOME" property="unGrantIncome"/> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </resultMap> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <!-- 会员网体月表数据,用于查询 网体跟业绩分开 横向分表--> | 
					
						
							|  |  |  |     <sql id="CuMemberTreeColumn"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         period | 
					
						
							|  |  |  |         NUMBER(6) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         pk_member         NUMBER(20) not null, | 
					
						
							|  |  |  |         pk_parent         NUMBER(20) not null, | 
					
						
							|  |  |  |         pk_place_parent   NUMBER(20), | 
					
						
							|  |  |  |         place_dept        NUMBER(3), | 
					
						
							|  |  |  |         member_code       VARCHAR2(30) not null, | 
					
						
							|  |  |  |         member_name       VARCHAR2(100) not null, | 
					
						
							|  |  |  |         customer_type     NUMBER(2) not null, | 
					
						
							|  |  |  |         phone             VARCHAR2(40) not null, | 
					
						
							|  |  |  |         pk_grade          NUMBER(4) not null, | 
					
						
							|  |  |  |         pk_awards          NUMBER(4) not null, | 
					
						
							|  |  |  |         account_status   number(1) default 0 not null, | 
					
						
							|  |  |  |         pay_status         NUMBER(2) default 0 not null, | 
					
						
							|  |  |  |         register_authority number(2) default 0 not null, | 
					
						
							|  |  |  |         category        number(2)  default 0 not null, | 
					
						
							|  |  |  |         purchase_type    number(2)  default 0 not null, | 
					
						
							|  |  |  |         purchase_status number(2)  default 0 not null, | 
					
						
							|  |  |  |         share_status  number(2)  default 0 not null, | 
					
						
							|  |  |  |         income_status number(2) default 0 not null, | 
					
						
							|  |  |  |         pk_team_code number(20), | 
					
						
							|  |  |  |         pk_center_code number(20), | 
					
						
							|  |  |  |         pk_vertex    number(20), | 
					
						
							|  |  |  |         pk_settle_country number(4) not null, | 
					
						
							|  |  |  |         is_real_name    NUMBER(1) default 1 not null, | 
					
						
							|  |  |  |         is_bus_license     NUMBER(1) default 1 not null, | 
					
						
							|  |  |  |         is_maker_space     NUMBER(1) default 1 not null, | 
					
						
							|  |  |  |         pk_country        number(4) default 1 not null, | 
					
						
							|  |  |  |         store_level       NUMBER(2) default 0, | 
					
						
							|  |  |  |         is_maker_gift     NUMBER(1) default 1, | 
					
						
							|  |  |  |         expire_status     number(1) default 1 | 
					
						
							|  |  |  |     </sql> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <!-- 结算数据会员网体+业绩数据,用于结算 网体跟业绩冗余在一起--> | 
					
						
							|  |  |  |     <sql id="CuMemberSettleColumn"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <include refid="CuMemberTreeColumn"></include>, | 
					
						
							|  |  |  |         <include refid="CuMemberSettleDetailColumn"></include>, | 
					
						
							|  |  |  |         <include refid="CuMemberBackColumn"></include> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </sql> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <sql id="CuMemberSettleDetailColumn"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         pk_rate | 
					
						
							|  |  |  |         NUMBER(6) , | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             a_balance         NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             b_balance         NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             a_sum_amount      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             b_sum_amount      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             a_sum_pv          NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             b_sum_pv          NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             a_new_amount      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             b_new_amount      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             a_new_pv          NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             b_new_pv          NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             a_sum_real_amount NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             b_sum_real_amount NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             a_sum_real_pv     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             b_sum_real_pv     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_a_balance     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_b_balance     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_a_new_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_b_new_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_a_new_pv      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_b_new_pv      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_a_sum_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_b_sum_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_a_sum_pv      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             rep_b_sum_pv      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             register_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             register_pv     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             register_new_amount     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             register_new_pv NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             upgrade_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             upgrade_pv      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             upgrade_new_amount       NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             upgrade_new_pv NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             repurchase_amount NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             repurchase_pv   NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             repurchase_new_amount    NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             repurchase_new_pv NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             hi_fun_amount NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             hi_fun_pv   NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             hi_fun_new_amount        NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             hi_fun_new_pv NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             mall_amount NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             mall_pv     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             mall_new_amount          NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             mall_new_pv NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             REGISTER_Blo_NEW_PV  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             UPGRADE_Blo_NEW_PV    NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             REPURCHASE_Blo_NEW_PV    NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             HI_FUN_Blo_NEW_PV    NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             MALL_Blo_NEW_PV    NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             min_achieve       number(17,6) default 0 not null, | 
					
						
							|  |  |  |             round             NUMBER(6) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |             second            NUMBER(4) default 1 not null, | 
					
						
							| 
									
										
										
										
											2025-04-15 09:19:15 +08:00
										 |  |  |             A_NEW_BOX         NUMBER(8) default 0 not null, | 
					
						
							|  |  |  |             B_NEW_BOX         NUMBER(8) default 0 not null, | 
					
						
							|  |  |  |             A_SUM_BOX         NUMBER(12) default 0 not null, | 
					
						
							|  |  |  |             B_SUM_BOX         NUMBER(12) default 0 not null, | 
					
						
							|  |  |  |             TOTAL_NEW_BOX     NUMBER(8) default 0 not null, | 
					
						
							|  |  |  |             TOTAL_SUM_BOX     NUMBER(12) default 0 not null | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </sql> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <sql id="memberParent"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |         pk_member, pk_parent, member_code, member_name, a.pk_awards, account_status, a.register_authority, | 
					
						
							|  |  |  |         customer_type, income_status, pk_settle_country, purchase_status, share_status, is_maker_space, | 
					
						
							|  |  |  |         a_balance, b_balance, r_a_balance, r_b_balance, rep_a_balance, rep_b_balance, r_rep_a_balance, r_rep_b_balance, | 
					
						
							|  |  |  |         register_amount, register_pv, upgrade_amount, upgrade_pv, repurchase_amount, repurchase_pv, | 
					
						
							|  |  |  |         hi_fun_amount, hi_fun_pv, mall_amount, mall_pv, category, pk_grade, pk_center_code, | 
					
						
							|  |  |  |         min_achieve, round, second, bg.grade_value, store_level, expire_status | 
					
						
							|  |  |  |         from ( | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <include refid="QueryMemberParent"></include> | 
					
						
							|  |  |  |         ) a | 
					
						
							|  |  |  |         inner join bd_grade bg | 
					
						
							|  |  |  |         on a.pk_grade = bg.pk_id | 
					
						
							|  |  |  |     </sql> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <sql id="CuMemberBackColumn"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         net_first_achieve | 
					
						
							|  |  |  |         NUMBER(17,6) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             net_repurchase_achieve  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_a_balance         NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_b_balance         NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_a_sum_amount      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_b_sum_amount      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_a_sum_pv          NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_b_sum_pv          NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_a_sum_real_amount NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_b_sum_real_amount NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_a_sum_real_pv     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_b_sum_real_pv     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_rep_a_balance     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_rep_b_balance     NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_rep_a_sum_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_rep_b_sum_amount  NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_rep_a_sum_pv      NUMBER(17,6) default 0 not null, | 
					
						
							|  |  |  |             r_rep_b_sum_pv      NUMBER(17,6) default 0 not null | 
					
						
							|  |  |  |     </sql> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <sql id="CuMemberTableTrig"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         CREATE | 
					
						
							|  |  |  |         OR REPLACE TRIGGER | 
					
						
							| 
									
										
										
										
											2025-04-12 09:09:15 +08:00
										 |  |  |         ${tableName}_TRIG | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         BEFORE | 
					
						
							|  |  |  |         INSERT | 
					
						
							|  |  |  |         OR | 
					
						
							|  |  |  |         UPDATE ON ${tableName} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             FOR EACH ROW | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         DECLARE | 
					
						
							|  |  |  |         v_newVal NUMBER(12) := 0; | 
					
						
							|  |  |  |         v_incval | 
					
						
							|  |  |  |         NUMBER(12) := 0; | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         BEGIN | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             IF | 
					
						
							|  |  |  |         INSERTING AND :new.pk_id IS NULL THEN | 
					
						
							|  |  |  |         SELECT ${tableNameSeq}.NEXTVAL | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         INTO v_newVal | 
					
						
							|  |  |  |         FROM DUAL; | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         IF | 
					
						
							|  |  |  |         v_newVal = 1 THEN | 
					
						
							|  |  |  |         SELECT NVL(max(pk_id), 0) | 
					
						
							|  |  |  |         INTO v_newVal | 
					
						
							|  |  |  |         FROM ${tableName}; | 
					
						
							|  |  |  |         v_newVal | 
					
						
							|  |  |  |         := v_newVal + 1; | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         LOOP | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         EXIT WHEN v_incval >= v_newVal; | 
					
						
							|  |  |  |         SELECT ${tableNameSeq}.nextval | 
					
						
							|  |  |  |         INTO v_incval | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         FROM dual; | 
					
						
							|  |  |  |         END LOOP; | 
					
						
							|  |  |  |         END IF; | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         :new | 
					
						
							|  |  |  |         .pk_id := v_newVal; | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         END IF; | 
					
						
							|  |  |  |         END; | 
					
						
							|  |  |  |     </sql> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <sql id="QueryMemberParent"> | 
					
						
							|  |  |  |         <foreach collection="pkMemberList" item="item" open=" " close=" " separator=" union "> | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |             select pk_member, pk_parent, member_code, member_name, pk_awards, register_authority, customer_type, | 
					
						
							|  |  |  |             account_status, income_status, pk_settle_country, purchase_status, share_status, is_maker_space, | 
					
						
							|  |  |  |             a_balance, b_balance, r_a_balance, r_b_balance, rep_a_balance, rep_b_balance, r_rep_a_balance, r_rep_b_balance, | 
					
						
							|  |  |  |             register_amount, register_pv, upgrade_amount, upgrade_pv, repurchase_amount, repurchase_pv, | 
					
						
							|  |  |  |             hi_fun_amount,hi_fun_pv,mall_amount,mall_pv, pk_center_code, category,pk_grade, | 
					
						
							|  |  |  |             min_achieve, round, second, store_level, expire_status | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             from ${settleTableName} | 
					
						
							|  |  |  |             where pay_status = 1 | 
					
						
							|  |  |  |             start with pk_member = #{item} | 
					
						
							|  |  |  |             connect by pk_member = prior pk_parent | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |     </sql> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <insert id="insertCuMemberSettleByMember"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         insert into ${settleTableName}(pk_member, pk_parent, pk_place_parent, place_dept, member_code, member_name, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                                        customer_type, phone, pk_grade, pk_awards, account_status, pay_status, | 
					
						
							|  |  |  |                                        register_authority, category, | 
					
						
							|  |  |  |                                        purchase_type, purchase_status, share_status, income_status, pk_team_code, | 
					
						
							|  |  |  |                                        is_maker_space, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                                        pk_center_code, pk_vertex, pk_settle_country, is_real_name, pk_country, pk_rate, | 
					
						
							|  |  |  |                                        store_level, is_maker_gift, expire_status) | 
					
						
							|  |  |  |         select cm.pk_id, | 
					
						
							|  |  |  |                pk_parent, | 
					
						
							|  |  |  |                pk_place_parent, | 
					
						
							|  |  |  |                place_dept, | 
					
						
							|  |  |  |                member_code, | 
					
						
							|  |  |  |                member_name, | 
					
						
							|  |  |  |                customer_type, | 
					
						
							|  |  |  |                phone, | 
					
						
							|  |  |  |                pk_settle_grade, | 
					
						
							|  |  |  |                pk_awards, | 
					
						
							|  |  |  |                account_status, | 
					
						
							|  |  |  |                pay_status, | 
					
						
							|  |  |  |                register_authority, | 
					
						
							|  |  |  |                category, | 
					
						
							|  |  |  |                (case when purchase_status = 0 then 1 else 0 end) purchase_type, | 
					
						
							|  |  |  |                purchase_status, | 
					
						
							|  |  |  |                share_status, | 
					
						
							|  |  |  |                income_status, | 
					
						
							|  |  |  |                pk_team_code, | 
					
						
							|  |  |  |                is_maker_space, | 
					
						
							|  |  |  |                pk_center_code, | 
					
						
							|  |  |  |                pk_vertex, | 
					
						
							|  |  |  |                pk_settle_country, | 
					
						
							|  |  |  |                is_real_name, | 
					
						
							|  |  |  |                cm.pk_country, | 
					
						
							|  |  |  |                nvl(bc.pk_id, -1)                                 pk_rate, | 
					
						
							|  |  |  |                nvl(b.store_level, 0)                             store_level, | 
					
						
							|  |  |  |                cm.is_maker_gift, | 
					
						
							|  |  |  |                cm.expire_status | 
					
						
							|  |  |  |         from cu_member cm | 
					
						
							|  |  |  |                  left join ( | 
					
						
							|  |  |  |             select pk_country, max(pk_id) pk_id | 
					
						
							|  |  |  |             from bd_currency | 
					
						
							|  |  |  |             where del_flag = 0 | 
					
						
							|  |  |  |               and pk_country = 1 | 
					
						
							|  |  |  |               and enable_state = 0 | 
					
						
							|  |  |  |               and effective_date <= sysdate | 
					
						
							|  |  |  |             group by pk_country) bc | 
					
						
							|  |  |  |                            on cm.pk_settle_country = bc.pk_country | 
					
						
							|  |  |  |                  left join( | 
					
						
							|  |  |  |             select pk_member, store_level | 
					
						
							|  |  |  |             from cu_maker_space | 
					
						
							|  |  |  |             where del_flag = 0 | 
					
						
							|  |  |  |               and approve_status = 5 | 
					
						
							|  |  |  |               and apply_status = 5 | 
					
						
							|  |  |  |               and store_type = 1 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) b | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                           on cm.pk_id = b.pk_member | 
					
						
							|  |  |  |         where cm.del_flag = 0 | 
					
						
							|  |  |  |           and cm.system_type = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </insert> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <insert id="insertCuMemberTreeBySettleDate"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         insert into ${targetTableName}(period, pk_member, pk_parent, pk_place_parent, place_dept, member_code, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                                        member_name, customer_type, phone, pk_grade, pk_awards, account_status, | 
					
						
							|  |  |  |                                        pay_status, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                                        register_authority, category, purchase_type, purchase_status, | 
					
						
							|  |  |  |                                        share_status, income_status, pk_team_code, pk_center_code, pk_vertex, | 
					
						
							|  |  |  |                                        pk_settle_country, is_real_name, is_bus_license, is_maker_space, pk_country) | 
					
						
							|  |  |  |         select #{period} period, | 
					
						
							|  |  |  |                pk_member, | 
					
						
							|  |  |  |                pk_parent, | 
					
						
							|  |  |  |                pk_place_parent, | 
					
						
							|  |  |  |                place_dept, | 
					
						
							|  |  |  |                member_code, | 
					
						
							|  |  |  |                member_name, | 
					
						
							|  |  |  |                customer_type, | 
					
						
							|  |  |  |                phone, | 
					
						
							|  |  |  |                pk_grade, | 
					
						
							|  |  |  |                pk_awards, | 
					
						
							|  |  |  |                account_status, | 
					
						
							|  |  |  |                pay_status, | 
					
						
							|  |  |  |                register_authority, | 
					
						
							|  |  |  |                category, | 
					
						
							|  |  |  |                purchase_type, | 
					
						
							|  |  |  |                purchase_status, | 
					
						
							|  |  |  |                share_status, | 
					
						
							|  |  |  |                income_status, | 
					
						
							|  |  |  |                pk_team_code, | 
					
						
							|  |  |  |                pk_center_code, | 
					
						
							|  |  |  |                pk_vertex, | 
					
						
							|  |  |  |                pk_settle_country, | 
					
						
							|  |  |  |                is_real_name, | 
					
						
							|  |  |  |                is_bus_license, | 
					
						
							|  |  |  |                is_maker_space, | 
					
						
							|  |  |  |                pk_country | 
					
						
							|  |  |  |         from ${sourceTableName} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </insert> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberTreeTable"> | 
					
						
							|  |  |  |         create table ${tableName} | 
					
						
							|  |  |  |         ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         pk_id NUMBER(20) primary key, | 
					
						
							|  |  |  |         <include refid="CuMemberTreeColumn"></include> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) | 
					
						
							|  |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberSettleTable"> | 
					
						
							|  |  |  |         create table ${tableName} | 
					
						
							|  |  |  |         ( | 
					
						
							|  |  |  |         <include refid="CuMemberSettleColumn"></include> | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberSecondTable"> | 
					
						
							|  |  |  |         create table ${tableName} | 
					
						
							|  |  |  |         ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         pk_member NUMBER(20) not null, | 
					
						
							|  |  |  |         pk_country number(4) default 1 not null, | 
					
						
							|  |  |  |         expire_status number(1) default 1, | 
					
						
							|  |  |  |         <include refid="CuMemberSettleDetailColumn"></include> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) | 
					
						
							|  |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberTreeParentIndex"> | 
					
						
							| 
									
										
										
										
											2025-04-12 09:09:15 +08:00
										 |  |  |         create index ${tableName}_parent | 
					
						
							|  |  |  |         on ${tableName} ( pk_parent ) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberTreePlaceIndex"> | 
					
						
							| 
									
										
										
										
											2025-04-12 09:09:15 +08:00
										 |  |  |         create index ${tableName}_place | 
					
						
							|  |  |  |         on ${tableName} ( pk_place_parent, place_dept ) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberTableUniqueIndex"> | 
					
						
							| 
									
										
										
										
											2025-04-12 09:09:15 +08:00
										 |  |  |         create unique index ${tableName}_PK_M | 
					
						
							|  |  |  |         on ${tableName} ( PK_MEMBER, period ) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberTreeDayOnlyIndex"> | 
					
						
							| 
									
										
										
										
											2025-04-12 09:09:15 +08:00
										 |  |  |         create unique index | 
					
						
							|  |  |  |         ${tableName}_PK_M on ${tableName} ( PK_MEMBER ) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberTreeByCancelOrder"> | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |         update ${settleTableName} set customer_type = 2, category = 1 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         where pk_member in | 
					
						
							|  |  |  |         <foreach collection="saOrderExtList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item.pkMember} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |     <!-- 更新会员网体奖衔数据,更新月表、结算表 --> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberSettleByPeriod"> | 
					
						
							|  |  |  |         merge into ${updateTableName} a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             using ( | 
					
						
							|  |  |  |                 select pk_member, max(new_level) pk_awards | 
					
						
							|  |  |  |                 from cu_member_awards | 
					
						
							|  |  |  |                 where period = #{period} | 
					
						
							|  |  |  |                   and del_flag = 0 | 
					
						
							|  |  |  |                 group by pk_member) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set | 
					
						
							|  |  |  |                     a.pk_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <insert id="insertCuMemberSettleByHis"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         insert into ${settleTableName}(pk_member, PK_PARENT, PK_PLACE_PARENT, PLACE_DEPT, MEMBER_CODE, member_name, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                                        CUSTOMER_TYPE, PHONE, PK_GRADE, PK_AWARDS, ACCOUNT_STATUS, PAY_STATUS, | 
					
						
							|  |  |  |                                        REGISTER_AUTHORITY, | 
					
						
							|  |  |  |                                        CATEGORY, PURCHASE_TYPE, PURCHASE_STATUS, SHARE_STATUS, INCOME_STATUS, | 
					
						
							|  |  |  |                                        PK_TEAM_CODE, PK_CENTER_CODE, | 
					
						
							|  |  |  |                                        PK_VERTEX, PK_SETTLE_COUNTRY, IS_REAL_NAME, IS_BUS_LICENSE, IS_MAKER_SPACE, | 
					
						
							|  |  |  |                                        PK_COUNTRY, PK_RATE, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                                        a_balance, b_balance, A_SUM_AMOUNT, B_SUM_AMOUNT, A_SUM_PV, B_SUM_PV, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                                        A_NEW_AMOUNT, B_NEW_AMOUNT, A_NEW_PV, B_NEW_PV, A_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |                                        B_SUM_REAL_AMOUNT, A_SUM_REAL_PV, B_SUM_REAL_PV, | 
					
						
							|  |  |  |                                        REP_A_BALANCE, REP_B_BALANCE, REP_A_NEW_AMOUNT, REP_B_NEW_AMOUNT, REP_A_NEW_PV, | 
					
						
							|  |  |  |                                        REP_B_NEW_PV, REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |                                        REP_B_SUM_AMOUNT, REP_A_SUM_PV, REP_B_SUM_PV, REGISTER_AMOUNT, REGISTER_PV, | 
					
						
							|  |  |  |                                        REGISTER_NEW_AMOUNT, REGISTER_NEW_PV, | 
					
						
							|  |  |  |                                        UPGRADE_AMOUNT, UPGRADE_PV, UPGRADE_NEW_AMOUNT, UPGRADE_NEW_PV, | 
					
						
							|  |  |  |                                        REPURCHASE_AMOUNT, REPURCHASE_PV, | 
					
						
							|  |  |  |                                        REPURCHASE_NEW_AMOUNT, REPURCHASE_NEW_PV, HI_FUN_AMOUNT, HI_FUN_PV, | 
					
						
							|  |  |  |                                        HI_FUN_NEW_AMOUNT, HI_FUN_NEW_PV, | 
					
						
							|  |  |  |                                        MALL_AMOUNT, MALL_PV, MALL_NEW_AMOUNT, MALL_NEW_PV, REGISTER_BLO_NEW_PV, | 
					
						
							|  |  |  |                                        UPGRADE_BLO_NEW_PV, REPURCHASE_BLO_NEW_PV, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                                        HI_FUN_BLO_NEW_PV, MALL_BLO_NEW_PV, MIN_ACHIEVE, ROUND, SECOND) | 
					
						
							|  |  |  |         select ca.pk_member, | 
					
						
							|  |  |  |                ca.PK_PARENT, | 
					
						
							|  |  |  |                ca.PK_PLACE_PARENT, | 
					
						
							|  |  |  |                ca.PLACE_DEPT, | 
					
						
							|  |  |  |                ca.MEMBER_CODE, | 
					
						
							|  |  |  |                ca.member_name, | 
					
						
							|  |  |  |                ca.CUSTOMER_TYPE, | 
					
						
							|  |  |  |                ca.PHONE, | 
					
						
							|  |  |  |                PK_GRADE, | 
					
						
							|  |  |  |                PK_AWARDS, | 
					
						
							|  |  |  |                ACCOUNT_STATUS, | 
					
						
							|  |  |  |                PAY_STATUS, | 
					
						
							|  |  |  |                REGISTER_AUTHORITY, | 
					
						
							|  |  |  |                CATEGORY, | 
					
						
							|  |  |  |                PURCHASE_TYPE, | 
					
						
							|  |  |  |                PURCHASE_STATUS, | 
					
						
							|  |  |  |                SHARE_STATUS, | 
					
						
							|  |  |  |                INCOME_STATUS, | 
					
						
							|  |  |  |                PK_TEAM_CODE, | 
					
						
							|  |  |  |                PK_CENTER_CODE, | 
					
						
							|  |  |  |                PK_VERTEX, | 
					
						
							|  |  |  |                ca.PK_SETTLE_COUNTRY, | 
					
						
							|  |  |  |                IS_REAL_NAME, | 
					
						
							|  |  |  |                IS_BUS_LICENSE, | 
					
						
							|  |  |  |                IS_MAKER_SPACE, | 
					
						
							|  |  |  |                ca.PK_COUNTRY, | 
					
						
							|  |  |  |                PK_RATE, | 
					
						
							|  |  |  |                a_balance, | 
					
						
							|  |  |  |                b_balance, | 
					
						
							|  |  |  |                A_SUM_AMOUNT, | 
					
						
							|  |  |  |                B_SUM_AMOUNT, | 
					
						
							|  |  |  |                A_SUM_PV, | 
					
						
							|  |  |  |                B_SUM_PV, | 
					
						
							|  |  |  |                A_NEW_AMOUNT, | 
					
						
							|  |  |  |                B_NEW_AMOUNT, | 
					
						
							|  |  |  |                A_NEW_PV, | 
					
						
							|  |  |  |                B_NEW_PV, | 
					
						
							|  |  |  |                A_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |                B_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |                A_SUM_REAL_PV, | 
					
						
							|  |  |  |                B_SUM_REAL_PV, | 
					
						
							|  |  |  |                REP_A_BALANCE, | 
					
						
							|  |  |  |                REP_B_BALANCE, | 
					
						
							|  |  |  |                REP_A_NEW_AMOUNT, | 
					
						
							|  |  |  |                REP_B_NEW_AMOUNT, | 
					
						
							|  |  |  |                REP_A_NEW_PV, | 
					
						
							|  |  |  |                REP_B_NEW_PV, | 
					
						
							|  |  |  |                REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |                REP_B_SUM_AMOUNT, | 
					
						
							|  |  |  |                REP_A_SUM_PV, | 
					
						
							|  |  |  |                REP_B_SUM_PV, | 
					
						
							|  |  |  |                REGISTER_AMOUNT, | 
					
						
							|  |  |  |                REGISTER_PV, | 
					
						
							|  |  |  |                REGISTER_NEW_AMOUNT, | 
					
						
							|  |  |  |                REGISTER_NEW_PV, | 
					
						
							|  |  |  |                UPGRADE_AMOUNT, | 
					
						
							|  |  |  |                UPGRADE_PV, | 
					
						
							|  |  |  |                UPGRADE_NEW_AMOUNT, | 
					
						
							|  |  |  |                UPGRADE_NEW_PV, | 
					
						
							|  |  |  |                REPURCHASE_AMOUNT, | 
					
						
							|  |  |  |                REPURCHASE_PV, | 
					
						
							|  |  |  |                REPURCHASE_NEW_AMOUNT, | 
					
						
							|  |  |  |                REPURCHASE_NEW_PV, | 
					
						
							|  |  |  |                HI_FUN_AMOUNT, | 
					
						
							|  |  |  |                HI_FUN_PV, | 
					
						
							|  |  |  |                HI_FUN_NEW_AMOUNT, | 
					
						
							|  |  |  |                HI_FUN_NEW_PV, | 
					
						
							|  |  |  |                MALL_AMOUNT, | 
					
						
							|  |  |  |                MALL_PV, | 
					
						
							|  |  |  |                MALL_NEW_AMOUNT, | 
					
						
							|  |  |  |                MALL_NEW_PV, | 
					
						
							|  |  |  |                REGISTER_BLO_NEW_PV, | 
					
						
							|  |  |  |                UPGRADE_BLO_NEW_PV, | 
					
						
							|  |  |  |                REPURCHASE_BLO_NEW_PV, | 
					
						
							|  |  |  |                HI_FUN_BLO_NEW_PV, | 
					
						
							|  |  |  |                MALL_BLO_NEW_PV, | 
					
						
							|  |  |  |                0 MIN_ACHIEVE, | 
					
						
							|  |  |  |                0 ROUND, | 
					
						
							|  |  |  |                1 SECOND | 
					
						
							|  |  |  |         from ${achieveTableName} ct | 
					
						
							|  |  |  |                  inner join ${treeTableName} ca | 
					
						
							|  |  |  |                             on ca.pk_member = ct.pk_member and ca.period = ct.period | 
					
						
							|  |  |  |         where ca.period = #{period} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </insert> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <insert id="insertCuMemberRangeByMember"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         insert into ${settleTableName}(pk_member, pk_parent, member_code, member_name, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                                        customer_type, phone, pk_grade, pk_awards, pk_range_awards, pk_benefit_awards, | 
					
						
							|  |  |  |                                        account_status, pay_status, register_authority, category, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                                        purchase_status, income_status, pk_team_code, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                                        pk_center_code, pk_vertex, pk_settle_country, is_real_name, pk_country, pk_rate, | 
					
						
							|  |  |  |                                        assess_status, month_member, range_store_status, pay_time) | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select cm.pk_id, | 
					
						
							|  |  |  |                pk_parent, | 
					
						
							|  |  |  |                member_code, | 
					
						
							|  |  |  |                member_name, | 
					
						
							|  |  |  |                customer_type, | 
					
						
							|  |  |  |                phone, | 
					
						
							|  |  |  |                pk_settle_grade, | 
					
						
							|  |  |  |                cm.pk_awards, | 
					
						
							|  |  |  |                pk_range_awards, | 
					
						
							|  |  |  |                pk_benefit_awards, | 
					
						
							|  |  |  |                account_status, | 
					
						
							|  |  |  |                pay_status, | 
					
						
							|  |  |  |                register_authority, | 
					
						
							|  |  |  |                category, | 
					
						
							|  |  |  |                purchase_status, | 
					
						
							|  |  |  |                income_status, | 
					
						
							|  |  |  |                pk_team_code, | 
					
						
							|  |  |  |                pk_center_code, | 
					
						
							|  |  |  |                pk_vertex, | 
					
						
							|  |  |  |                pk_settle_country, | 
					
						
							|  |  |  |                is_real_name, | 
					
						
							|  |  |  |                cm.pk_country, | 
					
						
							|  |  |  |                nvl(bc.pk_id, -1)                                                                 pk_rate, | 
					
						
							|  |  |  |                (case when nvl(ca.assess_status, 2) = 1 then 0 else nvl(ca.assess_status, 2) end) assess_status, | 
					
						
							|  |  |  |                (case when pay_time > #{firstDate,jdbcType=DATE} then 0 else 1 end)               month_member, | 
					
						
							|  |  |  |                nvl(cs.status, 0)                                                                 range_store_status, | 
					
						
							|  |  |  |                cm.pay_time | 
					
						
							|  |  |  |         from cu_member cm | 
					
						
							|  |  |  |                  left join ( | 
					
						
							|  |  |  |             select pk_country, max(pk_id) pk_id | 
					
						
							|  |  |  |             from bd_currency | 
					
						
							|  |  |  |             where del_flag = 0 | 
					
						
							|  |  |  |               and pk_country = 1 | 
					
						
							|  |  |  |               and enable_state = 0 | 
					
						
							|  |  |  |               and effective_date <= sysdate | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             group by pk_country) bc | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                            on cm.pk_settle_country = bc.pk_country | 
					
						
							|  |  |  |                  left join cu_range_store cs | 
					
						
							|  |  |  |                            on cs.pk_member = cm.pk_id and cs.del_flag = 0 | 
					
						
							|  |  |  |                  left join cu_member_assess${year} ca | 
					
						
							|  |  |  |                            on ca.pk_member = cm.pk_id and ca.period = #{period} and ca.assess_type = 0 | 
					
						
							|  |  |  |         where cm.del_flag = 0 | 
					
						
							|  |  |  |           and cm.system_type = 1 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </insert> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="updateCuMemberSettleMonthByPeriod"> | 
					
						
							|  |  |  |         merge into ${updateTableName} a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             using (select pk_member, pk_awards | 
					
						
							|  |  |  |                    from tmp_cu_member_awards) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set | 
					
						
							|  |  |  |                     a.pk_awards = b.pk_awards where period >= #{period} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="createCuMemberTableSequence" statementType="STATEMENT"> | 
					
						
							|  |  |  |         <include refid="CuMemberTableTrig"></include> | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberSettleExemptByAward"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             using ( | 
					
						
							|  |  |  |                 select pk_member, max(purchase_type) purchase_type | 
					
						
							|  |  |  |                 from ( | 
					
						
							|  |  |  |                          select pk_id pk_member, 2 purchase_type | 
					
						
							|  |  |  |                          from cu_member | 
					
						
							|  |  |  |                          where del_flag = 0 | 
					
						
							|  |  |  |                            and category = 0 | 
					
						
							|  |  |  |                            and pay_status = 1 | 
					
						
							|  |  |  |                            and pay_time >= #{startDate, jdbcType=DATE} | 
					
						
							|  |  |  |                            and pay_time < #{endDate, jdbcType=DATE} | 
					
						
							|  |  |  |                          union | 
					
						
							|  |  |  |                          select pk_member, 3 purchase_type | 
					
						
							|  |  |  |                          from cu_member_awards | 
					
						
							|  |  |  |                          where del_flag = 0 | 
					
						
							|  |  |  |                            and purchase_status = 0 | 
					
						
							|  |  |  |                            and creation_time >= #{startDate, jdbcType=DATE} | 
					
						
							|  |  |  |                            and creation_time < #{endDate, jdbcType=DATE}) | 
					
						
							|  |  |  |                 group by pk_member | 
					
						
							|  |  |  |             ) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set a.purchase_status = 0,a.purchase_type = b.purchase_type | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberSettle"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							|  |  |  |         using( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select * from ( | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <foreach collection="cuMemberTreeList" item="item" open=" " separator=" union " close=" "> | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |             select #{item.pkMember} pk_member, | 
					
						
							|  |  |  |             #{item.aBalance} a_balance, #{item.bBalance} b_balance, | 
					
						
							|  |  |  |             #{item.aNewAmount} a_new_amount, #{item.bNewAmount} b_new_amount, | 
					
						
							|  |  |  |             #{item.aNewPv} a_new_pv, #{item.bNewPv} b_new_pv, | 
					
						
							|  |  |  |             #{item.repABalance} rep_a_balance, #{item.repBBalance} rep_b_balance, | 
					
						
							|  |  |  |             #{item.repANewAmount} rep_a_new_amount, #{item.repBNewAmount} rep_b_new_amount, | 
					
						
							|  |  |  |             #{item.repANewPv} rep_a_new_pv, #{item.repBNewPv} rep_b_new_pv, | 
					
						
							|  |  |  |             #{item.registerAmount} register_amount, #{item.registerPv} register_pv, | 
					
						
							|  |  |  |             #{item.registerNewAmount} register_new_amount, #{item.registerNewPv} register_new_pv, | 
					
						
							|  |  |  |             #{item.upgradeAmount} upgrade_amount, #{item.upgradePv} upgrade_pv, | 
					
						
							|  |  |  |             #{item.upgradeNewAmount} upgrade_new_amount ,#{item.upgradeNewPv} upgrade_new_pv, | 
					
						
							|  |  |  |             #{item.repurchaseAmount} repurchase_amount, #{item.repurchasePv} repurchase_pv, | 
					
						
							|  |  |  |             #{item.repurchaseNewAmount} repurchase_new_amount, #{item.repurchaseNewPv} repurchase_new_pV, | 
					
						
							|  |  |  |             #{item.hiFunAmount} hi_fun_amount, #{item.hiFunPv} hi_fun_pv, | 
					
						
							|  |  |  |             #{item.hiFunNewAmount} hi_fun_new_amount, #{item.hiFunNewPv} hi_fun_new_pv, | 
					
						
							|  |  |  |             #{item.mallAmount} mall_amount, #{item.mallPv} mall_pv, | 
					
						
							|  |  |  |             #{item.mallNewAmount} mall_new_amount, #{item.mallNewPv} mall_new_pv, | 
					
						
							|  |  |  |             #{item.registerBloNewPv} register_blo_new_pv, #{item.upgradeBloNewPv} upgrade_blo_new_pv, | 
					
						
							|  |  |  |             #{item.repurchaseBloNewPv} repurchase_blo_new_pv, #{item.hiFunBloNewPv} hi_fun_blo_new_pv, | 
					
						
							|  |  |  |             #{item.mallBloNewPv} mall_blo_new_pv, | 
					
						
							|  |  |  |             #{item.rABalance} r_a_balance, #{item.rBBalance} r_b_balance, | 
					
						
							|  |  |  |             #{item.rRepABalance} r_rep_a_balance, #{item.rRepBBalance} r_rep_b_balance, | 
					
						
							|  |  |  |             #{item.minAchieve} min_achieve, | 
					
						
							|  |  |  |             #{item.round} round, #{item.second} second | 
					
						
							|  |  |  |             from dual | 
					
						
							| 
									
										
										
										
											2025-04-02 21:40:05 +08:00
										 |  |  |         </foreach>) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) b | 
					
						
							|  |  |  |         on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |         when matched then | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |         update set | 
					
						
							|  |  |  |         a.a_balance = b.a_balance, a.b_balance = b.b_balance, | 
					
						
							|  |  |  |         a.a_new_amount = b.a_new_amount, a.b_new_amount = b.b_new_amount, | 
					
						
							|  |  |  |         a.a_new_pv = b.a_new_pv, a.b_new_pv = b.b_new_pv, | 
					
						
							|  |  |  |         a.rep_a_balance = b.rep_a_balance, a.rep_b_balance = b.rep_b_balance, | 
					
						
							|  |  |  |         a.rep_a_new_amount = b.rep_a_new_amount, a.rep_b_new_amount = b.rep_b_new_amount, | 
					
						
							|  |  |  |         a.rep_a_new_pv = b.rep_a_new_pv, a.rep_b_new_pv = b.rep_b_new_pv, | 
					
						
							|  |  |  |         a.register_amount = b.register_amount, a.register_pv = b.register_pv, | 
					
						
							|  |  |  |         a.register_new_amount = b.register_new_amount, a.register_new_pv = b.register_new_pv, | 
					
						
							|  |  |  |         a.upgrade_amount = b.upgrade_amount, a.upgrade_pv = b.upgrade_pv, | 
					
						
							|  |  |  |         a.upgrade_new_amount = b.upgrade_new_amount, a.upgrade_new_pv = b.upgrade_new_pv, | 
					
						
							|  |  |  |         a.repurchase_amount = b.repurchase_amount, a.repurchase_pv = b.repurchase_pv, | 
					
						
							|  |  |  |         a.repurchase_new_amount = b.repurchase_new_amount, a.repurchase_new_pv = b.repurchase_new_pv, | 
					
						
							|  |  |  |         a.hi_fun_amount = b.hi_fun_amount, a.hi_fun_pv = b.hi_fun_pv, | 
					
						
							|  |  |  |         a.hi_fun_new_amount = b.hi_fun_new_amount, a.hi_fun_new_pv = b.hi_fun_new_pv, | 
					
						
							|  |  |  |         a.mall_amount = b.mall_amount, a.mall_pv = b.mall_pv, | 
					
						
							|  |  |  |         a.mall_new_amount = b.mall_new_amount,a.mall_new_pv = b.mall_new_pv, | 
					
						
							|  |  |  |         a.register_blo_new_pv = b.register_blo_new_pv, a.upgrade_blo_new_pv = b.upgrade_blo_new_pv, | 
					
						
							|  |  |  |         a.repurchase_blo_new_pv = b.repurchase_blo_new_pv, | 
					
						
							|  |  |  |         a.hi_fun_blo_new_pv = b.hi_fun_blo_new_pv, a.mall_blo_new_pv = b.mall_blo_new_pv, | 
					
						
							|  |  |  |         a.r_a_balance = b.r_a_balance, a.r_b_balance = b.r_b_balance, | 
					
						
							|  |  |  |         a.r_rep_a_balance = b.r_rep_a_balance, a.r_rep_b_balance = b.r_rep_b_balance, | 
					
						
							|  |  |  |         a.min_achieve = b.min_achieve, a.round = b.round, a.second = b.second, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         a.a_sum_amount = a.a_sum_amount + b.a_new_amount, | 
					
						
							|  |  |  |         a.b_sum_amount = a.b_sum_amount + b.b_new_amount, | 
					
						
							|  |  |  |         a.a_sum_pv = a.a_sum_pv + b.a_new_pv, | 
					
						
							|  |  |  |         a.b_sum_pv = a.b_sum_pv + b.b_new_pv, | 
					
						
							|  |  |  |         a.rep_a_sum_amount = a.rep_a_sum_amount + b.rep_a_new_amount, | 
					
						
							|  |  |  |         a.rep_b_sum_amount = a.rep_b_sum_amount + b.rep_b_new_amount, | 
					
						
							|  |  |  |         a.rep_a_sum_pv = a.rep_a_sum_pv + b.rep_a_new_pv, | 
					
						
							|  |  |  |         a.rep_b_sum_pv = a.rep_b_sum_pv + b.rep_b_new_pv, | 
					
						
							|  |  |  |         a.a_sum_real_amount = a.a_sum_real_amount + b.a_new_amount + b.rep_a_new_amount, | 
					
						
							|  |  |  |         a.b_sum_real_amount = a.b_sum_real_amount + b.b_new_amount + b.rep_b_new_amount, | 
					
						
							|  |  |  |         a.a_sum_real_pv = a.a_sum_real_pv + b.a_new_pv + b.rep_a_new_pv, | 
					
						
							|  |  |  |         a.b_sum_real_pv = a.b_sum_real_pv + b.b_new_pv + b.rep_b_new_pv | 
					
						
							|  |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="updateCuMemberSecond"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							|  |  |  |         using( | 
					
						
							|  |  |  |         <foreach collection="cuMemberTreeList" item="item" open=" " separator=" union all " close=" "> | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |             select #{item.pkMember} pk_member, | 
					
						
							|  |  |  |             #{item.aBalance} a_balance, #{item.bBalance} b_balance, | 
					
						
							|  |  |  |             #{item.aNewAmount} a_new_amount,#{item.bNewAmount} b_new_amount, | 
					
						
							|  |  |  |             #{item.aNewPv} a_new_pv, #{item.bNewPv} b_new_pv, | 
					
						
							|  |  |  |             #{item.repABalance} rep_a_balance, #{item.repBBalance} rep_b_balance, | 
					
						
							|  |  |  |             #{item.repANewAmount} rep_a_new_amount, #{item.repBNewAmount} rep_b_new_amount, | 
					
						
							|  |  |  |             #{item.repANewPv} rep_a_new_pv, #{item.repBNewPv} rep_b_new_pv, | 
					
						
							|  |  |  |             #{item.registerAmount} register_amount, #{item.registerPv} register_pv, #{item.registerNewPv} register_new_pv, | 
					
						
							|  |  |  |             #{item.upgradeAmount} upgrade_amount ,#{item.upgradePv} upgrade_pv, #{item.upgradeNewPv} upgrade_new_pv, | 
					
						
							|  |  |  |             #{item.repurchaseAmount} repurchase_amount, #{item.repurchasePv} repurchase_pv, #{item.repurchaseNewPv} repurchase_new_pv, | 
					
						
							|  |  |  |             #{item.hiFunAmount} hi_fun_amount, #{item.hiFunPv} hi_fun_pv, #{item.hiFunNewPv} hi_fun_new_pv, | 
					
						
							|  |  |  |             #{item.mallAmount} mall_amount, #{item.mallPv} mall_pv, #{item.mallNewPv} mall_new_pv, | 
					
						
							|  |  |  |             #{item.minAchieve} min_achieve, #{item.round} round, #{item.second} second , | 
					
						
							|  |  |  |             #{item.aNewBox} a_new_box, #{item.bNewBox} b_new_box, | 
					
						
							|  |  |  |             from dual | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </foreach> | 
					
						
							|  |  |  |         ) b | 
					
						
							|  |  |  |         on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |         when matched then | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |         update set | 
					
						
							|  |  |  |         a.a_balance = b.a_balance, a.b_balance = b.b_balance, | 
					
						
							|  |  |  |         a.a_new_amount = b.a_new_amount, a.b_new_amount = b.b_new_amount, | 
					
						
							|  |  |  |         a.a_new_pv = b.a_new_pv, a.b_new_pv = b.b_new_pv, | 
					
						
							|  |  |  |         a.rep_a_balance = b.rep_a_balance, a.rep_b_balance = b.rep_b_balance, | 
					
						
							|  |  |  |         a.rep_a_new_amount = b.rep_a_new_amount, a.rep_b_new_amount = b.rep_b_new_amount, | 
					
						
							|  |  |  |         a.rep_a_new_pv = b.rep_a_new_pv, a.rep_b_new_pv = b.rep_b_new_pv, | 
					
						
							|  |  |  |         a.register_amount = b.register_amount, a.register_pv = b.register_pv, a.register_new_pv = b.register_new_pv, | 
					
						
							|  |  |  |         a.upgrade_amount = b.upgrade_amount, a.upgrade_pv = b.upgrade_pv, a.upgrade_new_pv = b.upgrade_new_pv, | 
					
						
							|  |  |  |         a.repurchase_amount = b.repurchase_amount, a.repurchase_pv = b.repurchase_pv, a.repurchase_new_pv = b.repurchase_new_pv, | 
					
						
							|  |  |  |         a.hi_fun_amount = b.hi_fun_amount, a.hi_fun_pv = b.hi_fun_pv, a.hi_fun_new_pv = b.hi_fun_new_pv, | 
					
						
							|  |  |  |         a.mall_amount = b.mall_amount, a.mall_pv = b.mall_pv, a.mall_new_pv = b.mall_new_pv, | 
					
						
							|  |  |  |         a.min_achieve = b.min_achieve, a.round = b.round, a.second = b.second, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         a.a_sum_amount = a.a_sum_amount + b.a_new_amount, | 
					
						
							|  |  |  |         a.b_sum_amount = a.b_sum_amount + b.b_new_amount, | 
					
						
							|  |  |  |         a.a_sum_pv = a.a_sum_pv + b.a_new_pv, | 
					
						
							|  |  |  |         a.b_sum_pv = a.b_sum_pv + b.b_new_pv, | 
					
						
							|  |  |  |         a.rep_a_sum_amount = a.rep_a_sum_amount + b.rep_a_new_amount, | 
					
						
							|  |  |  |         a.rep_b_sum_amount = a.rep_b_sum_amount + b.rep_b_new_amount, | 
					
						
							|  |  |  |         a.rep_a_sum_pv = a.rep_a_sum_pv + b.rep_a_new_pv, | 
					
						
							|  |  |  |         a.rep_b_sum_pv = a.rep_b_sum_pv + b.rep_b_new_pv, | 
					
						
							|  |  |  |         a.a_sum_real_amount = a.a_sum_real_amount + b.a_new_amount + b.rep_a_new_amount, | 
					
						
							|  |  |  |         a.b_sum_real_amount = a.b_sum_real_amount + b.b_new_amount + b.rep_b_new_amount, | 
					
						
							|  |  |  |         a.a_sum_real_pv = a.a_sum_real_pv + b.a_new_pv + b.rep_a_new_pv, | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |         a.b_sum_real_pv = a.b_sum_real_pv + b.b_new_pv + b.rep_b_new_pv, | 
					
						
							|  |  |  |         a.a_new_box = b.a_new_box, a.b_new_box = b.b_new_box, | 
					
						
							|  |  |  |         a.a_sum_box = a.a_sum_box + b.a_new_box, a.b_sum_box = a.b_sum_box + b.b_new_box | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="updateCuMemberSecondPlaceParent"> | 
					
						
							|  |  |  |         merge into ${secondTableName} a | 
					
						
							|  |  |  |         using ( | 
					
						
							|  |  |  |         select B.pk_id,b.pk_settle_country pk_country,nvl(st.A_BALANCE,0) A_BALANCE,nvl(st.B_BALANCE,0) B_BALANCE, | 
					
						
							|  |  |  |         nvl(yt.A_SUM_AMOUNT,0) A_SUM_AMOUNT,nvl(yt.B_SUM_AMOUNT,0) B_SUM_AMOUNT, | 
					
						
							|  |  |  |         nvl(yt.A_SUM_PV,0) A_SUM_PV,nvl(yt.b_SUM_PV,0) b_SUM_PV,nvl(st.A_NEW_AMOUNT,0) A_NEW_AMOUNT, | 
					
						
							|  |  |  |         nvl(st.B_NEW_AMOUNT,0) B_NEW_AMOUNT,nvl(st.A_NEW_PV,0) A_NEW_PV, | 
					
						
							|  |  |  |         nvl(ST.B_NEW_PV,0) B_NEW_PV,nvl(yt.A_SUM_REAL_AMOUNT,0) A_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |         nvl(yt.B_SUM_REAL_AMOUNT,0) B_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |         nvl(yt.A_SUM_REAL_PV,0) A_SUM_REAL_PV, | 
					
						
							|  |  |  |         nvl(yt.B_SUM_REAL_PV,0) B_SUM_REAL_PV, | 
					
						
							|  |  |  |         nvl(ST.REP_A_BALANCE,0) REP_A_BALANCE,nvl(ST.REP_B_BALANCE,0) REP_B_BALANCE, | 
					
						
							|  |  |  |         nvl(ST.REP_A_NEW_AMOUNT,0) REP_A_NEW_AMOUNT, | 
					
						
							|  |  |  |         nvl(ST.REP_B_NEW_AMOUNT,0) REP_B_NEW_AMOUNT,nvl(ST.REP_A_NEW_PV,0) REP_A_NEW_PV, | 
					
						
							|  |  |  |         nvl(ST.REP_B_NEW_PV,0) REP_B_NEW_PV,nvl(yt.REP_A_SUM_AMOUNT,0) REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |         nvl(yt.REP_B_SUM_AMOUNT,0) REP_B_SUM_AMOUNT,nvl(yt.REP_A_SUM_PV,0) REP_A_SUM_PV, | 
					
						
							|  |  |  |         nvl(yt.REP_B_SUM_PV,0) REP_B_SUM_PV, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         nvl(ST.ROUND,0) ROUND,nvl(nvl(ST.SECOND,yt.second),1) SECOND,nvl(ST.MIN_ACHIEVE,0) MIN_ACHIEVE,b.expire_status | 
					
						
							|  |  |  |         from | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         (select t.pk_id,t.pk_settle_country,t.expire_status from cu_member t | 
					
						
							|  |  |  |         where t.del_flag = 0 start with t.pk_id = #{pkMember} | 
					
						
							|  |  |  |         connect by t.pk_id = prior | 
					
						
							|  |  |  |         <choose> | 
					
						
							|  |  |  |             <when test="isPlace == 0">t.pk_place_parent</when> | 
					
						
							|  |  |  |             <otherwise>t.pk_parent</otherwise> | 
					
						
							|  |  |  |         </choose> | 
					
						
							|  |  |  |         <if test="cuMemberTreeList != null and cuMemberTreeList.size >0"> | 
					
						
							|  |  |  |             union | 
					
						
							|  |  |  |             select pk_id,t.pk_settle_country,t.expire_status from cu_member t | 
					
						
							|  |  |  |             where t.del_flag= 0 and pk_id in | 
					
						
							|  |  |  |             <foreach collection="cuMemberTreeList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |                 #{item} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |         ) b | 
					
						
							|  |  |  |         left join ${secondTableName} st | 
					
						
							|  |  |  |         on b.pk_id = st.pk_member | 
					
						
							|  |  |  |         left join ${settleTableName} yt | 
					
						
							|  |  |  |         on b.pk_id=yt.pk_member | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) b | 
					
						
							|  |  |  |         on (a.pk_member = b.pk_id) | 
					
						
							|  |  |  |         when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         update set a.a_sum_amount=b.a_sum_amount,a.b_sum_amount=b.b_sum_amount, | 
					
						
							|  |  |  |         a.a_sum_pv=b.a_sum_pv,a.b_sum_pv=b.b_sum_pv, | 
					
						
							|  |  |  |         a.a_sum_real_amount=b.a_sum_real_amount, | 
					
						
							|  |  |  |         a.b_sum_real_amount=b.b_sum_real_amount, | 
					
						
							|  |  |  |         a.a_sum_real_pv=b.a_sum_real_pv, | 
					
						
							|  |  |  |         a.b_sum_real_pv=b.b_sum_real_pv, | 
					
						
							|  |  |  |         a.rep_a_sum_amount=b.rep_a_sum_amount,a.rep_b_sum_amount=b.rep_b_sum_amount, | 
					
						
							|  |  |  |         a.rep_a_sum_pv=b.rep_a_sum_pv,a.rep_b_sum_pv=b.rep_b_sum_pv | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         when not matched then | 
					
						
							|  |  |  |         insert (pk_member,pk_country,a_balance,b_balance,a_sum_amount,b_sum_amount,a_sum_pv,b_sum_pv, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         a_new_amount,b_new_amount,a_new_pv,b_new_pv,a_sum_real_amount,b_sum_real_amount, | 
					
						
							|  |  |  |         a_sum_real_pv,b_sum_real_pv,rep_a_balance,rep_b_balance,rep_a_new_amount, | 
					
						
							|  |  |  |         rep_b_new_amount,rep_a_new_pv,rep_b_new_pv,rep_a_sum_amount,rep_b_sum_amount, | 
					
						
							|  |  |  |         rep_a_sum_pv,rep_b_sum_pv,round,second,min_achieve,expire_status) | 
					
						
							|  |  |  |         values(b.pk_id,b.pk_country,b.a_balance,b.b_balance,b.a_sum_amount, b.b_sum_amount,b.a_sum_pv,b.b_sum_pv, | 
					
						
							|  |  |  |         b.a_new_amount,b.b_new_amount,b.a_new_pv,b.b_new_pv,b.a_sum_real_amount,b.b_sum_real_amount, | 
					
						
							|  |  |  |         b.a_sum_real_pv,b.b_sum_real_pv,b.rep_a_balance,b.rep_b_balance,b.rep_a_new_amount, | 
					
						
							|  |  |  |         b.rep_b_new_amount,b.rep_a_new_pv,b.rep_b_new_pv,b.rep_a_sum_amount,b.rep_b_sum_amount, | 
					
						
							|  |  |  |         b.rep_a_sum_pv,b.rep_b_sum_pv,b.round,b.second,b.min_achieve,b.expire_status) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="dropCuMemberSettleTable"> | 
					
						
							|  |  |  |         drop table ${tableName} | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberTreeGradeByCancelOrder"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |         using (select cl.pk_id,cl.pk_member, cl.new_level from cu_member_level cl | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         inner join ( | 
					
						
							| 
									
										
										
										
											2025-04-11 18:17:50 +08:00
										 |  |  |         select pk_member, max(pk_id) pk_id from cu_member_level | 
					
						
							|  |  |  |         where del_flag = 0 and upgrade_time < #{currentDate, jdbcType=DATE} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         and pk_member in | 
					
						
							|  |  |  |         <foreach collection="saOrderExtList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item.pkMember} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |         group by pk_member) ce | 
					
						
							|  |  |  |         on cl.pk_id = ce.pk_id | 
					
						
							|  |  |  |         ) b | 
					
						
							|  |  |  |         on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |         when matched then | 
					
						
							|  |  |  |         update set a.pk_grade = b.new_level | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="mergeCuMemberTreeBySettleDate"> | 
					
						
							|  |  |  |         merge into ${targetTableName} a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             using ( | 
					
						
							|  |  |  |                 select #{period} period, | 
					
						
							|  |  |  |                        pk_member, | 
					
						
							|  |  |  |                        pk_parent, | 
					
						
							|  |  |  |                        pk_place_parent, | 
					
						
							|  |  |  |                        place_dept, | 
					
						
							|  |  |  |                        member_code, | 
					
						
							|  |  |  |                        member_name, | 
					
						
							|  |  |  |                        customer_type, | 
					
						
							|  |  |  |                        phone, | 
					
						
							|  |  |  |                        pk_grade, | 
					
						
							|  |  |  |                        pk_awards, | 
					
						
							|  |  |  |                        account_status, | 
					
						
							|  |  |  |                        pay_status, | 
					
						
							|  |  |  |                        register_authority, | 
					
						
							|  |  |  |                        category, | 
					
						
							|  |  |  |                        purchase_type, | 
					
						
							|  |  |  |                        purchase_status, | 
					
						
							|  |  |  |                        share_status, | 
					
						
							|  |  |  |                        income_status, | 
					
						
							|  |  |  |                        pk_team_code, | 
					
						
							|  |  |  |                        pk_center_code, | 
					
						
							|  |  |  |                        pk_vertex, | 
					
						
							|  |  |  |                        pk_settle_country, | 
					
						
							|  |  |  |                        is_real_name, | 
					
						
							|  |  |  |                        is_bus_license, | 
					
						
							|  |  |  |                        is_maker_space, | 
					
						
							|  |  |  |                        pk_country | 
					
						
							|  |  |  |                 from ${sourceTableName} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             ) b | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             on (a.pk_member = b.pk_member and a.period = b.period) | 
					
						
							|  |  |  |             WHEN MATCHED THEN | 
					
						
							|  |  |  |                 update set a.pk_parent = b.pk_parent,a.pk_place_parent = b.pk_place_parent,a.place_dept = b.place_dept, | 
					
						
							|  |  |  |                     a.member_code = b.member_code,a.member_name = b.member_name,a.customer_type = b.customer_type,a.phone = b.phone, | 
					
						
							|  |  |  |                     a.pk_grade = b.pk_grade,a.pk_awards = b.pk_awards,a.account_status = b.account_status,a.pay_status = b.pay_status, | 
					
						
							|  |  |  |                     a.register_authority = b.register_authority,a.category = b.category,a.purchase_type = b.purchase_type, | 
					
						
							|  |  |  |                     a.purchase_status = b.purchase_status,a.share_status = b.share_status,a.income_status = b.income_status, | 
					
						
							|  |  |  |                     a.pk_team_code = b.pk_team_code,a.pk_center_code = b.pk_center_code,a.pk_vertex = b.pk_vertex, | 
					
						
							|  |  |  |                     a.pk_settle_country = b.pk_settle_country,a.is_real_name = b.is_real_name, | 
					
						
							|  |  |  |                     a.is_bus_license = b.is_bus_license,a.is_maker_space = b.is_maker_space,a.pk_country = b.pk_country | 
					
						
							|  |  |  |             WHEN NOT MATCHED THEN | 
					
						
							|  |  |  |                 insert (period, pk_member, pk_parent, pk_place_parent, place_dept, member_code, | 
					
						
							|  |  |  |                         member_name, customer_type, phone, pk_grade, pk_awards, account_status, pay_status, | 
					
						
							|  |  |  |                         register_authority, category, purchase_type, purchase_status, | 
					
						
							|  |  |  |                         share_status, income_status, pk_team_code, pk_center_code, pk_vertex, | 
					
						
							|  |  |  |                         pk_settle_country, is_real_name, is_bus_license, is_maker_space, pk_country) | 
					
						
							|  |  |  |                     values (b.period, b.pk_member, b.pk_parent, b.pk_place_parent, b.place_dept, b.member_code, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                             b.member_name, b.customer_type, b.phone, b.pk_grade, b.pk_awards, b.account_status, | 
					
						
							|  |  |  |                             b.pay_status, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                             b.register_authority, b.category, b.purchase_type, b.purchase_status, | 
					
						
							|  |  |  |                             b.share_status, b.income_status, b.pk_team_code, b.pk_center_code, b.pk_vertex, | 
					
						
							|  |  |  |                             b.pk_settle_country, b.is_real_name, b.is_bus_license, b.is_maker_space, b.pk_country) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateBackCuMemberSettleAward"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |             using (select pk_member, max(old_level) old_level | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                    from cu_member_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |                    where period = #{period} | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |                      and del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                    group by pk_member) b | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set | 
					
						
							|  |  |  |                     a.pk_awards = b.old_level | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateBackCuMemberSettleRangeAward"> | 
					
						
							|  |  |  |         merge into ${rangeTableName} a | 
					
						
							|  |  |  |             using ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 select pk_member, old_level, ba.pk_awards | 
					
						
							|  |  |  |                 from ( | 
					
						
							|  |  |  |                          select pk_member, max(old_level) old_level | 
					
						
							|  |  |  |                          from cu_member_awards | 
					
						
							|  |  |  |                          where period = #{period} | 
					
						
							|  |  |  |                            and up_type = 1 | 
					
						
							|  |  |  |                          group by pk_member) ca | 
					
						
							|  |  |  |                          inner join bd_range_awards ba | 
					
						
							|  |  |  |                                     on ca.old_level = ba.pk_id | 
					
						
							|  |  |  |                 where ba.del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             ) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                     a.pk_awards = b.pk_awards,a.pk_range_awards = b.old_level | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberExpandSettle"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							|  |  |  |         using( | 
					
						
							|  |  |  |         select * from ( | 
					
						
							|  |  |  |         <foreach collection="cuMemberTreeList" item="item" open=" " separator=" union " close=" "> | 
					
						
							|  |  |  |             select #{item.pkMember} pk_member,#{item.aBalance} a_balance, #{item.bBalance} b_balance, | 
					
						
							|  |  |  |             #{item.minAchieve} min_achieve,#{item.round} round,#{item.second} second from dual | 
					
						
							| 
									
										
										
										
											2025-04-02 21:40:05 +08:00
										 |  |  |         </foreach>) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) b | 
					
						
							|  |  |  |         on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |         when matched then | 
					
						
							|  |  |  |         update set a.a_balance = b.a_balance, a.b_balance=b.b_balance, | 
					
						
							|  |  |  |         a.min_achieve=b.min_achieve,a.round = b.round,a.second=b.second | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberAwardsBySettle"> | 
					
						
							|  |  |  |         merge into cu_member a | 
					
						
							|  |  |  |             using ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 select ca.pk_member, max(ca.pk_awards) pk_awards | 
					
						
							|  |  |  |                 from cu_member_settle_awards ca | 
					
						
							|  |  |  |                          inner join cu_member cm | 
					
						
							|  |  |  |                                     on cm.pk_id = ca.pk_member | 
					
						
							|  |  |  |                 where cm.system_type = 0 | 
					
						
							|  |  |  |                   and period between #{startPeriod} and #{period} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |                 group by ca.pk_member | 
					
						
							|  |  |  |             ) b | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             on (a.pk_id = b.pk_member) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 update set a.pk_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="updateCuMemberSettleAwardsBySettle"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							|  |  |  |             using ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 select pk_member, max(pk_awards) pk_awards | 
					
						
							|  |  |  |                 from cu_member_settle_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |                 where period between #{startPeriod} and #{period} | 
					
						
							|  |  |  |                 group by pk_member | 
					
						
							|  |  |  |             ) b | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 update set a.pk_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="updateCuMemberMaxAwardsBySettle"> | 
					
						
							|  |  |  |         merge into cu_member a | 
					
						
							|  |  |  |             using ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 select pk_member, max(pk_awards) pk_awards | 
					
						
							|  |  |  |                 from cu_member_settle_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |                 group by pk_member | 
					
						
							|  |  |  |             ) b | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             on (a.pk_id = b.pk_member) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 update set a.pk_max_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberAwardsInit"> | 
					
						
							|  |  |  |         merge into cu_member a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             using ( | 
					
						
							|  |  |  |                 select ct.pk_id, ba.pk_id pk_awards | 
					
						
							|  |  |  |                 from cu_member ct | 
					
						
							|  |  |  |                          inner join bd_awards ba | 
					
						
							|  |  |  |                                     on ct.pk_settle_country = ba.pk_country | 
					
						
							|  |  |  |                 where ba.awards_value = 0 | 
					
						
							|  |  |  |                   and ba.del_flag = 0 | 
					
						
							|  |  |  |                   and ct.system_type = 0) b | 
					
						
							|  |  |  |             on (a.pk_id = b.pk_id) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set a.pk_awards = b.pk_awards,a.pk_max_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <update id="updateCuMemberSettleAwardsInit"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         merge into ${settleTableName} a | 
					
						
							|  |  |  |             using ( | 
					
						
							|  |  |  |                 select ct.pk_member, ba.pk_id pk_awards | 
					
						
							|  |  |  |                 from ${settleTableName} ct | 
					
						
							|  |  |  |                          inner join bd_awards ba | 
					
						
							|  |  |  |                                     on ct.pk_settle_country = ba.pk_country | 
					
						
							|  |  |  |                 where ba.awards_value = 0 | 
					
						
							|  |  |  |                   and ba.del_flag = 0) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set a.pk_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="createCuMemberRangeTable"> | 
					
						
							|  |  |  |         create table ${tableName} | 
					
						
							|  |  |  |         ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             pk_member                NUMBER(20) not null, | 
					
						
							|  |  |  |             pk_parent                NUMBER(20) not null, | 
					
						
							|  |  |  |             member_code              VARCHAR2(30) not null, | 
					
						
							|  |  |  |             member_name              VARCHAR2(100) not null, | 
					
						
							|  |  |  |             customer_type            NUMBER(2) not null, | 
					
						
							|  |  |  |             phone                    VARCHAR2(40) not null, | 
					
						
							|  |  |  |             pk_grade                 NUMBER(4) not null, | 
					
						
							|  |  |  |             pk_awards                NUMBER(4) not null, | 
					
						
							|  |  |  |             pk_range_awards          number(4) default 1 not null, | 
					
						
							|  |  |  |             pk_benefit_awards        number(6) default 1 not null, | 
					
						
							|  |  |  |             account_status           number(1) default 0 not null, | 
					
						
							|  |  |  |             pay_status               NUMBER(2) default 0 not null, | 
					
						
							|  |  |  |             pay_time                 DATE, | 
					
						
							|  |  |  |             register_authority       number(2) default 0 not null, | 
					
						
							|  |  |  |             category                 number(2) default 0 not null, | 
					
						
							|  |  |  |             purchase_status          number(2) default 0 not null, | 
					
						
							|  |  |  |             income_status            number(2) default 0 not null, | 
					
						
							|  |  |  |             pk_team_code             number(20), | 
					
						
							|  |  |  |             pk_center_code           number(20), | 
					
						
							|  |  |  |             pk_vertex                number(20), | 
					
						
							|  |  |  |             pk_settle_country        number(4) not null, | 
					
						
							|  |  |  |             is_real_name             NUMBER(1) default 1 not null, | 
					
						
							|  |  |  |             pk_country               number(4) default 1 not null, | 
					
						
							|  |  |  |             pk_rate                  NUMBER(6), | 
					
						
							|  |  |  |             consume_status           number(2) default 1 not null, | 
					
						
							|  |  |  |             consume_pv               number(17,6) default 0 not null, | 
					
						
							|  |  |  |             month_pv                 number(17,6) default 0 not null, | 
					
						
							|  |  |  |             new_pv                   number(17,6) default 0 not null, | 
					
						
							|  |  |  |             new_team_pv              number(17,6) default 0 not null, | 
					
						
							|  |  |  |             dept_new_team_pv         number(17,6) default 0 not null, | 
					
						
							|  |  |  |             effective_num            number(8) default 0 not null, | 
					
						
							|  |  |  |             ev_effective_num         number(8) default 0 not null, | 
					
						
							|  |  |  |             provide_state            number(1) default 1 not null, | 
					
						
							|  |  |  |             buy_effective_num        number(8) default 0 not null, | 
					
						
							|  |  |  |             first_agent              number(4) default 0 not null, | 
					
						
							|  |  |  |             second_agent             number(4) default 0 not null, | 
					
						
							|  |  |  |             recommend_num            number(8) default 0 not null, | 
					
						
							|  |  |  |             team_num                 number(8) default 0 not null, | 
					
						
							|  |  |  |             team_consume_amount      number(17,6) default 0 not null, | 
					
						
							|  |  |  |             team_consume_pv          number(17,6) default 0 not null, | 
					
						
							|  |  |  |             team_month_amount        number(17,6) default 0 not null, | 
					
						
							|  |  |  |             team_month_pv            number(17,6) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             dept_team_consume_amount number(17,6) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             dept_team_consume_pv     number(17,6) default 0 not null, | 
					
						
							|  |  |  |             dept_team_month_amount   number(17,6) default 0 not null, | 
					
						
							|  |  |  |             dept_team_month_pv       number(17,6) default 0 not null, | 
					
						
							|  |  |  |             small_area_pv            number(17,6) default 0 not null, | 
					
						
							|  |  |  |             assess_status            number(2) default 3 not null, | 
					
						
							|  |  |  |             month_member             number(1) default 1 not null, | 
					
						
							|  |  |  |             range_store_status       number(1) default 0 not null | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="createCuMemberRangeSecondTable"> | 
					
						
							|  |  |  |         create table ${tableName} | 
					
						
							|  |  |  |         ( | 
					
						
							|  |  |  |             pk_member         NUMBER(20) not null, | 
					
						
							|  |  |  |             pk_parent         NUMBER(20) not null, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             pk_range_awards   number(4) default 1 not null, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             buy_effective_num number(8) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             first_agent       number(4) default 0 not null, | 
					
						
							|  |  |  |             second_agent      number(4) default 0 not null, | 
					
						
							|  |  |  |             new_pv            number(17,6) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             new_effective_num number(8) default 0 not null, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             new_team_pv       number(17,6) default 0 not null, | 
					
						
							|  |  |  |             dept_new_team_pv  number(17,6) default 0 not null, | 
					
						
							|  |  |  |             assess_status     number(2) default 3 not null, | 
					
						
							|  |  |  |             consume_status    number(2) default 1 not null, | 
					
						
							|  |  |  |             month_member      number(1) default 1 not null | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) | 
					
						
							|  |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberRangeAwardsInit"> | 
					
						
							|  |  |  |         merge into ${rangeTableName} a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             using ( | 
					
						
							|  |  |  |                 select ct.pk_member, ba.pk_id pk_awards | 
					
						
							|  |  |  |                 from ${rangeTableName} ct | 
					
						
							|  |  |  |                          inner join bd_awards ba | 
					
						
							|  |  |  |                                     on ct.pk_settle_country = ba.pk_country | 
					
						
							|  |  |  |                 where ba.awards_value = 0 | 
					
						
							|  |  |  |                   and ba.del_flag = 0) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 update set a.pk_benefit_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateCuMemberRangeAwardsBySettle"> | 
					
						
							|  |  |  |         merge into ${rangeTableName} a | 
					
						
							|  |  |  |             using ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 select pk_member, max(pk_awards) pk_awards | 
					
						
							|  |  |  |                 from cu_member_settle_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |                 where period between #{startPeriod} and #{period} | 
					
						
							|  |  |  |                 group by pk_member | 
					
						
							|  |  |  |             ) b | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 update set a.pk_benefit_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateMemberRangeAwardsInit"> | 
					
						
							|  |  |  |         merge into cu_member a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             using ( | 
					
						
							|  |  |  |                 select ct.pk_id, ba.pk_id pk_awards | 
					
						
							|  |  |  |                 from cu_member ct | 
					
						
							|  |  |  |                          inner join bd_awards ba | 
					
						
							|  |  |  |                                     on ct.pk_settle_country = ba.pk_country | 
					
						
							|  |  |  |                 where ba.awards_value = 0 | 
					
						
							|  |  |  |                   and ba.del_flag = 0 | 
					
						
							|  |  |  |                   and ct.system_type = 1) b | 
					
						
							|  |  |  |             on (a.pk_id = b.pk_id) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 update set a.pk_benefit_awards = b.pk_awards,a.pk_max_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <update id="updateMemberRangeAwardsBySettle"> | 
					
						
							|  |  |  |         merge into cu_member a | 
					
						
							|  |  |  |             using ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 select ca.pk_member, max(ca.pk_awards) pk_awards | 
					
						
							|  |  |  |                 from cu_member_settle_awards ca | 
					
						
							|  |  |  |                          inner join cu_member cm | 
					
						
							|  |  |  |                                     on cm.pk_id = ca.pk_member | 
					
						
							|  |  |  |                 where cm.system_type = 1 | 
					
						
							|  |  |  |                   and period between #{startPeriod} and #{period} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |                 group by ca.pk_member | 
					
						
							|  |  |  |             ) b | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             on (a.pk_id = b.pk_member) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             when matched then | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 update set a.pk_benefit_awards = b.pk_awards | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </update> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <delete id="deleteCuMemberTreeByPeriod"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         delete | 
					
						
							|  |  |  |         from ${targetTableName} | 
					
						
							|  |  |  |         where period = #{period} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </delete> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <delete id="truncateCuMemberTreeTable"> | 
					
						
							|  |  |  |         truncate table ${tableName} | 
					
						
							|  |  |  |     </delete> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="queryExistOracleTable" resultType="java.lang.Integer"> | 
					
						
							|  |  |  |         select 1 | 
					
						
							|  |  |  |         from user_tables | 
					
						
							|  |  |  |         where table_name = upper(#{tableName}) | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryExistOrderTableCount" resultType="java.lang.Integer"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select count(1) | 
					
						
							|  |  |  |         from ${tableName} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberTreeExt" resultType="com.hzs.common.domain.member.ext.CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select ct.* | 
					
						
							|  |  |  |         from ${settleTableName} ct | 
					
						
							|  |  |  |                  inner join( | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             select t.pk_member | 
					
						
							|  |  |  |             from ${settleTableName} t | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                 start | 
					
						
							|  |  |  |             with t.pk_member = #{pkMember} | 
					
						
							|  |  |  |             connect by t.pk_member = prior t.pk_place_parent) tmp | 
					
						
							|  |  |  |                            on ct.pk_member = tmp.pk_member | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-04-12 10:23:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="queryCuMemberSettleEnoughAwardAchieve" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select a.pk_member, | 
					
						
							|  |  |  |                a.pk_parent, | 
					
						
							|  |  |  |                a.pk_place_parent, | 
					
						
							|  |  |  |                a.a_sum_real_pv, | 
					
						
							|  |  |  |                a.b_sum_real_pv, | 
					
						
							|  |  |  |                a.pk_country, | 
					
						
							|  |  |  |                a.pk_settle_country, | 
					
						
							|  |  |  |                bw.pk_id  pk_awards, | 
					
						
							|  |  |  |                bdw.pk_id pk_ori_awards | 
					
						
							|  |  |  |         from (select ct.pk_member, | 
					
						
							|  |  |  |                      ct.pk_parent, | 
					
						
							|  |  |  |                      ct.pk_place_parent, | 
					
						
							|  |  |  |                      (ba.awards_value + 5) awards_value, | 
					
						
							|  |  |  |                      ba.awards_value       ori_awards_value, | 
					
						
							|  |  |  |                      ct.a_sum_real_pv, | 
					
						
							|  |  |  |                      ct.b_sum_real_pv, | 
					
						
							|  |  |  |                      ct.pk_country, | 
					
						
							|  |  |  |                      ct.pk_settle_country | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |               from ${settleTableName} ct | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                        inner join bd_awards ba | 
					
						
							|  |  |  |                                   on ct.pk_awards = ba.pk_id | 
					
						
							|  |  |  |               where ct.category = 0 | 
					
						
							|  |  |  |                 and ct.income_status = 0 | 
					
						
							|  |  |  |                 and ba.del_flag = 0) a | 
					
						
							|  |  |  |                  inner join bd_awards bw | 
					
						
							|  |  |  |                             on a.awards_value = bw.awards_value and a.pk_settle_country = bw.pk_country | 
					
						
							|  |  |  |                  inner join bd_awards bdw | 
					
						
							|  |  |  |                             on a.ori_awards_value = bdw.awards_value and a.pk_settle_country = bdw.pk_country | 
					
						
							|  |  |  |         where bw.del_flag = 0 | 
					
						
							|  |  |  |           and bw.community_check <= a.a_sum_real_pv | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |           and bw.community_check <= a.b_sum_real_pv | 
					
						
							|  |  |  |         order by pk_member desc | 
					
						
							|  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="queryCuMemberSettlePlaceUnderUmbrella" resultType="java.lang.Integer"> | 
					
						
							|  |  |  |         select count(a.pk_member) | 
					
						
							|  |  |  |         from (select a.*, b.pk_awards | 
					
						
							|  |  |  |               from (select pk_member, pk_parent, pk_place_parent, place_dept | 
					
						
							|  |  |  |                     from ${settleTableName} start with pk_place_parent = #{pkMember} and place_dept=#{placeDept} | 
					
						
							|  |  |  |                     connect by pk_place_parent = prior pk_member) a | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                        inner join (select cw.pk_member, cw.new_level pk_awards | 
					
						
							|  |  |  |                                    from cu_member_awards cw | 
					
						
							|  |  |  |                                             inner join(select pk_member, max(pk_id) pk_id | 
					
						
							|  |  |  |                                                        from cu_member_awards | 
					
						
							|  |  |  |                                                        where del_flag = 0 | 
					
						
							|  |  |  |                                                          and UP_TYPE in (1, 3) | 
					
						
							|  |  |  |                                                        group by pk_member) ca | 
					
						
							|  |  |  |                                                       on cw.pk_id = ca.pk_id) b | 
					
						
							|  |  |  |                                   on a.pk_member = b.pk_member) a | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |                  inner join bd_awards ba | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                             on a.pk_awards = ba.pk_id | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         where ba.awards_value >= (select awards_value from bd_awards where pk_id = #{awardsValue}) | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberSettleBloodUnderUmbrella" resultType="java.lang.Integer"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select count(pk_member) | 
					
						
							|  |  |  |         from ( | 
					
						
							|  |  |  |                  select pk_member | 
					
						
							|  |  |  |                  from ${settleTableName} start with pk_parent = #{pkMember} | 
					
						
							|  |  |  |                  connect by pk_parent = prior pk_member) a | 
					
						
							|  |  |  |         where a.pk_member in ( | 
					
						
							|  |  |  |             select x.pk_member | 
					
						
							|  |  |  |             from ( | 
					
						
							|  |  |  |                      select a.*, b.pk_awards | 
					
						
							|  |  |  |                      from ( | 
					
						
							|  |  |  |                               select pk_member, pk_parent, pk_place_parent, place_dept | 
					
						
							|  |  |  |                               from ${settleTableName} start with pk_place_parent = #{pkMember} and place_dept=#{placeDept} | 
					
						
							|  |  |  |                               connect by pk_place_parent = prior pk_member) a | 
					
						
							|  |  |  |                               inner join (select cw.pk_member, cw.new_level pk_awards | 
					
						
							|  |  |  |                                           from cu_member_awards cw | 
					
						
							|  |  |  |                                                    inner join(select pk_member, max(pk_id) pk_id | 
					
						
							|  |  |  |                                                               from cu_member_awards | 
					
						
							|  |  |  |                                                               where del_flag = 0 | 
					
						
							|  |  |  |                                                                 and UP_TYPE in (1, 3) | 
					
						
							|  |  |  |                                                               group by pk_member) ca | 
					
						
							|  |  |  |                                                              on cw.pk_id = ca.pk_id) b | 
					
						
							|  |  |  |                                          on a.pk_member = b.pk_member | 
					
						
							|  |  |  |                  ) x | 
					
						
							|  |  |  |                      inner join bd_awards ba | 
					
						
							|  |  |  |                                 on x.pk_awards = ba.pk_id | 
					
						
							|  |  |  |             where ba.awards_value >= (select awards_value from bd_awards where pk_id = #{awardsValue})) | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="queryExemptCuMemberSettle" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select pk_member, 0 assess_type | 
					
						
							|  |  |  |         from ${tableName} | 
					
						
							|  |  |  |         where purchase_status = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         union | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select pk_member, 1 assess_type | 
					
						
							|  |  |  |         from ${tableName} | 
					
						
							|  |  |  |         where share_status = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryMemberSettleBySaOrder" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-11 10:07:30 +08:00
										 |  |  |         pk_member,member_code,member_name, | 
					
						
							|  |  |  |         c.pk_awards,c.pk_grade, | 
					
						
							|  |  |  |         account_status,category,income_status, | 
					
						
							|  |  |  |         pk_settle_country, is_maker_space, | 
					
						
							|  |  |  |         purchase_status, share_status, | 
					
						
							|  |  |  |         bg.grade_value,pk_parent, | 
					
						
							|  |  |  |         a_balance,b_balance, | 
					
						
							|  |  |  |         r_a_balance,r_b_balance, | 
					
						
							|  |  |  |         rep_a_balance,rep_b_balance, | 
					
						
							|  |  |  |         r_rep_a_balance,r_rep_b_balance, | 
					
						
							|  |  |  |         register_amount,register_pv, | 
					
						
							|  |  |  |         upgrade_amount,upgrade_pv, | 
					
						
							|  |  |  |         repurchase_amount,repurchase_pv, | 
					
						
							|  |  |  |         pk_center_code,c.pk_vertex, | 
					
						
							|  |  |  |         hi_fun_amount,hi_fun_pv, | 
					
						
							|  |  |  |         mall_amount,mall_pv, | 
					
						
							|  |  |  |         min_achieve, | 
					
						
							|  |  |  |         round,second,store_level, | 
					
						
							|  |  |  |         c.register_authority, c.is_maker_gift,c.expire_status | 
					
						
							|  |  |  |         from ${settleTableName} c | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         left join bd_grade bg | 
					
						
							|  |  |  |         on c.pk_grade = bg.pk_id | 
					
						
							|  |  |  |         where pk_member in | 
					
						
							|  |  |  |         <foreach collection="memberPkList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-26 16:55:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="batchQueryCuMemberSettlePlaceParent" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-17 09:27:05 +08:00
										 |  |  |         a.pk_order, a.pk_member, a.member_code, a.member_name, | 
					
						
							|  |  |  |         a.pk_place_parent, a.place_dept, a.pk_grade, a.pk_awards, | 
					
						
							|  |  |  |         a.bg.grade_value, a.account_status, a.income_status, a.pk_settle_country, | 
					
						
							|  |  |  |         a.purchase_status, a.share_status, a.register_authority, | 
					
						
							|  |  |  |         a.a_balance, a.b_balance, a.r_a_balance, a.r_b_balance, | 
					
						
							|  |  |  |         a.rep_a_balance, a.rep_b_balance, a.r_rep_a_balance, a.r_rep_b_balance, | 
					
						
							|  |  |  |         a.register_amount, a.register_pv, a.upgrade_amount, a.upgrade_pv, | 
					
						
							|  |  |  |         a.repurchase_amount, a.repurchase_pv, | 
					
						
							|  |  |  |         a.hi_fun_amount, a.hi_fun_pv, | 
					
						
							|  |  |  |         a.mall_amount, a.mall_pv, | 
					
						
							|  |  |  |         a.pk_center_code, a.pk_vertex, a.category, | 
					
						
							|  |  |  |         a.min_achieve, a.round, a.second, | 
					
						
							|  |  |  |         a.store_level, a.expire_status, | 
					
						
							|  |  |  |         nvl(cmb.after_grant_income, 0) un_grant_income | 
					
						
							|  |  |  |         from ( | 
					
						
							| 
									
										
										
										
											2025-03-26 16:55:07 +08:00
										 |  |  |         <foreach collection="firPurchaseOrderList" item="item" open=" " close=" " separator=" union all "> | 
					
						
							| 
									
										
										
										
											2025-04-17 09:27:05 +08:00
										 |  |  |             select #{item.pkId} pk_order, pk_member, member_code, member_name, pk_place_parent, place_dept, | 
					
						
							|  |  |  |             pk_grade, pk_awards, account_status, income_status, pk_settle_country, purchase_status, share_status, register_authority, | 
					
						
							|  |  |  |             a_balance, b_balance, r_a_balance, r_b_balance, rep_a_balance, rep_b_balance, r_rep_a_balance, r_rep_b_balance, | 
					
						
							|  |  |  |             register_amount, register_pv, upgrade_amount, upgrade_pv, repurchase_amount, repurchase_pv, hi_fun_amount, hi_fun_pv, | 
					
						
							|  |  |  |             mall_amount, mall_pv, category, pk_vertex, pk_center_code, | 
					
						
							|  |  |  |             min_achieve, round, second, store_level, expire_status, level sort | 
					
						
							| 
									
										
										
										
											2025-03-26 16:55:07 +08:00
										 |  |  |             from ${settleTableName} | 
					
						
							|  |  |  |             start with pk_member = #{item.pkMember} | 
					
						
							|  |  |  |             connect by pk_member = prior pk_place_parent | 
					
						
							|  |  |  |         </foreach> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) a | 
					
						
							|  |  |  |         left join bd_grade bg | 
					
						
							|  |  |  |         on a.pk_grade = bg.pk_id | 
					
						
							| 
									
										
										
										
											2025-04-17 09:27:05 +08:00
										 |  |  |         left join ( | 
					
						
							|  |  |  |         select cmbd.pk_member, cmbd.after_grant_income | 
					
						
							|  |  |  |         from CU_MEMBER_BONUS_DELAY cmbd | 
					
						
							| 
									
										
										
										
											2025-04-19 15:18:05 +08:00
										 |  |  |         where exists (select 1 | 
					
						
							|  |  |  |         from (select cmbd.pk_member, max(cmbd.period) period | 
					
						
							|  |  |  |         from cu_member_bonus_delay cmbd | 
					
						
							| 
									
										
										
										
											2025-04-17 09:27:05 +08:00
										 |  |  |         where cmbd.del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-04-21 13:48:23 +08:00
										 |  |  |         and #{period} > cmbd.period | 
					
						
							| 
									
										
										
										
											2025-04-19 15:18:05 +08:00
										 |  |  |         group by cmbd.pk_member) t | 
					
						
							|  |  |  |         where t.pk_member = cmbd.pk_member | 
					
						
							|  |  |  |         and t.period = cmbd.period) | 
					
						
							| 
									
										
										
										
											2025-04-17 09:27:05 +08:00
										 |  |  |         ) cmb | 
					
						
							|  |  |  |         on cmb.pk_member = a.pk_member | 
					
						
							| 
									
										
										
										
											2025-04-19 15:18:05 +08:00
										 |  |  |         order by a.pk_order, a.sort | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-26 16:55:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="batchQueryCuMemberSettleParent" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         <include refid="memberParent"></include> | 
					
						
							|  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-26 16:55:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="batchQuerySpecialCuMemberSettleParent" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |         select a.*, (case when nvl(so.order_achieve,0)>0 then 0 else 1 end ) is_pay_reg from ( | 
					
						
							|  |  |  |         <include refid="memberParent"></include> | 
					
						
							|  |  |  |         ) a | 
					
						
							|  |  |  |         left join (select pk_member, max(order_achieve) order_achieve from sa_order | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         where del_flag = 0 and order_status = 1 | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |         and order_type = 24 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         group by pk_member) so | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |         on so.pk_member = a.pk_member | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-26 16:55:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="batchQueryCuMemberSettleParentForSpecial" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select | 
					
						
							|  |  |  |         a.pk_member,a.pk_parent,a.member_code,a.member_name,a.pk_awards,a.account_status,a.register_authority,a.customer_type, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         a.income_status,a.pk_settle_country,a.purchase_status,a.share_status,a.is_maker_space, | 
					
						
							|  |  |  |         a.a_balance,a.b_balance,a.r_a_balance,a.r_b_balance,a.rep_a_balance,a.rep_b_balance,a.r_rep_a_balance,a.r_rep_b_balance, | 
					
						
							|  |  |  |         a.register_amount,a.register_pv,a.upgrade_amount,a.upgrade_pv,a.repurchase_amount,a.pk_center_code, | 
					
						
							|  |  |  |         a.repurchase_pv,a.hi_fun_amount,a.hi_fun_pv,a.mall_amount,a.mall_pv,a.category,a.pk_grade,bg.grade_value, | 
					
						
							|  |  |  |         a.min_achieve,a.round,second,ap.pk_id ap_pk_id,nvl(ap.usable_quantity,0) usable_quantity, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         nvl(bp.retail_price,0) retail_price,ap.pk_data_id from ( | 
					
						
							|  |  |  |         <include refid="QueryMemberParent"></include> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         ) a | 
					
						
							|  |  |  |         inner join bd_grade bg | 
					
						
							|  |  |  |         on a.pk_grade = bg.pk_id | 
					
						
							|  |  |  |         left join ac_pick ap | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         on ap.pk_member = a.pk_member and ap.pick_type = 8 and ap.del_flag=0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         left join bd_product bp | 
					
						
							|  |  |  |         on ap.pk_data_id = bp.pk_id | 
					
						
							|  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="queryCuMemberSecondPlaceParent" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select b.pk_id pk_member, | 
					
						
							|  |  |  |                b.pk_parent, | 
					
						
							|  |  |  |                b.pk_place_parent, | 
					
						
							|  |  |  |                b.place_dept, | 
					
						
							|  |  |  |                b.pk_center_code, | 
					
						
							|  |  |  |                b.member_code, | 
					
						
							|  |  |  |                b.member_name, | 
					
						
							|  |  |  |                b.pk_grade, | 
					
						
							|  |  |  |                b.pk_awards, | 
					
						
							|  |  |  |                b.account_status, | 
					
						
							|  |  |  |                b.register_authority, | 
					
						
							|  |  |  |                b.customer_type, | 
					
						
							|  |  |  |                b.income_status, | 
					
						
							|  |  |  |                b.pk_settle_country, | 
					
						
							|  |  |  |                b.is_maker_space, | 
					
						
							|  |  |  |                b.purchase_status, | 
					
						
							|  |  |  |                b.share_status, | 
					
						
							|  |  |  |                bg.grade_value, | 
					
						
							|  |  |  |                b.category, | 
					
						
							|  |  |  |                st.a_balance, | 
					
						
							|  |  |  |                st.b_balance, | 
					
						
							|  |  |  |                0       r_a_balance, | 
					
						
							|  |  |  |                0       r_b_balance, | 
					
						
							|  |  |  |                st.a_sum_amount, | 
					
						
							|  |  |  |                st.b_sum_amount, | 
					
						
							|  |  |  |                st.a_sum_pv, | 
					
						
							|  |  |  |                st.b_sum_pv, | 
					
						
							|  |  |  |                st.a_new_amount, | 
					
						
							|  |  |  |                st.b_new_amount, | 
					
						
							|  |  |  |                st.a_new_pv, | 
					
						
							|  |  |  |                st.b_new_pv, | 
					
						
							|  |  |  |                st.a_sum_real_amount, | 
					
						
							|  |  |  |                st.b_sum_real_amount, | 
					
						
							|  |  |  |                st.a_sum_real_pv, | 
					
						
							|  |  |  |                st.b_sum_real_pv, | 
					
						
							|  |  |  |                st.rep_a_balance, | 
					
						
							|  |  |  |                st.rep_b_balance, | 
					
						
							|  |  |  |                0       r_rep_a_balance, | 
					
						
							|  |  |  |                0       r_rep_b_balance, | 
					
						
							|  |  |  |                st.rep_a_new_amount, | 
					
						
							|  |  |  |                st.rep_b_new_amount, | 
					
						
							|  |  |  |                st.rep_a_new_pv, | 
					
						
							|  |  |  |                st.rep_b_new_pv, | 
					
						
							|  |  |  |                st.rep_a_sum_amount, | 
					
						
							|  |  |  |                st.rep_b_sum_amount, | 
					
						
							|  |  |  |                st.rep_a_sum_pv, | 
					
						
							|  |  |  |                st.rep_b_sum_pv, | 
					
						
							|  |  |  |                st.register_amount, | 
					
						
							|  |  |  |                st.register_pv, | 
					
						
							|  |  |  |                st.register_new_amount, | 
					
						
							|  |  |  |                st.register_new_pv, | 
					
						
							|  |  |  |                st.upgrade_amount, | 
					
						
							|  |  |  |                st.upgrade_pv, | 
					
						
							|  |  |  |                st.upgrade_new_amount, | 
					
						
							|  |  |  |                st.upgrade_new_pv, | 
					
						
							|  |  |  |                st.repurchase_amount, | 
					
						
							|  |  |  |                st.repurchase_pv, | 
					
						
							|  |  |  |                st.repurchase_new_amount, | 
					
						
							|  |  |  |                st.repurchase_new_pv, | 
					
						
							|  |  |  |                st.hi_fun_amount, | 
					
						
							|  |  |  |                st.hi_fun_pv, | 
					
						
							|  |  |  |                st.hi_fun_new_amount, | 
					
						
							|  |  |  |                st.hi_fun_new_pv, | 
					
						
							|  |  |  |                st.mall_amount, | 
					
						
							|  |  |  |                st.mall_pv, | 
					
						
							|  |  |  |                st.mall_new_amount, | 
					
						
							|  |  |  |                st.mall_new_pv, | 
					
						
							|  |  |  |                st.round, | 
					
						
							|  |  |  |                st.second, | 
					
						
							|  |  |  |                st.min_achieve, | 
					
						
							|  |  |  |                st.expire_status | 
					
						
							|  |  |  |         from ${secondTableName} st | 
					
						
							|  |  |  |                  inner join | 
					
						
							|  |  |  |              (select pk_id, | 
					
						
							|  |  |  |                      pk_parent, | 
					
						
							|  |  |  |                      pk_place_parent, | 
					
						
							|  |  |  |                      place_dept, | 
					
						
							|  |  |  |                      member_code, | 
					
						
							|  |  |  |                      member_name, | 
					
						
							|  |  |  |                      pk_center_code, | 
					
						
							|  |  |  |                      pk_settle_grade pk_grade, | 
					
						
							|  |  |  |                      pk_awards, | 
					
						
							|  |  |  |                      account_status, | 
					
						
							|  |  |  |                      register_authority, | 
					
						
							|  |  |  |                      customer_type, | 
					
						
							|  |  |  |                      income_status, | 
					
						
							|  |  |  |                      pk_settle_country, | 
					
						
							|  |  |  |                      purchase_status, | 
					
						
							|  |  |  |                      share_status, | 
					
						
							|  |  |  |                      category, | 
					
						
							|  |  |  |                      is_maker_space, | 
					
						
							|  |  |  |                      0               orders | 
					
						
							|  |  |  |               from cu_member | 
					
						
							|  |  |  |               where del_flag = 0 start | 
					
						
							|  |  |  |               with pk_id = #{pkMember} | 
					
						
							|  |  |  |               connect by pk_id = prior pk_place_parent | 
					
						
							|  |  |  |              ) b | 
					
						
							|  |  |  |              on b.pk_id = st.pk_member | 
					
						
							|  |  |  |                  left join bd_grade bg | 
					
						
							|  |  |  |                            on b.pk_grade = bg.pk_id | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         order by b.orders | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberSecondBloParent" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select b.pk_id pk_member, | 
					
						
							|  |  |  |                b.pk_parent, | 
					
						
							|  |  |  |                b.pk_place_parent, | 
					
						
							|  |  |  |                b.place_dept, | 
					
						
							|  |  |  |                b.pk_center_code, | 
					
						
							|  |  |  |                b.member_code, | 
					
						
							|  |  |  |                b.member_name, | 
					
						
							|  |  |  |                b.pk_grade, | 
					
						
							|  |  |  |                b.pk_awards, | 
					
						
							|  |  |  |                b.account_status, | 
					
						
							|  |  |  |                b.register_authority, | 
					
						
							|  |  |  |                b.customer_type, | 
					
						
							|  |  |  |                b.income_status, | 
					
						
							|  |  |  |                b.pk_settle_country, | 
					
						
							|  |  |  |                b.is_maker_space, | 
					
						
							|  |  |  |                b.purchase_status, | 
					
						
							|  |  |  |                b.share_status, | 
					
						
							|  |  |  |                bg.grade_value, | 
					
						
							|  |  |  |                b.category, | 
					
						
							|  |  |  |                st.a_balance, | 
					
						
							|  |  |  |                st.b_balance, | 
					
						
							|  |  |  |                0       r_a_balance, | 
					
						
							|  |  |  |                0       r_b_balance, | 
					
						
							|  |  |  |                st.a_sum_amount, | 
					
						
							|  |  |  |                st.b_sum_amount, | 
					
						
							|  |  |  |                st.a_sum_pv, | 
					
						
							|  |  |  |                st.b_sum_pv, | 
					
						
							|  |  |  |                st.a_new_amount, | 
					
						
							|  |  |  |                st.b_new_amount, | 
					
						
							|  |  |  |                st.a_new_pv, | 
					
						
							|  |  |  |                st.b_new_pv, | 
					
						
							|  |  |  |                st.a_sum_real_amount, | 
					
						
							|  |  |  |                st.b_sum_real_amount, | 
					
						
							|  |  |  |                st.a_sum_real_pv, | 
					
						
							|  |  |  |                st.b_sum_real_pv, | 
					
						
							|  |  |  |                st.rep_a_balance, | 
					
						
							|  |  |  |                st.rep_b_balance, | 
					
						
							|  |  |  |                0       r_rep_a_balance, | 
					
						
							|  |  |  |                0       r_rep_b_balance, | 
					
						
							|  |  |  |                st.rep_a_new_amount, | 
					
						
							|  |  |  |                st.rep_b_new_amount, | 
					
						
							|  |  |  |                st.rep_a_new_pv, | 
					
						
							|  |  |  |                st.rep_b_new_pv, | 
					
						
							|  |  |  |                st.rep_a_sum_amount, | 
					
						
							|  |  |  |                st.rep_b_sum_amount, | 
					
						
							|  |  |  |                st.rep_a_sum_pv, | 
					
						
							|  |  |  |                st.rep_b_sum_pv, | 
					
						
							|  |  |  |                st.register_amount, | 
					
						
							|  |  |  |                st.register_pv, | 
					
						
							|  |  |  |                st.register_new_amount, | 
					
						
							|  |  |  |                st.register_new_pv, | 
					
						
							|  |  |  |                st.upgrade_amount, | 
					
						
							|  |  |  |                st.upgrade_pv, | 
					
						
							|  |  |  |                st.upgrade_new_amount, | 
					
						
							|  |  |  |                st.upgrade_new_pv, | 
					
						
							|  |  |  |                st.repurchase_amount, | 
					
						
							|  |  |  |                st.repurchase_pv, | 
					
						
							|  |  |  |                st.repurchase_new_amount, | 
					
						
							|  |  |  |                st.repurchase_new_pv, | 
					
						
							|  |  |  |                st.hi_fun_amount, | 
					
						
							|  |  |  |                st.hi_fun_pv, | 
					
						
							|  |  |  |                st.hi_fun_new_amount, | 
					
						
							|  |  |  |                st.hi_fun_new_pv, | 
					
						
							|  |  |  |                st.mall_amount, | 
					
						
							|  |  |  |                st.mall_pv, | 
					
						
							|  |  |  |                st.mall_new_amount, | 
					
						
							|  |  |  |                st.mall_new_pv, | 
					
						
							|  |  |  |                st.round, | 
					
						
							|  |  |  |                st.second, | 
					
						
							|  |  |  |                st.min_achieve, | 
					
						
							|  |  |  |                st.expire_status | 
					
						
							|  |  |  |         from ${secondTableName} st | 
					
						
							|  |  |  |                  inner join | 
					
						
							|  |  |  |              (select pk_id, | 
					
						
							|  |  |  |                      pk_parent, | 
					
						
							|  |  |  |                      pk_place_parent, | 
					
						
							|  |  |  |                      place_dept, | 
					
						
							|  |  |  |                      member_code, | 
					
						
							|  |  |  |                      member_name, | 
					
						
							|  |  |  |                      pk_center_code, | 
					
						
							|  |  |  |                      pk_settle_grade pk_grade, | 
					
						
							|  |  |  |                      pk_awards, | 
					
						
							|  |  |  |                      account_status, | 
					
						
							|  |  |  |                      register_authority, | 
					
						
							|  |  |  |                      customer_type, | 
					
						
							|  |  |  |                      income_status, | 
					
						
							|  |  |  |                      pk_settle_country, | 
					
						
							|  |  |  |                      purchase_status, | 
					
						
							|  |  |  |                      share_status, | 
					
						
							|  |  |  |                      category, | 
					
						
							|  |  |  |                      is_maker_space, | 
					
						
							|  |  |  |                      0               orders | 
					
						
							|  |  |  |               from cu_member | 
					
						
							|  |  |  |               where del_flag = 0 start | 
					
						
							|  |  |  |               with pk_id = #{pkMember} | 
					
						
							|  |  |  |               connect by pk_id = prior pk_parent | 
					
						
							|  |  |  |              ) b | 
					
						
							|  |  |  |              on b.pk_id = st.pk_member | 
					
						
							|  |  |  |                  left join bd_grade bg | 
					
						
							|  |  |  |                            on b.pk_grade = bg.pk_id | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         order by b.orders | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberSecondParent" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select b.pk_id | 
					
						
							|  |  |  |         pk_member,b.pk_parent,b.pk_place_parent,b.place_dept,b.pk_center_code,b.member_code,b.member_name,b.pk_grade,b.pk_awards,b.account_status, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         b.register_authority,b.customer_type,b.income_status,b.pk_settle_country,b.is_maker_space,b.purchase_status, | 
					
						
							|  |  |  |         b.share_status,bg.grade_value,b.category,st.a_balance,st.b_balance,0 r_a_balance,0 r_b_balance, | 
					
						
							|  |  |  |         st.a_sum_amount,st.b_sum_amount,st.a_sum_pv,st.b_sum_pv,st.a_new_amount,st.b_new_amount,st.a_new_pv, | 
					
						
							|  |  |  |         st.b_new_pv,st.a_sum_real_amount,st.b_sum_real_amount,st.a_sum_real_pv, | 
					
						
							|  |  |  |         st.b_sum_real_pv,st.rep_a_balance,st.rep_b_balance,0 r_rep_a_balance,0 r_rep_b_balance,st.rep_a_new_amount, | 
					
						
							|  |  |  |         st.rep_b_new_amount,st.rep_a_new_pv,st.rep_b_new_pv,st.rep_a_sum_amount, | 
					
						
							|  |  |  |         st.rep_b_sum_amount,st.rep_a_sum_pv,st.rep_b_sum_pv, | 
					
						
							|  |  |  |         st.register_amount,st.register_pv,st.register_new_amount,st.register_new_pv, | 
					
						
							|  |  |  |         st.upgrade_amount,st.upgrade_pv,st.upgrade_new_amount,st.upgrade_new_pv, | 
					
						
							|  |  |  |         st.repurchase_amount,st.repurchase_pv,st.repurchase_new_amount,st.repurchase_new_pv, | 
					
						
							|  |  |  |         st.hi_fun_amount,st.hi_fun_pv,st.hi_fun_new_amount,st.hi_fun_new_pv, | 
					
						
							|  |  |  |         st.mall_amount,st.mall_pv,st.mall_new_amount,st.mall_new_pv, | 
					
						
							|  |  |  |         st.round,st.second,st.min_achieve,st.expire_status from | 
					
						
							|  |  |  |         ( | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select pk_id,pk_parent,pk_place_parent,place_dept,member_code,member_name,pk_center_code,pk_settle_grade | 
					
						
							|  |  |  |         pk_grade,pk_awards,account_status,register_authority,customer_type, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         income_status,pk_settle_country,purchase_status,share_status,category,is_maker_space from cu_member | 
					
						
							|  |  |  |         where del_flag= 0 and pk_id in | 
					
						
							|  |  |  |         <foreach collection="cuMemberTreeList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |         ) b | 
					
						
							|  |  |  |         inner join ${secondTableName} st | 
					
						
							|  |  |  |         on b.pk_id = st.pk_member | 
					
						
							|  |  |  |         left join bd_grade bg | 
					
						
							|  |  |  |         on b.pk_grade = bg.pk_id | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberTreePlaceParentTable" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select t.*,cm.PK_PLACE_PARENT,cm.PK_PARENT, level,cm.PLACE_DEPT | 
					
						
							|  |  |  |         from ${tableName} t | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         left join CU_MEMBER cm on cm.PK_ID = t.PK_MEMBER | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         where level < #{level} | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         and cm.DEL_FLAG = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <if test="memberIdList.size() > 0 and memberIdList != ''"> | 
					
						
							|  |  |  |             and cm.PK_ID in | 
					
						
							|  |  |  |             <foreach collection="memberIdList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |                 #{item} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |         start with cm.PK_PLACE_PARENT = #{pkMember} | 
					
						
							|  |  |  |         connect by cm.PK_PLACE_PARENT = prior t.pk_member | 
					
						
							|  |  |  |         order by cm.PLACE_DEPT ASC | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberTreeByPkMemberTable" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select | 
					
						
							|  |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             t.PK_RATE,t.A_BALANCE,t.B_BALANCE,t.A_SUM_AMOUNT,t.B_SUM_AMOUNT,t.A_SUM_PV,t.B_SUM_PV,t.A_NEW_AMOUNT, | 
					
						
							|  |  |  |             t.B_NEW_AMOUNT,t.A_NEW_PV,t.B_NEW_PV,t.A_SUM_REAL_AMOUNT,t.B_SUM_REAL_AMOUNT,t.A_SUM_REAL_PV,t.B_SUM_REAL_PV, | 
					
						
							|  |  |  |             t.REP_A_BALANCE,t.REP_B_BALANCE,t.REP_A_NEW_AMOUNT,t.REP_B_NEW_AMOUNT,t.REP_A_NEW_PV,t.REP_B_NEW_PV,t.REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |             t.REP_B_SUM_AMOUNT,t.REP_A_SUM_PV,t.REP_B_SUM_PV,t.REGISTER_AMOUNT,t.REGISTER_PV,t.REGISTER_NEW_PV,t.UPGRADE_AMOUNT,t.UPGRADE_PV, | 
					
						
							|  |  |  |             t.UPGRADE_NEW_PV,t.REPURCHASE_AMOUNT,t.REPURCHASE_PV,t.REPURCHASE_NEW_PV,t.HI_FUN_AMOUNT,t.HI_FUN_PV,t.HI_FUN_NEW_PV,t.MALL_AMOUNT, | 
					
						
							|  |  |  |             t.MALL_PV ,t.MALL_NEW_PV,t.MIN_ACHIEVE,t.ROUND,t.SECOND, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         cm.PK_AWARDS,cm.PK_PLACE_PARENT,cm.PK_PARENT ,cm.PLACE_DEPT ,cm.MEMBER_NAME, cm.MEMBER_CODE,cm.PK_ID | 
					
						
							|  |  |  |         PK_MEMBER,cm.PK_COUNTRY,cm.PK_SETTLE_COUNTRY,cme.MEMBER_CODE parentMemberCode, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         (select count(cr.pk_id) from CU_MEMBER cr where cr.pk_parent = cm.pk_id and cr.del_flag = 0) directPushNumber | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         from | 
					
						
							|  |  |  |         CU_MEMBER cm | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         left join CU_MEMBER cme on cme.PK_ID = cm.PK_PLACE_PARENT | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             left join ${tableName} t on cm.PK_ID = t.PK_MEMBER | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         where cm.PK_ID = #{pkMember} | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         and cm.DEL_FLAG = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryCuMemberTreeParentTable" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         select | 
					
						
							|  |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             t.PK_RATE, | 
					
						
							|  |  |  |             t.A_BALANCE, | 
					
						
							|  |  |  |             t.B_BALANCE, | 
					
						
							|  |  |  |             t.A_SUM_AMOUNT, | 
					
						
							|  |  |  |             t.B_SUM_AMOUNT, | 
					
						
							|  |  |  |             t.A_SUM_PV, | 
					
						
							|  |  |  |             t.B_SUM_PV, | 
					
						
							|  |  |  |             t.A_NEW_AMOUNT, | 
					
						
							|  |  |  |             t.B_NEW_AMOUNT, | 
					
						
							|  |  |  |             t.A_NEW_PV, | 
					
						
							|  |  |  |             t.B_NEW_PV, | 
					
						
							|  |  |  |             t.A_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |             t.B_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |             t.A_SUM_REAL_PV, | 
					
						
							|  |  |  |             t.B_SUM_REAL_PV, | 
					
						
							|  |  |  |             t.REP_A_BALANCE, | 
					
						
							|  |  |  |             t.REP_B_BALANCE, | 
					
						
							|  |  |  |             t.REP_A_NEW_AMOUNT, | 
					
						
							|  |  |  |             t.REP_B_NEW_AMOUNT, | 
					
						
							|  |  |  |             t.REP_A_NEW_PV, | 
					
						
							|  |  |  |             t.REP_B_NEW_PV, | 
					
						
							|  |  |  |             t.REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |             t.REP_B_SUM_AMOUNT, | 
					
						
							|  |  |  |             t.REP_A_SUM_PV, | 
					
						
							|  |  |  |             t.REP_B_SUM_PV, | 
					
						
							|  |  |  |             t.REGISTER_AMOUNT, | 
					
						
							|  |  |  |             t.REGISTER_PV, | 
					
						
							|  |  |  |             t.REGISTER_NEW_PV, | 
					
						
							|  |  |  |             t.UPGRADE_AMOUNT, | 
					
						
							|  |  |  |             t.UPGRADE_PV, | 
					
						
							|  |  |  |             t.UPGRADE_NEW_PV, | 
					
						
							|  |  |  |             t.REPURCHASE_AMOUNT, | 
					
						
							|  |  |  |             t.REPURCHASE_PV, | 
					
						
							|  |  |  |             t.REPURCHASE_NEW_PV, | 
					
						
							|  |  |  |             t.HI_FUN_AMOUNT, | 
					
						
							|  |  |  |             t.HI_FUN_PV, | 
					
						
							|  |  |  |             t.HI_FUN_NEW_PV, | 
					
						
							|  |  |  |             t.MALL_AMOUNT, | 
					
						
							|  |  |  |             t.MALL_PV, | 
					
						
							|  |  |  |             t.MALL_NEW_PV, | 
					
						
							|  |  |  |             t.MIN_ACHIEVE, | 
					
						
							|  |  |  |             t.ROUND, | 
					
						
							|  |  |  |             t.SECOND, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         cm.*, cme.MEMBER_CODE parentMemberCode from ( select | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         level,cm.PK_ID, | 
					
						
							|  |  |  |         cm.PK_COUNTRY, | 
					
						
							|  |  |  |         cm.PK_PLACE_PARENT, | 
					
						
							|  |  |  |         cm.PK_PARENT, | 
					
						
							|  |  |  |         cm.PLACE_DEPT, | 
					
						
							|  |  |  |         cm.MEMBER_NAME, | 
					
						
							|  |  |  |         cm.MEMBER_CODE, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         cm.PK_ID PK_MEMBER, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         cm.PK_SETTLE_COUNTRY | 
					
						
							|  |  |  |         from CU_MEMBER cm | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         where 1 = 1 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <if test="level != null"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             and level < #{level} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							|  |  |  |         and cm.del_flag = 0 | 
					
						
							|  |  |  |         start with cm.PK_PARENT = #{pkMember} | 
					
						
							|  |  |  |         connect by cm.PK_PARENT = prior cm.pk_id | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         order by cm.Place_Dept ASC ) cm | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         left join CU_MEMBER cme | 
					
						
							|  |  |  |         on cme.PK_ID = cm.PK_PARENT | 
					
						
							|  |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             left join ${tableName} t | 
					
						
							|  |  |  |             on cm.PK_ID = t.PK_MEMBER | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryCuMemberTreeParentTableCount" resultType="long"> | 
					
						
							|  |  |  |         select count(PK_MEMBER) | 
					
						
							|  |  |  |         from ${tableName} t | 
					
						
							|  |  |  |                  left join CU_MEMBER cm on cm.pk_id = t.PK_MEMBER | 
					
						
							|  |  |  |         where cm.PK_PARENT = #{pkMember} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberTreePlaceParentHistoryTable" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select | 
					
						
							|  |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							|  |  |  |             t.PK_RATE,t.A_BALANCE,t.B_BALANCE,t.A_SUM_AMOUNT,t.B_SUM_AMOUNT,t.A_SUM_PV,t.B_SUM_PV,t.A_NEW_AMOUNT, | 
					
						
							|  |  |  |             t.B_NEW_AMOUNT,t.A_NEW_PV,t.B_NEW_PV,t.A_SUM_REAL_AMOUNT,t.B_SUM_REAL_AMOUNT,t.A_SUM_REAL_PV,t.B_SUM_REAL_PV, | 
					
						
							|  |  |  |             t.REP_A_BALANCE,t.REP_B_BALANCE,t.REP_A_NEW_AMOUNT,t.REP_B_NEW_AMOUNT,t.REP_A_NEW_PV,t.REP_B_NEW_PV,t.REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |             t.REP_B_SUM_AMOUNT,t.REP_A_SUM_PV,t.REP_B_SUM_PV,t.REGISTER_AMOUNT,t.REGISTER_PV,t.REGISTER_NEW_PV,t.UPGRADE_AMOUNT,t.UPGRADE_PV, | 
					
						
							|  |  |  |             t.UPGRADE_NEW_PV,t.REPURCHASE_AMOUNT,t.REPURCHASE_PV,t.REPURCHASE_NEW_PV,t.HI_FUN_AMOUNT,t.HI_FUN_PV,t.HI_FUN_NEW_PV,t.MALL_AMOUNT, | 
					
						
							|  |  |  |             t.MALL_PV ,t.MALL_NEW_PV,t.MIN_ACHIEVE,t.ROUND,t.SECOND, | 
					
						
							|  |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         level,cm.PK_AWARDS,cm.PK_PLACE_PARENT,cm.PK_PARENT ,cm.PLACE_DEPT ,cm.MEMBER_NAME, cm.MEMBER_CODE,cm.PK_ID | 
					
						
							|  |  |  |         PK_MEMBER,cm.PK_COUNTRY,cm.PK_SETTLE_COUNTRY,cme.MEMBER_CODE parentMemberCode | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         from CU_MEMBER cm | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             left join ${tableName} t on cm.PK_ID = t.PK_MEMBER | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         left join CU_MEMBER cme on cme.PK_ID = cm.PK_PLACE_PARENT | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         where level < #{level} | 
					
						
							|  |  |  |         <if test="memberIdList.size() > 0 and memberIdList != ''"> | 
					
						
							|  |  |  |             and cm.PK_ID in | 
					
						
							|  |  |  |             <foreach collection="memberIdList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |                 #{item} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |         start with cm.PK_PLACE_PARENT = #{pkMember} | 
					
						
							|  |  |  |         connect by cm.PK_PLACE_PARENT = prior cm.pk_id | 
					
						
							|  |  |  |         order by cm.Place_Dept ASC | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryCuMemberTreeParentSumTable" resultType="com.hzs.bonus.census.vo.CensusSummaryVo"> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         nvl(sum(REGISTER_NEW_AMOUNT + UPGRADE_NEW_AMOUNT),0) firstBuyAmount , | 
					
						
							|  |  |  |         nvl(sum(UPGRADE_NEW_AMOUNT),0) upgradeAmount, | 
					
						
							|  |  |  |         nvl(sum(REPURCHASE_NEW_AMOUNT),0) repurchaseAmount, | 
					
						
							|  |  |  |         nvl(sum(HI_FUN_NEW_AMOUNT),0) fansAmount, | 
					
						
							|  |  |  |         nvl(sum(REGISTER_NEW_PV+UPGRADE_NEW_PV),0) firstBuyAmountPv, | 
					
						
							|  |  |  |         nvl(sum(UPGRADE_NEW_PV),0) upgradePv, | 
					
						
							|  |  |  |         nvl(sum(REPURCHASE_NEW_PV),0) repurchasePv, | 
					
						
							|  |  |  |         nvl(sum(HI_FUN_NEW_PV),0) hiFunAmountPv | 
					
						
							|  |  |  |         from ${tableName} t | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         left join cu_member cm on cm.pk_id = t.PK_MEMBER | 
					
						
							|  |  |  |         <if test="censusSummaryParam.pkVertex != null and censusSummaryParam.pkVertex.size() > 0"> | 
					
						
							|  |  |  |             and cm.PK_VERTEX in | 
					
						
							|  |  |  |             <foreach collection="censusSummaryParam.pkVertex" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |                 #{item} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |         <if test="censusSummaryParam.pkMemberTeam != null and censusSummaryParam.pkMemberTeam.size() > 0"> | 
					
						
							|  |  |  |             and cm.PK_TEAM_CODE in | 
					
						
							|  |  |  |             <foreach collection="censusSummaryParam.pkMemberTeam" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |                 #{item} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryCuMemberTreeLastPlaceParent" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select cu.place_dept, | 
					
						
							|  |  |  |                cu.pk_member, | 
					
						
							|  |  |  |                cu.member_code, | 
					
						
							|  |  |  |                cu.member_name, | 
					
						
							|  |  |  |                cu.phone, | 
					
						
							|  |  |  |                cu.category, | 
					
						
							|  |  |  |                cu.pk_grade, | 
					
						
							|  |  |  |                bg.grade_value | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         from ( | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                  select * | 
					
						
							|  |  |  |                  from (select t.place_dept, t.pk_member, t.member_name, t.member_code, t.phone, t.category, t.pk_grade | 
					
						
							|  |  |  |                        from ${tableName} t | 
					
						
							|  |  |  |                        where t.place_dept = 1 | 
					
						
							|  |  |  |                            start | 
					
						
							|  |  |  |                        with t.pk_member = (select u.pk_member | 
					
						
							|  |  |  |                            from ${tableName} u | 
					
						
							|  |  |  |                            where u.pk_place_parent=#{pkMember} | 
					
						
							|  |  |  |                            and place_dept = 1) | 
					
						
							|  |  |  |                        connect by prior | 
					
						
							|  |  |  |                            t.pk_member = (select u.pk_place_parent | 
					
						
							|  |  |  |                            from ${tableName} u | 
					
						
							|  |  |  |                            where u.pk_member = t.pk_member | 
					
						
							|  |  |  |                               and u.place_dept = 1) | 
					
						
							|  |  |  |                        order by level desc) n | 
					
						
							|  |  |  |                  where rownum = 1 | 
					
						
							|  |  |  |                  union | 
					
						
							|  |  |  |                  select * | 
					
						
							|  |  |  |                  from ( | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |                           select t.place_dept, | 
					
						
							|  |  |  |                                  t.pk_member, | 
					
						
							|  |  |  |                                  t.member_name, | 
					
						
							|  |  |  |                                  t.member_code, | 
					
						
							|  |  |  |                                  t.phone, | 
					
						
							|  |  |  |                                  t.category, | 
					
						
							|  |  |  |                                  t.pk_grade | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                           from ${tableName} t | 
					
						
							|  |  |  |                           where t.place_dept = 2 | 
					
						
							|  |  |  |                               start | 
					
						
							|  |  |  |                           with t.pk_member = (select u.pk_member | 
					
						
							|  |  |  |                               from ${tableName} u | 
					
						
							|  |  |  |                               where u.pk_place_parent=#{pkMember} | 
					
						
							|  |  |  |                               and place_dept = 2) | 
					
						
							|  |  |  |                           connect by prior | 
					
						
							|  |  |  |                               t.pk_member = (select u.pk_place_parent | 
					
						
							|  |  |  |                               from ${tableName} u | 
					
						
							|  |  |  |                               where u.pk_member = t.pk_member | 
					
						
							|  |  |  |                                  and u.place_dept = 2) | 
					
						
							|  |  |  |                           order by level desc) n | 
					
						
							|  |  |  |                  where rownum = 1) cu | 
					
						
							|  |  |  |                  left join bd_grade bg | 
					
						
							|  |  |  |                            on cu.pk_grade = bg.pk_id | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="queryCuMemberTree" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select t.place_dept, t.pk_member, t.member_name,t.member_code, t.phone,t.category,t.pk_grade,bg.grade_value from | 
					
						
							|  |  |  |         ${tableName} t | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         left join bd_grade bg | 
					
						
							|  |  |  |         on bg.pk_id = t.pk_grade | 
					
						
							|  |  |  |         where 1=1 | 
					
						
							|  |  |  |         <if test="pkMember != null"> | 
					
						
							|  |  |  |             and pk_member = #{pkMember} | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |         <if test="pkPlaceParent != null"> | 
					
						
							|  |  |  |             and pk_place_parent=#{pkPlaceParent} | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="selectByTreeMemberList" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select t.PK_RATE, | 
					
						
							|  |  |  |                t.A_BALANCE, | 
					
						
							|  |  |  |                t.B_BALANCE, | 
					
						
							|  |  |  |                t.A_SUM_AMOUNT, | 
					
						
							|  |  |  |                t.B_SUM_AMOUNT, | 
					
						
							|  |  |  |                t.A_SUM_PV, | 
					
						
							|  |  |  |                t.B_SUM_PV, | 
					
						
							|  |  |  |                t.A_NEW_AMOUNT, | 
					
						
							|  |  |  |                t.B_NEW_AMOUNT, | 
					
						
							|  |  |  |                t.A_NEW_PV, | 
					
						
							|  |  |  |                t.B_NEW_PV, | 
					
						
							|  |  |  |                t.A_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |                t.B_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |                t.A_SUM_REAL_PV, | 
					
						
							|  |  |  |                t.B_SUM_REAL_PV, | 
					
						
							|  |  |  |                t.REP_A_BALANCE, | 
					
						
							|  |  |  |                t.REP_B_BALANCE, | 
					
						
							|  |  |  |                t.REP_A_NEW_AMOUNT, | 
					
						
							|  |  |  |                t.REP_B_NEW_AMOUNT, | 
					
						
							|  |  |  |                t.REP_A_NEW_PV, | 
					
						
							|  |  |  |                t.REP_B_NEW_PV, | 
					
						
							|  |  |  |                t.REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |                t.REP_B_SUM_AMOUNT, | 
					
						
							|  |  |  |                t.REP_A_SUM_PV, | 
					
						
							|  |  |  |                t.REP_B_SUM_PV, | 
					
						
							|  |  |  |                t.REGISTER_AMOUNT, | 
					
						
							|  |  |  |                t.REGISTER_PV, | 
					
						
							|  |  |  |                t.REGISTER_NEW_PV, | 
					
						
							|  |  |  |                t.UPGRADE_AMOUNT, | 
					
						
							|  |  |  |                t.UPGRADE_PV, | 
					
						
							|  |  |  |                t.UPGRADE_NEW_PV, | 
					
						
							|  |  |  |                t.REPURCHASE_AMOUNT, | 
					
						
							|  |  |  |                t.REPURCHASE_PV, | 
					
						
							|  |  |  |                t.REPURCHASE_NEW_PV, | 
					
						
							|  |  |  |                t.HI_FUN_AMOUNT, | 
					
						
							|  |  |  |                t.HI_FUN_PV, | 
					
						
							|  |  |  |                t.HI_FUN_NEW_PV, | 
					
						
							|  |  |  |                t.MALL_AMOUNT, | 
					
						
							|  |  |  |                t.MALL_PV, | 
					
						
							|  |  |  |                t.MALL_NEW_PV, | 
					
						
							|  |  |  |                t.MIN_ACHIEVE, | 
					
						
							|  |  |  |                t.ROUND, | 
					
						
							|  |  |  |                t.SECOND, | 
					
						
							|  |  |  |                level, | 
					
						
							|  |  |  |                cm.PK_AWARDS, | 
					
						
							|  |  |  |                cm.PK_SETTLE_COUNTRY, | 
					
						
							|  |  |  |                cm.PK_PLACE_PARENT, | 
					
						
							|  |  |  |                cm.PK_PARENT, | 
					
						
							|  |  |  |                cm.PLACE_DEPT, | 
					
						
							|  |  |  |                cm.MEMBER_NAME, | 
					
						
							|  |  |  |                cm.MEMBER_CODE, | 
					
						
							|  |  |  |                cm.PK_ID        PK_MEMBER, | 
					
						
							|  |  |  |                cm.PK_COUNTRY, | 
					
						
							|  |  |  |                cme.MEMBER_CODE parentMemberCode | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         from CU_MEMBER cm | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                  left join CU_MEMBER cme on cme.PK_ID = cm.PK_PLACE_PARENT | 
					
						
							|  |  |  |                  left join ${tableName} t on cm.PK_ID = t.PK_MEMBER | 
					
						
							|  |  |  |         where level < #{level} | 
					
						
							|  |  |  |           and cm.del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             start | 
					
						
							|  |  |  |         with cm.PK_PLACE_PARENT = #{pkMember} | 
					
						
							|  |  |  |         connect by cm.PK_PLACE_PARENT = prior cm.PK_ID | 
					
						
							|  |  |  |         order by cm.PLACE_DEPT | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="getCuMemberRealPerformanceByMemberId" resultType="com.hzs.common.domain.member.ext.CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         select t.* | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         from ${tableName} t | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         where t.PK_MEMBER = #{pkMember} | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryPlaceParentPeopleNumber" resultType="long"> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         select count(t.PK_ID) | 
					
						
							|  |  |  |         from CU_MEMBER t | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         where t.PLACE_DEPT = #{placeDept} start | 
					
						
							|  |  |  |         with t.PK_PLACE_PARENT = #{memberId} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         connect by t.PK_PLACE_PARENT = prior t.PK_ID | 
					
						
							|  |  |  |         order by level | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryParentPeopleNumber" resultType="long"> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         select count(t.PK_ID) | 
					
						
							|  |  |  |         from CU_MEMBER t | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         where t.PLACE_DEPT = #{placeDept} start | 
					
						
							|  |  |  |         with t.PK_PARENT = #{memberId} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         connect by t.PK_PARENT = prior t.PK_ID | 
					
						
							|  |  |  |         order by level | 
					
						
							|  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="batchQueryMemberSettleParentByMemberPk" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select | 
					
						
							|  |  |  |         cl.pk_member,cl.member_code,cl.member_name,cl.pk_awards,cl.pk_grade,cl.account_status,cl.category,cl.income_status,cl.pk_settle_country, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         cl.is_maker_space,cl.purchase_status,cl.share_status, | 
					
						
							|  |  |  |         cl.a_balance,cl.b_balance,cl.r_a_balance,cl.r_b_balance,cl.rep_a_balance,cl.rep_b_balance,cl.r_rep_a_balance,cl.r_rep_b_balance, | 
					
						
							|  |  |  |         cl.register_amount,cl.register_pv,cl.upgrade_amount,cl.upgrade_pv,cl.repurchase_amount,cl.pk_center_code,cl.register_authority, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         cl.repurchase_pv,cl.hi_fun_amount,cl.hi_fun_pv,cl.mall_amount,cl.mall_pv,cl.min_achieve,cl.round,cl.second from | 
					
						
							|  |  |  |         ${settleTableName} ct | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         inner join ${settleTableName} cl | 
					
						
							|  |  |  |         on ct.pk_parent = cl.pk_member | 
					
						
							|  |  |  |         where ct.pk_member in | 
					
						
							|  |  |  |         <foreach collection="memberPkList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |         union | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select | 
					
						
							|  |  |  |         pk_member,member_code,member_name,pk_awards,pk_grade,account_status,category,income_status,pk_settle_country, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         is_maker_space,purchase_status,share_status, | 
					
						
							|  |  |  |         a_balance,b_balance,r_a_balance,r_b_balance,rep_a_balance,rep_b_balance,r_rep_a_balance,r_rep_b_balance, | 
					
						
							|  |  |  |         register_amount,register_pv,upgrade_amount,upgrade_pv,repurchase_amount,pk_center_code,register_authority, | 
					
						
							|  |  |  |         repurchase_pv,hi_fun_amount,hi_fun_pv,mall_amount,mall_pv,min_achieve,round,second from ${settleTableName} | 
					
						
							|  |  |  |         where pk_member in | 
					
						
							|  |  |  |         <foreach collection="memberPkList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="selectByselectByTreeMemberCount" resultType="long"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select count(PK_MEMBER) | 
					
						
							|  |  |  |         from ${tableName} | 
					
						
							|  |  |  |         where pk_member = #{pkMember} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="brollyBelowResettle" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select t.*, cm.PK_PLACE_PARENT, cm.PK_PARENT, level, cm.PLACE_DEPT | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         from ${tableName} t | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                  left join CU_MEMBER cm on cm.PK_ID = t.PK_MEMBER | 
					
						
							|  |  |  |         where cm.DEL_FLAG = 0 | 
					
						
							|  |  |  |             start | 
					
						
							|  |  |  |         with cm.PK_PLACE_PARENT = #{pkMember} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         connect by cm.PK_PLACE_PARENT = prior t.pk_member | 
					
						
							|  |  |  |         order by cm.PLACE_DEPT ASC | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberTreeByPlacePkMemberTable" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select | 
					
						
							|  |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							|  |  |  |             t.PK_RATE,t.A_BALANCE,t.B_BALANCE,t.A_SUM_AMOUNT,t.B_SUM_AMOUNT,t.A_SUM_PV,t.B_SUM_PV,t.A_NEW_AMOUNT, | 
					
						
							|  |  |  |             t.B_NEW_AMOUNT,t.A_NEW_PV,t.B_NEW_PV,t.A_SUM_REAL_AMOUNT,t.B_SUM_REAL_AMOUNT,t.A_SUM_REAL_PV,t.B_SUM_REAL_PV, | 
					
						
							|  |  |  |             t.REP_A_BALANCE,t.REP_B_BALANCE,t.REP_A_NEW_AMOUNT,t.REP_B_NEW_AMOUNT,t.REP_A_NEW_PV,t.REP_B_NEW_PV,t.REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |             t.REP_B_SUM_AMOUNT,t.REP_A_SUM_PV,t.REP_B_SUM_PV,t.REGISTER_AMOUNT,t.REGISTER_PV,t.REGISTER_NEW_PV,t.UPGRADE_AMOUNT,t.UPGRADE_PV, | 
					
						
							|  |  |  |             t.UPGRADE_NEW_PV,t.REPURCHASE_AMOUNT,t.REPURCHASE_PV,t.REPURCHASE_NEW_PV,t.HI_FUN_AMOUNT,t.HI_FUN_PV,t.HI_FUN_NEW_PV,t.MALL_AMOUNT, | 
					
						
							|  |  |  |             t.MALL_PV ,t.MALL_NEW_PV,t.MIN_ACHIEVE,t.ROUND,t.SECOND, | 
					
						
							|  |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         cm.PK_AWARDS,cm.PK_PLACE_PARENT,cm.PK_PARENT ,cm.PLACE_DEPT ,cm.MEMBER_NAME, cm.MEMBER_CODE,cm.PK_ID | 
					
						
							|  |  |  |         PK_MEMBER,cm.PK_COUNTRY,cm.PK_SETTLE_COUNTRY,cme.MEMBER_CODE parentMemberCode | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         from | 
					
						
							|  |  |  |         CU_MEMBER cm | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         left join CU_MEMBER cme on cme.PK_ID = cm.PK_PARENT | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <if test="tableName != null and tableName != ''"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             left join ${tableName} t on cm.PK_ID = t.PK_MEMBER | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							|  |  |  |         where cm.PK_ID = #{pkMember} | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         and cm.DEL_FLAG = 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryByMemberParentCount" resultType="com.hzs.bonus.achieve.param.MemberParentCountParam"> | 
					
						
							|  |  |  |         select count(cr.pk_id) parentMemberCount,cr.PK_PARENT pkMember from CU_MEMBER cr where cr.PK_PARENT in | 
					
						
							|  |  |  |         <trim suffixOverrides=" OR PK_ID IN()">    <!-- 表示删除最后一个条件 --> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             <foreach collection="memberIds" item="Id" index="index" open="(" close=")"> | 
					
						
							|  |  |  |                 <if test="index != 0"> | 
					
						
							|  |  |  |                     <choose> | 
					
						
							|  |  |  |                         <when test="index % 1000 == 999">) OR cr.PK_PARENT IN (</when> | 
					
						
							|  |  |  |                         <otherwise>,</otherwise> | 
					
						
							|  |  |  |                     </choose> | 
					
						
							|  |  |  |                 </if> | 
					
						
							|  |  |  |                 #{Id} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </trim> | 
					
						
							|  |  |  |         and cr.del_flag = 0 | 
					
						
							|  |  |  |         group by cr.PK_PARENT | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryByMemberParentSumPv" resultType="com.hzs.bonus.achieve.param.MemberParentCountParam"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select sum(cr.REGISTER_PV + cr.UPGRADE_PV + cr.REPURCHASE_PV + cr.HI_FUN_PV + cr.MALL_PV) | 
					
						
							|  |  |  |         parentMemberSumPv,cm.PK_PARENT pkMember from ${tableName} cr | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         left join CU_MEMBER cm on cm.PK_ID = cr.PK_MEMBER | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         where cm.del_flag = 0 and cm.PK_PARENT in | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <foreach collection="memberIds" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |         group by cm.PK_PARENT | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryCuMemberTreePlaceParentHistoryFramework" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         t.PK_RATE,t.A_BALANCE,t.B_BALANCE,t.A_SUM_AMOUNT,t.B_SUM_AMOUNT,t.A_SUM_PV,t.B_SUM_PV,t.A_NEW_AMOUNT, | 
					
						
							|  |  |  |         t.B_NEW_AMOUNT,t.A_NEW_PV,t.B_NEW_PV,t.A_SUM_REAL_AMOUNT,t.B_SUM_REAL_AMOUNT,t.A_SUM_REAL_PV,t.B_SUM_REAL_PV, | 
					
						
							|  |  |  |         t.REP_A_BALANCE,t.REP_B_BALANCE,t.REP_A_NEW_AMOUNT,t.REP_B_NEW_AMOUNT,t.REP_A_NEW_PV,t.REP_B_NEW_PV,t.REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |         t.REP_B_SUM_AMOUNT,t.REP_A_SUM_PV,t.REP_B_SUM_PV,t.REGISTER_AMOUNT,t.REGISTER_PV,t.REGISTER_NEW_PV,t.UPGRADE_AMOUNT,t.UPGRADE_PV, | 
					
						
							|  |  |  |         t.UPGRADE_NEW_PV,t.REPURCHASE_AMOUNT,t.REPURCHASE_PV,t.REPURCHASE_NEW_PV,t.HI_FUN_AMOUNT,t.HI_FUN_PV,t.HI_FUN_NEW_PV,t.MALL_AMOUNT, | 
					
						
							|  |  |  |         t.MALL_PV ,t.MALL_NEW_PV,t.MIN_ACHIEVE,t.ROUND,t.SECOND, | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         level,cm.PK_AWARDS,cm.PK_PLACE_PARENT,cm.PK_PARENT ,cm.PLACE_DEPT ,cm.MEMBER_NAME, cm.MEMBER_CODE,cm.PK_ID | 
					
						
							|  |  |  |         PK_MEMBER,cm.PK_COUNTRY,cm.PK_SETTLE_COUNTRY,cme.MEMBER_CODE parentMemberCode | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         from ${tableName} t | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         left join CU_MEMBER cm on cm.PK_ID = t.PK_MEMBER | 
					
						
							|  |  |  |         left join CU_MEMBER cme on cme.PK_ID = cm.PK_PLACE_PARENT | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         where level < #{level} | 
					
						
							|  |  |  |         <if test="memberIdList.size() > 0 and memberIdList != ''"> | 
					
						
							|  |  |  |             and cm.PK_ID in | 
					
						
							|  |  |  |             <foreach collection="memberIdList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |                 #{item} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </if> | 
					
						
							|  |  |  |         start with cm.PK_PLACE_PARENT = #{pkMember} | 
					
						
							|  |  |  |         connect by cm.PK_PLACE_PARENT = prior cm.pk_id | 
					
						
							|  |  |  |         order by cm.Place_Dept ASC | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |     <select id="queryCuMemberTreeParentHistoryFramework" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         cm.*, cme.MEMBER_CODE parentMemberCode from ( select | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         level,cm.PK_ID, | 
					
						
							|  |  |  |         cm.PK_COUNTRY, | 
					
						
							|  |  |  |         cm.PK_PLACE_PARENT, | 
					
						
							|  |  |  |         cm.PK_PARENT, | 
					
						
							|  |  |  |         cm.PLACE_DEPT, | 
					
						
							|  |  |  |         cm.MEMBER_NAME, | 
					
						
							|  |  |  |         cm.MEMBER_CODE, | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         cm.PK_ID PK_MEMBER, | 
					
						
							|  |  |  |         cm.PK_SETTLE_COUNTRY, t.PK_RATE, | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         t.A_BALANCE, | 
					
						
							|  |  |  |         t.B_BALANCE, | 
					
						
							|  |  |  |         t.A_SUM_AMOUNT, | 
					
						
							|  |  |  |         t.B_SUM_AMOUNT, | 
					
						
							|  |  |  |         t.A_SUM_PV, | 
					
						
							|  |  |  |         t.B_SUM_PV, | 
					
						
							|  |  |  |         t.A_NEW_AMOUNT, | 
					
						
							|  |  |  |         t.B_NEW_AMOUNT, | 
					
						
							|  |  |  |         t.A_NEW_PV, | 
					
						
							|  |  |  |         t.B_NEW_PV, | 
					
						
							|  |  |  |         t.A_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |         t.B_SUM_REAL_AMOUNT, | 
					
						
							|  |  |  |         t.A_SUM_REAL_PV, | 
					
						
							|  |  |  |         t.B_SUM_REAL_PV, | 
					
						
							|  |  |  |         t.REP_A_BALANCE, | 
					
						
							|  |  |  |         t.REP_B_BALANCE, | 
					
						
							|  |  |  |         t.REP_A_NEW_AMOUNT, | 
					
						
							|  |  |  |         t.REP_B_NEW_AMOUNT, | 
					
						
							|  |  |  |         t.REP_A_NEW_PV, | 
					
						
							|  |  |  |         t.REP_B_NEW_PV, | 
					
						
							|  |  |  |         t.REP_A_SUM_AMOUNT, | 
					
						
							|  |  |  |         t.REP_B_SUM_AMOUNT, | 
					
						
							|  |  |  |         t.REP_A_SUM_PV, | 
					
						
							|  |  |  |         t.REP_B_SUM_PV, | 
					
						
							|  |  |  |         t.REGISTER_AMOUNT, | 
					
						
							|  |  |  |         t.REGISTER_PV, | 
					
						
							|  |  |  |         t.REGISTER_NEW_PV, | 
					
						
							|  |  |  |         t.UPGRADE_AMOUNT, | 
					
						
							|  |  |  |         t.UPGRADE_PV, | 
					
						
							|  |  |  |         t.UPGRADE_NEW_PV, | 
					
						
							|  |  |  |         t.REPURCHASE_AMOUNT, | 
					
						
							|  |  |  |         t.REPURCHASE_PV, | 
					
						
							|  |  |  |         t.REPURCHASE_NEW_PV, | 
					
						
							|  |  |  |         t.HI_FUN_AMOUNT, | 
					
						
							|  |  |  |         t.HI_FUN_PV, | 
					
						
							|  |  |  |         t.HI_FUN_NEW_PV, | 
					
						
							|  |  |  |         t.MALL_AMOUNT, | 
					
						
							|  |  |  |         t.MALL_PV, | 
					
						
							|  |  |  |         t.MALL_NEW_PV, | 
					
						
							|  |  |  |         t.MIN_ACHIEVE, | 
					
						
							|  |  |  |         t.ROUND, | 
					
						
							|  |  |  |         t.SECOND | 
					
						
							|  |  |  |         from ${tableName} t | 
					
						
							|  |  |  |         left join CU_MEMBER cm | 
					
						
							|  |  |  |         on cm.PK_ID = t.PK_MEMBER | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         where 1 = 1 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <if test="level != null"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |             and level < #{level} | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         </if> | 
					
						
							|  |  |  |         and cm.del_flag = 0 | 
					
						
							|  |  |  |         start with cm.PK_PARENT = #{pkMember} | 
					
						
							|  |  |  |         connect by cm.PK_PARENT = prior cm.pk_id | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         order by cm.Place_Dept ASC ) cm | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         left join CU_MEMBER cme | 
					
						
							|  |  |  |         on cme.PK_ID = cm.PK_PARENT | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |     <select id="queryByMemberParentAndMemberSettleCount" | 
					
						
							|  |  |  |             resultType="com.hzs.bonus.achieve.param.MemberParentCountParam"> | 
					
						
							|  |  |  |         select count(cr.PK_MEMBER) parentMemberCount,cr.PK_PARENT pkMember from cu_member_settle981 cr where | 
					
						
							|  |  |  |         cr.PK_PARENT in | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         <trim suffixOverrides=" OR PK_ID IN()">    <!-- 表示删除最后一个条件 --> | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             <foreach collection="memberIds" item="Id" index="index" open="(" close=")"> | 
					
						
							|  |  |  |                 <if test="index != 0"> | 
					
						
							|  |  |  |                     <choose> | 
					
						
							|  |  |  |                         <when test="index % 1000 == 999">) OR cr.PK_PARENT IN (</when> | 
					
						
							|  |  |  |                         <otherwise>,</otherwise> | 
					
						
							|  |  |  |                     </choose> | 
					
						
							|  |  |  |                 </if> | 
					
						
							|  |  |  |                 #{Id} | 
					
						
							|  |  |  |             </foreach> | 
					
						
							|  |  |  |         </trim> | 
					
						
							|  |  |  |         group by cr.PK_PARENT | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryByMemberParentSettleSumPv" resultType="com.hzs.bonus.achieve.param.MemberParentCountParam"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select sum(cr.REGISTER_PV + cr.UPGRADE_PV + cr.REPURCHASE_PV + cr.HI_FUN_PV + cr.MALL_PV) | 
					
						
							|  |  |  |         parentMemberSumPv,cr.PK_PARENT pkMember from ${tableName} cr | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         where cr.PK_PARENT in | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         <foreach collection="memberIds" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |         group by cr.PK_PARENT | 
					
						
							|  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-03-25 10:57:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     <select id="queryCuMemberSettle" resultMap="CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         select * | 
					
						
							|  |  |  |         from ${settleTableName} | 
					
						
							|  |  |  |         where store_level = 2 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <select id="queryMemberSettleByAwards" resultType="com.hzs.common.domain.member.ext.CuMemberSettleExt"> | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select a.pk_settle_country, | 
					
						
							|  |  |  |                a.income_status, | 
					
						
							|  |  |  |                a.pk_member, | 
					
						
							|  |  |  |                a.expire_status, | 
					
						
							|  |  |  |                a.purchase_status, | 
					
						
							|  |  |  |                ba.abonus_ratio, | 
					
						
							|  |  |  |                c.real_income_total | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         from ${settleTableName} a | 
					
						
							|  |  |  |                  inner join bd_awards ba | 
					
						
							|  |  |  |                             on a.pk_awards = ba.pk_id | 
					
						
							|  |  |  |                  inner join ( | 
					
						
							|  |  |  |             select pk_member, sum(real_income_total - global_points) real_income_total | 
					
						
							|  |  |  |             from cu_member_bonus | 
					
						
							|  |  |  |             where del_flag = 0 | 
					
						
							|  |  |  |               and period between #{startPeriod} and #{endPeriod} | 
					
						
							|  |  |  |               and real_income_total > 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             group by pk_member) c | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                             on a.pk_member = c.pk_member | 
					
						
							|  |  |  |         where ba.del_flag = 0 | 
					
						
							|  |  |  |           and ba.awards_value >= 5 | 
					
						
							|  |  |  |           and ba.abonus_ratio > 0 | 
					
						
							|  |  |  |           and a.pk_settle_country = 1 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |         union | 
					
						
							| 
									
										
										
										
											2025-04-09 20:52:16 +08:00
										 |  |  |         select a.pk_settle_country, | 
					
						
							|  |  |  |                a.income_status, | 
					
						
							|  |  |  |                a.pk_member, | 
					
						
							|  |  |  |                1 expire_status, | 
					
						
							|  |  |  |                a.purchase_status, | 
					
						
							|  |  |  |                ba.abonus_ratio, | 
					
						
							|  |  |  |                c.real_income_total | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |         from ${rangeTableName} a | 
					
						
							|  |  |  |                  inner join bd_awards ba | 
					
						
							|  |  |  |                             on a.pk_benefit_awards = ba.pk_id | 
					
						
							|  |  |  |                  inner join ( | 
					
						
							|  |  |  |             select pk_member, sum(real_income_total) real_income_total | 
					
						
							|  |  |  |             from cu_member_bonus | 
					
						
							|  |  |  |             where del_flag = 0 | 
					
						
							|  |  |  |               and period between #{startPeriod} and #{endPeriod} | 
					
						
							|  |  |  |               and real_income_total > 0 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |             group by pk_member | 
					
						
							|  |  |  |         ) c | 
					
						
							| 
									
										
										
										
											2025-04-01 14:33:10 +08:00
										 |  |  |                             on a.pk_member = c.pk_member | 
					
						
							|  |  |  |         where ba.del_flag = 0 | 
					
						
							|  |  |  |           and ba.awards_value >= 5 | 
					
						
							|  |  |  |           and ba.abonus_ratio > 0 | 
					
						
							|  |  |  |           and a.pk_settle_country = 1 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-14 17:19:43 +08:00
										 |  |  |     <!-- 回退会员等级 --> | 
					
						
							|  |  |  |     <update id="updateBackCuMemberSettleGrade"> | 
					
						
							|  |  |  |         merge into ${settleTableName} a | 
					
						
							|  |  |  |             using (select pk_member, max(old_level) old_level | 
					
						
							|  |  |  |                    from cu_member_level | 
					
						
							|  |  |  |                    where period = #{period} | 
					
						
							|  |  |  |                      and del_flag = 0 | 
					
						
							|  |  |  |                    group by pk_member) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set | 
					
						
							|  |  |  |                     a.pk_grade = b.old_level | 
					
						
							|  |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <!-- 更新会员网体等级数据,更新结算表 --> | 
					
						
							|  |  |  |     <update id="updateCuMemberSettleGradeByPeriod"> | 
					
						
							|  |  |  |         merge into ${updateTableName} a | 
					
						
							|  |  |  |             using ( | 
					
						
							|  |  |  |                 select pk_member, max(new_level) pk_grade | 
					
						
							|  |  |  |                 from cu_member_level | 
					
						
							|  |  |  |                 where period = #{period} | 
					
						
							|  |  |  |                   and del_flag = 0 | 
					
						
							|  |  |  |                 group by pk_member) b | 
					
						
							|  |  |  |             on (a.pk_member = b.pk_member) | 
					
						
							|  |  |  |             when matched then | 
					
						
							|  |  |  |                 update set | 
					
						
							|  |  |  |                     a.pk_grade = b.pk_grade | 
					
						
							|  |  |  |     </update> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-15 17:04:56 +08:00
										 |  |  |     <!-- 查询左右区足够可以升级的会员 --> | 
					
						
							|  |  |  |     <select id="listUpgradeAwards" resultMap="CuMemberSettleExt"> | 
					
						
							|  |  |  |         select t.pk_member, ct.pk_awards | 
					
						
							|  |  |  |         from (select ct.pk_place_parent pk_member | 
					
						
							|  |  |  |               from ${settleTableName} ct | 
					
						
							|  |  |  |                        inner join bd_awards ba | 
					
						
							|  |  |  |                                   on ba.pk_id = ct.pk_awards | 
					
						
							|  |  |  |                                       and ba.del_flag = 0 | 
					
						
							|  |  |  |               where ct.category = 0 | 
					
						
							|  |  |  |                 and ct.income_status = 0 | 
					
						
							|  |  |  |                 and ba.awards_value >= #{awardsValue} | 
					
						
							|  |  |  |               group by ct.pk_place_parent | 
					
						
							|  |  |  |               having count(ct.pk_place_parent) = 2) t | 
					
						
							|  |  |  |                  left join ${settleTableName} ct | 
					
						
							|  |  |  |                            on ct.pk_member = t.pk_member | 
					
						
							|  |  |  |         order by t.pk_member | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-19 09:21:08 +08:00
										 |  |  |     <!-- 有奖衔的会员,上月最后一期左右区结余,本月左右区新増 --> | 
					
						
							|  |  |  |     <!-- 当期的 首购累计 + 复购累计 - 上月最后一期首购累计 - 上月最后一期复购累计 --> | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |     <select id="listMemberMonthAssess" resultType="com.hzs.common.domain.member.ext.CuMemberSettleExt"> | 
					
						
							|  |  |  |         select t.*, | 
					
						
							|  |  |  |         nvl(cms.a_balance, 0) a_balance, | 
					
						
							|  |  |  |         nvl(cms.b_balance, 0) b_balance, | 
					
						
							| 
									
										
										
										
											2025-04-21 13:19:07 +08:00
										 |  |  |         nvl(t.r_a_sum_pv, 0) + nvl(t.r_rep_a_sum_pv, 0) - nvl(cms.a_sum_pv, 0) - nvl(cms.rep_a_sum_pv, 0) a_sum_pv, | 
					
						
							|  |  |  |         nvl(t.r_b_sum_pv, 0) + nvl(t.r_rep_b_sum_pv, 0) - nvl(cms.b_sum_pv, 0) - nvl(cms.rep_b_sum_pv, 0) b_sum_pv | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |         from ( | 
					
						
							|  |  |  |         select cms.*, ba.awards_value | 
					
						
							| 
									
										
										
										
											2025-04-21 13:19:07 +08:00
										 |  |  |         from ( | 
					
						
							|  |  |  |         select cms.pk_member, cms.pk_awards, | 
					
						
							|  |  |  |         cms.r_a_sum_pv, cms.r_b_sum_pv, cms.r_rep_a_sum_pv, cms.r_rep_b_sum_pv | 
					
						
							| 
									
										
										
										
											2025-04-18 17:11:33 +08:00
										 |  |  |         from ${settleTableName} cms | 
					
						
							|  |  |  |         where cms.pk_member in | 
					
						
							|  |  |  |         <foreach collection="pkMemberList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |             #{item} | 
					
						
							|  |  |  |         </foreach> | 
					
						
							|  |  |  |         ) cms | 
					
						
							|  |  |  |         left join bd_awards ba | 
					
						
							|  |  |  |         on ba.pk_id = cms.pk_awards | 
					
						
							|  |  |  |         where ba.awards_value > 0 | 
					
						
							|  |  |  |         ) t | 
					
						
							|  |  |  |         left join ${settleTableNameMonthLast} cms | 
					
						
							|  |  |  |         on cms.pk_member = t.pk_member | 
					
						
							|  |  |  |     </select> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-23 08:39:16 +08:00
										 |  |  | </mapper> |