| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 |
- //
- // PromotionGoodsDetailVC.m
- // IBOSS
- //
- // Created by 关宏厚 on 2020/9/9.
- // Copyright © 2020 elongtian. All rights reserved.
- //
- #import "OrderGoodsSinglePromotionDetailVC.h"
- @interface OrderGoodsSinglePromotionDetailVC ()
- @end
- @implementation OrderGoodsSinglePromotionDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- [self loadNavStyle];
- [self initUI];
- _isCanChoose=[self isCanChooseFullGift];
- [self loadGoodsDetail];
- }
- /**
- 导航按钮样式
- */
- -(void)loadNavStyle
- {
- self.navigationItem.title=@"促销品详细";
-
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0, 15, 18);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- }
- -(void)initUI
- {
- [self.view setBackgroundColor:[UIColor whiteColor]];
- UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
- CGFloat h = 50;
- _vTableView = [[UITableView alloc]
- initWithFrame:CGRectMake(0,
- 0,
- self.view.frame.size.width,
- self.view.frame.size.height-h)];
-
- _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vTableView.backgroundColor = [UIColor whiteColor];
- _vTableView.delegate = self;
- _vTableView.dataSource=self;
- [self.view addSubview: _vTableView];
-
-
-
- //保存按钮
- _btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
- _btnSave.frame=CGRectMake(0, self.view.frame.size.height-h, Screen_Width,h) ;
- [_btnSave setBackgroundImage:pic forState:UIControlStateNormal];
- [_btnSave addTarget:self action:@selector(saveData) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:_btnSave];
-
- }
- /**
- 键盘弹出
-
- @param note
- */
- - (void)keyboardWillShow:(NSNotification *)note
- {
- CGRect keyBoardRect = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
- _vTableView.contentInset = UIEdgeInsetsMake(0, 0, keyBoardRect.size.height, 0);
- }
- /**
- 键盘隐藏
- @param note
- */
- - (void)keyboardWillHide:(NSNotification *)note
- {
- _vTableView.contentInset = UIEdgeInsetsZero;
- }
- /**
- 屏幕触摸回调函数
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- {
- [self.view endEditing:YES];
- }
- /**
- scrollview回调函数
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
- [self.view endEditing:YES];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vTableView.frame =CGRectMake(0, 0, self.view.frame.size.width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-50);
- _btnSave.frame=CGRectMake(0, self.view.safeAreaLayoutGuide.layoutFrame.size.height-50, self.view.frame.size.width, 50);
- [super viewSafeAreaInsetsDidChange];
- }
- -(void)saveData{
- if([_promotionOrderModel.promotionTypeId intValue]==4||[_promotionOrderModel.promotionTypeId intValue]==3){
- BOOL isCanChooseDiscount=[self isCanChooseDiscount];
- if(!isCanChooseDiscount)
- {
- [self showAlertViewText:@"不满足该促销条件"];
- return;
- }
- }
-
- NSMutableArray *submitOrderGoodsList=[[NSMutableArray alloc]init];
-
- double giftAmount=0;
-
- if(_orderGoodsDetailList!=nil&&_orderGoodsDetailList.count>0)
- {
- for(int i=0;i<_orderGoodsDetailList.count;i++)
- {
- InventoryListModel *goodsModel=[_orderGoodsDetailList objectAtIndex:i];
- if(goodsModel.isCheckedStatus)
- {
- [submitOrderGoodsList addObject:goodsModel];
- }
- }
- }
-
- if(submitOrderGoodsList!=nil&&submitOrderGoodsList.count>0)
- {
- if([_promotionOrderModel.promotionTypeId intValue]==2)
- {
- int giftNum=0;
- int noGiftNum=0;
- for(int i=0;i<submitOrderGoodsList.count;i++)
- {
- InventoryListModel *inventoryModel=[submitOrderGoodsList objectAtIndex:i];
- if(!inventoryModel.giftFlag)
- {
- if(noGiftNum==0)
- {
- noGiftNum= [inventoryModel.combinationQuantity intValue];
- }
- }
- else{
- giftNum++;
- }
- }
-
- if(giftNum>_promotionOrderModel.giftGoodsNumber)
- {
- [self showAlertViewText:@"赠品选择个数大于促销赠品可选个数"];
- return;
- }
- }
- else if([_promotionOrderModel.promotionTypeId intValue]==3)
- {
- int giftNum=0;
- for(int i=0;i<submitOrderGoodsList.count;i++)
- {
- InventoryListModel *goodsDetailModel=[submitOrderGoodsList objectAtIndex:i];
- giftNum+=[goodsDetailModel.salesQuantity doubleValue];
-
- }
- if(giftNum>_promotionOrderModel.giftGoodsNumber)
- {
- [self showAlertViewText:@"满再送促销赠品数量选择不符"];
- return;
- }
-
- }
- }
- else
- {
- if([_promotionOrderModel.promotionTypeId intValue]==3||[_promotionOrderModel.promotionTypeId intValue]==4)
- {
- if([_promotionOrderModel.promotionTypeId intValue]==3)
- {
- double promotionAmount=0;
- double factGoodsAmount=0;
- if(_promotionOrderModel.reachAmountFlag)
- {
- NSMutableArray *promotionOrderList=[[NSMutableArray alloc]init];
- for(int i=0;i<_orderGoodsDetailList.count;i++)
- {
- InventoryListModel *goodsModel=[_orderGoodsDetailList objectAtIndex:i];
- if(goodsModel.promotionDetailId!=nil&&goodsModel.promotionDetailId.length>0)
- {
- [promotionOrderList addObject:goodsModel];
- }
- }
-
- if(promotionOrderList!=nil&&promotionOrderList.count>0)
- {
- for(int i=0;i<promotionOrderList.count;i++)
- {
- InventoryListModel *goodsModel=[promotionOrderList objectAtIndex:i];
- promotionAmount+=[goodsModel.salesPrice doubleValue]*[goodsModel.salesQuantity doubleValue];
-
- }
- }
-
- factGoodsAmount=[_goodsAmount doubleValue]-promotionAmount;
- double num=floor(factGoodsAmount/_promotionOrderModel.reachAmount);
- giftAmount=_promotionOrderModel.giftAmount*num;
-
- }
- }
- }
- else
- {
- [self showAlertViewText:@"没有选择任何数据"];
- return;
- }
- }
-
- if([self.orderDelegate respondsToSelector:@selector(updatePromotionGoodsData: goodsDetailList:giftAmount: goodsDetailDic:)])
- {
- [self.orderDelegate updatePromotionGoodsData:_promotionOrderModel goodsDetailList:submitOrderGoodsList giftAmount:giftAmount goodsDetailDic:nil];
- [self.navigationController popViewControllerAnimated:YES];
- }
-
- }
- -(BOOL) isCanChooseDiscount
- {
- double factGoodsAmount=0;
- double promotionAmount=0;
- BOOL isCanChoose=YES;
- NSMutableArray *promotionOrderGoodsList=[[NSMutableArray alloc]init];
- if(_promotionOrderModel.reachAmountFlag)
- {
- for(int i=0;i<_orderGoodsDetailList.count;i++)
- {
- InventoryListModel *inventoryModel=[_orderGoodsDetailList objectAtIndex:i];
- if(inventoryModel.projectDetailID!=nil&&inventoryModel.projectDetailID.length>0)
- {
- [promotionOrderGoodsList addObject:inventoryModel];
- }
- }
-
- if(promotionOrderGoodsList!=nil&&promotionOrderGoodsList.count>0)
- {
- for(int i=0;i<promotionOrderGoodsList.count;i++)
- {
- InventoryListModel *inventoryModel=[promotionOrderGoodsList objectAtIndex:i];
- promotionAmount+=[inventoryModel.salesPrice doubleValue]*[inventoryModel.salesQuantity doubleValue];
-
- }
- }
-
- if(_goodsAmount==nil||[_goodsAmount isEqualToString:@""])
- {
- _goodsAmount=@"0";
- }
- factGoodsAmount=[_goodsAmount doubleValue]-promotionAmount;
- if(_promotionOrderModel.reachAmount!=0&&factGoodsAmount<_promotionOrderModel.reachAmount)
- {
- isCanChoose=NO;
- }
-
- if(isCanChoose)
- {
- if(_promotionOrderModel.reachDiscountFlag)
- {
- NSMutableArray *promotionGoodsList=[[NSMutableArray alloc]init];
- for(int i=0;i<_orderGoodsDetailList.count;i++)
- {
- InventoryListModel *goodsModel=[_orderGoodsDetailList objectAtIndex:i];
- if(goodsModel.promotionDetailId!=nil&&goodsModel.promotionDetailId.length>0)
- {
- [promotionGoodsList addObject:goodsModel];
- }
- }
- double factMarkAmount=0;
- for(int i=0;i<promotionGoodsList.count;i++)
- {
- InventoryListModel *goodsModel=[promotionGoodsList objectAtIndex:i];
- factMarkAmount+=[goodsModel.salesQuantity doubleValue]*[goodsModel.markedPrice doubleValue];
- promotionAmount+=[goodsModel.salesQuantity doubleValue]*[goodsModel.salesPrice doubleValue];
- }
- if(_markPriceAmount==nil||[_markPriceAmount isEqualToString:@""])
- {
- _markPriceAmount=@"0";
- }
-
- double discount=[_markPriceAmount doubleValue]-factMarkAmount==0?0:([_goodsAmount doubleValue]-promotionAmount)*100/([_markPriceAmount doubleValue]-factMarkAmount);
- if(_promotionOrderModel.reachDiscount>discount)
- {
- isCanChoose=NO;
- }
-
-
-
-
- }
- else
- {
- if(_promotionOrderModel.reachDiscount>[_fullDiscount doubleValue])
- {
- isCanChoose=NO;
- }
- }
- }
- }
-
- return isCanChoose;
- }
- -(BOOL) isCanChooseFullGift
- {
- double factGoodsAmount=0;
- double promotionAmount=0;
- BOOL isCanChoose=YES;
- NSMutableArray *promotionOrderList=[[NSMutableArray alloc]init];
- if([_promotionOrderModel reachAmountFlag])
- {
- if(_orderGoodsDetailList!=nil&&_orderGoodsDetailList.count>0)
- {
- for(int i=0;i<_orderGoodsDetailList.count;i++)
- {
- InventoryListModel *inventoryModel=[_orderGoodsDetailList objectAtIndex:i];
- if(inventoryModel.promotionDetailId!=nil&&inventoryModel.promotionDetailId.length>0)
- {
- [promotionOrderList addObject:inventoryModel];
- }
-
- }
-
- if(promotionOrderList!=nil&&promotionOrderList.count>0)
- {
- for(int i=0;i<promotionOrderList.count;i++)
- {
- InventoryListModel *inventoryModel=[promotionOrderList objectAtIndex:i];
- promotionAmount+=[inventoryModel.salesPrice doubleValue]*[inventoryModel.salesQuantity doubleValue ];
- }
- }
-
- if(_goodsAmount==nil||[_goodsAmount isEqualToString:@""])
- {
- _goodsAmount=@"0";
- }
-
- factGoodsAmount=[_goodsAmount doubleValue]-promotionAmount;
-
- if(_promotionOrderModel.reachAmount!=0&&factGoodsAmount<_promotionOrderModel.reachAmount)
- {
- isCanChoose=NO;
- }
-
- if(isCanChoose&&_promotionOrderModel.reachDiscount!=0)
- {
- double detailDiscount=0;
- for(int i=0;i<_orderGoodsDetailList.count;i++)
- {
- InventoryListModel *inventoryModel=[_orderGoodsDetailList objectAtIndex:i];
- if(!_promotionOrderModel.reachDiscountFlag&&(inventoryModel.promotionDetailId!=nil&&inventoryModel.promotionDetailId.length>0))
- {
- continue;
- }
-
- if(inventoryModel.discount!=nil&&inventoryModel.discount.length>0)
- {
- detailDiscount=[inventoryModel.discount doubleValue];
- if(detailDiscount<_promotionOrderModel.reachDiscount)
- {
- isCanChoose=NO;
- break;
- }
- }
- else
- {
- isCanChoose=NO;
- break;
- }
- }
- }
- }
- }
- return isCanChoose;
- }
- -(void)loadGoodsDetail
- {
- [self startLoading];
-
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetPromotionDetailData" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_code forKeyedSubscript:@"Code"];
- [dict setObject:_brandId forKeyedSubscript:@"BrandID"];
- [dict setObject:_kindCode forKeyedSubscript:@"KindCode"];
- [dict setObject:_warehouseId forKeyedSubscript:@"WarehouseID"];
-
- [dict setObject:_varietyId forKeyedSubscript:@"VarietyID"];
-
- [dict setObject:_seriesId forKeyedSubscript:@"SeriesID"];
-
- [dict setObject:_specification forKeyedSubscript:@"Specification"];
-
- [dict setObject:_onlyCode forKeyedSubscript:@"OnlyCode"];
-
- [dict setObject:_colorNumber forKeyedSubscript:@"ColorNumber"];
-
- [dict setObject:_gradeIds forKeyedSubscript:@"GradeIDs"];
-
- [dict setObject:_promotionTypeId forKeyedSubscript:@"PromotionsType"];
- [dict setObject:_promotionDetailName forKeyedSubscript:@"PromotionDetailName"];
-
- [dict setObject:_promotionName forKeyedSubscript:@"PromotionName"];
-
- [dict setObject:_organizationCode forKeyedSubscript:@"OrganizationCode"];
-
- [dict setObject:_promotionOrderModel.detailId forKeyedSubscript:@"DetailID"];
-
- _downManager = [[ASIDownManager alloc] init];
- [self startLoading];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onPromotionGoodsListLoadFinish:);
- _downManager.onRequestFail = @selector(onPromotionGoodsListLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- -(void)onPromotionGoodsListLoadFinish:(ASIDownManager *)sender {
- NSDictionary *dic = [sender.mWebStr JSONValue];
- [self stopLoading];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- int iNewCount = 0;
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0)
- {
- NSDictionary *resultDic=[dic objectForKey:@"Result"];
- NSArray *resultArray= [resultDic objectForKey:@"Table"];
-
- if(resultArray!=nil&&resultArray.count>0)
- {
- _orderGoodsDetailList=[[NSMutableArray alloc]init];
- for(int i=0;i<resultArray.count;i++)
- {
- NSDictionary *dic=[resultArray objectAtIndex:i];
- InventoryListModel *model = [InventoryListModel new];
-
- model.promotionGoodsId=[dic objectForKey:@"PromotionGoodsID"];
- int promotionDetailId= [[dic objectForKey:@"PromotionDetailID"]intValue];
- model.promotionDetailId=[NSString stringWithFormat:@"%d",promotionDetailId];
- model.codeId=[[dic objectForKey:@"CodeID"]intValue];
-
- model.code=[dic objectForKey:@"Code"];
-
- model.onlyCode=[dic objectForKey:@"OnlyCode"];
- model.specification=[dic objectForKey:@"Specification"];
- model.brandId=[dic objectForKey:@"BrandID"];
- model.brandName=[dic objectForKey:@"BrandName"];
- model.gradeId=[[dic objectForKey:@"GradeID"]intValue];
- model.gradeName=[dic objectForKey:@"GradeName"];
- model.kindId=[dic objectForKey:@"KindID"];
- model.kindName=[dic objectForKey:@"KindName"];
- model.seriesId=[dic objectForKey:@"SeriesID"];
- model.seriesName=[dic objectForKey:@"SeriesName"];
- model.varietyId=[dic objectForKey:@"VarietyID"];
- model.varietyName=[dic objectForKey:@"VarietyName"];
- model.unitId=[dic objectForKey:@"UnitID"];
- model.unitName=[dic objectForKey:@"UnitName"];
- model.warehouseId=[dic objectForKey:@"WarehouseID"];
- model.wareHouseName=[dic objectForKey:@"WarehouseName"];
- model.positionNumber=[dic objectForKey:@"PositionNumber"];
- double salesPriceValue= [[dic objectForKey:@"SalsePrice"]doubleValue];
- model.salesPrice=[NSString stringWithFormat:@"%lf",salesPriceValue];
- model.usePositionId=@"0";
- model.giftFlag=[[dic objectForKey:@"GiftGoodsFlag"]boolValue];
- int goodsNumberValue= [[dic objectForKey:@"GoodsNumber"]intValue];
- model.goodsQuantity=[NSString stringWithFormat:@"%d",goodsNumberValue];
- model.colorNumber=[dic objectForKey:@"ColorNumber"];
- model.acreage=[[dic objectForKey:@"Acreage"]doubleValue];
- double weightValue= [[dic objectForKey:@"Weight"]doubleValue];
- model.weight=[NSString stringWithFormat:@"%lf",weightValue];
-
- double volumeValue= [[dic objectForKey:@"Volume"]doubleValue];
-
- model.volume=[NSString stringWithFormat:@"%lf",volumeValue];
-
- model.decimalPlaces=[dic objectForKey:@"DecimalPlaces"];
- int promotionTypeId= [[dic objectForKey:@"PromotionTypeDetailID"]intValue];
- model.promotionTypeDetailId=[NSString stringWithFormat:@"%d",promotionTypeId];
- model.circulateType=[[dic objectForKey:@"CirculateType"]integerValue];
-
- int packageValue= [[dic objectForKey:@"Package"]intValue];
- model.package=[NSString stringWithFormat:@"%d",packageValue];
-
- model.goodsName=[dic objectForKey:@"GoodsName"];
- double markedPriceValue= [[dic objectForKey:@"MarkedPrice"]doubleValue];
- model.markedPrice=[NSString stringWithFormat:@"%lf",markedPriceValue];
- int inventoryQuantityValue= [[dic objectForKey:@"InventoryQuantity"]intValue];
- model.inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
-
- int salesQuantityValue= [[dic objectForKey:@"salesQuantity"]intValue];
- model.salesQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
- model.canSaleQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
- model.promotionTypeId=[dic objectForKey:@"PromotionsTypeID"];
- model.acreageFlag=[[dic objectForKey:@"AcreageFlag"]boolValue];
- model.inventoryId=[dic objectForKey:@"InventoryID"];
-
- int goodsNumberHideValue= [[dic objectForKey:@"GoodsNumberHide"]intValue];
- model.goodsQuantityHide=[NSString stringWithFormat:@"%d",goodsNumberHideValue];
-
- int minimumPurchaseQuantityValue= [[dic objectForKey:@"MinimPurchaseQuantity"]intValue];
- model.minimumPurchaseQuantity=[NSString stringWithFormat:@"%d",minimumPurchaseQuantityValue];
-
- model.priceSource=[dic objectForKey:@"PriceSource"];
- model.installationFlag=[dic objectForKey:@"InstallationFlag"];
- model.combinationQuantity=@"0";
- OrderQuantity *orderQuantity=[OrderQuantity new];
- [orderQuantity setSalesOrderDetailBoxAndPiece:[model.salesQuantity intValue] inventoryModel:model];
- [_orderGoodsDetailList addObject:model];
-
- }
- [_vTableView reloadData];
- }
- }
- }
- }
- -(void)onPromotionGoodsListLoadFail:(ASIDownManager *)sender {
- [self stopLoading];
- [self showAlertViewText:@"加载失败"];
- }
- #pragma mark - 委托回调函数
- -(void)goodsQuantityChanged:(NSString*)goodsQuantity position:(NSInteger)pos
- {
- InventoryListModel *inventoryModel= [_orderGoodsDetailList objectAtIndex:pos];
- [inventoryModel setSalesQuantity:goodsQuantity];
- if(goodsQuantity!=nil&&goodsQuantity.length>0)
- {
- OrderQuantity *orderQuantity=[OrderQuantity new];
- [orderQuantity setSalesOrderDetailBoxAndPiece:[goodsQuantity intValue] inventoryModel:inventoryModel];
- if([goodsQuantity doubleValue]>0)
- {
- [inventoryModel setIsCheckedStatus:YES];
- }
- else
- {
- [inventoryModel setIsCheckedStatus:NO];
- }
- }
- else
- {
- [inventoryModel setIsCheckedStatus:NO];
-
- }
- [_vTableView reloadData];
-
- }
- -(void)combinationQuantityChanged:(NSString*)combinationQuantity position:(NSInteger)pos
- {
- InventoryListModel *inventoryModel= [_orderGoodsDetailList objectAtIndex:pos];
- if(combinationQuantity==nil||[combinationQuantity isEqualToString:@""])
- {
- combinationQuantity=@"0";
- }
- if(!inventoryModel.giftFlag)
- {
- for(int i=0;i<_orderGoodsDetailList.count;i++)
- {
- InventoryListModel *goodsModel=[_orderGoodsDetailList objectAtIndex:i];
- if(!goodsModel.giftFlag)
- {
- NSString *goodsQuantityHide=goodsModel.goodsQuantityHide;
- int decimalPlaces=[goodsModel.decimalPlaces intValue];
- double goodsQuantity=[goodsQuantityHide doubleValue]*[combinationQuantity doubleValue];
- NSString *decimalPlacesStr=[NSString stringWithFormat:@"%@%d%@",@"%.",decimalPlaces,@"f"];
- NSString *goodsQuantityStr=[NSString stringWithFormat:decimalPlacesStr,goodsQuantity];
- [goodsModel setSalesQuantity:goodsQuantityStr];
- [goodsModel setCombinationQuantity:combinationQuantity];
- if([combinationQuantity intValue]>0)
- {
- [goodsModel setIsCheckedStatus:YES];
- }
- else{
- [goodsModel setIsCheckedStatus:NO];
- }
-
-
- }
- }
- }
- else{
- double goodsQuantityHideValue= [inventoryModel.goodsQuantityHide doubleValue];
- double goodsQuantityValue=goodsQuantityHideValue*[combinationQuantity doubleValue];
-
- int decimalPlaces=[[inventoryModel decimalPlaces]intValue];
- NSString *decimalPlacesStr=[NSString stringWithFormat:@"%@%d%@",@"%.",decimalPlaces,@"f"];
- NSString *goodsQuantity=[NSString stringWithFormat:decimalPlacesStr,goodsQuantityValue];
- [inventoryModel setSalesQuantity:goodsQuantity];
- [inventoryModel setCombinationQuantity:combinationQuantity];
- if([combinationQuantity intValue]>0)
- {
- [inventoryModel setIsCheckedStatus:YES];
- }
- else{
- [inventoryModel setIsCheckedStatus:NO];
- }
- }
- [_vTableView reloadData];
-
- }
- -(void)btnOrderGoodsSinglePromotionCheckPressed:(OrderGoodsSinglePromotionDetailCell*)cell
- {
- NSInteger pos= cell.position;
- InventoryListModel *goodsModel= [_orderGoodsDetailList objectAtIndex:pos];
- goodsModel.isCheckedStatus=!goodsModel.isCheckedStatus;
- [cell setCheckBackground: goodsModel.isCheckedStatus];
-
- }
- /**
- 单元格cell个数
-
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_orderGoodsDetailList count];
- }
- /**
- <#Description#>
-
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 高度
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return [self.heights[@(indexPath.row)] floatValue];
-
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"OrderGoodsListCell";
- OrderGoodsSinglePromotionDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
- if (!cell) {
- cell=[[OrderGoodsSinglePromotionDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
-
- InventoryListModel *goodsModel= [_orderGoodsDetailList objectAtIndex:indexPath.row];
- cell.delegate = self;
- cell.position=indexPath.row;
-
- [cell setPromotionGoodsDetailCell:goodsModel isCanChoose:_isCanChoose];
- self.heights[@(indexPath.row)] = @(cell.height);
- BOOL checked = goodsModel.isCheckedStatus;
- [cell setCheckBackground:checked];
- return cell;
- }
- /**
- 预防高度
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 355;
- }
- /**
- 高度
-
- @return <#return value description#>
- */
- - (NSMutableDictionary *)heights{
- if (_heights == nil){
- _heights = [NSMutableDictionary dictionary];
- }
- return _heights;
- }
- /**
- 返回函数
- */
- - (void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- @end
|