Commit 86b307be by NitefullWind

1. 实现已结算的订单不显示界面自动退款。

parent 0080b5c8
...@@ -21,6 +21,10 @@ Item::Item(const QJsonObject &json, QObject *parent) ...@@ -21,6 +21,10 @@ Item::Item(const QJsonObject &json, QObject *parent)
this->SetPropertiesByJson(json); this->SetPropertiesByJson(json);
} }
Item::~Item()
{
}
void Item::SetPropertiesByJson(const QJsonObject &json) void Item::SetPropertiesByJson(const QJsonObject &json)
{ {
foreach(const QString &key, json.keys()) { foreach(const QString &key, json.keys()) {
......
...@@ -20,6 +20,8 @@ namespace FMItem { ...@@ -20,6 +20,8 @@ namespace FMItem {
explicit Item(QObject *parent = 0); explicit Item(QObject *parent = 0);
explicit Item(const QJsonObject &json, QObject *parent = 0); explicit Item(const QJsonObject &json, QObject *parent = 0);
virtual ~Item();
void SetPropertiesByJson(const QJsonObject &json); void SetPropertiesByJson(const QJsonObject &json);
void SetPropertiesByJson(const QByteArray &json); void SetPropertiesByJson(const QByteArray &json);
void SetPropertiesBySqlRecord(const QSqlRecord &record); void SetPropertiesBySqlRecord(const QSqlRecord &record);
......
...@@ -23,6 +23,10 @@ Order::Order(QObject *parent) ...@@ -23,6 +23,10 @@ Order::Order(QObject *parent)
} }
Order::~Order()
{
}
QString Order::orderId() const QString Order::orderId() const
{ {
return _orderId; return _orderId;
......
...@@ -32,6 +32,8 @@ namespace FMItem { ...@@ -32,6 +32,8 @@ namespace FMItem {
public: public:
explicit Order(QObject *parent = 0); explicit Order(QObject *parent = 0);
virtual ~Order();
QString orderId() const; QString orderId() const;
void setOrderId(const QString &orderId); void setOrderId(const QString &orderId);
......
...@@ -17,6 +17,11 @@ Pay::Pay(QObject *parent) ...@@ -17,6 +17,11 @@ Pay::Pay(QObject *parent)
} }
Pay::~Pay()
{
}
QString Pay::payId() const QString Pay::payId() const
{ {
return _payId; return _payId;
......
...@@ -21,6 +21,7 @@ namespace FMItem { ...@@ -21,6 +21,7 @@ namespace FMItem {
Q_PROPERTY(int orderDBID READ orderDBID WRITE setOrderDBID) Q_PROPERTY(int orderDBID READ orderDBID WRITE setOrderDBID)
public: public:
explicit Pay(QObject *parent = 0); explicit Pay(QObject *parent = 0);
virtual ~Pay();
QString payId() const; QString payId() const;
void setPayId(const QString &payId); void setPayId(const QString &payId);
......
...@@ -11,6 +11,11 @@ Product::Product(QObject *parent) ...@@ -11,6 +11,11 @@ Product::Product(QObject *parent)
} }
Product::~Product()
{
}
int Product::quantity() const int Product::quantity() const
{ {
return _quantity; return _quantity;
......
...@@ -14,6 +14,7 @@ namespace FMItem { ...@@ -14,6 +14,7 @@ namespace FMItem {
Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString name READ name WRITE setName)
public: public:
explicit Product(QObject *parent = 0); explicit Product(QObject *parent = 0);
virtual ~Product();
int quantity() const; int quantity() const;
void setQuantity(int quantity); void setQuantity(int quantity);
......
...@@ -12,6 +12,11 @@ namespace FMItem { ...@@ -12,6 +12,11 @@ namespace FMItem {
} }
StoreInfo::~StoreInfo()
{
}
QString StoreInfo::storeId() const QString StoreInfo::storeId() const
{ {
return _storeId; return _storeId;
......
...@@ -14,6 +14,7 @@ namespace FMItem { ...@@ -14,6 +14,7 @@ namespace FMItem {
Q_PROPERTY(QString operator_id READ operatorId WRITE setOperatorId) Q_PROPERTY(QString operator_id READ operatorId WRITE setOperatorId)
public: public:
explicit StoreInfo(QObject *parent = 0); explicit StoreInfo(QObject *parent = 0);
virtual ~StoreInfo();
QString storeId() const; QString storeId() const;
void setStoreId(const QString &storeId); void setStoreId(const QString &storeId);
......
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
TaskRefund::TaskRefund(QJsonObject &jsonObj, Session *session, QObject *parent) TaskRefund::TaskRefund(QJsonObject &jsonObj, Session *session, QObject *parent)
: FMTask(jsonObj, FM_Refund, session, parent) : FMTask(jsonObj, FM_Refund, session, parent)
, _refundAmount(0) , _refundAmount(0),
_order(new FMItem::Order(this))
{ {
} }
TaskRefund::~TaskRefund() TaskRefund::~TaskRefund()
{ {
delete _order;
} }
void TaskRefund::packagePOSReq() void TaskRefund::packagePOSReq()
...@@ -37,14 +38,38 @@ void TaskRefund::packagePOSReq() ...@@ -37,14 +38,38 @@ void TaskRefund::packagePOSReq()
setError(FM_API_ERROR, info); setError(FM_API_ERROR, info);
return; return;
} }
DBOP::GetOrderByOrderId(orderId, _order);
if(_order->isNew()) {
QString info = QString::fromLocal8Bit("未找到订单信息,不能进行退款.");
FMP_WARN() << info;
setError(FM_API_ERROR, info);
return;
} else if(DBOP::GetPaysByOrderDBId(_order->DBID()).isEmpty()) {
QString info = QString::fromLocal8Bit("订单中没有可以进行退款的支付.");
FMP_WARN() << info;
setError(FM_API_ERROR, info);
return;
}
} }
void TaskRefund::setWindow() void TaskRefund::setWindow()
{ {
_window = new FMVipRefund(); // 已结算则直接退订单
if(_order->settled()) {
connect(qobject_cast<FMVipRefund*>(_window), &FMVipRefund::refundPay, this, &TaskRefund::onRefundPay); onRefundOrder(_order->DBID());
connect(qobject_cast<FMVipRefund*>(_window), &FMVipRefund::refundOrder, this, &TaskRefund::onRefundOrder); }
// 未结算,仅有一笔支付则直接退该笔支付
// else if(_order->payList().size() == 1) {
// onRefundPay(_order->payList().first()->DBID());
// }
// 其他情况显示界面
else {
_window = new FMVipRefund();
connect(qobject_cast<FMVipRefund*>(_window), &FMVipRefund::refundPay, this, &TaskRefund::onRefundPay);
connect(qobject_cast<FMVipRefund*>(_window), &FMVipRefund::refundOrder, this, &TaskRefund::onRefundOrder);
}
} }
void TaskRefund::packageServerReq() void TaskRefund::packageServerReq()
...@@ -81,8 +106,11 @@ void TaskRefund::onRefundPay(int DBID) ...@@ -81,8 +106,11 @@ void TaskRefund::onRefundPay(int DBID)
_refundAmount += payPointer->payAmount(); _refundAmount += payPointer->payAmount();
} }
qobject_cast<FMVipRefund*>(_window)->refresh(); if(_window!=nullptr) {
qobject_cast<FMVipRefund*>(_window)->setIsRefundSuccess(true); qobject_cast<FMVipRefund*>(_window)->refresh();
qobject_cast<FMVipRefund*>(_window)->setIsRefundSuccess(true);
}
} else { } else {
QString msg = searchJsonValue(rspObj, PosProps.Msg).toString(); QString msg = searchJsonValue(rspObj, PosProps.Msg).toString();
FMMsgWnd::FailureWnd(msg, _window); FMMsgWnd::FailureWnd(msg, _window);
...@@ -101,8 +129,10 @@ void TaskRefund::onRefundOrder(int DBID) ...@@ -101,8 +129,10 @@ void TaskRefund::onRefundOrder(int DBID)
if(rspObj[PosProps.StatusCode].toInt() == FM_API_SUCCESS) { if(rspObj[PosProps.StatusCode].toInt() == FM_API_SUCCESS) {
orderPointer->setRefunded(true); orderPointer->setRefunded(true);
DBOP::Save(orderPointer.data()); DBOP::Save(orderPointer.data());
qobject_cast<FMVipRefund*>(_window)->refresh(); if(_window!=nullptr) {
qobject_cast<FMVipRefund*>(_window)->setIsRefundSuccess(true); qobject_cast<FMVipRefund*>(_window)->refresh();
qobject_cast<FMVipRefund*>(_window)->setIsRefundSuccess(true);
}
_refundAmount = orderPointer->paidAmount(); _refundAmount = orderPointer->paidAmount();
} else { } else {
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#define TASKREFUND_H #define TASKREFUND_H
#include "fmtask.h" #include "fmtask.h"
namespace FMItem {
class Order;
}
class TaskRefund : public FMTask class TaskRefund : public FMTask
{ {
Q_OBJECT Q_OBJECT
...@@ -20,6 +24,7 @@ private: ...@@ -20,6 +24,7 @@ private:
void onRefundOrder(int DBID); void onRefundOrder(int DBID);
int _refundAmount; int _refundAmount;
FMItem::Order *_order;
}; };
#endif // TASKREFUND_H #endif // TASKREFUND_H
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 35 #define VER_BUILD 36
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #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