InstallReceiptDetailModel.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // InstallReceiptDetailModel.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2017/8/1.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:安装回执明细模型
  9. #import "InstallReceiptDetailModel.h"
  10. @implementation InstallReceiptDetailModel
  11. /*!
  12. * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
  13. * 前:模型的属性 后:字典里的属性
  14. */
  15. + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
  16. return @{@"saleNo":@"SalesNo",
  17. @"receiptRemark":@"ReceiptRemarks",
  18. @"receiptType":@"ReceiptType",
  19. @"code":@"Code",
  20. @"onlyCode":@"OnlyCode",
  21. @"kindName":@"KindName",
  22. @"brandName":@"BrandName",
  23. @"varietyName":@"VarietyName",
  24. @"seriesName":@"SeriesName",
  25. @"unitName":@"UnitName",
  26. @"package":@"Package",
  27. @"weight":@"Weight",
  28. @"acreage":@"Acreage",
  29. @"box":@"Box",
  30. @"piece":@"Piece",
  31. @"m2":@"M2",
  32. @"otherContact":@"OtherContact",
  33. @"expandAttribute":@"ExpandAttribute",
  34. @"expandAttributeTwo":@"ExpandAttribute2"
  35. };
  36. }
  37. /*!
  38. * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法
  39. * NSDate *time dic[@"t"]是double类型的的秒数
  40. * Dic -> model
  41. */
  42. - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
  43. int decimalPlaces = [[dic objectForKey:@"DecimalPlaces"] intValue];
  44. NSString *str = [NSString stringWithFormat:@"%@%d%@",@"%.",decimalPlaces,@"f"];
  45. self.installQuantity = [NSString stringWithFormat:str,[[dic objectForKey:@"InstallationQuantity"]doubleValue]];
  46. self.receiptQuantity = [NSString stringWithFormat:str,[[dic objectForKey:@"ReceiptQuantity"]doubleValue]];
  47. _receiptType = [NSString stringWithFormat:@"%ld",(long)[[dic objectForKey:@"ReceiptType"] integerValue]];
  48. return YES;
  49. }
  50. @end