Commit 6aa8b2c2 by Carwyn

1.同步基础接口InitService/UninitService

parent 96d23ec1
...@@ -20,23 +20,22 @@ FMPePay::FMPePay(ctkPluginContext *context) ...@@ -20,23 +20,22 @@ FMPePay::FMPePay(ctkPluginContext *context)
_ste_handler(new FMPStartEventHandler(_ctx, this)), _ste_handler(new FMPStartEventHandler(_ctx, this)),
d_ptr(new FMPePayPrivate(this)) d_ptr(new FMPePayPrivate(this))
{ {
} }
int FMPePay::StopService() void FMPePay::InitService()
{ {
if (!_inited) return FMP_SUCCESS; if (_inited) return;
Q_D(FMPePay); Q_D(FMPePay);
return d->StopService(); d->Init();
} }
int FMPePay::Pay() void FMPePay::UninitService()
{ {
if (_inited) return FMP_SUCCESS; if (_inited) {
Q_D(FMPePay); Q_D(FMPePay);
return d->Pay(); d->Uninit();
}
} }
void FMPePay::SetBasicInfo(QVariantHash hash) void FMPePay::SetBasicInfo(QVariantHash hash)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
class FMPePayPrivate; class FMPePayPrivate;
class FMPStartEventHandler; class FMPStartEventHandler;
class FMPePay : public QObject, public FMPePayInterface class FMPePay : public FMPePayInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(FMPBaseInterface) Q_INTERFACES(FMPBaseInterface)
...@@ -19,10 +19,13 @@ class FMPePay : public QObject, public FMPePayInterface ...@@ -19,10 +19,13 @@ class FMPePay : public QObject, public FMPePayInterface
public: public:
FMPePay(ctkPluginContext *context); FMPePay(ctkPluginContext *context);
int StopService();
int Pay();
void SetBasicInfo(QVariantHash hash); void SetBasicInfo(QVariantHash hash);
protected slots:
void InitService();
void UninitService();
private: private:
bool _inited; bool _inited;
bool _needanimation; bool _needanimation;
......
...@@ -7,11 +7,24 @@ ...@@ -7,11 +7,24 @@
* 业务插件接口,必须继承自 FMPluginInterface * 业务插件接口,必须继承自 FMPluginInterface
* @brief The FMPePayInterface class * @brief The FMPePayInterface class
*/ */
class FMPePayInterface : public FMPluginInterface class FMPePayInterface : public QObject, public FMPluginInterface
{ {
Q_OBJECT
public: public:
explicit FMPePayInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx) {} explicit FMPePayInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx)
virtual int Pay() = 0; {
connect(this, &FMPePayInterface::TriggerInit, this, &FMPePayInterface::InitService);
connect(this, &FMPePayInterface::TriggerUninit, this, &FMPePayInterface::UninitService);
}
protected slots:
void InitService() = 0;
void UninitService() = 0;
signals:
void TriggerInit();
void TriggerUninit();
// /** // /**
// * @brief ShowPayDialog // * @brief ShowPayDialog
// * 呈现支付主界面 // * 呈现支付主界面
......
...@@ -60,7 +60,7 @@ FMPePayPrivate::~FMPePayPrivate() ...@@ -60,7 +60,7 @@ FMPePayPrivate::~FMPePayPrivate()
} }
} }
int FMPePayPrivate::StopService() void FMPePayPrivate::Uninit()
{ {
Q_Q(FMPePay); Q_Q(FMPePay);
q->_inited = false; q->_inited = false;
...@@ -84,40 +84,12 @@ int FMPePayPrivate::StopService() ...@@ -84,40 +84,12 @@ int FMPePayPrivate::StopService()
delete _db; delete _db;
_db = nullptr; _db = nullptr;
} }
return FMP_SUCCESS;
} }
int FMPePayPrivate::Pay() void FMPePayPrivate::Init()
{ {
Q_Q(FMPePay); Q_Q(FMPePay);
q->_inited = true; q->_inited = true;
connect(this, SIGNAL(showPayWnd()), this, SLOT(onShowPayWnd()));
emit showPayWnd();
return FMP_SUCCESS;
}
void FMPePayPrivate::clearorder()
{
Q_Q(FMPePay);
QtConcurrent::run( [q, this]()
{
FMPDataBase db(q->_databasename, QString("fmp_pay_clean")) ;
QDateTime date = QDateTime::currentDateTime();
QDateTime tmpdate = date.addDays(-(q->_ordershelflife));
QString deletedate = tmpdate.toString("yyyy-MM-dd");
FMP_INFO() << "deletedate" <<deletedate;
db.dlt(q->_table, QString(QString(SQL_KEY_BUSSINEDATE) + "<datetime('%1')").arg(deletedate));
});
}
void FMPePayPrivate::onShowPayWnd()
{
Q_Q(FMPePay);
clearorder(); clearorder();
...@@ -179,6 +151,25 @@ void FMPePayPrivate::onShowPayWnd() ...@@ -179,6 +151,25 @@ void FMPePayPrivate::onShowPayWnd()
_payDialog->show(); _payDialog->show();
} }
void FMPePayPrivate::clearorder()
{
Q_Q(FMPePay);
QtConcurrent::run( [q, this]()
{
FMPDataBase db(q->_databasename, QString("fmp_pay_clean")) ;
QDateTime date = QDateTime::currentDateTime();
QDateTime tmpdate = date.addDays(-(q->_ordershelflife));
QString deletedate = tmpdate.toString("yyyy-MM-dd");
FMP_INFO() << "deletedate" <<deletedate;
db.dlt(q->_table, QString(QString(SQL_KEY_BUSSINEDATE) + "<datetime('%1')").arg(deletedate));
});
}
QSqlTableModel *FMPePayPrivate::model() const QSqlTableModel *FMPePayPrivate::model() const
{ {
return _model; return _model;
......
...@@ -21,9 +21,9 @@ public: ...@@ -21,9 +21,9 @@ public:
explicit FMPePayPrivate(FMPePay* parent); explicit FMPePayPrivate(FMPePay* parent);
~FMPePayPrivate(); ~FMPePayPrivate();
int StopService(); void Uninit();
int Pay(); void Init();
void ControlPayJson(QString sum, QString code); void ControlPayJson(QString sum, QString code);
...@@ -52,16 +52,11 @@ private: ...@@ -52,16 +52,11 @@ private:
void clearorder(); void clearorder();
signals: signals:
void showPayWnd();
void error(QString errormsg); void error(QString errormsg);
void finished(QJsonObject json); void finished(QJsonObject json);
protected slots:
public slots:
void onShowPayWnd();
void witedata(); void witedata();
public: public:
......
...@@ -579,7 +579,7 @@ void FMPPayDialog::on_btn_clear_clicked() ...@@ -579,7 +579,7 @@ void FMPPayDialog::on_btn_clear_clicked()
void FMPPayDialog::on_btn_close_clicked() void FMPPayDialog::on_btn_close_clicked()
{ {
this->hide(); this->hide();
_control->StopService(); _control->Uninit();
} }
void FMPPayDialog::onLineeditCodeGetFocus() void FMPPayDialog::onLineeditCodeGetFocus()
......
...@@ -18,7 +18,7 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event) ...@@ -18,7 +18,7 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
if (_epay) { if (_epay) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) { if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
// _epay->UpgradeOldPlugins(event.getProperty(FMP_PROPKEY_PID_LIST).toList()); // _epay->UpgradeOldPlugins(event.getProperty(FMP_PROPKEY_PID_LIST).toList());
_epay->Pay(); _epay->TriggerInit();
} }
else { else {
FMP_WARN() << "Refused start request" << event.getTopic(); FMP_WARN() << "Refused start request" << event.getTopic();
...@@ -45,7 +45,7 @@ void FMPNetWorkEventHandler::handleEvent(const ctkEvent &event) ...@@ -45,7 +45,7 @@ void FMPNetWorkEventHandler::handleEvent(const ctkEvent &event)
{ {
if (_epay) { if (_epay) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) { if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
_epay->Pay(); _epay->TriggerInit();
} }
else { else {
FMP_WARN() << "Refused start request" << event.getTopic(); FMP_WARN() << "Refused start request" << event.getTopic();
......
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