| 
									
										
										
										
											2025-04-24 19:02:08 +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.member.statis.mapper.CuBonusVertexStatisMapper"> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!-- 通用查询映射结果 --> | 
					
						
							|  |  |  |  |     <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.statis.CuBonusVertexStatis"> | 
					
						
							|  |  |  |  |         <id column="PK_ID" property="pkId"/> | 
					
						
							|  |  |  |  |         <result column="CREATION_TIME" property="creationTime"/> | 
					
						
							|  |  |  |  |         <result column="PK_COUNTRY" property="pkCountry"/> | 
					
						
							|  |  |  |  |         <result column="DEL_FLAG" property="delFlag"/> | 
					
						
							|  |  |  |  |         <result column="STATIS_TYPE" property="statisType"/> | 
					
						
							|  |  |  |  |         <result column="PERIOD" property="period"/> | 
					
						
							|  |  |  |  |         <result column="START_DATE" property="startDate"/> | 
					
						
							|  |  |  |  |         <result column="END_DATE" property="endDate"/> | 
					
						
							|  |  |  |  |         <result column="MAIN_REG_AMOUNT" property="mainRegAmount"/> | 
					
						
							|  |  |  |  |         <result column="MAIN_UP_AMOUNT" property="mainUpAmount"/> | 
					
						
							|  |  |  |  |         <result column="MAIN_REPUR_AMOUNT" property="mainRepurAmount"/> | 
					
						
							|  |  |  |  |         <result column="HIFANS_REG_AMOUNT" property="hifansRegAmount"/> | 
					
						
							|  |  |  |  |         <result column="INTRODUCE_BONUS" property="introduceBonus"/> | 
					
						
							|  |  |  |  |         <result column="ORG_BONUS" property="orgBonus"/> | 
					
						
							|  |  |  |  |         <result column="LEADER_BONUS" property="leaderBonus"/> | 
					
						
							|  |  |  |  |         <result column="SHARE_BONUS" property="shareBonus"/> | 
					
						
							|  |  |  |  |         <result column="SERVICE_BONUS" property="serviceBonus"/> | 
					
						
							|  |  |  |  |         <result column="HI_FUN_INCOME" property="hiFunIncome"/> | 
					
						
							|  |  |  |  |         <result column="REPUR_RANGE_BONUS" property="repurRangeBonus"/> | 
					
						
							|  |  |  |  |         <result column="REPUR_ORG_BONUS" property="repurOrgBonus"/> | 
					
						
							|  |  |  |  |         <result column="MAIN_BONUS" property="mainBonus"/> | 
					
						
							|  |  |  |  |         <result column="REPUR_BONUS" property="repurBonus"/> | 
					
						
							|  |  |  |  |         <result column="PK_BD_VERTEX" property="pkBdVertex"/> | 
					
						
							|  |  |  |  |         <result column="PK_TEAM_CODE" property="pkTeamCode"/> | 
					
						
							|  |  |  |  |         <result column="HAI_FUN_INCOME" property="haiFunIncome"/> | 
					
						
							|  |  |  |  |         <result column="GIFT_ORDER" property="giftOrder"/> | 
					
						
							|  |  |  |  |         <result column="SPECIAL_REGISTER_AMOUNT" property="specialRegisterAmount"/> | 
					
						
							|  |  |  |  |         <result column="SPECIAL_UPGRADE_AMOUNT" property="specialUpgradeAmount"/> | 
					
						
							|  |  |  |  |         <result column="CLOUD_COLLEGE_AMOUNT" property="cloudCollegeAmount"/> | 
					
						
							|  |  |  |  |         <result column="MALL_AMOUNT" property="mallAmount"/> | 
					
						
							|  |  |  |  |         <result column="MAKER_GIFT_AMOUNT" property="makerGiftAmount"/> | 
					
						
							|  |  |  |  |         <result column="EMPOWERMENT_GIFT_AMOUNT" property="empowermentGiftAmount"/> | 
					
						
							|  |  |  |  |         <result column="COOPERATE_AMOUNT" property="cooperateAmount"/> | 
					
						
							|  |  |  |  |         <result column="SPECIAL_REPURCHASE_AMOUNT" property="specialRepurchaseAmount"/> | 
					
						
							|  |  |  |  |         <result column="HAI_FUN_UPGRADE_AMOUNT" property="haiFunUpgradeAmount"/> | 
					
						
							|  |  |  |  |         <result column="REPUR_PUSH_INCOME" property="repurPushIncome"/> | 
					
						
							|  |  |  |  |         <result column="MAKER_DIRECT" property="makerDirect"/> | 
					
						
							|  |  |  |  |         <result column="MAKER_SHARE" property="makerShare"/> | 
					
						
							|  |  |  |  |         <result column="THIRD_ORDER" property="thirdOrder"/> | 
					
						
							|  |  |  |  |         <result column="FICTITIOUS_AMOUNT" property="fictitiousAmount"/> | 
					
						
							|  |  |  |  |         <result column="MAKER_ORDER" property="makerOrder"/> | 
					
						
							|  |  |  |  |         <result column="WELFARE_ORDER" property="welfareOrder"/> | 
					
						
							|  |  |  |  |         <result column="MAIN_REG_PV" property="mainRegPv"/> | 
					
						
							|  |  |  |  |         <result column="MAIN_UP_PV" property="mainUpPv"/> | 
					
						
							|  |  |  |  |         <result column="MAIN_REPUR_PV" property="mainRepurPv"/> | 
					
						
							|  |  |  |  |         <result column="SPECIAL_REGISTER_PV" property="specialRegisterPv"/> | 
					
						
							|  |  |  |  |         <result column="SPECIAL_UPGRADE_PV" property="specialUpgradePv"/> | 
					
						
							|  |  |  |  |         <result column="SPECIAL_REPURCHASE_PV" property="specialRepurchasePv"/> | 
					
						
							|  |  |  |  |         <result column="FICTITIOUS_PV" property="fictitiousPv"/> | 
					
						
							|  |  |  |  |         <result column="HIFANS_REG_PV" property="hifansRegPv"/> | 
					
						
							|  |  |  |  |         <result column="HAI_FUN_UPGRADE_PV" property="haiFunUpgradePv"/> | 
					
						
							|  |  |  |  |         <result column="CLOUD_COLLEGE_PV" property="cloudCollegePv"/> | 
					
						
							|  |  |  |  |         <result column="MALL_PV" property="mallPv"/> | 
					
						
							|  |  |  |  |         <result column="EMPOWERMENT_GIFT_PV" property="empowermentGiftPv"/> | 
					
						
							|  |  |  |  |         <result column="COOPERATE_PV" property="cooperatePv"/> | 
					
						
							|  |  |  |  |         <result column="MAKER_ORDER_PV" property="makerOrderPv"/> | 
					
						
							|  |  |  |  |         <result column="MAKER_GIFT_PV" property="makerGiftPv"/> | 
					
						
							|  |  |  |  |         <result column="WELFARE_ORDER_PV" property="welfareOrderPv"/> | 
					
						
							|  |  |  |  |     </resultMap> | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |     <!-- 奖金拨比列表--> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     <select id="queryCuBonusStatis" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         SELECT | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         cbs.PK_BD_VERTEX pkVertex, | 
					
						
							|  |  |  |  |         cbs.PK_TEAM_CODE pkTeamCode, | 
					
						
							|  |  |  |  |         cm.MEMBER_CODE as memberCode, | 
					
						
							|  |  |  |  |         cm.MEMBER_NAME as memberName, | 
					
						
							|  |  |  |  |         cbs.PK_ID pkId, | 
					
						
							|  |  |  |  |         cbs.PERIOD period, | 
					
						
							|  |  |  |  |         cbs.CREATION_TIME creationTime, | 
					
						
							|  |  |  |  |         cbs.PK_COUNTRY pkCountry, | 
					
						
							|  |  |  |  |         <!-- PV字段 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         cbs.MAIN_REG_PV mainRegPv, | 
					
						
							|  |  |  |  |         cbs.MAIN_UP_PV mainUpPv, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         cbs.MAIN_REPUR_PV mainRepurPv, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         cbs.SPECIAL_REGISTER_PV specialRegisterPv, | 
					
						
							|  |  |  |  |         cbs.SPECIAL_UPGRADE_PV specialUpgradePv, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         cbs.SPECIAL_REPURCHASE_PV specialRepurchasePv, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         cbs.FICTITIOUS_PV fictitiousPv, | 
					
						
							|  |  |  |  |         cbs.HIFANS_REG_PV hifansRegPv, | 
					
						
							|  |  |  |  |         cbs.HAI_FUN_UPGRADE_PV haiFunUpgradePv, | 
					
						
							|  |  |  |  |         cbs.MALL_PV mallPv, | 
					
						
							|  |  |  |  |         cbs.COOPERATE_PV cooperatePv, | 
					
						
							|  |  |  |  |         cbs.WELFARE_ORDER_PV welfareOrderPv, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <!-- 金额字段 --> | 
					
						
							|  |  |  |  |         cbs.main_reg_amount mainRegAmount, | 
					
						
							|  |  |  |  |         cbs.main_up_amount mainUpAmount, | 
					
						
							|  |  |  |  |         cbs.main_repur_amount mainRepurAmount, | 
					
						
							|  |  |  |  |         cbs.special_register_amount, | 
					
						
							|  |  |  |  |         cbs.special_upgrade_amount, | 
					
						
							|  |  |  |  |         cbs.special_repurchase_amount, | 
					
						
							|  |  |  |  |         <!-- 奖金字段 --> | 
					
						
							|  |  |  |  |         cbs.introduce_bonus introduceBonus, | 
					
						
							|  |  |  |  |         cbs.org_bonus orgBonus, | 
					
						
							|  |  |  |  |         cbs.leader_bonus leaderBonus, | 
					
						
							|  |  |  |  |         cbs.service_bonus serviceBonus, | 
					
						
							|  |  |  |  |         cbs.repur_range_bonus repurRangeBonus, | 
					
						
							|  |  |  |  |         cbs.repur_org_bonus repurOrgBonus, | 
					
						
							|  |  |  |  |         cbs.repur_leader_bonus repurLeaderBonus, | 
					
						
							|  |  |  |  |         <!-- 首购相关收益占比,页面未使用
 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         CASE WHEN (cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(#{perCent}*cbs.INTRODUCE_BONUS/(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT),4) end as introduceBonusRate, | 
					
						
							|  |  |  |  |         CASE WHEN (cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(#{perCent}*cbs.ORG_BONUS/(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT),4) end as orgBonusRate, | 
					
						
							|  |  |  |  |         CASE WHEN (cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(#{perCent}*cbs.LEADER_BONUS/(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT),4) end leaderBonusRate, | 
					
						
							|  |  |  |  |         CASE WHEN (cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(#{perCent}*cbs.SHARE_BONUS/(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT),4) end shareBonusRate, | 
					
						
							|  |  |  |  |         CASE WHEN (cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(#{perCent}*cbs.SERVICE_BONUS/(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT),4) end serviceBonusRate, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         --> | 
					
						
							|  |  |  |  |         <!-- 首购金额 = 注册 + 升级 + 特殊注册 + 特殊升级 + 虚拟订单(空单) --> | 
					
						
							|  |  |  |  |         (cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) | 
					
						
							|  |  |  |  |         AS firstPurchaseAll, | 
					
						
							|  |  |  |  |         <!-- 复购金额 = 复购 + 直播 + 合作 + 特殊复购 + 福利订单 --> | 
					
						
							|  |  |  |  |         (cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) | 
					
						
							|  |  |  |  |         AS repurchaseAllAmount, | 
					
						
							|  |  |  |  |         <!-- 首购拨出金额 = 直推收益 + 拓展收益 + 辅导收益 + 服务补贴  --> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         (cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         AS mainBonus, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <!-- 首购拨出比例 = 首购金额为0,首购拨出比例 = 0;否则,首购拨出比例 = 100 * 首购拨出金额 / 首购金额 --> | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN (cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND((#{perCent} * (cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS)) | 
					
						
							|  |  |  |  |         / (cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusRate, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <!-- 首购PV拨出比例 = 首购PV为0,首购PV拨出比例 = 0;否则,首购PV拨出比例 = 100 * 首购拨出金额 / 汇率 / 首购PV --> | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN (cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND((#{perCent} * (cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS)) | 
					
						
							|  |  |  |  |         / #{rate} / (cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusPvRate, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <!-- 复购拨出金额 = 复购级差收益 + 复购拓展收益 + 复购推荐收益 + 复购辅导收益 --> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         (cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         AS repurBonus, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <!-- 复购拨出比例 = 复购金额为0,复购拨出比例 = 0;否则,复购拨出比例 = 100 * 复购拨出金额 / 复购金额 --> | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN (cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * (cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / (cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusRate, | 
					
						
							|  |  |  |  |         <!-- 复购PV拨出比例 = 复购PV为0,复购PV拨出比例 = 0;否则,复购PV拨出比例 = 100 * 首购拨出金额 / 汇率 / 首购PV --> | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN (cbs.MAIN_REPUR_PV + cbs.MALL_PV + cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * (cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / #{rate} / (cbs.MAIN_REPUR_PV + cbs.MALL_PV +cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusPvRate, | 
					
						
							|  |  |  |  |         <!-- 总拨出金额 = 直推收益 + 拓展收益 + 辅导收益 + 服务补贴 + 复购级差收益 + 复购拓展收益 + 复购推荐收益 + 复购辅导收益 --> | 
					
						
							|  |  |  |  |         (cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS | 
					
						
							|  |  |  |  |         + cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         AS totalBonus, | 
					
						
							|  |  |  |  |         <!-- 总拨出比例 = 首购 + 复购金额为0,总拨出比例 = 0;否则,总拨出比例 = 100 * 首购 + 复购拨出金额 / 首购 + 复购金额 --> | 
					
						
							|  |  |  |  |         CASE | 
					
						
							|  |  |  |  |         WHEN (cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT | 
					
						
							|  |  |  |  |         + cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT +cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND (#{perCent} * (cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS | 
					
						
							|  |  |  |  |         + cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / (cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT | 
					
						
							|  |  |  |  |         + cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS totalBonusRate | 
					
						
							|  |  |  |  |         FROM CU_BONUS_VERTEX_STATIS cbs | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX AND cm.DEL_FLAG = 0 | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         WHERE 1 = 1 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="pkCountry != null"> | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |             and cbs.PK_COUNTRY = #{pkCountry} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="pkVertex != null "> | 
					
						
							|  |  |  |  |             and cbs.PK_BD_VERTEX =#{pkVertex} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <if test="startDate != null and startDate != '' "> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |             and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <if test="endDate != null and endDate != '' "> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |             and cbs.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         ORDER BY cbs.CREATION_TIME asc | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--     查询顶点拓展封顶人数--> | 
					
						
							|  |  |  |  |     <select id="queryOrgTopNumber" parameterType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO"> | 
					
						
							|  |  |  |  |         SELECT COUNT(cb.pk_id) orgTopNumber, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex | 
					
						
							|  |  |  |  |         FROM cu_member_bonus cb | 
					
						
							|  |  |  |  |         INNER JOIN ( | 
					
						
							|  |  |  |  |         SELECT pk_id, pk_settle_grade | 
					
						
							|  |  |  |  |         FROM cu_member cm | 
					
						
							|  |  |  |  |         START WITH cm.pk_id=#{pkVertex} | 
					
						
							|  |  |  |  |         CONNECT BY PRIOR pk_id = pk_place_parent | 
					
						
							|  |  |  |  |         ) a ON a.pk_id = cb.pk_member | 
					
						
							|  |  |  |  |         INNER JOIN bd_grade bg ON bg.pk_id = a.pk_settle_grade AND bg.del_flag = 0 | 
					
						
							|  |  |  |  |         INNER JOIN cu_member_settle_period cp ON cb.period = cp.pk_id | 
					
						
							|  |  |  |  |         WHERE cb.del_flag = 0 | 
					
						
							|  |  |  |  |         AND cp.del_flag = 0 | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and cp.settle_date >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and cp.settle_date <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         AND (cb.expand_income + cb.repur_expand_income) >= bg.expand_capping | 
					
						
							| 
									
										
										
										
											2025-08-09 10:08:47 +08:00
										 |  |  |  |         and (cb.expand_income + cb.repur_expand_income) != 0 | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--    查询顶点拓展平均碰次和拓展最高碰次--> | 
					
						
							|  |  |  |  |     <select id="queryTouch" parameterType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO"> | 
					
						
							|  |  |  |  |         SELECT | 
					
						
							|  |  |  |  |         cm.pk_id pkVertex, | 
					
						
							|  |  |  |  |         round(sum(expand_touch) / count(pk_order), 2) orgAvTouch, | 
					
						
							|  |  |  |  |         max(expand_touch) orgMaxTouch | 
					
						
							|  |  |  |  |         FROM ( | 
					
						
							|  |  |  |  |         SELECT #{pkVertex} pkVertex, b.* | 
					
						
							|  |  |  |  |         FROM ( | 
					
						
							|  |  |  |  |         SELECT | 
					
						
							|  |  |  |  |         cd.pk_order, | 
					
						
							|  |  |  |  |         max(expand_touch) expand_touch | 
					
						
							|  |  |  |  |         FROM cu_member_bonus cb | 
					
						
							|  |  |  |  |         INNER JOIN cu_member_bonus_expand cd ON cb.pk_id = cd.pk_bonus | 
					
						
							|  |  |  |  |         INNER JOIN ( | 
					
						
							|  |  |  |  |         SELECT * FROM cu_member cm | 
					
						
							|  |  |  |  |         START WITH cm.pk_id = #{pkVertex} | 
					
						
							|  |  |  |  |         CONNECT BY pk_place_parent = PRIOR pk_id | 
					
						
							|  |  |  |  |         ) a ON a.pk_id = cb.pk_member | 
					
						
							|  |  |  |  |         INNER JOIN cu_member_settle_period cp ON cb.period = cp.pk_id | 
					
						
							|  |  |  |  |         WHERE | 
					
						
							|  |  |  |  |         cb.del_flag = 0 | 
					
						
							|  |  |  |  |         AND cp.del_flag = 0 | 
					
						
							|  |  |  |  |         AND cd.del_flag = 0 | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and cp.settle_date >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and cp.settle_date <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY cd.pk_order | 
					
						
							|  |  |  |  |         ) b | 
					
						
							|  |  |  |  |         ) a | 
					
						
							|  |  |  |  |         INNER JOIN cu_member cm ON a.pkVertex = cm.pk_id | 
					
						
							|  |  |  |  |         LEFT JOIN bd_vertex bv ON cm.pk_vertex = bv.pk_id | 
					
						
							|  |  |  |  |         GROUP BY | 
					
						
							|  |  |  |  |         cm.pk_id, cm.member_name, bv.vertex_name | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |     <!-- 奖金拨比列表统计小计(最后一行)--> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     <select id="queryCuBonusSumStatis" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         SELECT | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <!-- 金额字段 --> | 
					
						
							|  |  |  |  |         sum (cbs.main_reg_amount) mainRegAmountSum, | 
					
						
							|  |  |  |  |         sum (cbs.main_up_amount) mainUpAmountSum, | 
					
						
							|  |  |  |  |         sum (cbs.main_repur_amount) mainRepurAmountSum, | 
					
						
							|  |  |  |  |         sum (cbs.special_register_amount) specialRegisterAmountSum, | 
					
						
							|  |  |  |  |         sum (cbs.special_upgrade_amount) specialUpgradeAmountSum, | 
					
						
							|  |  |  |  |         sum (cbs.special_repurchase_amount) specialRepurchaseAmountSum, | 
					
						
							|  |  |  |  |         <!-- 奖金字段 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         sum (cbs.INTRODUCE_BONUS) introduceBonusSum, | 
					
						
							|  |  |  |  |         sum (cbs.ORG_BONUS) orgBonusSum, | 
					
						
							|  |  |  |  |         sum (cbs.LEADER_BONUS) leaderBonusSum, | 
					
						
							|  |  |  |  |         sum (cbs.SERVICE_BONUS) serviceBonusSum, | 
					
						
							|  |  |  |  |         sum (cbs.REPUR_RANGE_BONUS) repurRangeBonusSum, | 
					
						
							|  |  |  |  |         sum (cbs.REPUR_ORG_BONUS) repurOrgBonusSum, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         sum (cbs.REPUR_LEADER_BONUS) repurLeaderBonusSum, | 
					
						
							|  |  |  |  |         <!-- 首购相关收益占比,页面未使用
 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         CASE WHEN (sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT))=0 THEN 0 ELSE | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         ROUND(sum(#{perCent}*cbs.INTRODUCE_BONUS)/(sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)),4) end as introduceBonusRateSum, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         CASE WHEN (sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT))=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(sum(#{perCent}*cbs.ORG_BONUS)/(sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)),4) end as orgBonusRateSum, | 
					
						
							|  |  |  |  |         CASE WHEN (sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT))=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(sum(#{perCent}*cbs.LEADER_BONUS)/(sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)),4) end leaderBonusRateSum, | 
					
						
							|  |  |  |  |         CASE WHEN (sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT))=0 THEN 0 ELSE | 
					
						
							|  |  |  |  |         ROUND(sum(#{perCent}*cbs.SHARE_BONUS)/(sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)),4) end shareBonusRateSum, | 
					
						
							|  |  |  |  |         CASE WHEN (sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT))=0 THEN 0 ELSE | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         ROUND(sum(#{perCent}*cbs.SERVICE_BONUS)/(sum(cbs.MAIN_REG_AMOUNT+cbs.MAIN_UP_AMOUNT)),4) end serviceBonusRateSum, | 
					
						
							|  |  |  |  |         --> | 
					
						
							|  |  |  |  |         sum (cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) | 
					
						
							|  |  |  |  |         AS firstPurchaseAllSum, | 
					
						
							|  |  |  |  |         sum (cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) | 
					
						
							|  |  |  |  |         AS repurchaseAllAmountSum, | 
					
						
							|  |  |  |  |         sum (cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         AS mainBonusSum, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusRateSum, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         / #{rate} / sum(cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusPvRateSum, | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) AS repurBonusSum, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusRateSum, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_PV + cbs.MALL_PV + cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / #{rate} / sum(cbs.MAIN_REPUR_PV + cbs.MALL_PV +cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusPvRateSum, | 
					
						
							|  |  |  |  |         sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS | 
					
						
							|  |  |  |  |         + cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         AS totalBonusSum, | 
					
						
							|  |  |  |  |         CASE | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT | 
					
						
							|  |  |  |  |         + cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT +cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND (#{perCent} * sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS | 
					
						
							|  |  |  |  |         + cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT | 
					
						
							|  |  |  |  |         + cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS totalBonusRateSum | 
					
						
							|  |  |  |  |         FROM CU_BONUS_VERTEX_STATIS cbs | 
					
						
							|  |  |  |  |         LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX AND cm.DEL_FLAG = 0 | 
					
						
							|  |  |  |  |         WHERE 1 = 1 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="pkCountry != null"> | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |             and cbs.PK_COUNTRY = #{pkCountry} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="pkVertex != null "> | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |             and cbs.PK_BD_VERTEX = #{pkVertex} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |     <!-- 查询顶点奖金拨比汇总--> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |     <select id="queryCuBonusStatisTotal" parameterType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO"> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         select * from( | 
					
						
							|  |  |  |  |         SELECT | 
					
						
							|  |  |  |  |         cbs.PK_BD_VERTEX pkVertex, | 
					
						
							|  |  |  |  |         cm.MEMBER_CODE as memberCode, | 
					
						
							|  |  |  |  |         cm.MEMBER_NAME as memberName, | 
					
						
							|  |  |  |  |         sum (cbs.INTRODUCE_BONUS) introduceBonus, | 
					
						
							|  |  |  |  |         sum (cbs.ORG_BONUS) orgBonus, | 
					
						
							|  |  |  |  |         sum (cbs.LEADER_BONUS) leaderBonus, | 
					
						
							|  |  |  |  |         sum (cbs.SERVICE_BONUS) serviceBonus, | 
					
						
							|  |  |  |  |         sum (cbs.REPUR_RANGE_BONUS) repurRangeBonus, | 
					
						
							|  |  |  |  |         sum (cbs.REPUR_ORG_BONUS) repurOrgBonus, | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         sum (cbs.REPUR_LEADER_BONUS) repurLeaderBonus, | 
					
						
							|  |  |  |  |         <!-- 首购相关 --> | 
					
						
							|  |  |  |  |         sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) | 
					
						
							|  |  |  |  |         AS firstPurchaseAll, | 
					
						
							|  |  |  |  |         sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         AS mainBonus, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusRate, | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         / #{rate} / sum(cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusPvRate, | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         <!-- 复购相关 --> | 
					
						
							|  |  |  |  |         sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) | 
					
						
							|  |  |  |  |         AS repurchaseAllAmount, | 
					
						
							|  |  |  |  |         sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         AS repurBonus, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusRate, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_PV + cbs.MALL_PV + cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / #{rate} / sum(cbs.MAIN_REPUR_PV + cbs.MALL_PV + cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusPvRate | 
					
						
							|  |  |  |  |         FROM CU_BONUS_VERTEX_STATIS cbs | 
					
						
							|  |  |  |  |         LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX and cm.del_flag = 0 | 
					
						
							|  |  |  |  |         WHERE 1 = 1 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="pkCountry != null"> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |             and cbs.PK_COUNTRY = #{pkCountry} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="pkVertex != null "> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |             and cbs.PK_BD_VERTEX = #{pkVertex} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         GROUP BY cbs.PK_BD_VERTEX, cm.MEMBER_CODE, cm.MEMBER_NAME | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         ORDER BY firstPurchaseAll desc, repurchaseAllAmount desc | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--    顶点奖金拨比汇总查询总和--> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |     <select id="queryCuBonusStatisSum" parameterType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO"> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         SELECT | 
					
						
							|  |  |  |  |         sum (cbs.INTRODUCE_BONUS) introduceBonus, | 
					
						
							|  |  |  |  |         sum (cbs.ORG_BONUS) orgBonus, | 
					
						
							|  |  |  |  |         sum (cbs.LEADER_BONUS) leaderBonus, | 
					
						
							|  |  |  |  |         sum (cbs.SERVICE_BONUS) serviceBonus, | 
					
						
							|  |  |  |  |         sum (cbs.REPUR_RANGE_BONUS) repurRangeBonus, | 
					
						
							|  |  |  |  |         sum (cbs.REPUR_ORG_BONUS) repurOrgBonus, | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         sum (cbs.REPUR_LEADER_BONUS) repurLeaderBonus, | 
					
						
							|  |  |  |  |         <!-- 首购相关 --> | 
					
						
							|  |  |  |  |         sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) | 
					
						
							|  |  |  |  |         AS firstPurchaseAll, | 
					
						
							|  |  |  |  |         sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         AS mainBonus, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusRate, | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.INTRODUCE_BONUS + cbs.ORG_BONUS + cbs.LEADER_BONUS + cbs.SERVICE_BONUS) | 
					
						
							|  |  |  |  |         / #{rate} / sum(cbs.MAIN_REG_PV + cbs.MAIN_UP_PV + cbs.SPECIAL_REGISTER_PV + cbs.SPECIAL_UPGRADE_PV + cbs.FICTITIOUS_PV), 4) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         end AS mainBonusPvRate, | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         <!-- 复购相关 --> | 
					
						
							|  |  |  |  |         sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) | 
					
						
							|  |  |  |  |         AS repurchaseAllAmount, | 
					
						
							|  |  |  |  |         sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         AS repurBonus, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusRate, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_PV + cbs.MALL_PV + cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_RANGE_BONUS + cbs.REPUR_ORG_BONUS + cbs.REPUR_PUSH_INCOME + cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / #{rate} / sum(cbs.MAIN_REPUR_PV + cbs.MALL_PV + cbs.COOPERATE_PV + cbs.SPECIAL_REPURCHASE_PV + cbs.WELFARE_ORDER_PV), 4) | 
					
						
							|  |  |  |  |         end AS repurBonusPvRate, | 
					
						
							|  |  |  |  |         <!-- 首购奖金占比 --> | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.INTRODUCE_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							|  |  |  |  |         end AS introduceBonusRate, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.ORG_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							|  |  |  |  |         end AS orgBonusRate, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.LEADER_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							|  |  |  |  |         end AS leaderBonusRate, | 
					
						
							|  |  |  |  |         case | 
					
						
							| 
									
										
										
										
											2025-06-11 14:09:52 +08:00
										 |  |  |  |         WHEN sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT) = 0 | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.SERVICE_BONUS) | 
					
						
							| 
									
										
										
										
											2025-06-11 14:09:52 +08:00
										 |  |  |  |         / sum(cbs.MAIN_REG_AMOUNT + cbs.MAIN_UP_AMOUNT + cbs.SPECIAL_REGISTER_AMOUNT + cbs.SPECIAL_UPGRADE_AMOUNT + cbs.FICTITIOUS_AMOUNT), 4) | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |         end AS serviceBonusRate, | 
					
						
							|  |  |  |  |         <!-- 复购奖金占比 --> | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_RANGE_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS repurRangeBonusRate, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_ORG_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS repurOrgBonusRate, | 
					
						
							|  |  |  |  |         case | 
					
						
							|  |  |  |  |         WHEN sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER) = 0 | 
					
						
							|  |  |  |  |         THEN 0 | 
					
						
							|  |  |  |  |         ELSE ROUND(#{perCent} * sum(cbs.REPUR_LEADER_BONUS) | 
					
						
							|  |  |  |  |         / sum(cbs.MAIN_REPUR_AMOUNT + cbs.MALL_AMOUNT + cbs.COOPERATE_AMOUNT + cbs.SPECIAL_REPURCHASE_AMOUNT + cbs.WELFARE_ORDER), 4) | 
					
						
							|  |  |  |  |         end AS repurLeaderBonusRate | 
					
						
							|  |  |  |  |         FROM CU_BONUS_VERTEX_STATIS cbs | 
					
						
							|  |  |  |  |         LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX and cm.del_flag = 0 | 
					
						
							|  |  |  |  |         WHERE 1 = 1 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="pkCountry != null"> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |             and cbs.PK_COUNTRY= #{pkCountry} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         <if test="pkVertex != null "> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |             and cbs.PK_BD_VERTEX = #{pkVertex} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     <!--    查询时间内奖金拨比顶点会员--> | 
					
						
							| 
									
										
										
										
											2025-05-24 10:29:38 +08:00
										 |  |  |  |     <select id="queryCuBonusVertex" parameterType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStaticTotalVO"> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         select cbs.PK_BD_VERTEX pkVertex | 
					
						
							|  |  |  |  |         from CU_BONUS_VERTEX_STATIS cbs where 1=1 | 
					
						
							|  |  |  |  |         <if test="pkCountry != null"> | 
					
						
							|  |  |  |  |             and cbs.PK_COUNTRY=#{pkCountry} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="pkVertex != null"> | 
					
						
							|  |  |  |  |             and cbs.PK_BD_VERTEX=#{pkVertex} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and cbs.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY cbs.PK_BD_VERTEX | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--    查询小于当天全部已支付或撤单订单信息--> | 
					
						
							|  |  |  |  |     <select id="querySaOrderByLessDay" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         select * from ( | 
					
						
							|  |  |  |  |         select | 
					
						
							|  |  |  |  |         cm.pk_id pkMember, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         so.PK_COUNTRY pkCountry, | 
					
						
							|  |  |  |  |         so.ORDER_TYPE orderType, | 
					
						
							|  |  |  |  |         (so.ORDER_AMOUNT-nvl(so.CONSUME_AMOUNT,0)) orderAmount, | 
					
						
							|  |  |  |  |         so.ORDER_ACHIEVE orderAchieve, | 
					
						
							|  |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime | 
					
						
							|  |  |  |  |         from ( | 
					
						
							|  |  |  |  |         SELECT | 
					
						
							|  |  |  |  |         cm.pk_id | 
					
						
							|  |  |  |  |         FROM | 
					
						
							|  |  |  |  |         cu_member cm | 
					
						
							|  |  |  |  |         WHERE del_flag=0 and category=0 | 
					
						
							|  |  |  |  |         START WITH pk_place_parent =#{pkVertex} | 
					
						
							|  |  |  |  |         CONNECT BY pk_place_parent = PRIOR pk_id | 
					
						
							|  |  |  |  |         ) cm | 
					
						
							|  |  |  |  |         INNER JOIN SA_ORDER so on so.pk_member=cm.pk_id | 
					
						
							|  |  |  |  |         where so.ORDER_TYPE in (1,2,3,4,5,6,7,10,12,13,14,18,19,20,22,24,25,26,27,28,31) | 
					
						
							|  |  |  |  |         <if test="pkCountry != null"> | 
					
						
							|  |  |  |  |             and so.pk_country=#{pkCountry} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="delFlag != null"> | 
					
						
							|  |  |  |  |             AND so.DEL_FLAG=#{delFlag} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="orderStatus != null"> | 
					
						
							|  |  |  |  |             AND so.order_status=#{orderStatus} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         <if test="startDate != null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate != null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="payTimeStr != null and payTimeStr!='' "> | 
					
						
							|  |  |  |  |             AND so.PAY_TIME = to_date(#{payTimeStr}, 'YYYY-MM-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         ) | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |     <!-- 7天重算查询订单--> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     <select id="queryAnewSaOrderByLessDay" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         select * from ( | 
					
						
							|  |  |  |  |         select | 
					
						
							|  |  |  |  |         cm.pk_Member pkMember, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         so.PK_COUNTRY pkCountry, | 
					
						
							|  |  |  |  |         so.ORDER_TYPE orderType, | 
					
						
							|  |  |  |  |         so.ORDER_AMOUNT orderAmount, | 
					
						
							|  |  |  |  |         so.ORDER_ACHIEVE orderAchieve, | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'), 'yyyy-mm-dd') AS creationTime | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         from ( | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         SELECT pk_member | 
					
						
							|  |  |  |  |         FROM ${settleTableName} | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         WHERE category = 0 | 
					
						
							| 
									
										
										
										
											2025-05-26 09:46:12 +08:00
										 |  |  |  |         start with pk_member = #{pkVertex} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         connect by pk_place_parent = prior pk_member | 
					
						
							|  |  |  |  |         ) cm | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         INNER JOIN SA_ORDER so on so.pk_member = cm.pk_member | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         where so.ORDER_TYPE in (1, 2, 3, 13, 20, 24, 25, 26) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="pkCountry != null"> | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |             and so.pk_country = #{pkCountry} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="delFlag != null"> | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |             AND so.DEL_FLAG = #{delFlag} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="orderStatus != null"> | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |             AND so.order_status = #{orderStatus} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="startDate != null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate != null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="payTimeStr != null and payTimeStr!='' "> | 
					
						
							|  |  |  |  |             AND so.PAY_TIME = to_date(#{payTimeStr}, 'YYYY-MM-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         ) | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--    删除奖金拨比统计表数据--> | 
					
						
							|  |  |  |  |     <delete id="delStatis"> | 
					
						
							|  |  |  |  |         delete from CU_BONUS_VERTEX_STATIS | 
					
						
							|  |  |  |  |         where 1=1 | 
					
						
							|  |  |  |  |         <if test="pkVertexList!=null and pkVertexList.size> 0 "> | 
					
						
							|  |  |  |  |             and PK_BD_VERTEX not in | 
					
						
							|  |  |  |  |             <foreach collection="pkVertexList" item="item" open="(" close=")" separator=","> | 
					
						
							|  |  |  |  |                 #{item} | 
					
						
							|  |  |  |  |             </foreach> | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="startDate != null and startDate!='' "> | 
					
						
							|  |  |  |  |             and CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate != null and endDate!='' "> | 
					
						
							|  |  |  |  |             and CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |     </delete> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--   查询奖金扣项配置参数--> | 
					
						
							|  |  |  |  |     <select id="bonusDeductlist" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         select a.PK_ID, | 
					
						
							|  |  |  |  |         b.PK_ID as pkId, | 
					
						
							|  |  |  |  |         (a.BACK_RATIO+a.PLATFORM_RATIO)/100 backRatio | 
					
						
							|  |  |  |  |         from BD_BONUS_ITEMS b | 
					
						
							|  |  |  |  |         left JOIN BD_BONUS_DEDUCT a on a.PK_BONUS_ITEMS=b.PK_ID | 
					
						
							|  |  |  |  |         where | 
					
						
							|  |  |  |  |         b.DEL_FLAG =0 | 
					
						
							|  |  |  |  |         and a.BACK_RATIO>0 | 
					
						
							|  |  |  |  |         and a.PLATFORM_RATIO>0 | 
					
						
							|  |  |  |  |         <if test="pkCountry != null "> | 
					
						
							|  |  |  |  |             AND b.PK_COUNTRY = #{pkCountry} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         ORDER BY a.BACK_RATIO,a.PLATFORM_RATIO DESC | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--      查询生效国外国家--> | 
					
						
							|  |  |  |  |     <select id="countrylist" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         select pk_id as pkCountry | 
					
						
							|  |  |  |  |         from BD_COUNTRY | 
					
						
							|  |  |  |  |         where pk_id!=1 and del_flag = 0 and EFFECTIVE_DATE <= sysdate | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |     <!-- 查询有效顶点 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     <select id="vertexList" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         SELECT | 
					
						
							| 
									
										
										
										
											2025-05-20 08:58:52 +08:00
										 |  |  |  |         m.pk_id as pkVertex, | 
					
						
							|  |  |  |  |         m.MEMBER_CODE as memberCode, | 
					
						
							| 
									
										
										
										
											2025-05-20 09:26:52 +08:00
										 |  |  |  |         m.MEMBER_NAME as memberName | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         FROM | 
					
						
							|  |  |  |  |         cu_member m | 
					
						
							|  |  |  |  |         WHERE | 
					
						
							|  |  |  |  |         m.pk_place_parent = 2 | 
					
						
							|  |  |  |  |         AND m.del_flag = 0 | 
					
						
							|  |  |  |  |         AND m.category = 0 | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         AND m.pk_country = 1 | 
					
						
							|  |  |  |  |         AND m.pay_status = 1 | 
					
						
							| 
									
										
										
										
											2025-05-23 15:44:31 +08:00
										 |  |  |  |         <if test="pkVertex != null"> | 
					
						
							| 
									
										
										
										
											2025-05-20 08:58:52 +08:00
										 |  |  |  |             AND m.pk_id = #{pkVertex} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         </if> | 
					
						
							| 
									
										
										
										
											2025-05-20 09:26:52 +08:00
										 |  |  |  |         ORDER BY m.pk_id ASC | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--     查询中国奖金--> | 
					
						
							|  |  |  |  |     <select id="queryChinaCountryBonus" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							|  |  |  |  |         select | 
					
						
							|  |  |  |  |         #{pkCountry} pkCountry,sum(mbp.REAL_INCOME) realIncome, | 
					
						
							|  |  |  |  |         mbp.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime | 
					
						
							|  |  |  |  |         from cu_member_bonus_push mbp | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbp.PK_BONUS=cmb.pk_id | 
					
						
							|  |  |  |  |         INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH pk_place_parent | 
					
						
							|  |  |  |  |         =#{pkVertex} CONNECT BY pk_place_parent = PRIOR pk_id ) cm | 
					
						
							|  |  |  |  |         on cm.pk_id = cmb.pk_member | 
					
						
							|  |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbp.PK_BONUS_ITEMS | 
					
						
							|  |  |  |  |         INNER JOIN sa_order so on so.pk_id=mbp.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0 | 
					
						
							|  |  |  |  |         where mbp.DEL_FLAG=0 | 
					
						
							|  |  |  |  |         and mbp.INCOME_STATUS=0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1) | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY mbp.PK_COUNTRY, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							|  |  |  |  |         select | 
					
						
							|  |  |  |  |         #{pkCountry} pkCountry,sum(mbe.REAL_INCOME) realIncome, | 
					
						
							|  |  |  |  |         mbe.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime | 
					
						
							|  |  |  |  |         from CU_MEMBER_BONUS_EXPAND mbe | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbe.PK_BONUS=cmb.pk_id | 
					
						
							|  |  |  |  |         INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH pk_place_parent | 
					
						
							|  |  |  |  |         =#{pkVertex} CONNECT BY pk_place_parent = PRIOR pk_id ) cm | 
					
						
							|  |  |  |  |         on cm.pk_id = cmb.pk_member | 
					
						
							|  |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbe.PK_BONUS_ITEMS | 
					
						
							|  |  |  |  |         INNER JOIN sa_order so on so.pk_id=mbe.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0 | 
					
						
							|  |  |  |  |         where mbe.DEL_FLAG=0 | 
					
						
							|  |  |  |  |         and mbe.INCOME_STATUS=0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1) | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY mbe.PK_COUNTRY, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							|  |  |  |  |         select | 
					
						
							|  |  |  |  |         #{pkCountry} pkCountry,sum(mbc.REAL_INCOME) realIncome, | 
					
						
							|  |  |  |  |         mbc.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime | 
					
						
							|  |  |  |  |         from CU_MEMBER_BONUS_COACH mbc | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbc.PK_BONUS=cmb.pk_id | 
					
						
							|  |  |  |  |         INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH pk_place_parent | 
					
						
							|  |  |  |  |         =#{pkVertex} CONNECT BY pk_place_parent = PRIOR pk_id ) cm | 
					
						
							|  |  |  |  |         on cm.pk_id = cmb.pk_member | 
					
						
							|  |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbc.PK_BONUS_ITEMS | 
					
						
							|  |  |  |  |         INNER JOIN sa_order so on so.pk_id=mbc.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0 | 
					
						
							|  |  |  |  |         where mbc.DEL_FLAG=0 | 
					
						
							|  |  |  |  |         and mbc.INCOME_STATUS=0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1) | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY mbc.PK_COUNTRY, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							|  |  |  |  |         select | 
					
						
							|  |  |  |  |         #{pkCountry} pkCountry,sum(mbr.REAL_INCOME) realIncome, | 
					
						
							|  |  |  |  |         mbr.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime | 
					
						
							|  |  |  |  |         from cu_member_bonus_range mbr | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbr.PK_BONUS=cmb.pk_id | 
					
						
							|  |  |  |  |         INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH pk_place_parent | 
					
						
							|  |  |  |  |         =#{pkVertex} CONNECT BY pk_place_parent = PRIOR pk_id ) cm | 
					
						
							|  |  |  |  |         on cm.pk_id = cmb.pk_member | 
					
						
							|  |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbr.PK_BONUS_ITEMS | 
					
						
							|  |  |  |  |         INNER JOIN sa_order so on so.pk_id=mbr.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0 | 
					
						
							|  |  |  |  |         where mbr.DEL_FLAG=0 | 
					
						
							|  |  |  |  |         and mbr.INCOME_STATUS=0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1) | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         mbr.PK_COUNTRY, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							|  |  |  |  |         select | 
					
						
							|  |  |  |  |         #{pkCountry} pkCountry,sum(mbd.REAL_INCOME) realIncome, | 
					
						
							|  |  |  |  |         mbd.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime | 
					
						
							|  |  |  |  |         from cu_member_bonus_detail mbd | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbd.PK_BONUS=cmb.pk_id | 
					
						
							|  |  |  |  |         INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH pk_place_parent | 
					
						
							|  |  |  |  |         =#{pkVertex} CONNECT BY pk_place_parent = PRIOR pk_id ) cm | 
					
						
							|  |  |  |  |         on cm.pk_id = cmb.pk_member | 
					
						
							|  |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbd.PK_BONUS_ITEMS | 
					
						
							|  |  |  |  |         INNER JOIN sa_order so on so.pk_id=mbd.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0 | 
					
						
							|  |  |  |  |         where mbd.DEL_FLAG=0 | 
					
						
							|  |  |  |  |         and mbd.INCOME_STATUS=0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1) | 
					
						
							|  |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         mbd.PK_COUNTRY, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |     </select> | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |     <!-- 查询7天重算奖金查询--> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |     <select id="queryVertexChinaCountryBonus" parameterType="com.hzs.member.statis.vo.CuBonusVertexStatisVO" | 
					
						
							|  |  |  |  |             resultType="com.hzs.member.statis.vo.CuBonusVertexStatisVO"> | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         <!-- 直推收益 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         #{pkCountry} pkCountry, mbp.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         sum(mbp.REAL_INCOME) realIncome, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							| 
									
										
										
										
											2025-05-17 11:23:58 +08:00
										 |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'), 'yyyy-mm-dd') AS creationTime | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         from cu_member_bonus_push mbp | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbp.PK_BONUS = cmb.pk_id | 
					
						
							|  |  |  |  |         INNER join ( | 
					
						
							|  |  |  |  |         SELECT pk_member | 
					
						
							|  |  |  |  |         FROM ${settleTableName} | 
					
						
							|  |  |  |  |         WHERE category = 0 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         start with pk_member = #{pkVertex} | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         connect by pk_place_parent = prior pk_member) cm | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         on cm.pk_member = cmb.pk_member | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id = mbp.PK_BONUS_ITEMS | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         INNER JOIN sa_order so on so.pk_id = mbp.pk_order | 
					
						
							|  |  |  |  |         and so.PK_COUNTRY = #{pkCountry} and so.del_flag = 0 | 
					
						
							|  |  |  |  |         where mbp.DEL_FLAG = 0 | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         and mbp.INCOME_STATUS = 0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (1, 3, 4, 5, 7, 8, 9, 12, 14, 15, 16, 20, 21, 24, 25) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY mbp.PK_COUNTRY, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         <!-- 拓展收益、消费拓展收益,收益状态:正常,延缓发放 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         #{pkCountry} pkCountry, mbe.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         sum(mbe.REAL_INCOME) realIncome, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							|  |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime | 
					
						
							|  |  |  |  |         from CU_MEMBER_BONUS_EXPAND mbe | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbe.PK_BONUS=cmb.pk_id | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         INNER join ( SELECT pk_member | 
					
						
							|  |  |  |  |         FROM ${settleTableName} | 
					
						
							|  |  |  |  |         WHERE category = 0 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         start with pk_member = #{pkVertex} | 
					
						
							|  |  |  |  |         connect by pk_place_parent = prior pk_member ) cm | 
					
						
							|  |  |  |  |         on cm.pk_member = cmb.pk_member | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id = mbe.PK_BONUS_ITEMS | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         INNER JOIN sa_order so on so.pk_id = mbe.pk_order | 
					
						
							|  |  |  |  |         and so.PK_COUNTRY = #{pkCountry} and so.del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         where mbe.DEL_FLAG = 0 | 
					
						
							|  |  |  |  |         and mbe.INCOME_STATUS in (0, 4) | 
					
						
							|  |  |  |  |         and mbe.pk_order != 0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (1, 3, 4, 5, 7, 8, 9, 12, 14, 15, 16, 20, 21, 24, 25) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY mbe.PK_COUNTRY, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         <!-- 辅导收益,收益状态:正常,延缓发放 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         #{pkCountry} pkCountry, mbc.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         sum(mbc.REAL_INCOME) realIncome, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'), 'yyyy-mm-dd') AS creationTime | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         from CU_MEMBER_BONUS_COACH mbc | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbc.PK_BONUS=cmb.pk_id | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         INNER join ( SELECT pk_member | 
					
						
							|  |  |  |  |         FROM ${settleTableName} | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         WHERE category=0 | 
					
						
							|  |  |  |  |         start with pk_member = #{pkVertex} | 
					
						
							|  |  |  |  |         connect by pk_place_parent = prior pk_member ) cm | 
					
						
							|  |  |  |  |         on cm.pk_member = cmb.pk_member | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id = mbc.PK_BONUS_ITEMS | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         INNER JOIN sa_order so on so.pk_id = mbc.pk_order | 
					
						
							|  |  |  |  |         and so.PK_COUNTRY = #{pkCountry} and so.del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         where mbc.DEL_FLAG = 0 | 
					
						
							|  |  |  |  |         and mbc.INCOME_STATUS in (0, 4) | 
					
						
							|  |  |  |  |         and mbc.pk_order != 0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (1, 3, 4, 5, 7, 8, 9, 12, 14, 15, 16, 20, 21, 24, 25) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY mbc.PK_COUNTRY, | 
					
						
							|  |  |  |  |         bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         <!-- 复购级差 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         #{pkCountry} pkCountry, mbr.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         sum(mbr.REAL_INCOME) realIncome, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'), 'yyyy-mm-dd') AS creationTime | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         from cu_member_bonus_range mbr | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbr.PK_BONUS=cmb.pk_id | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         INNER join ( SELECT pk_member | 
					
						
							|  |  |  |  |         FROM ${settleTableName} | 
					
						
							|  |  |  |  |         WHERE category = 0 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         start with pk_member = #{pkVertex} | 
					
						
							|  |  |  |  |         connect by pk_place_parent = prior pk_member ) cm | 
					
						
							|  |  |  |  |         on cm.pk_member = cmb.pk_member | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id = mbr.PK_BONUS_ITEMS | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         INNER JOIN sa_order so on so.pk_id = mbr.pk_order | 
					
						
							|  |  |  |  |         and so.PK_COUNTRY = #{pkCountry} and so.del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         where mbr.DEL_FLAG = 0 | 
					
						
							|  |  |  |  |         and mbr.INCOME_STATUS = 0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (1, 3, 4, 5, 7, 8, 9, 12, 14, 15, 16, 20, 21, 24, 25) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         mbr.PK_COUNTRY, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         UNION ALL | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         <!-- 报单服务费 --> | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         select | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         #{pkCountry} pkCountry, mbd.PK_COUNTRY con, | 
					
						
							|  |  |  |  |         sum(mbd.REAL_INCOME) realIncome, | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         bbi.BONUS_VALUE bonusType, | 
					
						
							|  |  |  |  |         #{pkVertex} pkVertex, | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'), 'yyyy-mm-dd') AS creationTime | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         from cu_member_bonus_detail mbd | 
					
						
							|  |  |  |  |         INNER JOIN CU_MEMBER_BONUS cmb on mbd.PK_BONUS=cmb.pk_id | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         INNER join ( SELECT pk_member | 
					
						
							|  |  |  |  |         FROM ${settleTableName} | 
					
						
							|  |  |  |  |         WHERE category = 0 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         start with pk_member = #{pkVertex} | 
					
						
							|  |  |  |  |         connect by pk_place_parent = prior pk_member ) cm | 
					
						
							|  |  |  |  |         on cm.pk_member = cmb.pk_member | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         inner join BD_BONUS_ITEMS bbi on bbi.pk_id = mbd.PK_BONUS_ITEMS | 
					
						
							| 
									
										
										
										
											2025-05-17 10:38:51 +08:00
										 |  |  |  |         INNER JOIN sa_order so on so.pk_id = mbd.pk_order | 
					
						
							|  |  |  |  |         and so.PK_COUNTRY = #{pkCountry} and so.del_flag = 0 | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         where mbd.DEL_FLAG = 0 | 
					
						
							|  |  |  |  |         and mbd.INCOME_STATUS = 0 | 
					
						
							|  |  |  |  |         and bbi.BONUS_VALUE in (1, 3, 4, 5, 7, 8, 9, 12, 14, 15, 16, 20, 21, 24, 25) | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="startDate!=null and startDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="endDate!=null and endDate!='' "> | 
					
						
							|  |  |  |  |             and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         GROUP BY bbi.BONUS_VALUE, | 
					
						
							|  |  |  |  |         mbd.PK_COUNTRY, | 
					
						
							|  |  |  |  |         to_char(so.PAY_TIME, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     <!--   查询当天团队统计数据--> | 
					
						
							|  |  |  |  |     <select id="getCuBonusStatis" parameterType="com.hzs.common.domain.member.statis.CuBonusVertexStatis" | 
					
						
							|  |  |  |  |             resultType="com.hzs.common.domain.member.statis.CuBonusVertexStatis"> | 
					
						
							|  |  |  |  |         SELECT * | 
					
						
							| 
									
										
										
										
											2025-04-25 15:21:46 +08:00
										 |  |  |  |         FROM CU_BONUS_VERTEX_STATIS a | 
					
						
							|  |  |  |  |         WHERE 1 = 1 | 
					
						
							| 
									
										
										
										
											2025-04-24 19:02:08 +08:00
										 |  |  |  |         <if test="pkBdVertex != null "> | 
					
						
							|  |  |  |  |             AND a.PK_BD_VERTEX = #{pkBdVertex} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="pkCountry != null "> | 
					
						
							|  |  |  |  |             AND a.PK_COUNTRY = #{pkCountry} | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |         <if test="creationTime != null "> | 
					
						
							|  |  |  |  |             and to_char(a.CREATION_TIME, 'yyyy-mm-dd') = to_char(#{creationTime}, 'yyyy-mm-dd') | 
					
						
							|  |  |  |  |         </if> | 
					
						
							|  |  |  |  |     </select> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | </mapper> |