Commit b06641a5 by guanghui.cui

插件更新

parent 26345010
......@@ -3,10 +3,10 @@
#include "fmp_pe_handlers.h"
#include <QDateTime>
class ctkPluginContext;
FMPePay::FMPePay(ctkPluginContext *context)
: FMPePayInterface(context),
FMPePay::FMPePay(const FMPContext ctx)
: FMPePayInterface(),
pluginContext(ctx),
//_url(DEFAULT_EPAY_RWQUESTURL),
_inited(false),
//_needanimation(false),
......@@ -19,7 +19,7 @@ FMPePay::FMPePay(ctkPluginContext *context)
_store_id(DEFAULT_EPAY_STRID),
_station_id(DEFAULT_EPAY_STNID),
_time_out(60),
_ste_handler(new FMPStartEventHandler(_ctx, this)),
_ste_handler(new FMPStartEventHandler(this)),
d_ptr(new FMPePayPrivate(this))
{
}
......
......@@ -18,7 +18,7 @@ class FMPePay : public FMPePayInterface
Q_DECLARE_PRIVATE(FMPePay)
public:
explicit FMPePay(ctkPluginContext *context);
explicit FMPePay(const FMPContext ctx);
virtual ~FMPePay();
void SetBasicInfo(QVariantHash hash);
......@@ -28,12 +28,13 @@ public:
void DockRefundRequest(const QByteArray &json);
QByteArray DockRefundRespond();
protected:
const FMPContext GetContext() const { return pluginContext; }
protected slots:
void InitService();
void UninitService();
private:
bool _inited;
//bool _needanimation;
......@@ -52,6 +53,7 @@ private:
int _ordershelflife;
FMPePayPrivate* d_ptr;
const FMPContext pluginContext;
QPointer<FMPStartEventHandler> _ste_handler;
};
......
......@@ -16,7 +16,7 @@ class FMPePayInterface : public QObject, public FMPluginInterface
Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPluginInterface)
public:
explicit FMPePayInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx)
explicit FMPePayInterface() : FMPluginInterface()
{
connect(this, &FMPePayInterface::TriggerInit, this, &FMPePayInterface::OnTriggerInit);
connect(this, &FMPePayInterface::TriggerUninit, this, &FMPePayInterface::OnTriggerUninit);
......@@ -35,38 +35,9 @@ signals:
protected slots:
void OnTriggerInit() { FMPluginInterface::OnTriggerInit(); }
void OnTriggerUninit() { FMPluginInterface::OnTriggerUninit(); }
// /**
// * @brief ShowPayDialog
// * 呈现支付主界面
// * @return
// */
// virtual int ShowPayDialog() = 0;
// /**
// * @brief ControlPayJson
// * 获取发送支付请求
// * @param sum
// * @param code
// */
// virtual void ControlPayJson(QString sum, QString code) = 0;
// /**
// * @brief ControlRefundJson
// * 获取发送退款请求
// * @param sum
// * @param code(fmID/pay_transId)
// */
// virtual void ControlRefundJson(QString sum, QString code) = 0;
// /**
// * @brief ControlReverseJson
// * 冲正
// */
// virtual void ControlReverseJson() = 0;
};
Q_DECLARE_INTERFACE(FMPePayInterface, "com.fmp.epay")
Q_DECLARE_INTERFACE(FMPePayInterface, "fmp.epay")
#endif // FMP_LOGGER_I_H
......@@ -2,7 +2,6 @@
#include <QDateTime>
#include <fmp_settings_i.h>
#include <QCoreApplication>
#include <ctkPluginContext.h>
#include <ctkServiceReference.h>
#include "fmp_epay_p.h"
#include "fmp_epay_def.h"
......@@ -46,7 +45,6 @@ FMPePayPrivate::FMPePayPrivate(FMPePay *parent)
_queryThread(nullptr)
{
Q_Q(FMPePay);
FMPLoggerInterface::InitContext(q_ptr->_ctx);
_watcher = new QFutureWatcher<QByteArray>();
connect( _watcher, SIGNAL( finished() ), this, SLOT( witedata() ) );
......@@ -87,14 +85,25 @@ FMPePayPrivate::FMPePayPrivate(FMPePay *parent)
_queryThread=new CQueryThread(this);
//读取配置文件信息
_setting = q->GetService<FMPSettingsInterface>(q->_ctx);
q->_url = _setting->GetString(FMP_INIKEY_EPAYURL);
q->_partner_id = _setting->GetString(FMP_INIKEY_LOGINPARTNERID);
q->_time_out = _setting->GetInt(FMP_INIKEY_EPAYTIMEOUT);
QString apppath=QCoreApplication::applicationDirPath();
QSettings *settings = new QSettings(QString("%1/FreemudPOS.ini").arg(apppath), QSettings::IniFormat);
q->_url = settings->value(FMP_INIKEY_EPAYURL).toString();
q->_partner_id = settings->value(FMP_INIKEY_LOGINPARTNERID).toString();
q->_time_out = settings->value(FMP_INIKEY_EPAYTIMEOUT).toInt();
q->_time_out = (q->_time_out > 60 ? q->_time_out : 60);
q->_store_id = _setting->GetString(FMP_INIKEY_LOGINSTOREID);
q->_station_id = _setting->GetString(FMP_INIKEY_LOGINPOSID);
q->_operator_id = _setting->GetString(FMP_INIKEY_LOGINCASHIER);
q->_store_id = settings->value(FMP_INIKEY_LOGINSTOREID).toString();
q->_station_id = settings->value(FMP_INIKEY_LOGINPOSID).toString();
q->_operator_id = settings->value(FMP_INIKEY_LOGINCASHIER).toString();
delete settings;
// _setting = FMP::GetService<FMPSettingsInterface>();
// q->_url = _setting->GetString(FMP_INIKEY_EPAYURL);
// q->_partner_id = _setting->GetString(FMP_INIKEY_LOGINPARTNERID);
// q->_time_out = _setting->GetInt(FMP_INIKEY_EPAYTIMEOUT);
// q->_time_out = (q->_time_out > 60 ? q->_time_out : 60);
// q->_store_id = _setting->GetString(FMP_INIKEY_LOGINSTOREID);
// q->_station_id = _setting->GetString(FMP_INIKEY_LOGINPOSID);
// q->_operator_id = _setting->GetString(FMP_INIKEY_LOGINCASHIER);
//检查异常订单
CheckErrorOrder();
......@@ -172,7 +181,7 @@ void FMPePayPrivate::Init()
if(_network == nullptr)
{
_network = q->GetService<FMPNetworkInterface>(q->_ctx);
_network = FMP::GetService<FMPNetworkInterface>();
}
if(_model == nullptr)
......@@ -190,9 +199,11 @@ void FMPePayPrivate::Init()
hash[FMP_EPAY_PARTNERID] = q->_partner_id;
hash[FMP_EPAY_TIMEOUT] = q->_time_out;
//更新日期
q->_businessdate=QDateTime::currentDateTime().toString("yyyy-MM-dd");
if (!_is_api) {
hash[FMP_EPAY_ANIMATION] = _setting->GetBool(FMP_INIKEY_ANIMATION);
//hash[FMP_EPAY_ANIMATION] = _setting->GetBool(FMP_INIKEY_ANIMATION);
hash[FMP_EPAY_ANIMATION] = true;
hash[FMP_EPAY_BUSINESSDATE] = q->_businessdate;
hash[FMP_EPAY_STOREID] = q->_store_id;
hash[FMP_EPAY_STATIONID] = q->_station_id;
......@@ -229,7 +240,7 @@ void FMPePayPrivate::Init()
}
hash["products"] = products;
}
FMP_INFO() << "++++++++++++++++++request JOSN" <<hash;
_payDialog = new FMPPayDialog(this, hash);
}
......@@ -326,6 +337,7 @@ void FMPePayPrivate::DockRefundRequest(const QByteArray &json)
{
_is_api = true;
_origin_request = QJsonDocument::fromJson(json).object();
FMP_INFO() << "DockRefundRequest : " << _docked_request;
}
QByteArray FMPePayPrivate::DockRefundRespond()
......@@ -588,6 +600,7 @@ void FMPePayPrivate::ControlRefundJson(const QJsonObject &trans)
Q_Q(FMPePay);
_origin_response = QJsonObject();
FMP_INFO() << "RefundJson trans: " << trans;
QtConcurrent::run( [q, trans, this ]()
{
QStringList keylist;
......@@ -718,8 +731,8 @@ bool FMPePayPrivate::GetPayJson(const QString& sum, const QString& code)
products.append(o);
}
transaction["products"] = products;
_docked_request[FMP_EPAY_STOREID] = _origin_request[FMP_EPAY_STOREID];
_docked_request[FMP_EPAY_STATIONID] = _origin_request["pos_id"];
_docked_request[FMP_EPAY_STOREID] = q->_store_id;
_docked_request[FMP_EPAY_STATIONID] = q->_station_id;
_docked_request[FMP_EPAY_OPERATORID] = _origin_request[FMP_EPAY_OPERATORID];
_docked_request[FMP_EPAY_BUSINESSDATE] = _origin_request[FMP_EPAY_BUSINESSDATE];
}
......@@ -762,6 +775,7 @@ bool FMPePayPrivate::GetRefundJson(const QJsonObject &trans)
int ver = 2;
FMP_INFO() << "RefundJson trans: " << trans;
if(trans.contains(FMP_JKEY_FM_ORDERID) && !trans[FMP_JKEY_FM_ORDERID].toString().isEmpty())
{
transaction.insert(FMP_EPAY_REFUND_TRANSTRACTION_FMID, trans[FMP_JKEY_FM_ORDERID]);
......@@ -801,7 +815,7 @@ bool FMPePayPrivate::GetRefundJson(const QJsonObject &trans)
_docked_request.insert( FMP_EPAY_OPERATORID, q->_operator_id);
_docked_request.insert( FMP_EPAY_TRANSTRACTION, transactionarry);
}
FMP_INFO() << "Refund Json:" << _docked_request;
return true;
}
......@@ -952,6 +966,7 @@ bool FMPePayPrivate::SendToMonitor(const QByteArray &data)
result=false;
}
client.close();
delete[] m_pFmPackage;
return result;
}
......@@ -986,8 +1001,8 @@ void FMPePayPrivate::GetDailyBillData(QVector<PayDetail> &vecPay)
QSqlQuery query;
PayDetail pay;
//支付宝查询
if(!_db->find(q->_table, query, keylist, QString("statusCode = %1 and business_date= '%2' and pay_ebcode='%3'").arg(100).arg(q->_businessdate).arg("10001")) || !query.next()) {
FMP_ERROR() << "查询支付数据错误!";
if(!_db->find(q->_table, query, keylist, QString("statusCode = %1 and addtime like '%2%%' and pay_ebcode='%3'").arg(100).arg(q->_businessdate).arg("10001")) || !query.next()) {
FMP_ERROR() << "查询支付数据错误!";
}
else {
pay.name=QString::fromLocal8Bit("支付宝");
......@@ -997,8 +1012,8 @@ void FMPePayPrivate::GetDailyBillData(QVector<PayDetail> &vecPay)
vecPay.push_back(pay);
}
//微信查询
if(!_db->find(q->_table, query, keylist, QString("statusCode = %1 and business_date= '%2' and pay_ebcode='%3'").arg(100).arg(q->_businessdate).arg("10004")) || !query.next()) {
FMP_ERROR() << "查询支付数据错误!";
if(!_db->find(q->_table, query, keylist, QString("statusCode = %1 and addtime like '%2%%' and pay_ebcode='%3'").arg(100).arg(q->_businessdate).arg("10004")) || !query.next()) {
FMP_ERROR() << "查询微信数据错误!";
}
else {
pay.name=QString::fromLocal8Bit("微信");
......@@ -1008,8 +1023,8 @@ void FMPePayPrivate::GetDailyBillData(QVector<PayDetail> &vecPay)
vecPay.push_back(pay);
}
//全部查询
if(!_db->find(q->_table, query, keylist, QString("statusCode = %1 and business_date= '%2'").arg(100).arg(q->_businessdate)) || !query.next()) {
FMP_ERROR() << "查询支付数据错误!";
if(!_db->find(q->_table, query, keylist, QString("statusCode = %1 and addtime like '%2%%'").arg(100).arg(q->_businessdate)) || !query.next()) {
FMP_ERROR() << "查询全部支付数据错误!";
}
else {
pay.name=QString::fromLocal8Bit("全部");
......@@ -1020,8 +1035,9 @@ void FMPePayPrivate::GetDailyBillData(QVector<PayDetail> &vecPay)
}
//QString::number(json[FMP_RPAY_PAY_RETURN_TOTAL].toDouble()/100)
//未成功支付
if(!_db->find(q->_table, query, keylist, QString("statusCode != %1 and business_date= '%2'").arg(100).arg(q->_businessdate)) || !query.next()) {
FMP_ERROR() << "查询支付数据错误!";
FMP_INFO() << "未成功支付查询!";
if(!_db->find(q->_table, query, keylist, QString("statusCode != %1 and addtime like '%2%%'").arg(100).arg(q->_businessdate)) || !query.next()) {
FMP_ERROR() << "查询未成功支付数据错误!";
}
else {
pay.name=QString::fromLocal8Bit("");
......
......@@ -749,6 +749,11 @@ void FMPPayDialog::PlayAnimation(QWidget *target0, QWidget *target1, Movemode mo
ui->btn_pay->setEnabled(false);
ui->btn_refund->setEnabled(false);
ui->btn_check->setEnabled(false);
ui->btn_waitPay->setEnabled(false);
ui->btn_errorOrder->setEnabled(false);
ui->btn_success->setEnabled(false);
ui->btn_done->setEnabled(false);
ui->btn_dailyBill->setEnabled(false);
int tg0_begin_x = 0, tg0_begin_y = 0;
int tg0_end_x = 0, tg0_end_y = 0;
......@@ -823,6 +828,11 @@ void FMPPayDialog::PlayAnimation(QWidget *target0, QWidget *target1, Movemode mo
ui->btn_pay->setEnabled(true);
ui->btn_refund->setEnabled(true);
ui->btn_check->setEnabled(true);
ui->btn_waitPay->setEnabled(true);
ui->btn_errorOrder->setEnabled(true);
ui->btn_success->setEnabled(true);
ui->btn_done->setEnabled(true);
ui->btn_dailyBill->setEnabled(true);
}
//确定按钮
......@@ -973,7 +983,7 @@ void FMPPayDialog::on_pushButton_2_clicked()
_wait->SetContent(FMPPayWait::LOADING, QString::fromLocal8Bit("退款中..."));
QJsonObject trans;
trans["refund_amount"] = ((int)model->data(idx.sibling(idx.row(), 6)).toDouble() + 0.005) * 100;
trans["refund_amount"] = (int)((model->data(idx.sibling(idx.row(), 6)).toDouble() + 0.005) * 100);
trans["fm_id"] = model->data(idx.sibling(idx.row(),0)).toString();
_control->ControlRefundJson(trans);
......@@ -1064,7 +1074,7 @@ void FMPPayDialog::setShowFunc()
}
else{
ui->btn_pay->setVisible(false);
ui->btn_check->setVisible(false);
ui->btn_check->setVisible(true);
ui->btn_refund->setVisible(false);
ui->btn_waitPay->setVisible(true);
ui->btn_errorOrder->setVisible(true);
......
......@@ -769,7 +769,7 @@ QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical
<property name="minimumSize">
<size>
<width>0</width>
<height>395</height>
<height>420</height>
</size>
</property>
<property name="maximumSize">
......@@ -790,19 +790,19 @@ QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical
<x>0</x>
<y>0</y>
<width>628</width>
<height>405</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>628</width>
<height>405</height>
<height>420</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>628</width>
<height>405</height>
<height>420</height>
</size>
</property>
<property name="styleSheet">
......@@ -1517,19 +1517,19 @@ QPushButton:hover {
<x>0</x>
<y>0</y>
<width>628</width>
<height>405</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>628</width>
<height>405</height>
<height>420</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>628</width>
<height>405</height>
<height>420</height>
</size>
</property>
<property name="styleSheet">
......@@ -2816,19 +2816,19 @@ border:0px</string>
<x>0</x>
<y>0</y>
<width>628</width>
<height>405</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>628</width>
<height>405</height>
<height>420</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>628</width>
<height>405</height>
<height>420</height>
</size>
</property>
<property name="styleSheet">
......@@ -3082,9 +3082,15 @@ QHeaderView::section {
<x>0</x>
<y>0</y>
<width>626</width>
<height>405</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>420</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
......@@ -3094,7 +3100,7 @@ QHeaderView::section {
<x>0</x>
<y>52</y>
<width>621</width>
<height>321</height>
<height>361</height>
</rect>
</property>
<property name="minimumSize">
......@@ -3238,9 +3244,15 @@ QHeaderView::section {
<x>0</x>
<y>0</y>
<width>628</width>
<height>405</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>420</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
......@@ -3250,7 +3262,7 @@ QHeaderView::section {
<x>0</x>
<y>0</y>
<width>628</width>
<height>405</height>
<height>411</height>
</rect>
</property>
<property name="styleSheet">
......@@ -3288,9 +3300,15 @@ QHeaderView::section {
<x>0</x>
<y>0</y>
<width>628</width>
<height>405</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>420</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
......@@ -3300,7 +3318,7 @@ QHeaderView::section {
<x>0</x>
<y>0</y>
<width>628</width>
<height>363</height>
<height>421</height>
</rect>
</property>
<property name="styleSheet">
......@@ -3338,9 +3356,15 @@ QHeaderView::section {
<x>0</x>
<y>0</y>
<width>628</width>
<height>405</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>420</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
......@@ -3350,7 +3374,7 @@ QHeaderView::section {
<x>0</x>
<y>0</y>
<width>661</width>
<height>401</height>
<height>421</height>
</rect>
</property>
<property name="styleSheet">
......@@ -3388,9 +3412,15 @@ QHeaderView::section {
<x>5</x>
<y>10</y>
<width>631</width>
<height>381</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>420</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
......@@ -3488,15 +3518,15 @@ QHeaderView::section {
</property>
</widget>
</widget>
<zorder>wdg_errorPay_main</zorder>
<zorder>wdg_refund_main</zorder>
<zorder>wdg_hasPay_main</zorder>
<zorder>wdg_query_main</zorder>
<zorder>wdg_waitPay_main</zorder>
<zorder>wdg_pay_main</zorder>
<zorder>wdg_done_main</zorder>
<zorder>wdg_dailyBill_main</zorder>
<zorder>wdg_waitPay_main</zorder>
<zorder>wdg_success_main</zorder>
<zorder>wdg_hasPay_main</zorder>
<zorder>wdg_errorPay_main</zorder>
<zorder>wdg_done_main</zorder>
</widget>
</item>
<item>
......
......@@ -2,14 +2,12 @@
#include "fmp_pe_handlers.h"
#include "fmp_epay.h"
FMPStartEventHandler::FMPStartEventHandler(ctkPluginContext *ctx, FMPePay *epay)
: FMPePayEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/"
+ QString::number(ctx->getPlugin()->getPluginId()), epay),
_ctx(ctx)
FMPStartEventHandler::FMPStartEventHandler(FMPePay *epay)
: FMPePayEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/" + QString::number(epay->GetPluginId()), epay)
{
FMPProps props;
props[ctkEventConstants::EVENT_TOPIC] = _topic;
_ctx->registerService<ctkEventHandler>(this, props);
FMP::RegisterService<ctkEventHandler>(this, props);
}
......@@ -30,14 +28,12 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
}
FMPNetWorkEventHandler::FMPNetWorkEventHandler(ctkPluginContext *ctx, FMPePay *epay)
: FMPePayEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/"
+ QString::number(ctx->getPlugin()->getPluginId()), epay),
_ctx(ctx)
FMPNetWorkEventHandler::FMPNetWorkEventHandler(FMPePay *epay)
: FMPePayEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/" + QString::number(epay->GetPluginId()), epay)
{
FMPProps props;
props[ctkEventConstants::EVENT_TOPIC] = _topic;
_ctx->registerService<ctkEventHandler>(this, props);
FMP::RegisterService<ctkEventHandler>(this, props);
}
......
......@@ -27,11 +27,8 @@ class FMPStartEventHandler : public QObject, public FMPePayEventHandler
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
explicit FMPStartEventHandler(ctkPluginContext *ctx, FMPePay *epay);
explicit FMPStartEventHandler(FMPePay *epay);
void handleEvent(const ctkEvent &event);
private:
ctkPluginContext* _ctx;
};
......@@ -44,11 +41,8 @@ class FMPNetWorkEventHandler : public QObject, public FMPePayEventHandler
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
explicit FMPNetWorkEventHandler(ctkPluginContext *ctx, FMPePay *epay);
explicit FMPNetWorkEventHandler(FMPePay *epay);
void handleEvent(const ctkEvent &event);
private:
ctkPluginContext* _ctx;
};
#endif // FMP_MANAGER_EVENT_HANDLERS_H
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 16
#define VER_BUILD 17
//! Convert version numbers to string
#define _STR(S) #S
......
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