Commit 6aa8b2c2 by Carwyn

1.同步基础接口InitService/UninitService

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