edit | blame | history | raw

queryByCondition

select 
@pageTag(){
t.*
@}
from xzx_user_redpaper_rule t
where 1=1  and t.del_flag=0 
@if(!isEmpty(ruleName)){
    and  t.rule_name =#ruleName#
@}
@if(!isEmpty(ruleType)){
        and  t.rule_type =#ruleType#
@}
@if(!isEmpty(partnerId)){
        and  t.partner_id =#partnerId#
@}

batchDelXzxUserRedpaperRuleByIds

  • 批量逻辑删除
    update xzx_user_redpaper_rule set del_flag = 1 where id in( #join(ids)#)

queryRebateList

select a.create_time,a.order_id,b.nick_name,b.mobile_phone,
       IFNULL(sum(c.weight),0) as designatedWeight,a.order_money,
       a.royalty_money,a.user_id,a.invited_user_id,
       (select d.applicable_object from xzx_user_redpaper_rule d where a.rule_id=d.id) as applicableObject 
from xzx_platform_capital_info a 
left join xzx_user_info b on b.user_id=a.user_id
left join xzx_order_item_info c on c.order_id=a.order_id
left join(
       select m.partner_id,n.order_id from xzx_user_other_info m
       LEFT JOIN xzx_order_info n on n.receiver=m.user_id
    )j on a.order_id = j.order_id
where a.rule_type=3 and a.royalty_money>0
 and b.del_flag=0 and b.user_type=1
    @if(!isEmpty(startTime)){
        and  a.create_time >=#startTime#
    @}
    @if(!isEmpty(endTime)){
        and  a.create_time <= #endTime#
    @}
    @if(!isEmpty(mobilePhone)){
        and  b.mobile_phone like #"%"+mobilePhone+"%"# or b.nick_name like #"%"+mobilePhone+"%"#
    @}
    @if(!isEmpty(partnerIds)){
                                  AND  j.partner_id in ( #join(partnerIds)# )
                          @}    
    group by a.order_id order by a.create_time desc
     LIMIT #page#, #limit#

queryRebateCount

select count(k.id) from (
            select a.id as id
            from xzx_platform_capital_info a 
            left join xzx_user_info b on b.user_id=a.user_id 
            left join xzx_order_item_info c on c.order_id=a.order_id
            left join(
                   select m.partner_id,n.order_id from xzx_user_other_info m
                   LEFT JOIN xzx_order_info n on n.receiver=m.user_id
                )j on a.order_id = j.order_id
            where a.rule_type=3 and a.royalty_money>0
                and b.del_flag=0 and b.user_type=1 
                @if(!isEmpty(startTime)){
                    and  a.create_time >=#startTime#
                @}
                @if(!isEmpty(endTime)){
                    and  a.create_time <= #endTime#
                @}
                @if(!isEmpty(mobilePhone)){
                    and  b.mobile_phone like #"%"+mobilePhone+"%"# or b.nick_name like #"%"+mobilePhone+"%"#
                @} 
                 @if(!isEmpty(partnerIds)){
                     AND  j.partner_id in ( #join(partnerIds)# )
                 @}    
                group by a.order_id 
            )k 

queryUserOrderIds

select a.order_id from xzx_order_info a
left join xzx_order_detail_info b on b.order_id=a.order_id
where a.order_status in (4,5,7)  
@if(!isEmpty(completeTime)){
    and  b.complete_time <= #completeTime#
@} 
@if(!isEmpty(userId)){
    and  a.create_user_id = #userId#
@} 

queryAfterWeightByOrderIds

select sum(weight) from xzx_order_item_info where order_id in   (#join(orderIds)#)  

queryTotalAmountByParam

 select sum(a.royalty_money)
                 from xzx_platform_capital_info a 
                 left join xzx_user_info b on b.user_id=a.user_id and b.del_flag=0 and b.user_type=1 
                 left join(
                        select m.partner_id,n.order_id from xzx_user_other_info m
                        LEFT JOIN xzx_order_info n on n.receiver=m.user_id
                     )j on a.order_id = j.order_id
                 where a.rule_type=3
                     @if(!isEmpty(startTime)){
                         and  a.create_time >=#startTime#
                     @}
                     @if(!isEmpty(endTime)){
                         and  a.create_time <= #endTime#
                     @}
                     @if(!isEmpty(mobilePhone)){
                         and  b.mobile_phone like #"%"+mobilePhone+"%"# or b.nick_name like #"%"+mobilePhone+"%"#
                     @}   
                      @if(!isEmpty(partnerIds)){
                         AND  j.partner_id in ( #join(partnerIds)# )
                       @}  

queryTotalOrderMoney

     select sum(money) from xzx_order_item_info where order_id in   (#join(orderIds)#)  

queryRedpaperList

  select * from  xzx_user_redpaper_rule 
  where   rule_type =1 
  and del_flag=0      
  @if(!isEmpty(startTime)){
       and  end_time>=#startTime#
  @}                          

queryShareListByTime

  select * from  xzx_user_redpaper_rule 
  where   rule_type =2 
  and del_flag=0      
  @if(!isEmpty(startTime)){
       and  (end_time>=#startTime# or end_time>=#endTime#)
  @}
  @if(!isEmpty(partnerId)){
             and  partner_id=#partnerId#
  @} else {
            and partner_id is null
        @}  

queryCommListByTime

  select * from  xzx_user_redpaper_rule 
  where   rule_type =8
  and del_flag=0      
  @if(!isEmpty(startTime)){
       and  (end_time>=#startTime# or end_time>=#endTime#)
  @} 
  @if(!isEmpty(id)){
             and  id<>#id#
        @}           

queryRedpaperListStartAndEnd

  select * from  xzx_user_redpaper_rule 
  where   rule_type =1 
  and del_flag=0      
  @if(!isEmpty(startTime)){
       and  (end_time>=#startTime# or end_time>=#endTime#)
  @} 
  @if(!isEmpty(partnerId)){
             and  partner_id=#partnerId#
  @} else {
      and partner_id is null
  @}  

queryRebateRuleList

  select * from  xzx_user_redpaper_rule 
  where   rule_type =3 
  and del_flag=0 
  @if(!isEmpty(partnerId)){
                   and  partner_id=#partnerId#
        @} else {
            and partner_id is null
        @}  

queryCommissioList

     select * from  xzx_user_redpaper_rule 
          where   rule_type =8
          and del_flag=0 

queryWeightRuleList

  select * from  xzx_user_redpaper_rule 
  where   rule_type =5 
  and del_flag=0
  @if(!isEmpty(partnerId)){
                         and  partner_id=#partnerId#
              @} else {
                  and partner_id is null
              @}    

queryAccountList

select a.create_time as commissionTime,a.flow_no as orderNo,sum(b.money) as orderMoney,
a.money as commissionEarn,a.create_user_name as partnerName,
a.create_user_mobile as mobile from xzx_platform_account_log a
left join xzx_order_item_info b on a.flow_no=b.order_id
where type=4 
@if(!isEmpty(partnerName)){
    and (a.create_user_name like #"%"+partnerName+"%"#  or mobile like #"%"+partnerName+"%"#)
@} 
@if(!isEmpty(startTime)){
    and a.create_time>=#startTime#
@}
@if(!isEmpty(endTime)){
    and a.create_time<=#endTime#
@}  
group by a.flow_no order by a.create_time desc
LIMIT #page#, #limit#

queryTotalCommissionMoney

select 
IFNULL(sum(a.money),0) from xzx_platform_account_log a
left join xzx_order_item_info b on a.flow_no=b.order_id
where type=4 
@if(!isEmpty(partnerName)){
    and (a.create_user_name like #"%"+partnerName+"%"#  or mobile like #"%"+partnerName+"%"#)
@} 
@if(!isEmpty(startTime)){
    and a.create_time>=#startTime#
@}
@if(!isEmpty(endTime)){
    and a.create_time<=#endTime#
@}  
group by a.flow_no order by a.create_time desc

queryAccountListCount

select count(a.flow_no) from xzx_platform_account_log a
left join xzx_order_item_info b on a.flow_no=b.order_id
where type=4 
@if(!isEmpty(partnerName)){
    and (a.create_user_name like #"%"+partnerName+"%"#  or mobile like #"%"+partnerName+"%"#)
@} 
@if(!isEmpty(startTime)){
    and a.create_time>=#startTime#
@}
@if(!isEmpty(endTime)){
    and a.create_time<=#endTime#
@}  
group by a.flow_no order by a.create_time desc
LIMIT #page#, #limit#

queryRoyalRuleList

  select * from  xzx_user_redpaper_rule 
  where   rule_type =7
  @if(!isEmpty(packageId)){
                   and package_id=#packageId# 
              @}  
  @if(!isEmpty(partnerId)){
             and partner_id=#partnerId#
        @}  

  and del_flag=0  

queryRebateRulePriceList

  select * from  xzx_rebate_rule_price 
    where   rule_id =#ruleId# order by sort asc

deleteByRuleId

 update xzx_rebate_rule_price  set del_flag=1  where rule_id =#ruleId#