Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmPOS
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
fmPOS
Commits
563ebb98
Commit
563ebb98
authored
Aug 25, 2017
by
gujin.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.给数据库添加一个字段,存放该订单的支付总额。2.添加对只使用卡券情况的处理逻辑 3.在支付失败的情况下,对已核销的卡券进行冲正,并从核销表中删除该券的核销记录。
parent
b1ad9a9c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
16 deletions
+40
-16
fmp_epay
+1
-1
fmp_redeem/fmp_redeem.cpp
+33
-15
fmp_redeem/fmp_redeem.h
+3
-0
fmp_redeem/fmp_redeem_i.h
+3
-0
No files found.
fmp_epay
@
c988b99a
Subproject commit
868048a7f72e86ed42cb700d87ea7374f9678a9a
Subproject commit
c988b99a3f696f278ec4e8ef323f37a2892f4dc0
fmp_redeem/fmp_redeem.cpp
View file @
563ebb98
...
@@ -100,6 +100,19 @@ QJsonValue FMPRedeem::SearchJsonArray(QJsonArray& searchJson, QString searchKey)
...
@@ -100,6 +100,19 @@ QJsonValue FMPRedeem::SearchJsonArray(QJsonArray& searchJson, QString searchKey)
return
value
;
return
value
;
}
}
QJsonObject
FMPRedeem
::
Reverse
(
QJsonObject
request
)
{
QString
apppath
=
QCoreApplication
::
applicationDirPath
();
QSettings
settings
(
QString
(
"%1/FreemudPOS.ini"
).
arg
(
apppath
),
QSettings
::
IniFormat
);
_url
=
settings
.
value
(
FMP_INIKEY_EPAYURL
).
toString
();
request
[
"reqtype"
]
=
3
;
QByteArray
reqData
=
QJsonDocument
(
request
).
toJson
(
QJsonDocument
::
Compact
);
reqData
=
CheckSendArray
(
reqData
);
QJsonObject
retJson
=
SendRequest
(
reqData
);
FMP_DEBUG
()
<<
"Reverse "
+
request
[
"transactions"
].
toObject
()[
"code"
].
toString
()
+
":"
<<
retJson
;
return
retJson
;
}
QJsonObject
FMPRedeem
::
Redeem
(
const
double
needPay
,
const
QJsonArray
&
productsInfo
)
QJsonObject
FMPRedeem
::
Redeem
(
const
double
needPay
,
const
QJsonArray
&
productsInfo
)
{
{
FMP_DEBUG
()
<<
"Recv redeem data: "
<<
QJsonDocument
(
productsInfo
).
toJson
(
QJsonDocument
::
Compact
);
FMP_DEBUG
()
<<
"Recv redeem data: "
<<
QJsonDocument
(
productsInfo
).
toJson
(
QJsonDocument
::
Compact
);
...
@@ -158,6 +171,7 @@ QJsonObject FMPRedeem::Redeem(const double needPay, const QJsonArray& productsIn
...
@@ -158,6 +171,7 @@ QJsonObject FMPRedeem::Redeem(const double needPay, const QJsonArray& productsIn
QJsonObject
FMPRedeem
::
SendRequest
(
const
QByteArray
&
reqData
)
QJsonObject
FMPRedeem
::
SendRequest
(
const
QByteArray
&
reqData
)
{
{
FMP_DEBUG
()
<<
"Send data: "
<<
reqData
;
FMP_DEBUG
()
<<
"Send data: "
<<
reqData
;
FMP_DEBUG
()
<<
"Send url: "
<<
_url
;
QJsonObject
retJson
;
QJsonObject
retJson
;
QNetworkAccessManager
nam
;
QNetworkAccessManager
nam
;
...
@@ -176,7 +190,6 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData)
...
@@ -176,7 +190,6 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData)
req
.
setHeader
(
QNetworkRequest
::
ContentLengthHeader
,
reqData
.
length
());
req
.
setHeader
(
QNetworkRequest
::
ContentLengthHeader
,
reqData
.
length
());
reply
=
nam
.
post
(
req
,
reqData
);
reply
=
nam
.
post
(
req
,
reqData
);
reply
->
deleteLater
();
// 使用定时器处理超时
// 使用定时器处理超时
QEventLoop
loop
;
QEventLoop
loop
;
...
@@ -210,7 +223,7 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData)
...
@@ -210,7 +223,7 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData)
retJson
[
"statusCode"
]
=
FM_API_TIMEOUT
;
retJson
[
"statusCode"
]
=
FM_API_TIMEOUT
;
retJson
[
"msg"
]
=
QString
::
fromLocal8Bit
(
"请求超时"
);
retJson
[
"msg"
]
=
QString
::
fromLocal8Bit
(
"请求超时"
);
}
}
reply
->
deleteLater
();
FMP_DEBUG
()
<<
"Server response: "
<<
QJsonDocument
(
retJson
).
toJson
(
QJsonDocument
::
Compact
);
FMP_DEBUG
()
<<
"Server response: "
<<
QJsonDocument
(
retJson
).
toJson
(
QJsonDocument
::
Compact
);
return
retJson
;
return
retJson
;
}
}
...
@@ -228,16 +241,16 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
...
@@ -228,16 +241,16 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
if
(
ConsumptionDialog
::
ShowForUnConsum
(
act_name
,
code_name
,
time_name
,
coupon
))
if
(
ConsumptionDialog
::
ShowForUnConsum
(
act_name
,
code_name
,
time_name
,
coupon
))
{
{
QJsonObject
redeemJson
;
_redeem_json
=
QJsonObject
()
;
redeemJ
son
[
"ver"
]
=
2
;
_redeem_j
son
[
"ver"
]
=
2
;
redeemJ
son
[
"clientReqCount"
]
=
(
++
_clientReqCount
%=
10000000
);
_redeem_j
son
[
"clientReqCount"
]
=
(
++
_clientReqCount
%=
10000000
);
redeemJ
son
[
"reqtype"
]
=
71
;
_redeem_j
son
[
"reqtype"
]
=
71
;
redeemJ
son
[
"partnerId"
]
=
_partner_id
;
_redeem_j
son
[
"partnerId"
]
=
_partner_id
;
redeemJ
son
[
"store_id"
]
=
_store_id
;
_redeem_j
son
[
"store_id"
]
=
_store_id
;
redeemJ
son
[
"station_id"
]
=
_station_id
;
_redeem_j
son
[
"station_id"
]
=
_station_id
;
redeemJ
son
[
"trans_id"
]
=
QString
::
number
(
QDateTime
::
currentDateTimeUtc
().
toTime_t
());
_redeem_j
son
[
"trans_id"
]
=
QString
::
number
(
QDateTime
::
currentDateTimeUtc
().
toTime_t
());
redeemJ
son
[
"operator_id"
]
=
_operator_id
;
_redeem_j
son
[
"operator_id"
]
=
_operator_id
;
redeemJ
son
[
"business_date"
]
=
QDate
::
currentDate
().
toString
(
"yyyyMMdd"
);
_redeem_j
son
[
"business_date"
]
=
QDate
::
currentDate
().
toString
(
"yyyyMMdd"
);
if
(
couponType
==
0
){
//商品券
if
(
couponType
==
0
){
//商品券
if
(
!
IsContinue
(
SearchJsonObject
(
json
,
"paid"
).
toInt
()))
if
(
!
IsContinue
(
SearchJsonObject
(
json
,
"paid"
).
toInt
()))
...
@@ -279,7 +292,7 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
...
@@ -279,7 +292,7 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
transaction
[
"products"
]
=
products
;
transaction
[
"products"
]
=
products
;
transactions
.
append
(
transaction
);
transactions
.
append
(
transaction
);
redeemJ
son
[
"transactions"
]
=
transactions
;
_redeem_j
son
[
"transactions"
]
=
transactions
;
}
}
if
(
couponType
==
1
){
//代金券
if
(
couponType
==
1
){
//代金券
if
(
!
IsContinue
(
SearchJsonObject
(
json
,
"amount"
).
toInt
()))
if
(
!
IsContinue
(
SearchJsonObject
(
json
,
"amount"
).
toInt
()))
...
@@ -297,9 +310,9 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
...
@@ -297,9 +310,9 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
QJsonArray
transactions
;
QJsonArray
transactions
;
transactions
.
append
(
transaction
);
transactions
.
append
(
transaction
);
redeemJ
son
[
"transactions"
]
=
transactions
;
_redeem_j
son
[
"transactions"
]
=
transactions
;
}
}
QByteArray
reqData
=
QJsonDocument
(
redeemJ
son
).
toJson
();
QByteArray
reqData
=
QJsonDocument
(
_redeem_j
son
).
toJson
();
reqData
=
CheckSendArray
(
reqData
);
reqData
=
CheckSendArray
(
reqData
);
QJsonObject
redeemResult
;
QJsonObject
redeemResult
;
...
@@ -379,6 +392,11 @@ QJsonObject FMPRedeem::ShowForMismatch(QJsonObject json)
...
@@ -379,6 +392,11 @@ QJsonObject FMPRedeem::ShowForMismatch(QJsonObject json)
return
mismatch
;
return
mismatch
;
}
}
QJsonObject
FMPRedeem
::
GetRedeemJson
()
const
{
return
_redeem_json
;
}
bool
FMPRedeem
::
IsContinue
(
int
couponAmount
)
bool
FMPRedeem
::
IsContinue
(
int
couponAmount
)
{
{
if
(
_needPay
<
couponAmount
/
100.0
)
if
(
_needPay
<
couponAmount
/
100.0
)
...
...
fmp_redeem/fmp_redeem.h
View file @
563ebb98
...
@@ -30,6 +30,8 @@ public:
...
@@ -30,6 +30,8 @@ public:
virtual
~
FMPRedeem
();
virtual
~
FMPRedeem
();
QJsonObject
Redeem
(
const
double
needPay
,
const
QJsonArray
&
productsInfo
);
//券码核销
QJsonObject
Redeem
(
const
double
needPay
,
const
QJsonArray
&
productsInfo
);
//券码核销
QJsonObject
Reverse
(
QJsonObject
request
);
QJsonObject
GetRedeemJson
()
const
;
protected
:
protected
:
const
FMPContext
GetContext
()
const
{
return
_context
;
}
const
FMPContext
GetContext
()
const
{
return
_context
;
}
...
@@ -61,6 +63,7 @@ private:
...
@@ -61,6 +63,7 @@ private:
int
_partner_id
;
int
_partner_id
;
QString
_url
;
QString
_url
;
QJsonArray
_products_info
;
QJsonArray
_products_info
;
QJsonObject
_redeem_json
;
//存放核销请求字符串
int
_clientReqCount
;
int
_clientReqCount
;
const
FMPContext
_context
;
const
FMPContext
_context
;
QPointer
<
FMPStartEventHandler
>
_ste_handler
;
QPointer
<
FMPStartEventHandler
>
_ste_handler
;
...
...
fmp_redeem/fmp_redeem_i.h
View file @
563ebb98
...
@@ -21,6 +21,9 @@ public:
...
@@ -21,6 +21,9 @@ public:
}
}
virtual
QJsonObject
Redeem
(
const
double
needPay
,
const
QJsonArray
&
productsInfo
)
=
0
;
//券码核销
virtual
QJsonObject
Redeem
(
const
double
needPay
,
const
QJsonArray
&
productsInfo
)
=
0
;
//券码核销
virtual
QJsonObject
Reverse
(
QJsonObject
request
)
=
0
;
//卡券冲正
virtual
QJsonObject
GetRedeemJson
()
const
=
0
;
signals
:
signals
:
void
TriggerInit
();
void
TriggerInit
();
void
TriggerUninit
();
void
TriggerUninit
();
...
...
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