Commit 7ba8658e authored by 曹云霄's avatar 曹云霄

修改项说明:优化促销条件冲突控制,优先级控制

parent 3a578a82
...@@ -86,12 +86,12 @@ ...@@ -86,12 +86,12 @@
} }
//安装权限降序排列 //安装权限降序排列
NSArray *chooseArray = [array sortedArrayUsingComparator:^NSComparisonResult(NSDictionary *obj1, NSDictionary *obj2) { NSArray *chooseArray = [array sortedArrayUsingComparator:^NSComparisonResult(NSDictionary *obj1, NSDictionary *obj2) {
if (obj1[@"priority"] < obj2[@"priority"]) { if ([obj1[@"priority"] integerValue] < [obj2[@"priority"] integerValue]) {
return NSOrderedAscending;
}
if (obj1[@"priority"] < obj2[@"priority"]) {
return NSOrderedDescending; return NSOrderedDescending;
} }
if ([obj1[@"priority"] integerValue] < [obj2[@"priority"] integerValue]) {
return NSOrderedAscending;
}
return NSOrderedSame; return NSOrderedSame;
}]; }];
//计算促销后的价格 //计算促销后的价格
......
...@@ -69,10 +69,15 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -69,10 +69,15 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
@property (nonatomic,strong) PromotionLuckDrawResultModel *customerDrawModel; @property (nonatomic,strong) PromotionLuckDrawResultModel *customerDrawModel;
/** /**
消费者促销列表<自定义> 消费者促销列表
*/ */
@property (nonatomic,strong) NSMutableArray *customerPromotionArray; @property (nonatomic,strong) NSMutableArray *customerPromotionArray;
/**
导购促销列表
*/
@property (nonatomic,strong) NSMutableArray *guidePromotionArray;
/** /**
微信卡劵 微信卡劵
...@@ -95,6 +100,14 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -95,6 +100,14 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
return _sectionTitle; return _sectionTitle;
} }
- (NSMutableArray *)guidePromotionArray
{
if (!_guidePromotionArray) {
_guidePromotionArray = [NSMutableArray array];
}
return _guidePromotionArray;
}
- (NSMutableArray *)promotionInformationArray - (NSMutableArray *)promotionInformationArray
{ {
if (!_promotionInformationArray) { if (!_promotionInformationArray) {
...@@ -494,14 +507,22 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -494,14 +507,22 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
- (void)scanWeChatCardNumber:(PromotionWeChatCardModel *)weChatModel - (void)scanWeChatCardNumber:(PromotionWeChatCardModel *)weChatModel
{ {
WS(weakSelf); WS(weakSelf);
QRViewController *qrVC = [[QRViewController alloc] initWithScanCompleteHandler:^(NSString *url) { QRViewController *scanVC = [[QRViewController alloc] initWithScanCompleteHandler:^(NSString *url) {
[weakSelf dismissViewControllerAnimated:YES completion:^{ [weakSelf dismissViewControllerAnimated:YES completion:^{
weakSelf.weChatModel.wxcardNumber = url; weakSelf.weChatModel.wxcardNumber = url;
[weakSelf consumerUseWeChatCard:url andOrderTotal:[weakSelf.orderDetails.order.orderPrice stringValue] andOrderNumber:self.orderCode]; [weakSelf consumerUseWeChatCard:url andOrderTotal:[weakSelf.orderDetails.order.orderPrice stringValue] andOrderNumber:self.orderCode];
}]; }];
}]; }];
[scanVC setCancelScanBlock:^{
for (JSONModel *model in weakSelf.promotionInformationArray) {
if ([model isMemberOfClass:[PromotionWeChatCardModel class]]) {
[weakSelf.promotionInformationArray removeObject:model];break;
}
}
[weakSelf.orderDetailsTableview reloadData];
}];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:qrVC animated:YES completion:nil]; [weakSelf presentViewController:scanVC animated:YES completion:nil];
}); });
} }
...@@ -539,6 +560,8 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -539,6 +560,8 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
{ {
if ([body isEqualToString:CONSUMER]) { if ([body isEqualToString:CONSUMER]) {
[self.customerPromotionArray addObject:model]; [self.customerPromotionArray addObject:model];
}else if ([body isEqualToString:GUIDE]) {
[self.guidePromotionArray addObject:model];
} }
} }
...@@ -665,7 +688,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -665,7 +688,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
id json = [NSJSONSerialization JSONObjectWithData:[dict[@"body"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; id json = [NSJSONSerialization JSONObjectWithData:[dict[@"body"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil];
if (json) { if (json) {
if ([json isKindOfClass:[NSDictionary class]]) { if ([json isKindOfClass:[NSDictionary class]]) {
[weakSelf promotionInformationExecutionOrder];
weakSelf.customerDrawModel = [[PromotionLuckDrawResultModel alloc]initWithDictionary:json error:nil]; weakSelf.customerDrawModel = [[PromotionLuckDrawResultModel alloc]initWithDictionary:json error:nil];
if ([BaseViewController isBlankString:weakSelf.customerDrawModel.awardId]) { if ([BaseViewController isBlankString:weakSelf.customerDrawModel.awardId]) {
[weakSelf SHOWPrompttext:@"未中奖"]; [weakSelf SHOWPrompttext:@"未中奖"];
...@@ -700,7 +723,8 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -700,7 +723,8 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
SettlementViewController *settlement = [[SettlementViewController alloc]init]; SettlementViewController *settlement = [[SettlementViewController alloc]init];
settlement.preferredContentSize = CGSizeMake(380, 500); settlement.preferredContentSize = CGSizeMake(380, 500);
settlement.goodsArray = self.orderDetails.orderdetailList; settlement.goodsArray = self.orderDetails.orderdetailList;
settlement.promotionalArray = self.promotionInformationArray; settlement.consumerPromotionalArray = self.promotionInformationArray;
settlement.guidePromotionArray = self.guidePromotionArray;
settlement.orderCode = self.orderCode; settlement.orderCode = self.orderCode;
settlement.resultModel = self.customerDrawModel; settlement.resultModel = self.customerDrawModel;
settlement.weChatModel = self.weChatModel; settlement.weChatModel = self.weChatModel;
...@@ -762,8 +786,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -762,8 +786,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
complete(result); complete(result);
}]; }];
[wkWebView setDismissLuckyDrawController:^{ [wkWebView setDismissLuckyDrawController:^{
[weakSelf promotionInformationExecutionOrder];
[weakSelf payButtonClickAction];
}]; }];
[self presentViewController:wkWebView animated:YES completion:nil]; [self presentViewController:wkWebView animated:YES completion:nil];
} }
......
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
//促销列表按降序排列 //促销列表按降序排列
self.customPromotionDatas = [NSMutableArray arrayWithArray:[promotionArray sortedArrayUsingComparator:^NSComparisonResult(CustomPromotionModel *obj1, CustomPromotionModel *obj2) { self.customPromotionDatas = [NSMutableArray arrayWithArray:[promotionArray sortedArrayUsingComparator:^NSComparisonResult(CustomPromotionModel *obj1, CustomPromotionModel *obj2) {
if (obj1.priority < obj2.priority) { if (obj1.priority < obj2.priority) {
return NSOrderedAscending; return NSOrderedDescending;
} }
if (obj1.priority < obj2.priority) { if (obj1.priority < obj2.priority) {
return NSOrderedDescending; return NSOrderedAscending;
} }
return NSOrderedSame; return NSOrderedSame;
}]]; }]];
...@@ -72,8 +72,16 @@ ...@@ -72,8 +72,16 @@
if (![promotionModel.conflicts containsObject:model1.type] && ![model1.conflicts containsObject:promotionModel.type]) { if (![promotionModel.conflicts containsObject:model1.type] && ![model1.conflicts containsObject:promotionModel.type]) {
for (int i=0;i<weakSelf.customPromotionDatas.count;i++) { for (int i=0;i<weakSelf.customPromotionDatas.count;i++) {
CustomPromotionModel *model2 = weakSelf.customPromotionDatas[i]; CustomPromotionModel *model2 = weakSelf.customPromotionDatas[i];
if (![model2.conflicts containsObject:model1.type] && ![model1.conflicts containsObject:model2.type] && ![model2 isEqual:promotionModel]) { if (![model2.conflicts containsObject:model1.type] && ![model1.conflicts containsObject:model2.type]) {
model1.isSelected = YES; for (int i=0;i<weakSelf.customPromotionDatas.count;i++) {
CustomPromotionModel *model3 = weakSelf.customPromotionDatas[i];
if ([model3.conflicts containsObject:model1.type]) {
break;
}
if (i == weakSelf.customPromotionDatas.count-1) {
model1.isSelected = YES;
}
}
} }
} }
}else { }else {
...@@ -83,6 +91,8 @@ ...@@ -83,6 +91,8 @@
[self.promotionChooseTableView reloadData]; [self.promotionChooseTableView reloadData];
} }
#pragma mark - UITableview #pragma mark - UITableview
- (void)setUpTableView - (void)setUpTableView
{ {
......
...@@ -20,9 +20,14 @@ ...@@ -20,9 +20,14 @@
@property (nonatomic,strong) NSArray *goodsArray; @property (nonatomic,strong) NSArray *goodsArray;
/** /**
* 促销信息 * 消费者促销信息
*/ */
@property (nonatomic,strong) NSArray *promotionalArray; @property (nonatomic,strong) NSArray *consumerPromotionalArray;
/**
导购促销信息
*/
@property (nonatomic,strong) NSArray *guidePromotionArray;
/** /**
* 商品总数量 * 商品总数量
......
...@@ -98,8 +98,8 @@ ...@@ -98,8 +98,8 @@
allPrice += [model.goodsPrice floatValue]*[model.goodsNum floatValue]; allPrice += [model.goodsPrice floatValue]*[model.goodsNum floatValue];
} }
//促销列表 //促销列表
for (JSONModel *model in self.promotionalArray) { for (JSONModel *model in self.consumerPromotionalArray) {
//微信卡劵 //微信卡劵
if ([model isMemberOfClass:[PromotionWeChatCardModel class]]) { if ([model isMemberOfClass:[PromotionWeChatCardModel class]]) {
PromotionWeChatCardModel *weChatModel = (PromotionWeChatCardModel *)model; PromotionWeChatCardModel *weChatModel = (PromotionWeChatCardModel *)model;
weChatPrice = @{@"price":[NSString stringWithFormat:@"%ld",self.weChatModel.wxcardDenomation],@"priority":@(weChatModel.priority)}; weChatPrice = @{@"price":[NSString stringWithFormat:@"%ld",self.weChatModel.wxcardDenomation],@"priority":@(weChatModel.priority)};
...@@ -140,10 +140,10 @@ ...@@ -140,10 +140,10 @@
//安装权限降序排列 //安装权限降序排列
NSArray *chooseArray = [array sortedArrayUsingComparator:^NSComparisonResult(NSDictionary *obj1, NSDictionary *obj2) { NSArray *chooseArray = [array sortedArrayUsingComparator:^NSComparisonResult(NSDictionary *obj1, NSDictionary *obj2) {
if (obj1[@"priority"] < obj2[@"priority"]) { if (obj1[@"priority"] < obj2[@"priority"]) {
return NSOrderedAscending; return NSOrderedDescending;
} }
if (obj1[@"priority"] < obj2[@"priority"]) { if (obj1[@"priority"] < obj2[@"priority"]) {
return NSOrderedDescending; return NSOrderedAscending;
} }
return NSOrderedSame; return NSOrderedSame;
}]; }];
...@@ -370,7 +370,7 @@ ...@@ -370,7 +370,7 @@
// 查询是否有赠送商品促销 // 查询是否有赠送商品促销
order.realAmount = [NSNumber numberWithFloat:[[self.goodsAllPrice.text substringFromIndex:1] floatValue]]; order.realAmount = [NSNumber numberWithFloat:[[self.goodsAllPrice.text substringFromIndex:1] floatValue]];
NSMutableArray *goodsArray = [NSMutableArray array]; NSMutableArray *goodsArray = [NSMutableArray array];
for (id object in self.promotionalArray) { for (id object in self.consumerPromotionalArray) {
if ([object isKindOfClass:[PromotionalGoodsModel class]]) { if ([object isKindOfClass:[PromotionalGoodsModel class]]) {
PromotionalGoodsModel *model = (PromotionalGoodsModel *)object; PromotionalGoodsModel *model = (PromotionalGoodsModel *)object;
if (model.isSelected) { if (model.isSelected) {
...@@ -388,7 +388,7 @@ ...@@ -388,7 +388,7 @@
order.promotionGoods = (NSArray<PromotionGoods> *)goodsArray; order.promotionGoods = (NSArray<PromotionGoods> *)goodsArray;
// 抵扣金额 // 抵扣金额
CGFloat promotionMoney = 0; CGFloat promotionMoney = 0;
for (id object in self.promotionalArray) { for (id object in self.consumerPromotionalArray) {
if ([object isKindOfClass:[PromotionalDeductionModel class]]) { if ([object isKindOfClass:[PromotionalDeductionModel class]]) {
PromotionalDeductionModel *model = (PromotionalDeductionModel *)object; PromotionalDeductionModel *model = (PromotionalDeductionModel *)object;
if (model.isSelected) { if (model.isSelected) {
...@@ -397,24 +397,27 @@ ...@@ -397,24 +397,27 @@
} }
} }
order.promotionMoney = @(promotionMoney); order.promotionMoney = @(promotionMoney);
// 查询是否有京东E卡促销 // 查询是否有京东E卡促销、是否有导购抽奖
NSInteger totalNumber = 0; NSInteger totalNumber = 0;
for (id object in self.promotionalArray) { for (id object in self.guidePromotionArray) {
if ([object isKindOfClass:[PromotionJDECardModel class]]) { if ([object isKindOfClass:[PromotionJDECardModel class]]) {
PromotionJDECardModel *model = (PromotionJDECardModel *)object; PromotionJDECardModel *model = (PromotionJDECardModel *)object;
if ([model.type isEqualToString:JDECardAction] && [model.body isEqualToString:GUIDE]) { if ([model.type isEqualToString:JDECardAction] && [model.body isEqualToString:GUIDE]) {
totalNumber += model.total; totalNumber += model.total;
} }
} }
}
order.jdCardDenomation = totalNumber;
// 查询是否有导购抽奖和客户抽奖
for (id object in self.promotionalArray) {
if ([object isKindOfClass:[PromotionLuckyDrawModel class]]) { if ([object isKindOfClass:[PromotionLuckyDrawModel class]]) {
PromotionLuckyDrawModel *model = (PromotionLuckyDrawModel *)object; PromotionLuckyDrawModel *model = (PromotionLuckyDrawModel *)object;
if ([model.body isEqualToString:GUIDE]) { if ([model.body isEqualToString:GUIDE]) {
order.lotteryId = model.lottery.uuid; order.lotteryId = model.lottery.uuid;
} }
}
}
order.jdCardDenomation = totalNumber;
// 查询是否有客户抽奖
for (id object in self.guidePromotionArray) {
if ([object isKindOfClass:[PromotionLuckyDrawModel class]]) {
PromotionLuckyDrawModel *model = (PromotionLuckyDrawModel *)object;
if ([model.body isEqualToString:CONSUMER]) { if ([model.body isEqualToString:CONSUMER]) {
order.drawId = self.resultModel.drawId; order.drawId = self.resultModel.drawId;
} }
......
...@@ -14,7 +14,13 @@ typedef void(^ScanCompleteBlock)(NSString *url); ...@@ -14,7 +14,13 @@ typedef void(^ScanCompleteBlock)(NSString *url);
@property (nonatomic, copy, readonly) NSString *urlString; @property (nonatomic, copy, readonly) NSString *urlString;
/**
取消扫描
*/
@property (nonatomic,copy) void(^cancelScanBlock)();
- (instancetype)initWithScanCompleteHandler:(ScanCompleteBlock)scanCompleteBlock; - (instancetype)initWithScanCompleteHandler:(ScanCompleteBlock)scanCompleteBlock;
- (void)stopRunning; - (void)stopRunning;
@end @end
...@@ -117,6 +117,9 @@ ...@@ -117,6 +117,9 @@
- (void)pop:(UIButton *)button { - (void)pop:(UIButton *)button {
if (self.cancelScanBlock) {
self.cancelScanBlock();
}
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment