Commit 9b0d07ae by 刘帅

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

parent 10d384ee
......@@ -207,7 +207,7 @@
<string>渠道:浦发银行</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labTime">
......
......@@ -65,8 +65,8 @@
}
#ebname{
font: 65 15pt &quot;微软雅黑&quot;;
color: rgb(255,255,255);
font: 65 13pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 0);
border:none;
}
......
......@@ -8,7 +8,6 @@ DateDialog::DateDialog(QWidget *parent) :
ui->setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
connect(ui->calendarWidget, SIGNAL(selectionChanged()), this, SLOT(OnSelectedChanged()));
connect(ui->closeBtn, SIGNAL(clicked(bool)), this, SLOT(close()));
}
......@@ -53,8 +52,16 @@ void DateDialog::keyPressEvent(QKeyEvent *e)
QDialog::keyPressEvent(e);
}
void DateDialog::OnSelectedChanged()
void DateDialog::close()
{
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:
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
private slots:
void OnSelectedChanged();
public slots:
void close();
void setDisplay(QDateTime dateTime);
signals:
void DateChanged(QDate curDate);
void DateChanged(QDateTime curDate);
private:
Ui::DateDialog *ui;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>464</width>
<height>346</height>
<height>356</height>
</rect>
</property>
<property name="windowTitle">
......@@ -34,7 +34,7 @@ QCalendarWidget QWidget#qt_calendar_navigationbar{
background: lightgrey;
}
QCalendarWidget QTableView{
font-size:25px;
font-size:16px;
}
#qt_calendar_monthbutton,#qt_calendar_yearbutton,#qt_calendar_monthbutton:focus,#qt_calendar_yearbutton:focus{
color:black;
......@@ -42,24 +42,13 @@ QCalendarWidget QTableView{
}
#qt_calendar_yearedit{
min-width:50px;
}</string>
}
#timeLabel,#timeEdit{
font-size:16px;
}
</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">
<property name="spacing">
......@@ -112,6 +101,42 @@ QCalendarWidget QTableView{
</property>
</widget>
</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>
</widget>
<resources/>
......
......@@ -19,6 +19,8 @@
#include <QDateTime>
extern bool isRedeeming;
#define DATE_TIME_FORMAT "yyyy-MM-dd HH:mm:ss"
RedeemDetail::RedeemDetail(int partnerId, QString storeId, QString url, QWidget *parent) :
QDialog(parent),
dateDlg(this),
......@@ -51,11 +53,21 @@ RedeemDetail::RedeemDetail(int partnerId, QString storeId, QString url, QWidget
connect(ui->delBtn, SIGNAL(clicked(bool)), this, SLOT(keyboardPressed(bool)));
connect(this, SIGNAL(Loaded(QJsonObject)), this, SLOT(ShowRedeemRecord(QJsonObject)));
connect(ui->shiftBtn, &QPushButton::clicked, this, &RedeemDetail::shiftWork);
ui->numWidget->hide();
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;
this->partnerId = partnerId;
......@@ -158,8 +170,8 @@ void RedeemDetail::LoadRedeemRecord()
QJsonObject reqObj;
reqObj["partnerId"] = partnerId;
reqObj["storeId"] = storeId;
reqObj["start"] = startDate.toString("yyyy-MM-dd 00:00:00");
reqObj["end"] = endDate.toString("yyyy-MM-dd 23:59:59");
reqObj["startTime"] = startTime.toString(DATE_TIME_FORMAT);
reqObj["endTime"] = endTime.toString(DATE_TIME_FORMAT);
QByteArray reqData = QJsonDocument(reqObj).toJson();
FMP_DEBUG() << "Send data: " << reqData;
......@@ -227,18 +239,28 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj)
ui->totalLabel->setText(QString::fromLocal8Bit("总核销 [%1]").arg(obj["msg"].toString()));
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;
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++)
{
QJsonObject tmp = logList[i].toObject();
if(stationId.trimmed() != tmp["pOSNO"].toString())
{
validNumber--;
continue;
}
QString couponCode = tmp["couponCode"].toString();
QString activeName = tmp["activeName"].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;
QString redeemDate;
if(tmp["redeemDate"].isString())
......@@ -252,7 +274,7 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj)
redeemDate = time.toString("yyyy-MM-dd HH:mm:ss");
}
totalMoney += realAmount;
totalMoney += faceAmount;
QList<QStandardItem*> row;
......@@ -273,22 +295,26 @@ void RedeemDetail::ShowRedeemRecord(QJsonObject obj)
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));
}
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();
disconnect(&dateDlg, SIGNAL(DateChanged(QDate)), this, SLOT(OnStartDateChanged(QDate)));
disconnect(&dateDlg, SIGNAL(DateChanged(QDateTime)), this, SLOT(OnStartDateChanged(QDateTime)));
}
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();
disconnect(&dateDlg, SIGNAL(DateChanged(QDate)), this, SLOT(OnEndDateChanged(QDate)));
disconnect(&dateDlg, SIGNAL(DateChanged(QDateTime)), this, SLOT(OnEndDateChanged(QDateTime)));
}
void RedeemDetail::keyboardPressed(bool)
......@@ -311,10 +337,10 @@ void RedeemDetail::keyboardPressed(bool)
}
}
void RedeemDetail::OnStartDateChanged(QDate cur)
void RedeemDetail::OnStartDateChanged(QDateTime cur)
{
startDate = cur;
ui->startDateBtn->setText(QString::fromLocal8Bit("开始日期:") + startDate.toString("yyyy-MM-dd"));
startTime = cur;
ui->startDateBtn->setText(QString::fromLocal8Bit("开始:") + startTime.toString(DATE_TIME_FORMAT));
if(reply != Q_NULLPTR)
{
......@@ -325,10 +351,10 @@ void RedeemDetail::OnStartDateChanged(QDate cur)
SetBusy(true);
}
void RedeemDetail::OnEndDateChanged(QDate cur)
void RedeemDetail::OnEndDateChanged(QDateTime cur)
{
endDate = cur;
ui->endDateBtn->setText(QString::fromLocal8Bit("结束日期:") + endDate.toString("yyyy-MM-dd"));
endTime = cur;
ui->endDateBtn->setText(QString::fromLocal8Bit("结束:") + endTime.toString(DATE_TIME_FORMAT));
if(reply != Q_NULLPTR)
{
......@@ -383,3 +409,18 @@ void RedeemDetail::SetBusy(bool busy)
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 @@
#include <QSqlQuery>
#include <QSqlError>
#include <QDate>
#include <QTime>
#include <QDateTime>
#include <QFuture>
#include <QStandardItemModel>
#include <QNetworkReply>
......@@ -49,12 +51,13 @@ private slots:
void OnStartDateClicked();
void OnEndDateClicked();
void keyboardPressed(bool);
void OnStartDateChanged(QDate cur);
void OnEndDateChanged(QDate cur);
void OnStartDateChanged(QDateTime cur);
void OnEndDateChanged(QDateTime cur);
void InitModel();
void ShowRedeemRecord(QJsonObject obj);
void FirstLoadRecord();
void SetBusy(bool busy);
void shiftWork(); //换班按钮响应函数
signals:
void Loaded(QJsonObject);
......@@ -69,6 +72,7 @@ private:
int partnerId;
QString storeId, url;
QDate startDate, endDate;
QDateTime startTime,endTime, shiftTime; //开始时间、结束时间、换班时间
QFuture<void> future;
QNetworkReply* reply;
};
......
......@@ -84,7 +84,7 @@ QHeaderView::section{
}
#findBtn, #startDateBtn, #endDateBtn, #keyBtn{
background-color:lightgrey;
font: normal 16px &quot;MicroSoft YaHei&quot;;
font: normal 13px &quot;MicroSoft YaHei&quot;;
border-radius:15px;
}
#findBtn:pressed, #startDateBtn:pressed, #endDateBtn:pressed{
......@@ -114,6 +114,11 @@ QHeaderView::section{
}
#tableView{
selection-background-color:rgb(0, 120, 215);
}
#shiftBtn{
background-color:lightgrey;
font: normal 13px &quot;MicroSoft YaHei&quot;;
border-radius:15px;
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
......@@ -214,7 +219,7 @@ QHeaderView::section{
<property name="minimumSize">
<size>
<width>900</width>
<height>200</height>
<height>100</height>
</size>
</property>
<property name="maximumSize">
......@@ -223,26 +228,17 @@ QHeaderView::section{
<height>200</height>
</size>
</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">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="totalLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
......@@ -267,6 +263,40 @@ QHeaderView::section{
</widget>
</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">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -336,8 +366,6 @@ QHeaderView::section{
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
......
......@@ -2,9 +2,10 @@
PartnerId=1946
[Pay]
Server="http://115.159.65.101:8001/api"
Server=http://115.159.65.101:8001/api
Timeout=60
[Coupon]
Server=http://115.159.142.32/api
RedeemLog=http://couponbackstage.freemudvip.com:8111/report/getLogList
\ No newline at end of file
RedeemLog=http://115.159.65.101:8111/fmcouponredeem/queryCouponRedeemReturnJson
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