Commit 9b0d07ae by 刘帅

添加换班功能,可按时间查询核销详情

parent 10d384ee
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
<string>渠道:浦发银行</string> <string>渠道:浦发银行</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labTime"> <widget class="QLabel" name="labTime">
......
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
} }
#ebname{ #ebname{
font: 65 15pt &quot;微软雅黑&quot;; font: 65 13pt &quot;微软雅黑&quot;;
color: rgb(255,255,255); color: rgb(255, 255, 0);
border:none; border:none;
} }
......
...@@ -8,7 +8,6 @@ DateDialog::DateDialog(QWidget *parent) : ...@@ -8,7 +8,6 @@ DateDialog::DateDialog(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
connect(ui->calendarWidget, SIGNAL(selectionChanged()), this, SLOT(OnSelectedChanged()));
connect(ui->closeBtn, SIGNAL(clicked(bool)), this, SLOT(close())); connect(ui->closeBtn, SIGNAL(clicked(bool)), this, SLOT(close()));
} }
...@@ -53,8 +52,16 @@ void DateDialog::keyPressEvent(QKeyEvent *e) ...@@ -53,8 +52,16 @@ void DateDialog::keyPressEvent(QKeyEvent *e)
QDialog::keyPressEvent(e); QDialog::keyPressEvent(e);
} }
void DateDialog::OnSelectedChanged() void DateDialog::close()
{ {
QDate cur = ui->calendarWidget->selectedDate(); QDate cur = ui->calendarWidget->selectedDate();
emit DateChanged(cur); QTime time = ui->timeEdit->time();
emit DateChanged(QDateTime(cur, time));
QDialog::close();
}
void DateDialog::setDisplay(QDateTime dateTime)
{
ui->calendarWidget->setSelectedDate(dateTime.date());
ui->timeEdit->setTime(dateTime.time());
} }
...@@ -22,12 +22,12 @@ protected: ...@@ -22,12 +22,12 @@ protected:
void mouseMoveEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e); void keyPressEvent(QKeyEvent *e);
public slots:
private slots: void close();
void OnSelectedChanged(); void setDisplay(QDateTime dateTime);
signals: signals:
void DateChanged(QDate curDate); void DateChanged(QDateTime curDate);
private: private:
Ui::DateDialog *ui; Ui::DateDialog *ui;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>464</width> <width>464</width>
<height>346</height> <height>356</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -34,7 +34,7 @@ QCalendarWidget QWidget#qt_calendar_navigationbar{ ...@@ -34,7 +34,7 @@ QCalendarWidget QWidget#qt_calendar_navigationbar{
background: lightgrey; background: lightgrey;
} }
QCalendarWidget QTableView{ QCalendarWidget QTableView{
font-size:25px; font-size:16px;
} }
#qt_calendar_monthbutton,#qt_calendar_yearbutton,#qt_calendar_monthbutton:focus,#qt_calendar_yearbutton:focus{ #qt_calendar_monthbutton,#qt_calendar_yearbutton,#qt_calendar_monthbutton:focus,#qt_calendar_yearbutton:focus{
color:black; color:black;
...@@ -42,24 +42,13 @@ QCalendarWidget QTableView{ ...@@ -42,24 +42,13 @@ QCalendarWidget QTableView{
} }
#qt_calendar_yearedit{ #qt_calendar_yearedit{
min-width:50px; min-width:50px;
}</string> }
#timeLabel,#timeEdit{
font-size:16px;
}
</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <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> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing"> <property name="spacing">
...@@ -112,6 +101,42 @@ QCalendarWidget QTableView{ ...@@ -112,6 +101,42 @@ QCalendarWidget QTableView{
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="timeLayout">
<item>
<widget class="QLabel" name="timeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>时间:</string>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="timeEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="displayFormat">
<string>HH:mm:ss</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include <QDateTime> #include <QDateTime>
extern bool isRedeeming; extern bool isRedeeming;
#define DATE_TIME_FORMAT "yyyy-MM-dd HH:mm:ss"
RedeemDetail::RedeemDetail(int partnerId, QString storeId, QString url, QWidget *parent) : RedeemDetail::RedeemDetail(int partnerId, QString storeId, QString url, QWidget *parent) :
QDialog(parent), QDialog(parent),
dateDlg(this), dateDlg(this),
...@@ -51,11 +53,21 @@ RedeemDetail::RedeemDetail(int partnerId, QString storeId, QString url, QWidget ...@@ -51,11 +53,21 @@ RedeemDetail::RedeemDetail(int partnerId, QString storeId, QString url, QWidget
connect(ui->delBtn, SIGNAL(clicked(bool)), this, SLOT(keyboardPressed(bool))); connect(ui->delBtn, SIGNAL(clicked(bool)), this, SLOT(keyboardPressed(bool)));
connect(this, SIGNAL(Loaded(QJsonObject)), this, SLOT(ShowRedeemRecord(QJsonObject))); connect(this, SIGNAL(Loaded(QJsonObject)), this, SLOT(ShowRedeemRecord(QJsonObject)));
connect(ui->shiftBtn, &QPushButton::clicked, this, &RedeemDetail::shiftWork);
ui->numWidget->hide(); ui->numWidget->hide();
startDate = endDate = QDate::currentDate(); startDate = endDate = QDate::currentDate();
ui->startDateBtn->setText(QString::fromLocal8Bit("开始日期:") + startDate.toString("yyyy-MM-dd"));
ui->endDateBtn->setText(QString::fromLocal8Bit("结束日期:") + endDate.toString("yyyy-MM-dd")); QSettings settings(QString("%1/server_url.ini").arg(QCoreApplication::applicationDirPath()), QSettings::IniFormat);
QString shiftTimeString = settings.value("Coupon/shiftTime").toString();
shiftTime = QDateTime::fromString(shiftTimeString, DATE_TIME_FORMAT);
if(!shiftTime.isValid())
shiftTime = QDateTime::currentDateTime();
startTime = shiftTime;
endTime = QDateTime::currentDateTime();
ui->startDateBtn->setText(QString::fromLocal8Bit("开始:") + startTime.toString(DATE_TIME_FORMAT));
ui->endDateBtn->setText(QString::fromLocal8Bit("结束:") + endTime.toString(DATE_TIME_FORMAT));
isRedeeming = true; isRedeeming = true;
this->partnerId = partnerId; this->partnerId = partnerId;
...@@ -158,8 +170,8 @@ void RedeemDetail::LoadRedeemRecord() ...@@ -158,8 +170,8 @@ void RedeemDetail::LoadRedeemRecord()
QJsonObject reqObj; QJsonObject reqObj;
reqObj["partnerId"] = partnerId; reqObj["partnerId"] = partnerId;
reqObj["storeId"] = storeId; reqObj["storeId"] = storeId;
reqObj["start"] = startDate.toString("yyyy-MM-dd 00:00:00"); reqObj["startTime"] = startTime.toString(DATE_TIME_FORMAT);
reqObj["end"] = endDate.toString("yyyy-MM-dd 23:59:59"); reqObj["endTime"] = endTime.toString(DATE_TIME_FORMAT);
QByteArray reqData = QJsonDocument(reqObj).toJson(); QByteArray reqData = QJsonDocument(reqObj).toJson();
FMP_DEBUG() << "Send data: " << reqData; FMP_DEBUG() << "Send data: " << reqData;
...@@ -227,18 +239,28 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj) ...@@ -227,18 +239,28 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj)
ui->totalLabel->setText(QString::fromLocal8Bit("总核销 [%1]").arg(obj["msg"].toString())); ui->totalLabel->setText(QString::fromLocal8Bit("总核销 [%1]").arg(obj["msg"].toString()));
return; return;
} }
ui->totalLabel->setText(QString::fromLocal8Bit("总核销 [%1 - %2]").arg(startDate.toString("yyyy/MM/dd")).arg(endDate.toString("yyyy/MM/dd"))); ui->totalLabel->setText(QString::fromLocal8Bit("总核销 [%1 - %2]").arg(startTime.toString(DATE_TIME_FORMAT)).arg(endTime.toString(DATE_TIME_FORMAT)));
double totalMoney = 0.0; double totalMoney = 0.0;
QJsonArray logList = obj["logList"].toArray();
QSettings settings(QString("%1/FreemudPOS.ini").arg(QCoreApplication::applicationDirPath()), QSettings::IniFormat);
QString stationId = settings.value(FMP_INIKEY_LOGINPOSID).toString();
QJsonArray logList = obj["bossRedeemList"].toArray();
int validNumber = logList.size();
for(int i = 0; i < logList.size(); i++) for(int i = 0; i < logList.size(); i++)
{ {
QJsonObject tmp = logList[i].toObject(); QJsonObject tmp = logList[i].toObject();
if(stationId.trimmed() != tmp["pOSNO"].toString())
{
validNumber--;
continue;
}
QString couponCode = tmp["couponCode"].toString(); QString couponCode = tmp["couponCode"].toString();
QString activeName = tmp["activeName"].toString(); QString activeName = tmp["activeName"].toString();
QString channel = tmp["channel"].toString(); QString channel = tmp["channel"].toString();
double faceAmount = tmp["amount"].toInt()/100.0; double faceAmount = tmp["priceOriginal"].toInt();
double realAmount = tmp["realAmount"].toInt()/100.0; double realAmount = tmp["realAmount"].toInt()/100.0;
QString redeemDate; QString redeemDate;
if(tmp["redeemDate"].isString()) if(tmp["redeemDate"].isString())
...@@ -252,7 +274,7 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj) ...@@ -252,7 +274,7 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj)
redeemDate = time.toString("yyyy-MM-dd HH:mm:ss"); redeemDate = time.toString("yyyy-MM-dd HH:mm:ss");
} }
totalMoney += realAmount; totalMoney += faceAmount;
QList<QStandardItem*> row; QList<QStandardItem*> row;
...@@ -273,22 +295,26 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj) ...@@ -273,22 +295,26 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj)
model.appendRow(row); model.appendRow(row);
} }
ui->totalRedeem->setText(QString::fromLocal8Bit("总核销数: %1").arg(logList.size())); ui->totalRedeem->setText(QString::fromLocal8Bit("总核销数: %1").arg(validNumber));
ui->totalRedeemMoney->setText(QString::fromLocal8Bit("总核销额: %1").arg(totalMoney)); ui->totalRedeemMoney->setText(QString::fromLocal8Bit("总核销额: %1").arg(totalMoney));
} }
void RedeemDetail::OnStartDateClicked() void RedeemDetail::OnStartDateClicked()
{ {
connect(&dateDlg, SIGNAL(DateChanged(QDate)), this, SLOT(OnStartDateChanged(QDate))); connect(&dateDlg, SIGNAL(DateChanged(QDateTime)), this, SLOT(OnStartDateChanged(QDateTime)));
QDateTime currentDisplay = QDateTime::fromString(ui->startDateBtn->text(), QString::fromLocal8Bit("开始:") + DATE_TIME_FORMAT);
dateDlg.setDisplay(currentDisplay);
dateDlg.exec(); dateDlg.exec();
disconnect(&dateDlg, SIGNAL(DateChanged(QDate)), this, SLOT(OnStartDateChanged(QDate))); disconnect(&dateDlg, SIGNAL(DateChanged(QDateTime)), this, SLOT(OnStartDateChanged(QDateTime)));
} }
void RedeemDetail::OnEndDateClicked() void RedeemDetail::OnEndDateClicked()
{ {
connect(&dateDlg, SIGNAL(DateChanged(QDate)), this, SLOT(OnEndDateChanged(QDate))); connect(&dateDlg, SIGNAL(DateChanged(QDateTime)), this, SLOT(OnEndDateChanged(QDateTime)));
QDateTime currentDisplay = QDateTime::fromString(ui->endDateBtn->text(), QString::fromLocal8Bit("结束:") + DATE_TIME_FORMAT);
dateDlg.setDisplay(currentDisplay);
dateDlg.exec(); dateDlg.exec();
disconnect(&dateDlg, SIGNAL(DateChanged(QDate)), this, SLOT(OnEndDateChanged(QDate))); disconnect(&dateDlg, SIGNAL(DateChanged(QDateTime)), this, SLOT(OnEndDateChanged(QDateTime)));
} }
void RedeemDetail::keyboardPressed(bool) void RedeemDetail::keyboardPressed(bool)
...@@ -311,10 +337,10 @@ void RedeemDetail::keyboardPressed(bool) ...@@ -311,10 +337,10 @@ void RedeemDetail::keyboardPressed(bool)
} }
} }
void RedeemDetail::OnStartDateChanged(QDate cur) void RedeemDetail::OnStartDateChanged(QDateTime cur)
{ {
startDate = cur; startTime = cur;
ui->startDateBtn->setText(QString::fromLocal8Bit("开始日期:") + startDate.toString("yyyy-MM-dd")); ui->startDateBtn->setText(QString::fromLocal8Bit("开始:") + startTime.toString(DATE_TIME_FORMAT));
if(reply != Q_NULLPTR) if(reply != Q_NULLPTR)
{ {
...@@ -325,10 +351,10 @@ void RedeemDetail::OnStartDateChanged(QDate cur) ...@@ -325,10 +351,10 @@ void RedeemDetail::OnStartDateChanged(QDate cur)
SetBusy(true); SetBusy(true);
} }
void RedeemDetail::OnEndDateChanged(QDate cur) void RedeemDetail::OnEndDateChanged(QDateTime cur)
{ {
endDate = cur; endTime = cur;
ui->endDateBtn->setText(QString::fromLocal8Bit("结束日期:") + endDate.toString("yyyy-MM-dd")); ui->endDateBtn->setText(QString::fromLocal8Bit("结束:") + endTime.toString(DATE_TIME_FORMAT));
if(reply != Q_NULLPTR) if(reply != Q_NULLPTR)
{ {
...@@ -383,3 +409,18 @@ void RedeemDetail::SetBusy(bool busy) ...@@ -383,3 +409,18 @@ void RedeemDetail::SetBusy(bool busy)
loadingDlg.hide(); loadingDlg.hide();
} }
} }
void RedeemDetail::shiftWork()
{
QDateTime currentTime = QDateTime::currentDateTime();
QString shiftTimeString = currentTime.toString(DATE_TIME_FORMAT);
FMP_INFO() << "shift work: " << shiftTimeString;
//显示本班次的核销详情
OnStartDateChanged(shiftTime);
OnEndDateChanged(currentTime);
QSettings settings(QString("%1/server_url.ini").arg(QCoreApplication::applicationDirPath()), QSettings::IniFormat);
settings.setValue("Coupon/shiftTime", shiftTimeString);
shiftTime = currentTime;
return;
}
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <QSqlQuery> #include <QSqlQuery>
#include <QSqlError> #include <QSqlError>
#include <QDate> #include <QDate>
#include <QTime>
#include <QDateTime>
#include <QFuture> #include <QFuture>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QNetworkReply> #include <QNetworkReply>
...@@ -49,12 +51,13 @@ private slots: ...@@ -49,12 +51,13 @@ private slots:
void OnStartDateClicked(); void OnStartDateClicked();
void OnEndDateClicked(); void OnEndDateClicked();
void keyboardPressed(bool); void keyboardPressed(bool);
void OnStartDateChanged(QDate cur); void OnStartDateChanged(QDateTime cur);
void OnEndDateChanged(QDate cur); void OnEndDateChanged(QDateTime cur);
void InitModel(); void InitModel();
void ShowRedeemRecord(QJsonObject obj); void ShowRedeemRecord(QJsonObject obj);
void FirstLoadRecord(); void FirstLoadRecord();
void SetBusy(bool busy); void SetBusy(bool busy);
void shiftWork(); //换班按钮响应函数
signals: signals:
void Loaded(QJsonObject); void Loaded(QJsonObject);
...@@ -69,6 +72,7 @@ private: ...@@ -69,6 +72,7 @@ private:
int partnerId; int partnerId;
QString storeId, url; QString storeId, url;
QDate startDate, endDate; QDate startDate, endDate;
QDateTime startTime,endTime, shiftTime; //开始时间、结束时间、换班时间
QFuture<void> future; QFuture<void> future;
QNetworkReply* reply; QNetworkReply* reply;
}; };
......
...@@ -84,7 +84,7 @@ QHeaderView::section{ ...@@ -84,7 +84,7 @@ QHeaderView::section{
} }
#findBtn, #startDateBtn, #endDateBtn, #keyBtn{ #findBtn, #startDateBtn, #endDateBtn, #keyBtn{
background-color:lightgrey; background-color:lightgrey;
font: normal 16px &quot;MicroSoft YaHei&quot;; font: normal 13px &quot;MicroSoft YaHei&quot;;
border-radius:15px; border-radius:15px;
} }
#findBtn:pressed, #startDateBtn:pressed, #endDateBtn:pressed{ #findBtn:pressed, #startDateBtn:pressed, #endDateBtn:pressed{
...@@ -114,6 +114,11 @@ QHeaderView::section{ ...@@ -114,6 +114,11 @@ QHeaderView::section{
} }
#tableView{ #tableView{
selection-background-color:rgb(0, 120, 215); selection-background-color:rgb(0, 120, 215);
}
#shiftBtn{
background-color:lightgrey;
font: normal 13px &quot;MicroSoft YaHei&quot;;
border-radius:15px;
}</string> }</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
...@@ -214,7 +219,7 @@ QHeaderView::section{ ...@@ -214,7 +219,7 @@ QHeaderView::section{
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>900</width> <width>900</width>
<height>200</height> <height>100</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
...@@ -223,26 +228,17 @@ QHeaderView::section{ ...@@ -223,26 +228,17 @@ QHeaderView::section{
<height>200</height> <height>200</height>
</size> </size>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<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="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="totalLabel"> <widget class="QLabel" name="totalLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>700</width> <width>700</width>
...@@ -267,6 +263,40 @@ QHeaderView::section{ ...@@ -267,6 +263,40 @@ QHeaderView::section{
</widget> </widget>
</item> </item>
<item> <item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="shiftBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>75</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>换班</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
...@@ -336,8 +366,6 @@ QHeaderView::section{ ...@@ -336,8 +366,6 @@ QHeaderView::section{
</layout> </layout>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
PartnerId=1946 PartnerId=1946
[Pay] [Pay]
Server="http://115.159.65.101:8001/api" Server=http://115.159.65.101:8001/api
Timeout=60 Timeout=60
[Coupon] [Coupon]
Server=http://115.159.142.32/api Server=http://115.159.142.32/api
RedeemLog=http://couponbackstage.freemudvip.com:8111/report/getLogList RedeemLog=http://115.159.65.101:8111/fmcouponredeem/queryCouponRedeemReturnJson
\ No newline at end of file shiftTime=2019-06-26 19:59:16
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment