Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
Opple-iOS
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
Opple-iOS
Commits
3a578a82
Commit
3a578a82
authored
8 years ago
by
曹云霄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改项说明:完成微信卡劵促销,完成促销优先级,完成促销冲突判定
parent
2cda6688
master
dev
No related merge requests found
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
237 additions
and
87 deletions
+237
-87
AllpriceTableViewCell.h
Class/AllpriceTableViewCell.h
+10
-0
AllpriceTableViewCell.m
Class/AllpriceTableViewCell.m
+101
-28
OrderdetailsViewController.m
Class/OrderdetailsViewController.m
+32
-28
PromotionWeChatCardModel.h
Class/PromotionWeChatCardModel.h
+1
-1
PromotionalTableViewCell.h
Class/PromotionalTableViewCell.h
+7
-1
PromotionalTableViewCell.m
Class/PromotionalTableViewCell.m
+3
-4
SettlementViewController.h
Class/SettlementViewController.h
+0
-5
SettlementViewController.m
Class/SettlementViewController.m
+80
-19
BaseViewController.m
Tools/BaseViewController.m
+1
-1
NetworkRequestClassManager.m
Tools/NetworkRequestClassManager.m
+2
-0
No files found.
Class/AllpriceTableViewCell.h
View file @
3a578a82
...
...
@@ -11,6 +11,10 @@
#import "ShopcarModel.h"
#import "PromotionalDeductionModel.h"
#import "PromotionalGoodsModel.h"
#import "PromotionLuckyDrawModel.h"
#import "PromotionalGoodsModel.h"
#import "PromotionalDeductionModel.h"
#import "PromotionWeChatCardModel.h"
@interface
AllpriceTableViewCell
:
UITableViewCell
...
...
@@ -48,4 +52,10 @@
*/
@property
(
nonatomic
,
copy
)
NSArray
*
promotionalArray
;
/**
微信卡劵
*/
@property
(
nonatomic
,
strong
)
WeChatCardModel
*
weChatModel
;
@end
This diff is collapsed.
Click to expand it.
Class/AllpriceTableViewCell.m
View file @
3a578a82
...
...
@@ -8,6 +8,7 @@
#import "AllpriceTableViewCell.h"
@implementation
AllpriceTableViewCell
-
(
void
)
awakeFromNib
{
...
...
@@ -36,42 +37,114 @@
_goodsArray
=
goodsArray
;
NSInteger
allNumber
=
0
;
//总数量
CGFloat
allPrice
=
0
;
//总价格
CGFloat
newPrice
=
0
;
//折后价格
CGFloat
deductionPrice
=
0
;
//抵扣金额
NSDictionary
*
deductionPrice
=
nil
;
//抵扣金额
NSDictionary
*
weChatPrice
=
nil
;
//微信卡劵
NSDictionary
*
drawPrice
=
nil
;
//转盘抽奖
for
(
TOOrderdetailEntity
*
model
in
_goodsArray
)
{
allNumber
+=
[
model
.
goodsNum
integerValue
];
allPrice
+=
[
model
.
goodsPrice
floatValue
]
*
[
model
.
goodsNum
intValue
];
}
newPrice
=
allPrice
;
// 抽奖折扣
if
(
!
[
BaseViewController
isBlankString
:
self
.
model
.
number
])
{
newPrice
=
allPrice
*
([
self
.
model
.
number
integerValue
]
/
100
.
0
);
allPrice
+=
[
model
.
goodsPrice
floatValue
]
*
[
model
.
goodsNum
floatValue
];
}
// 全局抵扣
for
(
id
object
in
self
.
promotionalArray
)
{
if
([
object
isKindOfClass
:[
PromotionalDeductionModel
class
]])
{
PromotionalDeductionModel
*
model
=
(
PromotionalDeductionModel
*
)
object
;
if
([
model
.
type
isEqualToString
:
@"deductionAction"
]
&&
model
.
isSelected
)
{
deductionPrice
=
model
.
total
;
}
//促销列表
for
(
JSONModel
*
model
in
self
.
promotionalArray
)
{
//微信卡劵
if
([
model
isMemberOfClass
:[
PromotionWeChatCardModel
class
]])
{
PromotionWeChatCardModel
*
newWeChatModel
=
(
PromotionWeChatCardModel
*
)
model
;
weChatPrice
=
@{
@"price"
:
[
NSString
stringWithFormat
:
@"%ld"
,
self
.
weChatModel
.
wxcardDenomation
],
@"priority"
:
@
(
newWeChatModel
.
priority
)};
}
else
if
([
model
isMemberOfClass
:[
PromotionalDeductionModel
class
]])
{
//抵扣
PromotionalDeductionModel
*
deductionModel
=
(
PromotionalDeductionModel
*
)
model
;
deductionPrice
=
@{
@"price"
:
[
NSString
stringWithFormat
:
@"%ld"
,
deductionModel
.
total
],
@"priority"
:
@
(
deductionModel
.
priority
)};
}
else
if
([
model
isMemberOfClass
:[
PromotionLuckyDrawModel
class
]])
{
//抽奖
PromotionLuckyDrawModel
*
drawModel
=
(
PromotionLuckyDrawModel
*
)
model
;
drawPrice
=
@{
@"price"
:
[
NSString
stringWithFormat
:
@"%@"
,
self
.
model
.
number
],
@"priority"
:
@
(
drawModel
.
priority
)};
}
else
if
([
model
isMemberOfClass
:[
PromotionalGoodsModel
class
]])
{
//送商品
// PromotionalGoodsModel *goodsModel = (PromotionalGoodsModel *)model;
}
}
NSString
*
goodsAllPriceString
=
nil
;
if
(
deductionPrice
&&
newPrice
!=
allPrice
)
{
goodsAllPriceString
=
[
NSString
stringWithFormat
:
@"¥%.2f (%.2f x %@ - %.2f)"
,
newPrice
-
deductionPrice
,
allPrice
,
self
.
model
.
descriptionString
,
deductionPrice
];
}
else
if
(
newPrice
==
allPrice
&&
!
deductionPrice
){
goodsAllPriceString
=
[
NSString
stringWithFormat
:
@"¥%.2f"
,
newPrice
];
}
else
if
(
newPrice
==
allPrice
&&
deductionPrice
){
goodsAllPriceString
=
[
NSString
stringWithFormat
:
@"¥%.2f (%.2f - %.2f)"
,
newPrice
-
deductionPrice
,
allPrice
,
deductionPrice
];
}
else
if
(
newPrice
!=
allPrice
&&
!
deductionPrice
){
goodsAllPriceString
=
[
NSString
stringWithFormat
:
@"¥%.2f (%.2f x %@)"
,
newPrice
-
deductionPrice
,
allPrice
,
self
.
model
.
descriptionString
];
}
NSString
*
goodsAllPriceString
=
[
self
promotionSorting
:
deductionPrice
andWeChatPrice
:
weChatPrice
andDrawPrice
:
drawPrice
andAllPrice
:
allPrice
];
self
.
goodsAllNumber
.
text
=
[
NSString
stringWithFormat
:
@"%ld"
,
allNumber
];
self
.
goodsAllPrice
.
text
=
goodsAllPriceString
;
}
#pragma mark - 通过优先级排列促销项
-
(
NSString
*
)
promotionSorting
:
(
NSDictionary
*
)
deductionPrice
andWeChatPrice
:
(
NSDictionary
*
)
weChatPrice
andDrawPrice
:
(
NSDictionary
*
)
drawPrice
andAllPrice
:
(
CGFloat
)
allPrice
{
NSMutableArray
*
array
=
[
NSMutableArray
array
];
if
(
deductionPrice
)
{
[
array
addObject
:
deductionPrice
];
}
if
(
weChatPrice
)
{
[
array
addObject
:
weChatPrice
];
}
if
(
drawPrice
)
{
[
array
addObject
:
drawPrice
];
}
//安装权限降序排列
NSArray
*
chooseArray
=
[
array
sortedArrayUsingComparator
:
^
NSComparisonResult
(
NSDictionary
*
obj1
,
NSDictionary
*
obj2
)
{
if
(
obj1
[
@"priority"
]
<
obj2
[
@"priority"
])
{
return
NSOrderedAscending
;
}
if
(
obj1
[
@"priority"
]
<
obj2
[
@"priority"
])
{
return
NSOrderedDescending
;
}
return
NSOrderedSame
;
}];
//计算促销后的价格
CGFloat
newPrice
=
allPrice
;
NSMutableString
*
priceString
=
[
NSMutableString
string
];
for
(
NSDictionary
*
dict
in
chooseArray
)
{
if
([
dict
isEqual
:
deductionPrice
])
{
CGFloat
deduction
=
[
dict
[
@"price"
]
floatValue
];
newPrice
=
newPrice
-
deduction
;
[
priceString
appendString
:[
NSString
stringWithFormat
:
@" - %.2f"
,
deduction
]];
}
else
if
([
dict
isEqual
:
weChatPrice
]){
CGFloat
weChat
=
[
dict
[
@"price"
]
floatValue
];
newPrice
=
newPrice
-
weChat
;
[
priceString
appendString
:[
NSString
stringWithFormat
:
@" - %.2f"
,
weChat
]];
}
else
if
([
dict
isEqual
:
drawPrice
]){
CGFloat
draw
=
[
self
.
model
.
number
floatValue
]
/
100
.
0
;
newPrice
=
newPrice
*
draw
;
[
priceString
appendString
:[
NSString
stringWithFormat
:
@" x %@"
,
self
.
model
.
descriptionString
]];
}
}
//判断促销是否为空
if
(
chooseArray
.
count
)
{
if
(
newPrice
<
0
)
{
newPrice
=
0
;
}
[
priceString
insertString
:[
NSString
stringWithFormat
:
@"¥%.2f(%.2f"
,
newPrice
,
allPrice
]
atIndex
:
0
];
[
priceString
appendString
:
@")"
];
}
else
{
priceString
=
[
NSMutableString
stringWithString
:[
NSString
stringWithFormat
:
@"¥%.2f"
,
allPrice
]];
}
return
priceString
;
}
@end
This diff is collapsed.
Click to expand it.
Class/OrderdetailsViewController.m
View file @
3a578a82
This diff is collapsed.
Click to expand it.
Class/PromotionWeChatCardModel.h
View file @
3a578a82
...
...
@@ -16,7 +16,7 @@
//** 类型 */
@property
(
nonatomic
,
copy
)
NSString
*
type
;
//
** 抵扣金额 */
//
卡劵面额
@property
(
nonatomic
,
assign
)
NSInteger
total
;
//** 描述 */
...
...
This diff is collapsed.
Click to expand it.
Class/PromotionalTableViewCell.h
View file @
3a578a82
...
...
@@ -7,7 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "PromotionLuckDrawResultModel.h"
@interface
PromotionalTableViewCell
:
UITableViewCell
...
...
@@ -22,4 +22,10 @@
*/
@property
(
nonatomic
,
copy
)
JSONModel
*
promotionModel
;
/**
* 抽奖结果
*/
@property
(
nonatomic
,
copy
)
PromotionLuckDrawResultModel
*
model
;
@end
This diff is collapsed.
Click to expand it.
Class/PromotionalTableViewCell.m
View file @
3a578a82
...
...
@@ -25,19 +25,18 @@
//微信卡劵
if
([
promotionModel
isMemberOfClass
:[
PromotionWeChatCardModel
class
]])
{
PromotionWeChatCardModel
*
weChatModel
=
(
PromotionWeChatCardModel
*
)
promotionModel
;
self
.
promotionalTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"微信卡劵: %
@"
,
weChatModel
.
descriptionString
];
self
.
promotionalTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"微信卡劵: %
ld"
,
weChatModel
.
total
];
}
else
if
([
promotionModel
isMemberOfClass
:[
PromotionalDeductionModel
class
]])
{
//抵扣
PromotionalDeductionModel
*
deductionModel
=
(
PromotionalDeductionModel
*
)
promotionModel
;
self
.
promotionalTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"抵扣: %@"
,
deductionModel
.
descriptionString
];
}
else
if
([
promotionModel
isMemberOfClass
:[
PromotionLuckyDrawModel
class
]])
{
//抽奖
PromotionLuckyDrawModel
*
drawModel
=
(
PromotionLuckyDrawModel
*
)
promotionModel
;
self
.
promotionalTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"转盘抽奖: %@"
,
drawModel
.
descriptionString
];
self
.
promotionalTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"转盘抽奖: %@"
,
self
.
model
.
descriptionString
];
}
else
if
([
promotionModel
isMemberOfClass
:[
PromotionalGoodsModel
class
]])
{
//送商品
PromotionalGoodsModel
*
goodsModel
=
(
PromotionalGoodsModel
*
)
promotionModel
;
self
.
promotionalTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"赠送商品: %@"
,
goodsModel
.
descriptionString
];
self
.
promotionalTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"赠送商品: %@"
,
goodsModel
.
goods
.
name
];
}
self
.
accessoryType
=
UITableViewCellAccessoryCheckmark
;
}
...
...
This diff is collapsed.
Click to expand it.
Class/SettlementViewController.h
View file @
3a578a82
...
...
@@ -24,11 +24,6 @@
*/
@property
(
nonatomic
,
strong
)
NSArray
*
promotionalArray
;
///**
// * 促销信息(京东E卡、抽奖)
// */
//@property (nonatomic,strong) NSArray *luckyDrawAndJDECardArray;
/**
* 商品总数量
*/
...
...
This diff is collapsed.
Click to expand it.
Class/SettlementViewController.m
View file @
3a578a82
...
...
@@ -87,32 +87,90 @@
-
(
void
)
setGoodsArray
{
NSInteger
goodsAllNumber
=
0
;
//总数量
CGFloat
goodAllprice
=
0
;
//总价格
for
(
TOOrderdetailEntity
*
model
in
_goodsArray
)
{
goodsAllNumber
+=
[
model
.
goodsNum
integerValue
];
goodAllprice
+=
[
model
.
goodsPrice
floatValue
]
*
[
model
.
goodsNum
integerValue
];
}
// 促销金额大于商品金额情况
goodAllprice
=
(
goodAllprice
<
0
)?
0
:
goodAllprice
;
// 抽奖结果<打折>
if
([
self
.
resultModel
.
type
isEqualToString
:
@"discount"
])
{
goodAllprice
=
goodAllprice
*
([
self
.
resultModel
.
number
integerValue
]
/
100
.
0
);
CGFloat
allPrice
=
0
;
//实际支付金额
NSDictionary
*
deductionPrice
=
nil
;
//抵扣金额
NSDictionary
*
weChatPrice
=
nil
;
//微信卡劵
NSDictionary
*
drawPrice
=
nil
;
//转盘抽奖
for
(
TOOrderdetailEntity
*
model
in
_goodsArray
)
{
allPrice
+=
[
model
.
goodsPrice
floatValue
]
*
[
model
.
goodsNum
floatValue
];
}
//** 促销金额 */
NSInteger
totalNumber
=
0
;
for
(
id
object
in
self
.
promotionalArray
)
{
if
([
object
isKindOfClass
:[
PromotionalDeductionModel
class
]])
{
PromotionalDeductionModel
*
model
=
(
PromotionalDeductionModel
*
)
object
;
if
(
model
.
isSelected
)
{
totalNumber
+=
model
.
total
;
}
//促销列表
for
(
JSONModel
*
model
in
self
.
promotionalArray
)
{
//微信卡劵
if
([
model
isMemberOfClass
:[
PromotionWeChatCardModel
class
]])
{
PromotionWeChatCardModel
*
weChatModel
=
(
PromotionWeChatCardModel
*
)
model
;
weChatPrice
=
@{
@"price"
:
[
NSString
stringWithFormat
:
@"%ld"
,
self
.
weChatModel
.
wxcardDenomation
],
@"priority"
:
@
(
weChatModel
.
priority
)};
}
else
if
([
model
isMemberOfClass
:[
PromotionalDeductionModel
class
]])
{
//抵扣
PromotionalDeductionModel
*
deductionModel
=
(
PromotionalDeductionModel
*
)
model
;
deductionPrice
=
@{
@"price"
:
[
NSString
stringWithFormat
:
@"%ld"
,
deductionModel
.
total
],
@"priority"
:
@
(
deductionModel
.
priority
)};
}
else
if
([
model
isMemberOfClass
:[
PromotionLuckyDrawModel
class
]])
{
//抽奖
PromotionLuckyDrawModel
*
drawModel
=
(
PromotionLuckyDrawModel
*
)
model
;
drawPrice
=
@{
@"price"
:
[
NSString
stringWithFormat
:
@"%@"
,
self
.
resultModel
.
number
],
@"priority"
:
@
(
drawModel
.
priority
)};
}
else
if
([
model
isMemberOfClass
:[
PromotionalGoodsModel
class
]])
{
//送商品
// PromotionalGoodsModel *goodsModel = (PromotionalGoodsModel *)model;
}
}
goodAllprice
-=
totalNumber
;
CGFloat
goodsAllPrice
=
[
self
promotionSorting
:
deductionPrice
andWeChatPrice
:
weChatPrice
andDrawPrice
:
drawPrice
andAllPrice
:
allPrice
]
;
self
.
goodsAllNumber
.
text
=
[
NSString
stringWithFormat
:
@"%ld"
,
goodsAllNumber
];
self
.
goodsAllPrice
.
text
=
[
NSString
stringWithFormat
:
@"¥%.2f"
,
good
Allp
rice
];
self
.
goodsAllPrice
.
text
=
[
NSString
stringWithFormat
:
@"¥%.2f"
,
good
sAllP
rice
];
}
#pragma mark - 通过优先级排列促销项
-
(
CGFloat
)
promotionSorting
:
(
NSDictionary
*
)
deductionPrice
andWeChatPrice
:
(
NSDictionary
*
)
weChatPrice
andDrawPrice
:
(
NSDictionary
*
)
drawPrice
andAllPrice
:
(
CGFloat
)
allPrice
{
NSMutableArray
*
array
=
[
NSMutableArray
array
];
if
(
deductionPrice
)
{
[
array
addObject
:
deductionPrice
];
}
if
(
weChatPrice
)
{
[
array
addObject
:
weChatPrice
];
}
if
(
drawPrice
)
{
[
array
addObject
:
drawPrice
];
}
//安装权限降序排列
NSArray
*
chooseArray
=
[
array
sortedArrayUsingComparator
:
^
NSComparisonResult
(
NSDictionary
*
obj1
,
NSDictionary
*
obj2
)
{
if
(
obj1
[
@"priority"
]
<
obj2
[
@"priority"
])
{
return
NSOrderedAscending
;
}
if
(
obj1
[
@"priority"
]
<
obj2
[
@"priority"
])
{
return
NSOrderedDescending
;
}
return
NSOrderedSame
;
}];
//计算促销后的价格
CGFloat
newPrice
=
allPrice
;
for
(
NSDictionary
*
dict
in
chooseArray
)
{
if
([
dict
isEqual
:
deductionPrice
])
{
CGFloat
deduction
=
[
dict
[
@"price"
]
floatValue
];
newPrice
=
newPrice
-
deduction
;
}
else
if
([
dict
isEqual
:
weChatPrice
]){
CGFloat
weChat
=
[
dict
[
@"price"
]
floatValue
];
newPrice
=
newPrice
-
weChat
;
}
else
if
([
dict
isEqual
:
drawPrice
]){
CGFloat
draw
=
[
self
.
resultModel
.
number
floatValue
]
/
100
.
0
;
newPrice
=
newPrice
*
draw
;
}
}
//判断促销是否为空
if
(
chooseArray
.
count
)
{
if
(
newPrice
<
0
)
{
newPrice
=
0
;
}
}
return
newPrice
;
}
#pragma mark -获取经营者支付二维码
-
(
void
)
getPayQrCode
...
...
@@ -309,7 +367,6 @@
order
.
orderNumber
=
self
.
orderCode
;
order
.
fnewstate
=
PAYSUCCESS
;
order
.
oldstate
=
NOTPAY
;
order
.
drawId
=
self
.
resultModel
.
drawId
;
// 查询是否有赠送商品促销
order
.
realAmount
=
[
NSNumber
numberWithFloat
:[[
self
.
goodsAllPrice
.
text
substringFromIndex
:
1
]
floatValue
]];
NSMutableArray
*
goodsArray
=
[
NSMutableArray
array
];
...
...
@@ -351,13 +408,16 @@
}
}
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
;
}
if
([
model
.
body
isEqualToString
:
CONSUMER
])
{
order
.
drawId
=
self
.
resultModel
.
drawId
;
}
}
}
// 查询是否有微信卡劵促销
...
...
@@ -394,6 +454,7 @@
}
[
self
CreateMBProgressHUDLoding
];
WS
(
weakSelf
);
NSSLog
(
@"%@"
,[
order
toDictionary
]);
[[
NetworkRequestClassManager
Manager
]
NetworkRequestWithURL
:
SERVERREQUESTURL
(
CONFIRMPAY
)
WithCallClass
:
weakSelf
WithRequestType
:
0
WithParameter
:
order
WithReturnValueBlock
:^
(
id
returnValue
)
{
[
weakSelf
RemoveMBProgressHUDLoding
];
...
...
This diff is collapsed.
Click to expand it.
Tools/BaseViewController.m
View file @
3a578a82
...
...
@@ -181,7 +181,7 @@
UIImage
*
image
=
[[
UIImage
imageNamed
:
@"Checkmark"
]
imageWithRenderingMode
:
UIImageRenderingModeAlwaysOriginal
];
hud
.
customView
=
[[
UIImageView
alloc
]
initWithImage
:
image
];
hud
.
color
=
[[
UIColor
blackColor
]
colorWithAlphaComponent
:
0
.
6
];
hud
.
labelFont
=
[
UIFont
systemFontOfSize
:
1
2
];
hud
.
labelFont
=
[
UIFont
systemFontOfSize
:
1
5
];
hud
.
labelText
=
successString
;
[
hud
hide
:
YES
afterDelay
:
3
];
}
...
...
This diff is collapsed.
Click to expand it.
Tools/NetworkRequestClassManager.m
View file @
3a578a82
...
...
@@ -50,6 +50,8 @@ static NetworkRequestClassManager *manager = nil;
manager
.
requestSerializer
=
[
AFJSONRequestSerializer
serializer
];
manager
.
requestSerializer
.
timeoutInterval
=
60
.
0
f
;
[
manager
.
requestSerializer
setValue
:
@"application/json;charset=utf-8"
forHTTPHeaderField
:
@"Content-Type"
];
[
manager
.
requestSerializer
setValue
:[[[
NSBundle
mainBundle
]
infoDictionary
]
objectForKey
:
@"CFBundleShortVersionString"
]
forHTTPHeaderField
:
@"version"
];
return
manager
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment