Commit ff979b36 by NitefullWind

1. 退款时如果fmId为空则直接返回错误。

parent 6b0c543f
......@@ -160,14 +160,6 @@ bool Control::InitPOSReqJsonObj(const char *indata)
QJsonDocument inDataDoc = QJsonDocument::fromJson(QString::fromLocal8Bit(indata).toUtf8(), &parseError);
if(parseError.error == QJsonParseError::NoError) {
_posReqJsonObj = inDataDoc.object();
int type = FMTool::GetJsonValue(_posReqJsonObj, JSON_KEY_REQTYPE).toInt(SPCC_sign);
if(type < SPCC_sign || type > SPCC_finds) {
_posReqJsonObj[JSON_KEY_REQTYPE] = SPCC_sign;
} else {
_posReqJsonObj[JSON_KEY_REQTYPE] = type - SPCC_sign;
}
} else {
QString error = QString::fromLocal8Bit("请求解析失败:%1").arg(parseError.errorString());
QLOG_ERROR() << error;
......@@ -175,6 +167,29 @@ bool Control::InitPOSReqJsonObj(const char *indata)
return false;
}
}
// 检查请求类型是否合法
int type = FMTool::GetJsonValue(_posReqJsonObj, JSON_KEY_REQTYPE).toInt();
if(type < SPCC_sign || type > SPCC_finds) {
QString error = QString::fromLocal8Bit("未知的请求类型:%1").arg(type);
QLOG_ERROR() << error;
SetResPonseWithMessage("23", error);
return false;
} else {
_posReqJsonObj[JSON_KEY_REQTYPE] = type - SPCC_sign;
}
// 检查是否缺少必要的字段
int reqType = _posReqJsonObj[JSON_KEY_REQTYPE].toInt();
if(reqType == refund) {
if(_posReqJsonObj[JSON_KEY_FMID].toString().isEmpty()) {
QString error = QString::fromLocal8Bit("fmId不能为空");
QLOG_ERROR() << error;
SetResPonseWithMessage("23", error);
return false;
}
}
return true;
}
......
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