Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FMVip_Today
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
FMVip_Today
Commits
2c93a60f
Commit
2c93a60f
authored
Sep 19, 2016
by
NitefllWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.新增警告类型弹窗。2.修复结算时未传给服务器代金券。3.新增Coupon(代金券)结构体,代金券以此类型存储在map中。4.修改代金券展示列表,选中的代金券总额超过待付时弹出警告框。
parent
ccbedfbc
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
32 deletions
+89
-32
FMVip/fmmsgwnd.cpp
+14
-0
FMVip/fmmsgwnd.h
+5
-1
FMVip/fmvipdispatcher.cpp
+1
-2
FMVip/fmvipforward.cpp
+17
-17
FMVip/fmvipforward.h
+10
-3
FMVip/fmviporder.cpp
+17
-7
FMVip/fmviporder.h
+24
-2
FMVip/res/FMVip.qrc
+1
-0
FMVip/res/tip_warning.png
+0
-0
No files found.
FMVip/fmmsgwnd.cpp
View file @
2c93a60f
...
...
@@ -26,6 +26,9 @@ void FMMsgWnd::show(InfoType type, const QString &info)
case
InfoType
:
:
T_Failure
:
iconUrl
=
":/tip_error.png"
;
break
;
case
InfoType
:
:
T_Warning
:
iconUrl
=
":/tip_warning.png"
;
break
;
default
:
iconUrl
=
""
;
break
;
...
...
@@ -43,6 +46,17 @@ void FMMsgWnd::show(InfoType type, const QString &info)
QDialog
::
exec
();
}
void
FMMsgWnd
::
FailureWnd
(
const
QString
&
info
)
{
FMMsgWnd
window
;
window
.
show
(
FMMsgWnd
::
T_Failure
,
info
);
}
void
FMMsgWnd
::
WarningWnd
(
const
QString
&
info
)
{
FMMsgWnd
window
;
window
.
show
(
FMMsgWnd
::
T_Warning
,
info
);
}
void
FMMsgWnd
::
on_alertBtnOk_clicked
()
{
this
->
close
();
...
...
FMVip/fmmsgwnd.h
View file @
2c93a60f
...
...
@@ -19,9 +19,13 @@ public:
{
T_Normal
,
T_Success
,
T_Failure
T_Failure
,
T_Warning
};
void
show
(
InfoType
type
=
T_Normal
,
const
QString
&
info
=
""
);
static
void
FailureWnd
(
const
QString
&
info
);
static
void
WarningWnd
(
const
QString
&
info
);
private
slots
:
void
on_alertBtnOk_clicked
();
...
...
FMVip/fmvipdispatcher.cpp
View file @
2c93a60f
...
...
@@ -189,8 +189,7 @@ void FMVipDispatcher::onServerResponsed(const QJsonObject &rspObj)
if
(
prompt
==
0
)
{
QString
msg
=
rspObj
[
"msg"
].
toString
();
FMMsgWnd
msgWnd
;
msgWnd
.
show
(
FMMsgWnd
::
T_Failure
,
msg
);
FMMsgWnd
::
FailureWnd
(
msg
);
}
requestSuccess
=
false
;
_vindow
=
0
;
...
...
FMVip/fmvipforward.cpp
View file @
2c93a60f
...
...
@@ -218,19 +218,22 @@ void FMVipForward::final(const QJsonObject &job, QJsonObject &fmjob)
QJsonArray
pay_ids
=
posTransObj
[
"pay_ids"
].
toArray
();
fmjob
[
"memberTransId"
]
=
job
[
"fm_id"
];
transObj
[
"coupons"
]
=
posTransObj
[
"coupons"
];
QJsonArray
coupons
=
posTransObj
[
"coupons"
].
toArray
();
int
codeAmount
=
0
,
scoreAmount
=
0
,
cashAmount
=
0
,
thirdAmount
=
0
;
foreach
(
QJsonValue
pay_v
,
pay_ids
)
{
QJsonObject
pay_ob
=
pay_v
.
toObject
();
if
(
pay_ob
[
"pay_id"
]
==
"24"
)
{
QString
type
=
pay_ob
[
"pay_id"
].
toString
();
if
(
type
==
"24"
)
{
codeAmount
=
pay_ob
[
"paid_total_amount"
].
toInt
();
}
if
(
pay_ob
[
"pay_id"
]
==
"25"
)
{
}
else
if
(
type
==
"25"
)
{
scoreAmount
=
pay_ob
[
"paid_total_amount"
].
toInt
();
}
else
if
(
type
==
"77"
)
{
coupons
.
append
(
pay_ob
[
"code"
].
toString
());
}
}
transObj
[
"coupons"
]
=
coupons
;
cashAmount
=
paidAmount
-
codeAmount
-
scoreAmount
-
thirdAmount
;
transObj
[
"amount"
]
=
amount
;
transObj
[
"payAmount"
]
=
paidAmount
;
...
...
@@ -287,13 +290,10 @@ void FMVipForward::logined(const QJsonObject &serverJob, QJsonObject &posJob)
{
QJsonObject
co
=
value
.
toObject
();
QString
codeStr
=
co
[
"couponCode"
].
toString
();
double
amount
Str
=
co
[
"disAmount"
].
toInt
()
/
100.0
;
double
amount
=
co
[
"disAmount"
].
toInt
()
/
100.0
;
QString
desc
=
co
[
"desc"
].
toString
();
QString
couponInfo
=
QString
(
"券码:%1 金额:%2 备注:%3"
)
.
arg
(
codeStr
)
.
arg
(
amountStr
)
.
arg
(
desc
);
_sessionCouponMap
[
co
[
"couponCode"
].
toString
()]
=
couponInfo
;
_sessionCouponMap
[
co
[
"couponCode"
].
toString
()]
=
Coupon
{
codeStr
,
amount
,
desc
};
}
QString
name
=
memberObj
[
"name"
].
toString
();
...
...
@@ -443,11 +443,6 @@ void FMVipForward::addSessionData(const QString key, const QString value)
_sessionDataMap
.
insert
(
key
,
value
);
}
void
FMVipForward
::
setSessionCouponMap
(
QMap
<
QString
,
QString
>
couponMap
)
{
_sessionCouponMap
=
couponMap
;
}
QString
FMVipForward
::
sessionData
(
const
QString
key
)
const
{
QString
value
=
""
;
...
...
@@ -463,7 +458,12 @@ int FMVipForward::sessionDataInt(const QString key) const
return
value
.
toInt
();
}
QMap
<
QString
,
QString
>
FMVipForward
::
sessionCouponMap
()
const
void
FMVipForward
::
setSessionCouponMap
(
QMap
<
QString
,
Coupon
>
couponMap
)
{
_sessionCouponMap
=
couponMap
;
}
QMap
<
QString
,
Coupon
>
FMVipForward
::
sessionCouponMap
()
const
{
return
_sessionCouponMap
;
}
FMVip/fmvipforward.h
View file @
2c93a60f
...
...
@@ -29,6 +29,13 @@
#define FM_VIP_COUPON 1006
#define FM_VIP_FINAL 1007
struct
Coupon
{
QString
code
;
double
disAmount
;
QString
desc
;
};
class
FMVipForward
:
public
QObject
{
Q_OBJECT
...
...
@@ -43,9 +50,9 @@ public:
void
addSessionData
(
const
QString
key
,
const
QString
value
);
QString
sessionData
(
const
QString
key
)
const
;
int
sessionDataInt
(
const
QString
key
)
const
;
QMap
<
QString
,
QString
>
sessionCouponMap
()
const
;
void
clearSessionData
();
void
setSessionCouponMap
(
QMap
<
QString
,
QString
>
);
QMap
<
QString
,
Coupon
>
sessionCouponMap
()
const
;
void
setSessionCouponMap
(
QMap
<
QString
,
Coupon
>
);
QString
getString
(
int
num
)
{
return
QString
::
number
(
num
);}
int
getInt
(
QString
num_str
)
{
return
num_str
.
toInt
();}
...
...
@@ -89,7 +96,7 @@ private:
QMap
<
QString
,
QString
>
_sessionDataMap
;
QStringList
_sessionDataList
;
QJsonObject
_sessionForward
;
QMap
<
QString
,
QString
>
_sessionCouponMap
;
QMap
<
QString
,
Coupon
>
_sessionCouponMap
;
signals
:
void
serverResponsed
(
const
QJsonObject
&
rspData
);
private
slots
:
...
...
FMVip/fmviporder.cpp
View file @
2c93a60f
#include "fmviporder.h"
#include "fm
vipforwar
d.h"
#include "fm
msgwn
d.h"
#include "ui_fmviporder.h"
#include <QApplication>
#include <QDebug>
FMVipOrder
::
FMVipOrder
(
QDialog
*
parent
)
:
...
...
@@ -30,11 +29,15 @@ FMVipOrder::FMVipOrder(QDialog *parent) :
ui
->
name_label
->
setText
(
name
);
couponMap
=
FMVipForward
::
instance
()
->
sessionCouponMap
();
for
(
QString
code
:
couponMap
.
key
s
())
for
(
Coupon
coupon
:
couponMap
.
value
s
())
{
QString
desc
=
couponMap
[
code
];
auto
item
=
new
QListWidgetItem
(
desc
);
item
->
setData
(
1
,
code
);
QString
value
=
QString
(
"券码:%1 金额:%2 备注:%3"
)
.
arg
(
coupon
.
code
)
.
arg
(
coupon
.
disAmount
)
.
arg
(
coupon
.
desc
);
auto
item
=
new
QListWidgetItem
(
value
);
item
->
setData
(
Coupon_Code
,
coupon
.
code
);
item
->
setData
(
Coupon_Amount
,
coupon
.
disAmount
);
item
->
setCheckState
(
Qt
::
Unchecked
);
ui
->
scrollAreaWidgetContents
->
addItem
(
item
);
}
...
...
@@ -69,7 +72,7 @@ void FMVipOrder::on_pay_btn_clicked()
{
auto
item
=
ui
->
scrollAreaWidgetContents
->
item
(
i
);
if
(
item
->
checkState
()
==
Qt
::
Checked
)
{
checkedCode
<<
item
->
data
(
1
).
toString
();
checkedCode
<<
item
->
data
(
Coupon_Code
).
toString
();
}
}
for
(
QString
key
:
couponMap
.
keys
())
...
...
@@ -102,14 +105,21 @@ void FMVipOrder::on_item_clicked(QListWidgetItem *item)
if
(
item
!=
NULL
)
{
Qt
::
CheckState
state
=
item
->
checkState
();
double
amount
=
item
->
data
(
Coupon_Amount
).
toDouble
();
bool
isAddCoupon
=
false
;
switch
(
state
)
{
case
Qt
:
:
Checked
:
item
->
setCheckState
(
Qt
::
Unchecked
);
break
;
case
Qt
:
:
Unchecked
:
item
->
setCheckState
(
Qt
::
Checked
);
isAddCoupon
=
true
;
default
:
break
;
}
bool
isOK
=
orderInfo
->
setCouponAmount
(
isAddCoupon
,
amount
);
if
(
!
isOK
){
FMMsgWnd
::
WarningWnd
(
"请注意代金券总额已超过待付金额!"
);
}
}
}
FMVip/fmviporder.h
View file @
2c93a60f
...
...
@@ -2,6 +2,7 @@
#define FMVIPORDER_H
#include <QListWidgetItem>
#include "fmvipwnd.h"
#include "fmvipforward.h"
#define MIN(a,b) ((a<b) ? a : b)
#define DOUBLE_STR(num) QString::number(num, 'f', 2)
...
...
@@ -25,13 +26,19 @@ public slots:
void
on_item_clicked
(
QListWidgetItem
*
);
private
:
enum
DataIndex
{
Coupon_Code
=
Qt
::
UserRole
,
Coupon_Amount
};
class
OrderInfo
{
public
:
OrderInfo
()
{
_amountStr
=
_scoreStr
=
_needPayStr
=
""
;
_amount
=
_score
=
_needPay
=
0
.
0
;
_amount
=
_score
=
_needPay
=
_couponAmount
=
0
.
0
;
}
OrderInfo
(
QString
amountStr
,
QString
scoreStr
,
QString
needPayStr
)
{
...
...
@@ -43,6 +50,7 @@ private:
_score
=
_scoreStr
.
toInt
()
/
100
.
0
;
_needPay
=
_needPayStr
.
toInt
()
/
100
.
0
;
_couponAmount
=
0
.
0
;
}
QString
getAmountStr
()
...
...
@@ -66,16 +74,30 @@ private:
return
QString
::
number
(
payAmount
);
}
// 可以正常加时返回true,否则返回false
bool
setCouponAmount
(
bool
isAdd
,
double
amount
)
{
bool
isOK
=
true
;
if
(
isAdd
)
{
_couponAmount
+=
amount
;
isOK
=
(
_couponAmount
<=
_needPay
);
}
else
{
_couponAmount
-=
amount
;
}
return
isOK
;
}
private
:
QString
_amountStr
,
_scoreStr
,
_needPayStr
;
double
_amount
,
_score
,
_needPay
;
double
_couponAmount
;
};
private
:
Ui
::
FMVipOrder
*
ui
;
FMVipOrder
::
OrderInfo
*
orderInfo
;
QMap
<
QString
,
QString
>
couponMap
;
QMap
<
QString
,
Coupon
>
couponMap
;
};
#endif // FMVIPORDER_H
FMVip/res/FMVip.qrc
View file @
2c93a60f
...
...
@@ -13,5 +13,6 @@
<file>data/user</file>
<file>loading.gif</file>
<file>alert_bg.png</file>
<file>tip_warning.png</file>
</qresource>
</RCC>
FMVip/res/tip_warning.png
0 → 100644
View file @
2c93a60f
2.48 KB
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