Commit 6a00b24e authored by 曹云霄's avatar 曹云霄

Merge branch 'master' into learningCenter

# Conflicts:
#	Class/OrderdetailsViewController.m
#	Class/PromotionChooseViewController.m
#	Tools/opple_objc_json_client.h
#	Tools/opple_objc_json_client.m
parents 9c26f7db 41e71846
......@@ -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;
}];
//计算促销后的价格
......
This diff is collapsed.
......@@ -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;
}]];
......@@ -70,10 +70,18 @@
}
[self.customPromotionDatas enumerateObjectsUsingBlock:^(CustomPromotionModel *model1, NSUInteger index, BOOL * _Nonnull stop) {
if (![promotionModel.conflicts containsObject:model1.type] && ![model1.conflicts containsObject:promotionModel.type]) {
for (NSInteger i=0;i<weakSelf.customPromotionDatas.count;i++) {
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;break;
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
{
......
......@@ -28,4 +28,6 @@
*/
@property (nonatomic,copy) PromotionLuckDrawResultModel *model;
@end
......@@ -29,7 +29,7 @@
}else if ([promotionModel isMemberOfClass:[PromotionalDeductionModel class]]) {
//抵扣
PromotionalDeductionModel *deductionModel = (PromotionalDeductionModel *)promotionModel;
self.promotionalTitleLabel.text = [NSString stringWithFormat:@"抵扣: %@",deductionModel.descriptionString];
self.promotionalTitleLabel.text = [NSString stringWithFormat:@"抵扣金额: %ld元",deductionModel.total];
}else if ([promotionModel isMemberOfClass:[PromotionLuckyDrawModel class]]) {
//抽奖
self.promotionalTitleLabel.text = [NSString stringWithFormat:@"转盘抽奖: %@",self.model.descriptionString];
......
......@@ -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;
}];
......@@ -367,64 +367,73 @@
order.orderNumber = self.orderCode;
order.fnewstate = PAYSUCCESS;
order.oldstate = NOTPAY;
// 查询是否有赠送商品促销
order.realAmount = [NSNumber numberWithFloat:[[self.goodsAllPrice.text substringFromIndex:1] floatValue]];
NSMutableArray *goodsArray = [NSMutableArray array];
for (id object in self.promotionalArray) {
if ([object isKindOfClass:[PromotionalGoodsModel class]]) {
PromotionalGoodsModel *model = (PromotionalGoodsModel *)object;
if (model.isSelected) {
PromotionGoods *goods = [[PromotionGoods alloc]init];
UCN *goodDetails = [[UCN alloc]init];
goodDetails.code = model.goods.code;
goodDetails.uuid = model.goods.uuid;
goodDetails.name = model.goods.name;
goods.goods = goodDetails;
goods.promotionNumber = [NSNumber numberWithInteger:model.count];
[goodsArray addObject:goods];
}
}
}
order.promotionGoods = (NSArray<PromotionGoods> *)goodsArray;
// 抵扣金额
CGFloat promotionMoney = 0;
for (id object in self.promotionalArray) {
if ([object isKindOfClass:[PromotionalDeductionModel class]]) {
PromotionalDeductionModel *model = (PromotionalDeductionModel *)object;
if (model.isSelected) {
promotionMoney += model.total;
}
}
}
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;
// 查询是否有消费者抽奖促销、微信卡劵促销、抵扣金额、商品促销
CGFloat promotionMoney = 0;
NSInteger deductionPrority = 0;//抵扣优先级
NSInteger goodsPrority = 0;//商品促销优先级
NSMutableArray *goodsArray = [NSMutableArray array];
for (id object in self.consumerPromotionalArray) {
if ([object isKindOfClass:[PromotionLuckyDrawModel class]]) {
PromotionLuckyDrawModel *model = (PromotionLuckyDrawModel *)object;
if ([model.body isEqualToString:CONSUMER]) {
order.drawId = self.resultModel.drawId;
order.drawPrority = model.priority;
}
}
if ([object isKindOfClass:[PromotionWeChatCardModel class]]) {
PromotionWeChatCardModel *model = (PromotionWeChatCardModel *)object;
if ([model.body isEqualToString:CONSUMER]) {
if (![[self class] isBlankString:self.weChatModel.wxcardNumber]) {
order.wxcardNumber = self.weChatModel.wxcardNumber;
order.wxcardDenomation = [NSNumber numberWithInteger:self.weChatModel.wxcardDenomation];
order.wxCardPrority = model.priority;
}
}
}
if ([object isKindOfClass:[PromotionalDeductionModel class]]) {
PromotionalDeductionModel *model = (PromotionalDeductionModel *)object;
if (model.isSelected) {
promotionMoney += model.total;
deductionPrority = model.priority;
}
}
if ([object isKindOfClass:[PromotionalGoodsModel class]]) {
PromotionalGoodsModel *model = (PromotionalGoodsModel *)object;
if (model.isSelected) {
PromotionGoods *goods = [[PromotionGoods alloc]init];
UCN *goodDetails = [[UCN alloc]init];
goodDetails.code = model.goods.code;
goodDetails.uuid = model.goods.uuid;
goodDetails.name = model.goods.name;
goods.goods = goodDetails;
goods.promotionNumber = [NSNumber numberWithInteger:model.count];
[goodsArray addObject:goods];
}
goodsPrority = model.priority;
}
}
// 查询是否有微信卡劵促销
if (![[self class] isBlankString:self.weChatModel.wxcardNumber]) {
order.wxcardNumber = self.weChatModel.wxcardNumber;
order.wxcardDenomation = [NSNumber numberWithInteger:self.weChatModel.wxcardDenomation];
}
order.promotionMoney = @(promotionMoney);
order.deductionPrority = deductionPrority;
order.promotionGoods = (NSArray<PromotionGoods> *)goodsArray;
order.goodsPrority = goodsPrority;
//支付类型
if (self.payTreasureButton.selected) {
order.payType = @"005";
......
......@@ -12,6 +12,7 @@
@property (nonatomic,strong) WKWebView *webView;
@property (nonatomic,strong) WKWebViewConfiguration *config;
@property (nonatomic,strong) UIButton *dismissButton;
@end
......@@ -61,15 +62,15 @@
#pragma mark - 添加删除按钮
- (void)addDismissButton
{
UIButton *dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:dismissButton];
[dismissButton mas_makeConstraints:^(MASConstraintMaker *make) {
self.dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:self.dismissButton];
[self.dismissButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(40);
make.top.mas_equalTo(40);
make.size.mas_equalTo(CGSizeMake(50, 50));
}];
[dismissButton setBackgroundImage:TCImage(@"1") forState:UIControlStateNormal];
[dismissButton addTarget:self action:@selector(dismissButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self.dismissButton setBackgroundImage:TCImage(@"1") forState:UIControlStateNormal];
[self.dismissButton addTarget:self action:@selector(dismissButtonClick) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - WKScriptMessageHandler
......@@ -78,8 +79,19 @@
if ([message.name isEqualToString:@"AppModel"]) {
// 打印所传过来的参数,只支持NSNumber, NSString, NSDate, NSArray,
// NSDictionary, and NSNull类型
if (self.luckyDrawFinishBlock) {
self.luckyDrawFinishBlock(message.body);
id json = [NSJSONSerialization JSONObjectWithData:[message.body[@"body"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil];
if (json) {
if ([json isKindOfClass:[NSDictionary class]]) {
NSDictionary *resultDict = (NSDictionary *)json;
if ([[resultDict allKeys] containsObject:@"click"]) {
self.dismissButton.enabled = NO;
}else {
self.dismissButton.enabled = YES;
if (self.luckyDrawFinishBlock) {
self.luckyDrawFinishBlock(resultDict);
}
}
}
}
}
}
......
......@@ -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,7 +117,12 @@
- (void)pop:(UIButton *)button {
[self dismissViewControllerAnimated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:^{
if (self.cancelScanBlock) {
self.cancelScanBlock();
}
}];
}
#pragma mark - Public Method
......
This diff is collapsed.
This diff is collapsed.
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