定义 多个条件判断 组合 为一个判断条件 的方法

来源:互联网 发布:金螳螂家装 知乎 编辑:程序博客网 时间:2024/05/29 15:11


#import <Foundation/Foundation.h>

//通知类型前台电商放在后面比较少

//    active * k + type * j + flag * i  来定义枚举后面的都是前面的一个量级所以即时加起来也永远不可能 >后面的一个量级 (尽量类型多的放在前面这样会使得总体的数小一点,计算机指令上计算效率高)

/*

 下一量级大于前面的每组最大的和保证了每个类型下的不符合状态下的不会错乱

 即:及时有多个0也不会出现已经定义的

  orderType = 0  applicationState最大是3也不可能会出现其他状态只有3的类型

 ----------------------------------------------------------

 分段                1n  * m  ,   m1 = (n0+1*m0 (计算方式)

 ****************   ***********    ************************

 applicationState   1~3   * 1  ,

 orderType          1~2   * 4  ,   4  = (3+1)*1

 OrderStatus        1~3   * 12 ,   12 = (2+1) * 4

 ----------------------------------------------------------

 ----------------------------------

 applicationState:

 active         --- 1

 Inactive       --- 2

 Background     --- 3

 ----------------------------------

 orderType:

 Takeout        --- 1

 Business       --- 2

 ----------------------------------

 OrderStatus:

 refund         --- 1  // 申请退款

 receive        --- 2  // 接单

 otherStatus    --- 3 // 其他状态通知

 ----------------------------------

 */


//----------------用来计算通知类型的基本元素--------------------------

//分段

#define App_State_Active_NT        1

#define App_State_Inactive_NT      2

#define App_State_Background_NT    3


#define OrderType_TakeOut_NT   1

#define OrderType_Business_NT  2


#define OrderStatus_Refund_NT  1

#define OrderStatus_Receive_NT 2

#define OrderStatus_Other_NT   3


//分段对应的基数

#define App_State_Base   1

#define OrderType_Base   4

#define OrderStatus_Base 12


//----------------判断需要用的通知类型-------------------------------


#define Active_T_Refund_NT 17          // 1*1 + 1* 4 + 1 * 12;前台外卖退款

#define Active_T_Rceive_NT 29          // 1*1 + 1* 4 + 2 * 12;前台外卖接单

#define Active_T_OtherStatus_NT 41     // 1*1 + 1* 4 + 3 * 12;前台外卖状态变化


#define Inactive_T_Refund_NT 18        // 2*1 + 1* 4 + 1 * 12;点击通知外卖退款

#define Inactive_T_Rceive_NT 30        // 2*1 + 1* 4 + 2 * 12;点击通知外卖接单

#define Inactive_T_OtherStatus_NT 42   // 2*1 + 1* 4 + 3 * 12;点击通知外卖状态变化


#define Background_T_Refund_NT 19      // 3*1 + 1* 4 + 1 * 12;后台外卖退款

#define Background_T_Rceive_NT 31      // 3*1 + 1* 4 + 2 * 12;后台外卖接单

#define Background_T_OtherStatus_NT 43 // 3*1 + 1* 4 + 3 * 12;后台外卖状态变化



#define Active_B_Refund_NT 21          // 1*1 + 2* 4 + 1 * 12;前台电商退款

#define Active_B_Rceive_NT 33          // 1*1 + 2* 4 + 2 * 12;前台电商接单

#define Active_B_OtherStatus_NT 45     // 1*1 + 2* 4 + 3 * 12;前台电商状态变化


#define Inactive_B_Refund_NT 22        // 2*1 + 2* 4 + 1 * 12;点击通知电商退款

#define Inactive_B_Rceive_NT 34        // 2*1 + 2* 4 + 2 * 12;点击通知电商接单

#define Inactive_B_OtherStatus_NT 46   // 2*1 + 2* 4 + 3 * 12;点击通知电商状态变化


#define Background_B_Refund_NT 23      // 3*1 + 2* 4 + 1 * 12;后台电商退款

#define Background_B_Rceive_NT 35      // 3*1 + 2* 4 + 2 * 12;后台电商接单

#define Background_B_OtherStatus_NT 47 // 3*1 + 2* 4 + 3 * 12;后台电商状态变化



@interface NotiTypeCustom : NSObject

+(NSInteger)getNotiTypeUserInfo:(NSDictionary *)userInfo applicationState:(UIApplicationState)applicationState;


+(NSInteger)getOrderStatusType:(NSDictionary *)userInfo;

+(NSInteger)getOrderType:(NSDictionary *)userInfo;

+(NSInteger)getAppState:(UIApplicationState)applicationState;

@end


0 0