Commit 7448cbf8 by NitefullWind

1. 增加卡券核销插件支持。

parent 064b676c
......@@ -27,6 +27,11 @@ bool FMPVipSettings::getIsNeedSocketHeader()
return _GetValue(FMP_INIKEY_NEEDSOCKETHEADER, false).toBool();
}
int FMPVipSettings::GetPayPartnerId()
{
return _GetValue("Home/PartnerId", 1371).toInt();
}
QVariant FMPVipSettings::_GetValue(const QString &key, QVariant defaultValue)
{
if (_settings) {
......
......@@ -17,6 +17,8 @@ public:
QString getServerUrl();
bool getIsNeedSocketHeader();
int GetPayPartnerId();
private:
explicit FMPVipSettings(QObject *parent = 0);
......
......@@ -19,6 +19,8 @@
#undef StartService
#include <fmp_epay_i.h>
#include "fmp_redeem_i.h"
#include "dbop.h"
#include "items/storeinfo.h"
FMVipDispatcher::FMVipDispatcher(QObject *parent) :
QObject(parent),
......@@ -85,13 +87,19 @@ void FMVipDispatcher::doTask(const QByteArray &reqData, QByteArray &rspData)
if(_ctx){
ctkServiceReference ref = _ctx->getServiceReference<FMPRedeemInterface>();
FMPRedeemInterface* redeem = _ctx->getService<FMPRedeemInterface>(ref);
//for test
// jsonObj["store_id"] = "fm99999";
// jsonObj["pos_id"] = "01";
// jsonObj["operator_id"] = "00000002";
// jsonObj["partner_id"] = 1371;
QJsonObject result = redeem->Redeem(jsonObj);
rspData = QJsonDocument(result).toJson(QJsonDocument::Compact);
FMItem::StoreInfo storeInfo;
bool isOk = DBOP::GetLastItem(&storeInfo);
if(!isOk) {
rspData = QString::fromLocal8Bit(ErrorMsgJson).arg(FM_API_ERROR).arg(QString::fromLocal8Bit("未设置门店信息,不能进行支付.")).toUtf8();
} else {
jsonObj[PosProps.StoreId] = storeInfo.storeId();
jsonObj[PosProps.PosId] = storeInfo.posId();
jsonObj[PosProps.OperatorId] = storeInfo.operatorId();
jsonObj[PosProps.PartnerId] = FMPVipSettings::instance()->GetPayPartnerId();
QJsonObject result = redeem->Redeem(jsonObj);
rspData = QJsonDocument(result).toJson(QJsonDocument::Compact);
}
}
else{
rspData = QString::fromLocal8Bit("{\"msg:\":\"卡券服务不可用\"}").toUtf8();
......
......@@ -71,7 +71,7 @@ struct PP{
PP()
{
AppId = "appId";
PartnerId = "partnerId";
PartnerId = "partner_id";
T = "t";
Sign = "sign";
StoreId = "store_id";
......@@ -278,6 +278,7 @@ const PropsMap::value_type PropsMapPairs[] =
PropsMap::value_type(PosProps.ConsumeNum, "consumeNum"),
PropsMap::value_type(PosProps.Price, "price"),
PropsMap::value_type(PosProps.ChargeAmount, "payAmount"),
PropsMap::value_type(PosProps.PartnerId, "partnerId"),
};
static PropsMap PosToServerProps(PropsMapPairs, PropsMapPairs + (sizeof(PropsMapPairs)/sizeof(PropsMapPairs[0])));
......@@ -339,7 +340,7 @@ enum {
};
// 返回错误信息的json
#define ErrorMsgJson "{\"status_code\":%1,\"msg\":\"%2\",\"prompt\":0}"
#define ErrorMsgJson "{\"status_code\":%1,\"msg\":\"%2\"}"
#define ErrorNeedPayCode "fmv:请使用支付码付款"
typedef std::map<const int, const char*> FMErrorMap;
......
......@@ -85,6 +85,7 @@ void TestPlugin::test_dotask_data()
"}");
QTest::newRow("Order") << QByteArray("{\"fm_cmd\": 1007,\"order_id\": \"20171018003\"}");
QTest::newRow("Fund") << QByteArray("{\"fm_cmd\": 1002,\"order_id\": \"20171018001\"}");
QTest::newRow("CouponPay") << QByteArray("{\"fm_cmd\": 10032}");
}
void TestPlugin::test_dotask()
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 21
#define VER_BUILD 25
//! 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