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

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

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