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
264cc8f9
Commit
264cc8f9
authored
Oct 22, 2016
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修复程序界面弹起期间退出程序会卡死问题。2.修复没有使用第三方支付向服务器发送的请求缺少字段问题。3.新增提示和限制使用余额支付金额的最大值。4.暂时修复程序第一次运行弹窗没有焦点问题。
parent
9407e487
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
19 deletions
+125
-19
FMVip/fmvipdispatcher.cpp
+1
-2
FMVip/fmvipforward.cpp
+1
-0
FMVip/fmviporder.cpp
+61
-4
FMVip/fmviporder.h
+39
-12
FMVip/forms/fmviporder.ui
+19
-1
FMVip/main.cpp
+4
-0
No files found.
FMVip/fmvipdispatcher.cpp
View file @
264cc8f9
...
...
@@ -127,15 +127,14 @@ void FMVipDispatcher::onRequest(const QJsonObject &jsonObj)
else
if
(
type
==
Type_Final
)
{
final
();
}
#ifdef _DEBUG
else
if
(
type
==
"-1"
)
{
serverIsBusy
.
wakeAll
();
qDebug
()
<<
"Quit"
;
jsonObj
[
"reqType"
]
=
-
1
;
QJsonDocument
d
=
QJsonDocument
(
jsonObj
);
_serverRspData
=
d
.
toJson
();
qApp
->
quit
();
}
#endif
else
if
(
type
==
Type_Pay
||
type
==
Type_Fund
)
{
requestSuccess
=
true
;
// 支付、充值先检查登陆状态。
...
...
FMVip/fmvipforward.cpp
View file @
264cc8f9
...
...
@@ -220,6 +220,7 @@ void FMVipForward::final(const QJsonObject &job, QJsonObject &fmjob)
QJsonArray
coupons
=
posTransObj
[
"coupons"
].
toArray
();
int
codeAmount
=
0
,
scoreAmount
=
0
,
cashAmount
=
0
,
thirdAmount
=
0
;
transObj
[
"thirdPayType"
]
=
4
;
foreach
(
QJsonValue
pay_v
,
pay_ids
)
{
QJsonObject
pay_ob
=
pay_v
.
toObject
();
...
...
FMVip/fmviporder.cpp
View file @
264cc8f9
...
...
@@ -9,6 +9,27 @@ FMVipOrder::FMVipOrder(QDialog *parent) :
FMVipWnd
(
parent
),
ui
(
new
Ui
::
FMVipOrder
)
{
// OrderInfo o1("10000","0","1000");
// qDebug() << o1.getMaxWillPay() << "/10";
// OrderInfo o2("2000","0","10000");
// qDebug() << o2.getMaxWillPay() << "/20";
// OrderInfo o3("1000","2000","4000");
// qDebug() << o3.getMaxWillPay() << "/10";
// o3.setUseScore(true);
// qDebug() << o3.getMaxWillPay() << "/10";
// OrderInfo o4("0","5000","1000");
// qDebug() << o4.getMaxWillPay() << "/0";
// o4.setUseScore(true);
// qDebug() << o4.getMaxWillPay() << "/0";
// OrderInfo o5("2000","9000","10000");
// qDebug() << o5.getMaxWillPay() << "/20";
// o5.setUseScore(true);
// qDebug() << o5.getMaxWillPay() << "/10";
ui
->
setupUi
(
this
);
QString
operator_id
=
SESSIONDATA_STRING
(
"operator_id"
);
QString
business_date
=
SESSIONDATA_STRING
(
"business_date"
);
...
...
@@ -20,6 +41,7 @@ FMVipOrder::FMVipOrder(QDialog *parent) :
QString
birthday
=
SESSIONDATA_STRING
(
"birthday"
);
double
standard_amount
=
SESSIONDATA_INT
(
"standard_amount"
)
/
100.0
;
// orderInfo = new OrderInfo("1000","4500","4000");
orderInfo
=
new
FMVipOrder
::
OrderInfo
(
amount_str
,
score_str
,
needPay_str
);
orderInfo
->
setCouponMap
(
SESSIONDATA_COUPONMAP
(
"couponMap"
));
...
...
@@ -35,17 +57,19 @@ FMVipOrder::FMVipOrder(QDialog *parent) :
initCouponItems
();
connect
(
ui
->
coupon_page
,
SIGNAL
(
itemClicked
(
QListWidgetItem
*
)),
this
,
SLOT
(
onItemClicked
(
QListWidgetItem
*
)));
ui
->
pay_chk
->
setText
(
QString
(
"使用积分
最多可
抵用 %1 元"
).
arg
(
orderInfo
->
getScoreAmount
()));
ui
->
pay_chk
->
setText
(
QString
(
"使用积分抵用 %1 元"
).
arg
(
orderInfo
->
getScoreAmount
()));
if
(
standard_amount
>
0
)
{
ui
->
standard_label
->
setText
(
QString
(
"满 %1 元可享受储值金满额优惠"
).
arg
(
standard_amount
));
}
else
{
ui
->
standard_label
->
setText
(
""
);
}
ui
->
pay_edit
->
setText
(
orderInfo
->
getNeedPayStr
());
ui
->
pay_edit
->
setFocus
();
ui
->
pay_edit
->
selectAll
();
oldPayText
=
DOUBLE_STR
(
orderInfo
->
getMaxWillPay
());
ui
->
pay_edit
->
setText
(
oldPayText
);
QRegExp
regexp
(
"^[0-9]+(.[0-9]{2})?$"
);
ui
->
pay_edit
->
setValidator
(
new
QRegExpValidator
(
regexp
));
setWillPayText
();
}
FMVipOrder
::~
FMVipOrder
()
...
...
@@ -74,6 +98,8 @@ void FMVipOrder::on_pay_chk_clicked(bool checked)
{
int
is
=
checked
?
1
:
0
;
SESSIONDATA_ADD
(
"isUseScore"
,
QString
::
number
(
is
));
orderInfo
->
setUseScore
(
checked
);
setWillPayText
();
}
void
FMVipOrder
::
onItemClicked
(
QListWidgetItem
*
item
)
...
...
@@ -84,6 +110,7 @@ void FMVipOrder::onItemClicked(QListWidgetItem *item)
if
(
orderInfo
->
selectCouponMap
.
contains
(
code
))
{
ui
->
coupon_page
->
itemWidget
(
item
)
->
setStyleSheet
(
"#FMCouponWidget{background-color: rgb(255, 255, 255); border: none; border-left: 5 solid rgb(255, 170, 37);}"
);
orderInfo
->
selectCouponMap
.
remove
(
code
);
orderInfo
->
enoughCoupon
();
// 计算一下当前代金券金额
}
else
{
ui
->
coupon_page
->
itemWidget
(
item
)
->
setStyleSheet
(
"#FMCouponWidget{background-color: rgb(255, 255, 255); border: none; border-image: url(:/coupon_select.png);}"
);
orderInfo
->
selectCouponMap
[
code
]
=
orderInfo
->
couponMap
()[
code
];
...
...
@@ -92,6 +119,7 @@ void FMVipOrder::onItemClicked(QListWidgetItem *item)
FMMsgWnd
::
WarningWnd
(
"请注意代金券总额已超过待付金额!"
);
}
}
setWillPayText
();
}
void
FMVipOrder
::
initCouponItems
()
...
...
@@ -109,6 +137,14 @@ void FMVipOrder::initCouponItems()
}
}
void
FMVipOrder
::
setWillPayText
()
{
on_pay_edit_textChanged
(
oldPayText
);
ui
->
pay_edit
->
setFocus
();
ui
->
pay_edit
->
selectAll
();
}
void
FMVipOrder
::
on_coupon_prev_btn_clicked
()
{
int
pos
=
ui
->
coupon_page
->
verticalScrollBar
()
->
value
();
...
...
@@ -120,3 +156,24 @@ void FMVipOrder::on_coupon_next_btn_clicked()
int
pos
=
ui
->
coupon_page
->
verticalScrollBar
()
->
value
();
ui
->
coupon_page
->
verticalScrollBar
()
->
setValue
(
pos
+
125
);
}
void
FMVipOrder
::
on_pay_edit_textChanged
(
const
QString
&
text
)
{
double
num
=
text
.
toDouble
();
double
maxPay
=
orderInfo
->
getMaxWillPay
();
if
(
num
>
maxPay
)
{
ui
->
pay_edit
->
setText
(
DOUBLE_STR
(
maxPay
));
QString
maxPay_info
=
"余额只需支付 %1 元"
;
if
(
maxPay
>=
orderInfo
->
getAmountStr
().
toDouble
())
{
maxPay_info
=
"余额最多支付 %1 元"
;
}
ui
->
pay_max
->
setText
(
maxPay_info
.
arg
(
maxPay
));
ui
->
pay_edit
->
setFocus
();
ui
->
pay_edit
->
selectAll
();
}
else
{
oldPayText
=
text
;
ui
->
pay_max
->
setText
(
""
);
}
}
FMVip/fmviporder.h
View file @
264cc8f9
...
...
@@ -5,6 +5,7 @@
#include "fmvipforward.h"
#define MIN(a,b) ((a<b) ? a : b)
#define MAX(a,b) ((a<b) ? b : a)
#define DOUBLE_STR(num) QString::number(num, 'f', 2)
namespace
Ui
{
...
...
@@ -19,6 +20,8 @@ public:
explicit
FMVipOrder
(
QDialog
*
parent
=
0
);
~
FMVipOrder
();
void
setWillPayText
();
public
slots
:
void
on_pay_btn_clicked
();
void
on_pay_chk_clicked
(
bool
checked
);
...
...
@@ -30,20 +33,16 @@ private slots:
void
on_coupon_next_btn_clicked
();
private
:
enum
DataIndex
{
Coupon_Code
=
Qt
::
UserRole
,
Coupon_Amount
};
void
on_pay_edit_textChanged
(
const
QString
&
text
);
private
:
class
OrderInfo
{
public
:
OrderInfo
()
{
_amountStr
=
_scoreStr
=
_needPayStr
=
""
;
_amount
=
_score
=
_needPay
;
_amount
=
_score
=
_needPay
=
_maxWillPay
=
_useScore
=
_couponAmount
=
0
;
}
OrderInfo
(
QString
amountStr
,
QString
scoreStr
,
QString
needPayStr
)
{
...
...
@@ -55,6 +54,8 @@ private:
_score
=
_scoreStr
.
toInt
()
/
100
.
0
;
_needPay
=
_needPayStr
.
toInt
()
/
100
.
0
;
_maxWillPay
=
_useScore
=
_couponAmount
=
0
;
setMaxWillPay
();
}
QString
getAmountStr
()
...
...
@@ -69,7 +70,7 @@ private:
QString
getScoreAmount
()
{
return
DOUBLE_STR
(
_score
);
return
DOUBLE_STR
(
MIN
(
_score
,
_needPay
)
);
}
QString
getPayAmountStr
(
QString
amountStr
)
...
...
@@ -78,18 +79,40 @@ private:
return
QString
::
number
(
payAmount
);
}
// 代金券总额超过待付时
范围
true
// 代金券总额超过待付时
返回
true
bool
enoughCoupon
()
{
double
coupon_a
mount
=
0
.
0
;
_couponA
mount
=
0
.
0
;
for
(
auto
coupon
:
selectCouponMap
)
{
coupon_a
mount
+=
coupon
.
disAmount
;
_couponA
mount
+=
coupon
.
disAmount
;
}
bool
isEnough
=
(
coupon_amount
>
_needPay
);
bool
isEnough
=
(
_couponAmount
>
_needPay
);
setMaxWillPay
();
return
isEnough
;
}
void
setUseScore
(
bool
isUse
)
{
if
(
isUse
)
{
_useScore
=
MIN
(
_score
,
_needPay
);
}
else
{
_useScore
=
0
;
}
setMaxWillPay
();
}
// 设置付款金额的最大值
void
setMaxWillPay
()
{
double
willPay
=
_needPay
-
_useScore
-
_couponAmount
;
_maxWillPay
=
MIN
(
MAX
(
willPay
,
0
),
_amount
);
}
double
getMaxWillPay
()
{
return
_maxWillPay
;
}
/// 代金券列表
void
setCouponMap
(
QMap
<
QString
,
Coupon
>
couponMap
)
{
...
...
@@ -140,6 +163,8 @@ private:
double
_amount
,
_score
,
_needPay
;
QMap
<
QString
,
Coupon
>
_couponMap
;
int
_maxPage
,
_nowPage
;
// 代金券金额 使用积分金额 余额将付金额
double
_couponAmount
,
_useScore
,
_maxWillPay
;
};
private
:
...
...
@@ -147,6 +172,8 @@ private:
FMVipOrder
::
OrderInfo
*
orderInfo
;
QString
oldPayText
;
void
initCouponItems
();
};
...
...
FMVip/forms/fmviporder.ui
View file @
264cc8f9
...
...
@@ -170,6 +170,11 @@
border-bottom: 1px solid silver;
}
#pay_max {
font: 400 20px
"
Microsoft YaHei
"
;
color: red;
}
#pay_edit {
min-height: 60px;
border: 1 solid silver;
...
...
@@ -735,7 +740,7 @@
<number>
60
</number>
</property>
<property
name=
"topMargin"
>
<number>
4
0
</number>
<number>
1
0
</number>
</property>
<property
name=
"rightMargin"
>
<number>
60
</number>
...
...
@@ -744,6 +749,16 @@
<number>
40
</number>
</property>
<item>
<widget
class=
"QLabel"
name=
"pay_max"
>
<property
name=
"text"
>
<string>
余额最多支付 0.00 元
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignBottom|Qt::AlignHCenter
</set>
</property>
</widget>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"pay_edit"
>
<property
name=
"maximumSize"
>
<size>
...
...
@@ -751,6 +766,9 @@
<height>
16777215
</height>
</size>
</property>
<property
name=
"inputMask"
>
<string/>
</property>
<property
name=
"text"
>
<string>
0.00
</string>
</property>
...
...
FMVip/main.cpp
View file @
264cc8f9
...
...
@@ -74,5 +74,9 @@ int main(int argc, char *argv[])
server
.
Listen
(
23770
);
QWidget
w
;
w
.
show
();
w
.
hide
();
return
a
.
exec
();
}
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