Commit 00d44745 by NitefullWind

1. 修复未设置门店信息支付时崩溃Bug。 2. 修复对象重复持久化Bug。 3. 修复支付取消后未删除订单信息Bug。 4.…

1. 修复未设置门店信息支付时崩溃Bug。 2. 修复对象重复持久化Bug。 3. 修复支付取消后未删除订单信息Bug。 4. 修复多次支付中更改订单信息数据库内未更改Bug。 5. 修复不能存储商品信息Bug。
parent 8f065ad9
......@@ -166,12 +166,16 @@ inline QSharedPointer<StoreInfo> GetLastStoreInfo()
try {
odb::transaction t (DBSP()->begin ());
StoreInfo_last storeInfo = DBSP()->query_value<StoreInfo_last>();
storeInfoP->setId(storeInfo._id);
storeInfoP->setStoreId(storeInfo._storeId);
storeInfoP->setPosId(storeInfo._posId);
storeInfoP->setBusinessDate(storeInfo._businessDate);
storeInfoP->setOperatorId(storeInfo._operatorId);
odb::result<StoreInfo_last> sl(DBSP()->query<StoreInfo_last>());
if(!sl.empty()) {
storeInfoP->setId(sl.begin()->_id);
storeInfoP->setStoreId(sl.begin()->_storeId);
storeInfoP->setPosId(sl.begin()->_posId);
storeInfoP->setBusinessDate(sl.begin()->_businessDate);
storeInfoP->setOperatorId(sl.begin()->_operatorId);
} else {
storeInfoP.clear();
}
t.commit ();
} catch (const odb::exception &e) {
......
......@@ -118,7 +118,7 @@ bool FMTask::sendToServer(bool isShowMsg)
QByteArray data = json.toJson(QJsonDocument::Compact);
url = FMPVipSettings::instance()->getServerUrl() + "/" + ReqUrl.at(FM_Type());
#ifdef FM_DEBUG
#ifdef FM_TEST
url = "http://127.0.0.1:5000/vip/" + ReqUrl.at(FM_Type());
#endif
......
......@@ -151,7 +151,7 @@ void TaskFinal::packageServerReq()
_order->setPaidAmount(_order->orderAmount());
}
DBSP()->persist(_order);
DBSP()->update(_order);
// 从数据库读取支付信息
PayList payList = _order->payList();
......
......@@ -91,7 +91,7 @@ void TaskLogin::onLogin()
}
bool canPay = (getServerJsonValue(PosProps.CanPay).toInt() == 1);
#ifdef FM_TEST
#ifdef FM_DEBUG
canPay = true;
#endif
if(!canPay) {
......
......@@ -46,16 +46,6 @@ void TaskPay::packagePOSReq()
_order->setStoreInfo(storeInfo);
_order->setOrderId(getPosJsonValue(PosProps.OrderId).toString());
_order->setOrderAmount(getPosJsonValue(PosProps.OrderAmount).toInt());
_order->setUndisAmount(getPosJsonValue(PosProps.UndisAmount).toInt());
QJsonObject productObj = getPosJsonValue(PosProps.Products).toObject();
QString productText = QJsonDocument(productObj).toJson(QJsonDocument::Compact);
_order->setProductText(productText);
DBSP()->persist(_order);
t.commit();
} else {
_order = DBSP()->load<Order>(r.begin()->id());
......@@ -68,6 +58,13 @@ void TaskPay::packagePOSReq()
}
}
_order->setOrderAmount(getPosJsonValue(PosProps.OrderAmount).toInt());
_order->setUndisAmount(getPosJsonValue(PosProps.UndisAmount).toInt());
QJsonArray productArray = getPosJsonValue(PosProps.Products).toArray();
QString productText = QJsonDocument(productArray).toJson(QJsonDocument::Compact);
_order->setProductText(productText);
} catch (const odb::exception &e) {
QString info = QString::fromLocal8Bit("查询订单时异常:%1").arg(e.what());
FMP_ERROR() << info;
......@@ -243,6 +240,10 @@ void TaskPay::packagePOSRsp()
// _transactionPay.reset(DBSP()->begin());
transaction t(DBSP()->begin());
if(_order->id() == 0) {
DBSP()->persist(_order);
}
//计算总支付额
QJsonArray pay_ids;
int totalPaid = 0;
......@@ -278,7 +279,7 @@ void TaskPay::packagePOSRsp()
posRspJsonObj[PosProps.Pay_list] = pay_ids;
posRspJsonObj[PosProps.DisAmount] = 0;
DBSP()->persist(_order);
DBSP()->update(_order);
t.commit();
// _transactionPay.commit();
} catch (const odb::exception &e) {
......
......@@ -92,7 +92,7 @@ void TaskQRPay::packagePOSReq()
}
}
DBSP()->persist(_order);
DBSP()->update(_order);
t.commit();
} catch (const odb::exception &e) {
......
......@@ -64,12 +64,12 @@ void TaskQRRefund::packagePOSReq()
if(posRspJsonObj["statusCode"] == FM_API_SUCCESS && refundPay!=nullptr) {
refundPay->setRefundAmount(refundPay->payAmount());
DBSP()->persist(refundPay);
DBSP()->update(refundPay);
_order->setPaidAmount(_order->paidAmount()-refundPay->refundAmount());
}
DBSP()->persist(_order);
DBSP()->update(_order);
t.commit();
} catch (const odb::exception &e) {
QString info = QString::fromLocal8Bit("存储退款信息时异常:%1").arg(e.what());
......
......@@ -115,10 +115,10 @@ void TaskRefund::onRefundPay(unsigned long DBID)
if(rspObj[PosProps.StatusCode].toInt() == FM_API_SUCCESS) {
payPointer->setRefundAmount(payPointer->payAmount());
DBSP()->persist(payPointer);
DBSP()->update(payPointer);
_order->setPaidAmount(_order->paidAmount() - payPointer->refundAmount());
DBSP()->persist(_order);
DBSP()->update(_order);
_refundAmount += payPointer->payAmount();
......@@ -154,7 +154,7 @@ void TaskRefund::onRefundOrder(unsigned long DBID)
if(rspObj[PosProps.StatusCode].toInt() == FM_API_SUCCESS) {
_order->setRefunded(true);
DBSP()->persist(_order);
DBSP()->update(_order);
if(_window!=nullptr) {
qobject_cast<FMVipRefund*>(_window)->refresh();
......
......@@ -5,3 +5,6 @@ SUBDIRS += \
autotest
CONFIG += ordered
DEFINES += FM_TEST
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 46
#define VER_BUILD 47
//! 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