AveragePriceMonitorModel.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // AveragePriceMonitorModel.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2017/9/8.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. // 功能描述:均价监控模型
  9. #import "AveragePriceMonitorModel.h"
  10. @implementation AveragePriceMonitorModel
  11. #pragma 委托函数
  12. /*!
  13. * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
  14. * 前:模型的属性 后:字典里的属性
  15. */
  16. + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
  17. return @{@"departmentName":@"OrganizationName",
  18. @"kindName":@"KindName",
  19. @"profit":@"Profit",
  20. @"orderQuantity":@"Quantity",
  21. @"orderAmount":@"GoodsAmount",
  22. @"orderAveragePrice":@"AveragePrice",
  23. @"costAmount":@"CostAmount",
  24. @"costAveragePrice":@"CostAveragePrice",
  25. @"kindId":@"KindID"
  26. };
  27. }
  28. /*!
  29. * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法
  30. * NSDate *time dic[@"t"]是double类型的的秒数
  31. */
  32. /// Dic -> model
  33. - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
  34. self.profit = [NSString stringWithFormat:@"%.2f%@",[[dic objectForKey:@"Profit"] doubleValue],@"%"];
  35. self.orderQuantity=[NSString stringWithFormat:@"%.2f",
  36. [[dic objectForKey:@"Quantity"] doubleValue]];
  37. self.orderAmount=[NSString stringWithFormat:@"%.2f",
  38. [[dic objectForKey:@"GoodsAmount"] doubleValue]];
  39. self.orderAveragePrice=[NSString stringWithFormat:@"%.2f",
  40. [[dic objectForKey:@"AveragePrice"] doubleValue]];
  41. self.costAmount=[NSString stringWithFormat:@"%.2f",
  42. [[dic objectForKey:@"CostAmount"] doubleValue]];
  43. self.costAveragePrice=[NSString stringWithFormat:@"%.2f",
  44. [[dic objectForKey:@"CostAveragePrice"] doubleValue]];
  45. return YES;
  46. }
  47. @end