// // AveragePriceMonitorModel.m // IBOSS // // Created by guan hong hou on 2017/9/8. // Copyright © 2017年 elongtian. All rights reserved. // // 功能描述:均价监控模型 #import "AveragePriceMonitorModel.h" @implementation AveragePriceMonitorModel #pragma 委托函数 /*! * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的 * 前:模型的属性 后:字典里的属性 */ + (nullable NSDictionary *)modelCustomPropertyMapper{ return @{@"departmentName":@"OrganizationName", @"kindName":@"KindName", @"profit":@"Profit", @"orderQuantity":@"Quantity", @"orderAmount":@"GoodsAmount", @"orderAveragePrice":@"AveragePrice", @"costAmount":@"CostAmount", @"costAveragePrice":@"CostAveragePrice", @"kindId":@"KindID" }; } /*! * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法 * NSDate *time dic[@"t"]是double类型的的秒数 */ /// Dic -> model - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic { self.profit = [NSString stringWithFormat:@"%.2f%@",[[dic objectForKey:@"Profit"] doubleValue],@"%"]; self.orderQuantity=[NSString stringWithFormat:@"%.2f", [[dic objectForKey:@"Quantity"] doubleValue]]; self.orderAmount=[NSString stringWithFormat:@"%.2f", [[dic objectForKey:@"GoodsAmount"] doubleValue]]; self.orderAveragePrice=[NSString stringWithFormat:@"%.2f", [[dic objectForKey:@"AveragePrice"] doubleValue]]; self.costAmount=[NSString stringWithFormat:@"%.2f", [[dic objectForKey:@"CostAmount"] doubleValue]]; self.costAveragePrice=[NSString stringWithFormat:@"%.2f", [[dic objectForKey:@"CostAveragePrice"] doubleValue]]; return YES; } @end