Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_epay
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
fmp_epay
Commits
868048a7
Commit
868048a7
authored
Aug 23, 2017
by
gujin.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
为订单管理模块添加查看支付详情功能
parent
30a8ed65
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
352 additions
and
13 deletions
+352
-13
fmp_detaildialog.cpp
+61
-0
fmp_detaildialog.h
+34
-0
fmp_detaildialog.ui
+151
-0
fmp_epay.cpp
+1
-0
fmp_epay.h
+1
-0
fmp_epay.pro
+6
-3
fmp_epay_def.h
+1
-0
fmp_epay_p.cpp
+29
-3
fmp_epay_p.h
+2
-0
fmp_epayview_dialog.cpp
+65
-6
fmp_epayview_dialog.h
+1
-1
No files found.
fmp_detaildialog.cpp
0 → 100644
View file @
868048a7
#
include
"fmp_detaildialog.h"
#include "ui_fmp_detaildialog.h"
DetailDialog
::
DetailDialog
(
int
x
,
int
y
,
int
distance
,
QWidget
*
parent
)
:
QDialog
(
parent
),
mouse_pressed
(
false
),
ui
(
new
Ui
::
DetailDialog
)
{
ui
->
setupUi
(
this
);
setWindowFlags
(
windowFlags
()
|
Qt
::
FramelessWindowHint
);
ui
->
tableWidget
->
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
ui
->
tableWidget
->
setEditTriggers
(
QAbstractItemView
::
NoEditTriggers
);
connect
(
ui
->
pushButton
,
&
QPushButton
::
clicked
,
this
,
&
DetailDialog
::
accept
);
animation
.
setTargetObject
(
this
);
animation
.
setPropertyName
(
"geometry"
);
animation
.
setDuration
(
800
);
animation
.
setEasingCurve
(
QEasingCurve
::
OutBack
);
animation
.
setStartValue
(
QRect
(
x
,
y
+
distance
,
550
,
0
));
animation
.
setEndValue
(
QRect
(
x
,
y
,
550
,
400
));
animation
.
start
();
}
DetailDialog
::~
DetailDialog
()
{
delete
ui
;
}
void
DetailDialog
::
mousePressEvent
(
QMouseEvent
*
event
)
{
mouse_pressed
=
true
;
movePosition
=
event
->
globalPos
()
-
pos
();
return
QDialog
::
mousePressEvent
(
event
);
}
void
DetailDialog
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
if
(
mouse_pressed
&&
(
event
->
buttons
()
&&
Qt
::
LeftButton
)
&&
(
event
->
globalPos
()
-
movePosition
).
manhattanLength
()
>
QApplication
::
startDragDistance
())
{
move
(
event
->
globalPos
()
-
movePosition
);
movePosition
=
event
->
globalPos
()
-
pos
();
}
return
QDialog
::
mouseMoveEvent
(
event
);
}
void
DetailDialog
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
mouse_pressed
=
false
;
}
void
DetailDialog
::
AddData
(
const
QSqlRecord
&
record
)
{
int
r
=
ui
->
tableWidget
->
rowCount
();
ui
->
tableWidget
->
insertRow
(
r
);
ui
->
tableWidget
->
setItem
(
r
,
0
,
new
QTableWidgetItem
(
record
.
value
(
"trans_id"
).
toString
()));
ui
->
tableWidget
->
setItem
(
r
,
1
,
new
QTableWidgetItem
(
record
.
value
(
"pay_id"
).
toString
()));
ui
->
tableWidget
->
setItem
(
r
,
2
,
new
QTableWidgetItem
(
record
.
value
(
"code"
).
toString
()));
ui
->
tableWidget
->
setItem
(
r
,
3
,
new
QTableWidgetItem
(
record
.
value
(
"pid"
).
toString
()));
ui
->
tableWidget
->
setItem
(
r
,
4
,
new
QTableWidgetItem
(
QString
::
number
(
record
.
value
(
"total_amount"
).
toInt
()
/
100.0
)));
}
fmp_detaildialog.h
0 → 100644
View file @
868048a7
#
ifndef
DETAILDIALOG_H
#define DETAILDIALOG_H
#include <QDialog>
#include <QMouseEvent>
#include <QSqlRecord>
#include <QPropertyAnimation>
namespace
Ui
{
class
DetailDialog
;
}
class
DetailDialog
:
public
QDialog
{
Q_OBJECT
public
:
explicit
DetailDialog
(
int
x
,
int
y
,
int
distance
,
QWidget
*
parent
=
0
);
~
DetailDialog
();
void
AddData
(
const
QSqlRecord
&
record
);
protected
:
void
mousePressEvent
(
QMouseEvent
*
);
void
mouseMoveEvent
(
QMouseEvent
*
);
void
mouseReleaseEvent
(
QMouseEvent
*
);
private
:
Ui
::
DetailDialog
*
ui
;
bool
mouse_pressed
;
QPoint
movePosition
;
QPropertyAnimation
animation
;
};
#endif // DETAILDIALOG_H
fmp_detaildialog.ui
0 → 100644
View file @
868048a7
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
DetailDialog
</class>
<widget
class=
"QDialog"
name=
"DetailDialog"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
553
</width>
<height>
417
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Dialog
</string>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
#DetailDialog
{
background-color: rgb(56, 56, 64);
}
#label
{
font: 75 22px
"
微软雅黑
"
;;
color: rgb(255, 255, 255);
}
#pushButton
{
background-color: rgb(56, 56, 64);
border-radius: 0px;
image: url(:/img/fm-icon_close_02.png);
}
#tableWidget::item:selected{
/*color:white;*/
background:rgb(128, 128, 128);
}
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<property
name=
"spacing"
>
<number>
0
</number>
</property>
<property
name=
"leftMargin"
>
<number>
0
</number>
</property>
<property
name=
"topMargin"
>
<number>
0
</number>
</property>
<property
name=
"rightMargin"
>
<number>
0
</number>
</property>
<property
name=
"bottomMargin"
>
<number>
0
</number>
</property>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
13
</width>
<height>
27
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"minimumSize"
>
<size>
<width>
50
</width>
<height>
55
</height>
</size>
</property>
<property
name=
"text"
>
<string>
支付详情
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
378
</width>
<height>
13
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QPushButton"
name=
"pushButton"
>
<property
name=
"minimumSize"
>
<size>
<width>
55
</width>
<height>
55
</height>
</size>
</property>
<property
name=
"cursor"
>
<cursorShape>
PointingHandCursor
</cursorShape>
</property>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QTableWidget"
name=
"tableWidget"
>
<attribute
name=
"horizontalHeaderStretchLastSection"
>
<bool>
true
</bool>
</attribute>
<attribute
name=
"verticalHeaderVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string>
POS交易号
</string>
</property>
</column>
<column>
<property
name=
"text"
>
<string>
支付类型
</string>
</property>
</column>
<column>
<property
name=
"text"
>
<string>
支付码
</string>
</property>
</column>
<column>
<property
name=
"text"
>
<string>
商品ID
</string>
</property>
</column>
<column>
<property
name=
"text"
>
<string>
金额
</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
fmp_epay.cpp
View file @
868048a7
...
...
@@ -13,6 +13,7 @@ FMPePay::FMPePay(const FMPContext ctx)
_partner_id
(
QString
(
""
)),
_databasename
(
DEFAULT_EPAY_DATABASENAME
),
_table
(
DEFAULT_EPAY_TABLE
),
_redeem_table
(
DEFAULT_REDEEM_TABLE
),
_businessdate
(
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd"
)),
_ordershelflife
(
DEFAULT_EPAY_ORDERLIFE
),
_operator_id
(
DEFAULT_EPAY_OPTID
),
...
...
fmp_epay.h
View file @
868048a7
...
...
@@ -41,6 +41,7 @@ private:
QString
_url
;
QString
_databasename
;
QString
_table
;
QString
_redeem_table
;
QString
_businessdate
;
QString
_store_id
;
QString
_station_id
;
...
...
fmp_epay.pro
View file @
868048a7
...
...
@@ -23,7 +23,8 @@ SOURCES += \
fmp_cashconfirm_dialog
.
cpp
\
fmp_forceclose_dialog
.
cpp
\
fmp_payfailed_dialog
.
cpp
\
cquerythread
.
cpp
cquerythread
.
cpp
\
fmp_detaildialog
.
cpp
HEADERS
+=
\
fmp_epay
.
h
\
...
...
@@ -41,7 +42,8 @@ HEADERS +=\
fmp_cashconfirm_dialog
.
h
\
fmp_forceclose_dialog
.
h
\
fmp_payfailed_dialog
.
h
\
cquerythread
.
h
cquerythread
.
h
\
fmp_detaildialog
.
h
unix
{
target
.
path
=
/
usr
/
lib
...
...
@@ -92,4 +94,5 @@ FORMS += \
fmnumpad
.
ui
\
fmp_cashconfirm_dialog
.
ui
\
fmp_forceclose_dialog
.
ui
\
fmp_payfailed_dialog
.
ui
fmp_payfailed_dialog
.
ui
\
fmp_detaildialog
.
ui
fmp_epay_def.h
View file @
868048a7
...
...
@@ -60,6 +60,7 @@
#define DEFAULT_EPAY_RWQUESTURL "https://115.159.18.100/api"
#define DEFAULT_EPAY_DATABASENAME "fmp_test.db"
#define DEFAULT_EPAY_TABLE "fmp_pay"
#define DEFAULT_REDEEM_TABLE "fmp_redeem"
#define DEFAULT_EPAY_CONNECTNAME "fmp_pay_connect"
#define DEFAULT_EPAY_ORDERLIFE 60
#define DEFAULT_EPAY_STRID "99999"
...
...
fmp_epay_p.cpp
View file @
868048a7
...
...
@@ -72,13 +72,23 @@ FMPePayPrivate::FMPePayPrivate(FMPePay *parent)
"addtime TIMESTAMP default (datetime('now', 'localtime')),"
"PRIMARY KEY (trans_id)"
")"
;
FMP_INFO
()
<<
" creat table sql:"
<<
sql
;
if
(
_db
->
creat
(
sql
))
if
(
_db
->
creat
(
sql
)
==
false
)
{
FMP_WARN
()
<<
"creat table fmp_pay failed"
;
}
sql
=
"create table "
+
q
->
_redeem_table
+
"("
"trans_id varchar(40),"
"pay_id varchar(50),"
"code varchar(20),"
"pid varchar(20),"
"total_amount integer)"
;
//卡券抵扣额,以分为单位
FMP_INFO
()
<<
"create table sql: "
<<
sql
;
if
(
_db
->
creat
(
sql
)
==
false
)
{
FMP_WARN
()
<<
"create table fmp_redeem failed"
;
}
}
if
(
_queryThread
==
nullptr
)
...
...
@@ -906,6 +916,22 @@ void FMPePayPrivate::writeOrderToSqlite()
FMP_INFO
()
<<
"writeOrderToSqlite json : "
<<
_dbWrite
;
}
void
FMPePayPrivate
::
WriteRedeemToSqlite
(
QJsonObject
redeemInfo
)
{
Q_Q
(
FMPePay
);
redeemInfo
[
FMP_EPAY_TRANSID
]
=
_pos_trans_id
;
FMP_DEBUG
()
<<
redeemInfo
;
if
(
!
_db
->
insert
(
q
->
_redeem_table
,
redeemInfo
.
toVariantHash
()))
{
FMP_ERROR
()
<<
"write redeem info to fmp_redeem table failed"
;
}
}
FMPDataBase
*
FMPePayPrivate
::
GetDB
()
const
{
return
_db
;
}
void
FMPePayPrivate
::
updateSqlite
(
const
QJsonObject
&
json
)
{
Q_Q
(
FMPePay
);
...
...
fmp_epay_p.h
View file @
868048a7
...
...
@@ -70,6 +70,8 @@ public:
void
GetDailyBillData
(
QVector
<
PayDetail
>
&
vecPay
);
void
WriteRedeemToSqlite
(
QJsonObject
redeemInfo
);
FMPDataBase
*
GetDB
()
const
;
private
:
void
ControlReverseJson
();
...
...
fmp_epayview_dialog.cpp
View file @
868048a7
...
...
@@ -7,6 +7,8 @@
#include "fmp_forceclose_dialog.h"
#include "fmp_redeem_i.h"
#include "fmp_home_i.h"
#include "fmp_detaildialog.h"
#include "fmp_database.h"
#include <QDebug>
#include <fmp_settings_i.h>
...
...
@@ -21,6 +23,9 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QSettings>
#include <QSqlRecord>
#include <QTableWidget>
#include <QSqlQuery>
FMPPayDialog
::
FMPPayDialog
(
FMPePayPrivate
*
control
,
QVariantHash
basicinfo
,
QWidget
*
parent
)
:
_control
(
control
),
...
...
@@ -188,6 +193,8 @@ FMPPayDialog::FMPPayDialog(FMPePayPrivate *control, QVariantHash basicinfo, QWid
QVBoxLayout
*
layout
=
qobject_cast
<
QVBoxLayout
*>
(
ui
->
frame
->
layout
());
layout
->
insertWidget
(
4
,
redeem
);
_products_info
=
basicinfo
[
"products"
].
toJsonArray
();
ui
->
tableView_hasPay
->
setToolTip
(
QString
::
fromLocal8Bit
(
"双击查看支付详情"
));
connect
(
ui
->
tableView_hasPay
,
&
QTableView
::
doubleClicked
,
this
,
&
FMPPayDialog
::
ShowPayDetail
);
setShowFunc
();
}
...
...
@@ -847,19 +854,26 @@ void FMPPayDialog::PlayAnimation(QWidget *target0, QWidget *target1, Movemode mo
//确定按钮
void
FMPPayDialog
::
onBtnConfirmClicked
()
{
if
(
ui
->
lineedit_num
->
text
().
toDouble
()
<=
0.0
)
{
_api_force_close
=
true
;
_control
->
ClosePayWindow
(
DIALOG_FORCE_CLOSE
);
this
->
close
();
_control
->
Uninit
();
return
;
}
if
(
_wait
==
NULL
)
{
_wait
=
new
FMPPayWait
(
this
);
_wait
->
setModal
(
true
);
}
if
((
ui
->
lineedit_num
->
text
()
==
""
&&
ui
->
lineedit_num_refund
->
text
()
==
""
)
||
(
ui
->
lineedit_num
->
text
().
toDouble
()
<
0.01
&&
ui
->
lineedit_num_refund
->
text
().
toDouble
()
<
0.01
)
||
(
ui
->
lineedit_code
->
text
()
==
""
&&
ui
->
lineedit_code_refund
->
text
()
==
""
)
||
(
ui
->
lineedit_code
->
text
().
size
()
<
15
&&
ui
->
lineedit_code_refund
->
text
().
size
()
<
15
)
)
{
(
ui
->
lineedit_code
->
text
().
size
()
<
15
&&
ui
->
lineedit_code_refund
->
text
().
size
()
<
15
))
{
if
(
!
_control
->
_is_api
)
{
if
(
ui
->
lineedit_num
->
isEnabled
())
ui
->
lineedit_num
->
clear
();
...
...
@@ -872,7 +886,6 @@ void FMPPayDialog::onBtnConfirmClicked()
return
;
}
if
(
ui
->
btn_pay
->
isChecked
())
{
_wait
->
SetContent
(
FMPPayWait
::
LOADING
,
QString
::
fromLocal8Bit
(
"支付中..."
));
...
...
@@ -1098,6 +1111,7 @@ void FMPPayDialog::setShowFunc()
}
}
//卡券核销
#ifdef Q_OS_WIN
//!命名冲突
#undef StartService
...
...
@@ -1109,6 +1123,51 @@ void FMPPayDialog::redeem()
redeem
->
StartService
();
QJsonObject
result
=
redeem
->
Redeem
(
needPay
,
_products_info
);
FMP_DEBUG
()
<<
"redeem result: "
<<
result
;
needPay
-=
result
[
"discount"
].
to
Double
()
;
needPay
-=
result
[
"discount"
].
to
Int
()
/
100.0
;
ui
->
lineedit_num
->
setText
(
QString
::
number
(
qMax
(
0.0
,
needPay
)));
if
(
result
[
"statusCode"
].
toInt
()
==
100
)
{
//记录核销详情
QJsonObject
redeemInfo
;
redeemInfo
[
"pay_id"
]
=
result
[
"couponType"
].
toString
();
redeemInfo
[
"code"
]
=
result
[
"code"
];
redeemInfo
[
"pid"
]
=
result
[
"pid"
];
redeemInfo
[
"total_amount"
]
=
result
[
"discount"
].
toInt
();
_control
->
WriteRedeemToSqlite
(
redeemInfo
);
}
}
//展示订单支付详情
void
FMPPayDialog
::
ShowPayDetail
(
const
QModelIndex
&
index
)
{
//计算动画参数
QPoint
gPos
=
mapToGlobal
(
ui
->
wdg_right_bg
->
pos
());
int
x
=
ui
->
wdg_right_bg
->
width
()
>=
550
?
gPos
.
x
()
+
(
ui
->
wdg_right_bg
->
width
()
-
550
)
/
2
:
gPos
.
x
();
int
y
=
gPos
.
y
();
int
dis
=
ui
->
wdg_right_bg
->
height
();
DetailDialog
detailDlg
(
x
,
y
,
dis
,
this
);
//微信支付详情
QSqlRecord
record
=
_control
->
model
()
->
record
(
index
.
row
());
detailDlg
.
AddData
(
record
);
//卡券支付详情
QString
transId
=
record
.
value
(
"trans_id"
).
toString
();
FMPDataBase
*
database
=
_control
->
GetDB
();
QSqlQuery
query
;
if
(
!
database
->
find
(
DEFAULT_REDEEM_TABLE
,
query
,
QStringList
(),
QString
(
"trans_id=%1"
).
arg
(
transId
)))
{
FMP_ERROR
()
<<
"query redeem info failed"
;
}
else
{
while
(
query
.
next
())
{
QSqlRecord
record
=
query
.
record
();
detailDlg
.
AddData
(
record
);
}
}
detailDlg
.
exec
();
}
fmp_epayview_dialog.h
View file @
868048a7
...
...
@@ -101,7 +101,7 @@ private slots:
void
on_btn_waitPay_close_clicked
();
void
redeem
();
void
ShowPayDetail
(
const
QModelIndex
&
index
);
public
:
void
setPayView
();
...
...
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