CartVM.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // CartVM.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2024/1/26.
  6. //
  7. #import "CartVM.h"
  8. @implementation CartVM
  9. - (void)ry_respnsSucessWithPath:(NSString *)mark data:(id)data reqNetType:(ReqNetType)reqNetType{
  10. if([mark isEqualToString:Cart_cartsMineTotals]){
  11. CartTotalsM *model = [CartTotalsM mj_objectWithKeyValues:data];
  12. if(model.extension_attributes){
  13. model.currency_symbol = model.extension_attributes[@"currency_symbol"];
  14. model.cart_id = model.extension_attributes[@"cart_id"];
  15. }
  16. if(model.items.count>0){
  17. for(CartTotalsItemsM *item in model.items){
  18. if(item.extension_attributes){
  19. NSDictionary *tepDic = [FTT_Helper dictionaryWithJsonString:item.extension_attributes[@"mposc"]];
  20. item.image = tepDic[@"image"];
  21. item.initial_price = tepDic[@"initial_price"];
  22. item.product_id = tepDic[@"product_id"];
  23. item.currency_symbol = model.currency_symbol;
  24. if([item.name hasPrefix:@"FREE"]){
  25. item.isGift = YES;
  26. }else{
  27. item.isGift = NO;
  28. }
  29. }
  30. }
  31. }
  32. NSMutableArray *ary = [NSMutableArray arrayWithArray:@[model]];
  33. [self ry_VMconfigDelegateData:data parseAry:ary success:YES mark:mark reqNetType:reqNetType];
  34. } else if ([mark isEqualToString:Chectout_getPaymentMode]) {
  35. NSArray *paymentArray = [ASCheckoutPaymentModel mj_objectArrayWithKeyValuesArray:data];
  36. for (int i = 0; i < paymentArray.count; i++) {
  37. ASCheckoutPaymentModel *payModel = [paymentArray objectAtIndex:i];
  38. if (i == 0) {
  39. payModel.isSelect = YES;
  40. } else {
  41. payModel.isSelect = NO;
  42. }
  43. }
  44. NSMutableArray *ary = [NSMutableArray arrayWithArray:paymentArray];
  45. [self ry_VMconfigDelegateData:data parseAry:ary success:YES mark:mark reqNetType:reqNetType];
  46. } else{
  47. [self ry_VMconfigDelegateData:data parseAry:[NSMutableArray array] success:YES mark:mark reqNetType:reqNetType];
  48. }
  49. }
  50. @end