Jelajahi Sumber

fix:下单地址相关bugx修改

“wangdongchao” 1 tahun lalu
induk
melakukan
69f9b05123

+ 43 - 21
Asteria/Fuction/Cart/Cart_CheckoutC.m

@@ -170,7 +170,11 @@
             //首次进入展示购物车数据UI
             [self updateData];
         }
-    } else if ([mark isEqualToString:Cart_cartInfo]) {
+    } else if ([mark isEqualToString:Chectout_addBillingAddress]) {
+        if(sucessOrFail){
+            
+        }
+    }else if ([mark isEqualToString:Cart_cartInfo]) {
         if(sucessOrFail){
             // 获取上次下单地址
             NSDictionary *dic = (NSDictionary *)data;
@@ -264,6 +268,9 @@
     } else if ([mark isEqualToString:Goods_productGetProductsById]) {
         //请求赠品详情
         if(sucessOrFail) {
+            if (!AS_Array_valid(arry)) {
+                return;
+            }
             GoodsInformationM *model = (GoodsInformationM *)[arry firstObject];
                     
             NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:@{@"product_id":model.Id, @"isPromoItems":@"yes"}];
@@ -277,7 +284,7 @@
                 [param addEntriesFromDictionary:optionDic];
             }
             [self.addGiftParamArr addObject:param];
-            if (self.giftShowCount < 1 && self.addGiftParamArr.count == 1 && self.addGiftView.hidden) {
+            if (self.giftShowCount <= 1 && self.addGiftParamArr.count == 1 && self.addGiftView.hidden) {
                 
                 dispatch_async(dispatch_get_main_queue(), ^{
                     self.addGiftView.hidden = NO;
@@ -346,6 +353,8 @@
                 NSString *entity_id = productDic[@"entity_id"];
                 [self reqNet_GoodsDetails_productGetProduct:entity_id];
             }
+            
+            self.giftShowCount++;
         }
     }
     
@@ -411,19 +420,36 @@
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     [self.VM ry_requestPostApi:Chectout_addShipAddress_id param:@{@"addressId":self.addressCellM.addressModel.Id}];
 }
+
+- (NSDictionary *)getAddressParam:(ASAddressModel *)addressModel {
+    NSDictionary *param = @{};
+    
+    NSArray *street = addressModel.street;
+    NSDictionary *shipping_address = @{@"region_code":addressModel.region_id,
+                                       @"country_id":addressModel.country_id,
+                                       @"postcode":addressModel.postcode,
+                                       @"lastname":addressModel.lastname,
+                                       @"firstname":addressModel.firstname,
+                                       @"city":addressModel.city,
+                                       @"region":addressModel.region.region,
+                                       @"region_id":addressModel.region.region_id,
+                                       @"telephone":addressModel.telephone,
+                                       @"street":street,
+                                       @"email":ASUserInfoManager.shared.userInfo.email};
+    
+    return shipping_address;
+//    @{@"addressInformation":shipping_address}
+}
+
 //添加账单地址
 - (void)requestAddBillingAddress {
 //    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     
-    NSDictionary *addressDic1 = (NSDictionary *)[self.addressCellM.addressModel.region mj_JSONObject];
-    NSDictionary *addressDic = (NSDictionary *)[self.addressCellM.addressModel mj_JSONObject];
-    NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:addressDic];
-    [param addEntriesFromDictionary:addressDic1];
-    
-    [param removeObjectForKey:@"extension_attributes"];//移除格式不正确的无用参数
+    NSDictionary *addressInformation = [self getAddressParam:self.addressCellM.addressModel];
     
+    NSDictionary *params = @{@"address":addressInformation, @"useForShipping":@"true"};
     
-    [self.VM ry_requestPostApi:Chectout_addBillingAddress param:@{@"address":param, @"useForShipping":@"true"}];
+    [self.VM ry_requestPostApi:Chectout_addBillingAddress param:params];
 }
 //根据邮寄地址获取邮寄方式
 - (void)requestGetShipMethodByAddress {
@@ -433,24 +459,20 @@
 //设置邮寄方式
 - (void)requestSetShipMethodByAddress {
     
-    NSDictionary *addressDic1 = (NSDictionary *)[self.addressCellM.addressModel.region mj_JSONObject];
-    NSDictionary *addressDic = (NSDictionary *)[self.addressCellM.addressModel mj_JSONObject];
-    NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:addressDic];
-    [param addEntriesFromDictionary:addressDic1];
-    
-    [param removeObjectForKey:@"extension_attributes"];//移除格式不正确的无用参数
-    
     if (NIL(self.shipmethodCellM.shipMethodModel.method_code) || NIL(self.shipmethodCellM.shipMethodModel.carrier_code)) {
         [self.view makeToast:self.shipmethodCellM.shipMethodModel.error_message];
         return;
     }
     
-    NSDictionary *params = @{@"shipping_address":param,
+    NSDictionary *shipping_address = [self getAddressParam:self.addressCellM.addressModel];
+    
+    NSDictionary *params = @{@"shipping_address":shipping_address,
                              @"shipping_method_code":self.shipmethodCellM.shipMethodModel.method_code,
                              @"shipping_carrier_code":self.shipmethodCellM.shipMethodModel.carrier_code};
-    
+    NSDictionary *finalDic = @{@"addressInformation":params};
+    NSLog(@"finalDic=====%@", [finalDic mj_JSONString]);
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-    [self.VM ry_requestPostApi:Chectout_setShipMethod param:@{@"addressInformation":params}];
+    [self.VM ry_requestPostApi:Chectout_setShipMethod param:finalDic];
 }
 //获取购物车信息(地址信息)
 - (void)requestCartInfo {
@@ -544,7 +566,7 @@
             NSString *msg = [NSString stringWithFormat:@"%@", [payDic objectForKey:@"msg"]];
             
             if ([msg isEqualToString:@"Payment anomaly"] && [payMethod isEqualToString:@"klarna_kco"]) {
-                [self.view makeToast:@"Payment Failed" duration:0.5 position:CSToastPositionCenter];
+                [self.view makeToast:msg duration:0.5 position:CSToastPositionCenter];
                 
                 K_WEAK_SELF;
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -592,7 +614,7 @@
     for (int i = 0; i < self.addGiftParamArr.count; i++) {
         NSDictionary *param = self.addGiftParamArr[i];
         self.index ++;
-        self.giftShowCount = 2;
+        self.giftShowCount = 1;
         [self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
     }
 }

+ 6 - 2
Asteria/Fuction/Cart/PayManager/ASCheckoutPayManager.m

@@ -163,7 +163,11 @@ static ASCheckoutPayManager *_instance = nil;
     K_WEAK_SELF;
     vc.WebViewBlock = ^(NSUInteger status, id  _Nonnull webData) {
         K_STRONG_SELF;
-        [self requestVerifyPaypalToken:webData];
+        if (status == 1) {
+            [self requestVerifyPaypalToken:webData];
+        } else {
+            [tmpvc.view makeToast:[(NSDictionary *)webData objectForKey:@"title"] duration:2 position:CSToastPositionCenter];
+        }
     };
     [vc xxx_dsWebLoadUrl:urlStr];
     vc.modalPresentationStyle = UIModalPresentationFullScreen;
@@ -209,7 +213,7 @@ static ASCheckoutPayManager *_instance = nil;
     [ASNetTools.shared postWithPath:Chectout_Verify_KlarnaCart param:params success:^(id _Nonnull json) {
         K_STRONG_SELF;
         
-        NSString *is_active = [(NSDictionary *)json objectForKey:@"is_active"];
+        NSString *is_active = [NSString stringWithFormat:@"%@", [(NSDictionary *)json objectForKey:@"is_active"]];
         NSLog(@"=======%@", is_active);
         if ([is_active isEqualToString:@"1"]) {
             [self tool_creatOrderAutoken:authToken];

+ 1 - 1
Asteria/Fuction/UserCenter/Orders/Model/ASOrderDetailsModel.h

@@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *sku;
 @property (nonatomic, copy) NSString *name;
 @property (nonatomic, copy) NSString *price;
-@property (nonatomic, copy) NSString *original_price;
+@property (nonatomic, copy) NSString *price_incl_tax;
 @property (nonatomic, copy) NSString *product_id;
 @property (nonatomic, copy) NSString *qty_ordered;
 @property (nonatomic, copy) NSString *currency_symbol;

+ 2 - 2
Asteria/Fuction/UserCenter/Orders/View/ASOrderDetailsItemsCell.m

@@ -124,9 +124,9 @@
     
     _nameLab.text = AS_String_NotNull(_itemModel.name);
     _countLab.text = [NSString stringWithFormat:@"X%@", AS_String_NotNull(_itemModel.qty_ordered)];
-    _realPriceLab.text = [NSString stringWithFormat:@"%@%@", AS_String_NotNull(_itemModel.currency_symbol), AS_String_NotNull(_itemModel.price)];
+    _realPriceLab.text = [NSString stringWithFormat:@"%@%.2f", AS_String_NotNull(_itemModel.currency_symbol), [AS_String_NotNull(_itemModel.price) floatValue]];
     
-    NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",AS_String_NotNull(_itemModel.currency_symbol),  AS_String_NotNull(_itemModel.original_price)]];
+    NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%.2f",AS_String_NotNull(_itemModel.currency_symbol),  [AS_String_NotNull(_itemModel.price_incl_tax) floatValue]]];
     [priceAtr addAttribute:NSStrikethroughStyleAttributeName
                     value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
                     range:NSMakeRange(0, priceAtr.length)];

+ 4 - 4
Asteria/Fuction/UserCenter/Orders/View/ASOrderDetailsPriceCell.m

@@ -43,7 +43,7 @@
     
     //subtotal
     if (AS_String_valid(_orderModel.subtotal)) {
-        NSDictionary *dic = @{@"title":@"Subtotal", @"value":[NSString stringWithFormat:@"%@%@", _orderModel.currency_symbol, _orderModel.subtotal]};
+        NSDictionary *dic = @{@"title":@"Subtotal", @"value":[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.subtotal floatValue]]};
         [listArr addObject:dic];
     }
     //优惠券
@@ -57,13 +57,13 @@
     
     //地址
     if (AS_String_valid(_orderModel.shipping_tax_amount)) {
-        NSDictionary *dic = @{@"title":@"Shipping & Handling", @"value":[NSString stringWithFormat:@"%@%@", _orderModel.currency_symbol, _orderModel.shipping_tax_amount]};
+        NSDictionary *dic = @{@"title":@"Shipping & Handling", @"value":[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.shipping_tax_amount floatValue]]};
         [listArr addObject:dic];
     }
     
     //丢件险
     if (AS_String_valid(_orderModel.amextrafee_fee_amount)) {
-        NSDictionary *dic = @{@"title":@"Extra Fee (Insurance For Lost)", @"value":[NSString stringWithFormat:@"%@%@", _orderModel.currency_symbol, _orderModel.amextrafee_fee_amount]};
+        NSDictionary *dic = @{@"title":@"Extra Fee (Insurance For Lost)", @"value":[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.amextrafee_fee_amount floatValue]]};
         [listArr addObject:dic];
     }
     
@@ -116,7 +116,7 @@
     }];
     
     
-    UILabel *grandRightLab = [UILabel labelCreateWithText:[NSString stringWithFormat:@"%@%@", _orderModel.currency_symbol, _orderModel.grand_total] font:[UIFont fontWithName:Rob_Bold size:24] textColor:Col_000];
+    UILabel *grandRightLab = [UILabel labelCreateWithText:[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.grand_total floatValue]] font:[UIFont fontWithName:Rob_Bold size:24] textColor:Col_000];
     grandRightLab.textAlignment = NSTextAlignmentRight;
     [_backView addSubview:grandRightLab];
     [grandRightLab mas_makeConstraints:^(MASConstraintMaker *make) {

+ 1 - 1
Asteria/NetTools/ASNetTools.m

@@ -543,7 +543,7 @@
                 }
             } else {
 //                NSString *msg = @"failed";
-                faild(0, nil);
+//                faild(0, nil);
             }
             
         });