Commit 58fb2639 by NitefullWind

1. 新增支付时查询可用代金券。 2. 修改了几个界面的大小。

parent d68793a5
......@@ -28,7 +28,8 @@ const static QStringList FM_Server_Type = QString(
"order_correct_request," // 冲正
"order_recharge_request,"
"order_cardlock_request,"
"order_cardactive_request").split(",");
"order_cardactive_request,"
"order_coupon_request").split(",");
// 请求类型的枚举值
enum FM_TYPE {
......@@ -40,8 +41,8 @@ enum FM_TYPE {
FM_Fund,
FM_Card_Lock,
FM_Card_Active,
FM_Coupon,
FM_Order_Revoke
};
......@@ -116,6 +117,7 @@ struct{
const QString Coupon_code = "code"; // 优惠券 / 代金券编码
const QString Coupon_disAmount = "disAmount"; // 代金券抵扣金额
const QString Coupon_desc = "desc"; // 代金券描述
const QString Coupon_name = "name"; // 优惠券名
const QString CouponMap = "payCouponMap"; // 代金券map
// 产品
const QString Products = "products";
......
......@@ -63,20 +63,20 @@ void TaskLogin::onLogin()
session()->addData(PosProps.Fm_open_id, account);
session()->addData(PosProps.Score, getServerJsonValue(PosProps.Score).toInt());
QMap<QString, QVariant> couponMap;
for (auto value : getServerJsonValue(PosProps.CouponList).toArray())
{
QJsonObject couponOb = value.toObject();
QString code = couponOb[ServerProps(PosProps.Coupon_code)].toString();
double amount = couponOb[ServerProps(PosProps.Coupon_disAmount)].toInt() / 100.0;
QString desc = couponOb[ServerProps(PosProps.Coupon_desc)].toString();
// QMap<QString, QVariant> couponMap;
// for (auto value : getServerJsonValue(PosProps.CouponList).toArray())
// {
// QJsonObject couponOb = value.toObject();
// QString code = couponOb[ServerProps(PosProps.Coupon_code)].toString();
// double amount = couponOb[ServerProps(PosProps.Coupon_disAmount)].toInt() / 100.0;
// QString desc = couponOb[ServerProps(PosProps.Coupon_desc)].toString();
Coupon c{code, amount, desc};
QVariant v;
v.setValue(c);
couponMap[code] = v;
}
session()->addData(PosProps.CouponMap, couponMap);
// Coupon c{code, amount, desc};
// QVariant v;
// v.setValue(c);
// couponMap[code] = v;
// }
// session()->addData(PosProps.CouponMap, couponMap);
}
closeWindow();
}
......
#include "taskothers.h"
/// 优惠券查询
TaskCoupon::TaskCoupon(QJsonObject &jsonObj, QObject *parent)
:FMTaskNoWnd(jsonObj, FM_Coupon, 0, parent)
TaskCoupon::TaskCoupon(QJsonObject &jsonObj, Session *session, QObject *parent)
:FMTaskNoWnd(jsonObj, FM_Coupon, session, parent)
{
}
void TaskCoupon::packageServerReq()
{
serverReqJsonObj[ServerProps(PosProps.Coupon)] = getPosJsonValue(PosProps.Coupon);
serverReqJsonObj[ServerProps(PosProps.TransId)] = getPosJsonValue(PosProps.TransId);
QJsonObject transaction;
transaction[ServerProps(PosProps.Fm_open_id)] = session()->data(PosProps.Fm_open_id).toString();
transaction[ServerProps(PosProps.PaidAmount)] = getPosJsonValue(PosProps.OrderAmount);
// 产品列表
QJsonArray propducts;
for(auto pValue : getPosJsonValue(PosProps.Products).toArray())
{
auto po = pValue.toObject();
QJsonObject spo;
for(auto prop : {PosProps.ConsumeNum, PosProps.Price, PosProps.ProductId}) {
spo[ServerProps(prop)] = po[prop];
}
propducts.append(spo);
}
transaction[ServerProps(PosProps.Products)] = propducts;
serverReqJsonObj[ServerProps(PosProps.Transaction)] = transaction;
}
void TaskCoupon::packagePOSRsp()
......@@ -17,8 +35,21 @@ void TaskCoupon::packagePOSRsp()
for(auto prop : {PosProps.Fm_open_id, PosProps.StatusCode, PosProps.Msg}) {
posRspJsonObj[prop] = getServerJsonValue(ServerProps(prop));
}
posRspJsonObj["pid"] = serverRspJsonObj["productCode"];
posRspJsonObj[PosProps.Prompt] = 1;
QMap<QString, QVariant> couponMap;
for (auto value : getServerJsonValue(PosProps.CouponList).toArray())
{
QJsonObject couponOb = value.toObject();
QString code = couponOb[ServerProps(PosProps.Coupon_code)].toString();
double amount = couponOb[ServerProps(PosProps.Coupon_disAmount)].toInt() / 100.0;
QString desc = couponOb[ServerProps(PosProps.Coupon_name)].toString();
Coupon c{code, amount, desc};
QVariant v;
v.setValue(c);
couponMap[code] = v;
}
session()->addData(PosProps.CouponMap, couponMap);
}
......
......@@ -3,12 +3,12 @@
#include "fmtasknownd.h"
// 优惠券查询
// 获取可用代金券列表
class TaskCoupon : public FMTaskNoWnd
{
Q_OBJECT
public:
explicit TaskCoupon(QJsonObject &jsonObj, QObject *parent = 0);
explicit TaskCoupon(QJsonObject &jsonObj, Session *session=0, QObject *parent = 0);
void packageServerReq();
void packagePOSRsp();
};
......@@ -52,4 +52,5 @@ public:
void packageServerReq();
void packagePOSRsp();
};
#endif // TASKOTHERS_H
#include "taskpay.h"
#include "fmviporder.h"
#include "tasklogin.h"
#include "taskothers.h"
TaskPay::TaskPay(QJsonObject &jsonObj, QObject *parent)
:FMTask(jsonObj, FM_Pay, 0, parent)
{
posReqJsonObj[PosProps.TransId] = createTransId();
}
QByteArray TaskPay::doTask()
......@@ -17,6 +18,14 @@ QByteArray TaskPay::doTask()
return loginRst;
}
this->_session = preTask->session();
del_p(preTask);
preTask = new TaskCoupon(posReqJsonObj, _session, this);
QByteArray couponRst = preTask->doTask();
if(preTask->error() != FM_API_SUCCESS) {
return couponRst;
}
this->_session = preTask->session();
return FMTask::doTask();
}
......@@ -46,7 +55,7 @@ void TaskPay::packageServerReq()
transObj[ServerProps(PosProps.Coupons)] = couponArr;
serverReqJsonObj[ServerProps(PosProps.Transaction)] = transObj;
serverReqJsonObj[ServerProps(PosProps.TransId)] = createTransId();
serverReqJsonObj[ServerProps(PosProps.TransId)] = getPosJsonValue(PosProps.TransId);
}
void TaskPay::packagePOSRsp()
......@@ -79,7 +88,7 @@ void TaskPay::packagePOSRsp()
QJsonObject cp = coupon.toObject();
pay_id[PosProps.Pay_id] = "77";
pay_id[PosProps.Pay_str] = "代金券支付";
int couponAmount = cp[PosProps.Coupon_disAmount].toInt();
int couponAmount = cp[ServerProps(PosProps.Coupon_disAmount)].toInt();
pay_id[PosProps.Paid_total_amount] = couponAmount;
paidTotalAmount += couponAmount;
pay_id[PosProps.Coupon_code] = cp[ServerProps(PosProps.Coupon_code)];
......
......@@ -16,7 +16,6 @@ public:
private slots:
void onPay();
};
#endif // TASKPAY_H
......@@ -145,8 +145,8 @@ QPushButton#fund_btn:hover {
<widget class="QWidget" name="FMVipWnd" native="true">
<property name="maximumSize">
<size>
<width>950</width>
<height>750</height>
<width>968</width>
<height>768</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......
......@@ -290,8 +290,8 @@ QWidget {
<widget class="QWidget" name="FMVipWnd" native="true">
<property name="maximumSize">
<size>
<width>950</width>
<height>750</height>
<width>968</width>
<height>768</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......
......@@ -193,8 +193,8 @@ QWidget {
<widget class="QWidget" name="FMVipWnd" native="true">
<property name="maximumSize">
<size>
<width>950</width>
<height>750</height>
<width>968</width>
<height>768</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......
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