Commit 2c62a2ab by NitefullWind

1. 优惠券接口改变。 2. 限制只能使用一张优惠券。

parent 035b9d0d
...@@ -11,6 +11,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets ...@@ -11,6 +11,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 CONFIG += c++11
DEFINES += TEST
SOURCES += \ SOURCES += \
fmp_vip.cpp \ fmp_vip.cpp \
fmp_vip_p.cpp \ fmp_vip_p.cpp \
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// 请求类型链表 // 请求类型链表
const static QStringList FM_Type_List = QString( const static QStringList FM_Type_List = QString(
"member_check_request," "member_check_request,"
"coupon_check_request," "order_coupon_request,"
"member_charge_request," "member_charge_request,"
"order_request," "order_request,"
"integral_request," "integral_request,"
...@@ -22,7 +22,7 @@ const static QStringList FM_Type_List = QString( ...@@ -22,7 +22,7 @@ const static QStringList FM_Type_List = QString(
// 服务端请求类型 // 服务端请求类型
const static QStringList FM_Server_Type = QString( const static QStringList FM_Server_Type = QString(
"member_check_request," "member_check_request,"
"coupon_check_request," "order_coupon_request,"
"member_charge_request," "member_charge_request,"
"order_request," "order_request,"
"integral_request," "integral_request,"
......
...@@ -27,7 +27,7 @@ QByteArray FMTaskNoWnd::doTask() ...@@ -27,7 +27,7 @@ QByteArray FMTaskNoWnd::doTask()
// } // }
copyPros(); copyPros();
bool isOk = sendToServer(); bool isOk = sendToServer(false);
if(!isOk) { if(!isOk) {
FMP_WARN() << QString("Task error %1: %2").arg(error()).arg(errorString()); FMP_WARN() << QString("Task error %1: %2").arg(error()).arg(errorString());
return QString(ErrorMsgJson).arg(error()).arg(errorString()).toLatin1(); return QString(ErrorMsgJson).arg(error()).arg(errorString()).toLatin1();
......
...@@ -50,12 +50,14 @@ void TaskLogin::onLogin() ...@@ -50,12 +50,14 @@ void TaskLogin::onLogin()
FMP_WARN() << "Login failed: " << info; FMP_WARN() << "Login failed: " << info;
FMMsgWnd::FailureWnd(info, _window); FMMsgWnd::FailureWnd(info, _window);
} }
#ifndef TEST
// 认证成功但限制用支付码 // 认证成功但限制用支付码
else if((session()->data(PosProps.FM_Type).toInt() == FM_Pay) && else if((session()->data(PosProps.FM_Type).toInt() == FM_Pay) &&
(getServerJsonValue(PosProps.CanPay).toInt() != 1)) { (getServerJsonValue(PosProps.CanPay).toInt() != 1)) {
FMP_WARN() << ErrorNeedPayCode; FMP_WARN() << ErrorNeedPayCode;
FMMsgWnd::FailureWnd(QString::fromLocal8Bit(ErrorNeedPayCode), _window); FMMsgWnd::FailureWnd(QString::fromLocal8Bit(ErrorNeedPayCode), _window);
} }
#endif
// 认证成功 // 认证成功
else { else {
QString fm_open_id = getServerJsonValue(PosProps.Fm_open_id).toString(); QString fm_open_id = getServerJsonValue(PosProps.Fm_open_id).toString();
...@@ -89,11 +91,24 @@ void TaskLogin::onLogin() ...@@ -89,11 +91,24 @@ void TaskLogin::onLogin()
double amount = couponOb[ServerProps(PosProps.Coupon_disAmount)].toInt() / 100.0; double amount = couponOb[ServerProps(PosProps.Coupon_disAmount)].toInt() / 100.0;
QString desc = couponOb[ServerProps(PosProps.Coupon_desc)].toString(); QString desc = couponOb[ServerProps(PosProps.Coupon_desc)].toString();
Coupon c(desc, code, amount, 0, 1); Coupon c(desc, code, amount, 0, false);
QVariant v; QVariant v;
v.setValue(c); v.setValue(c);
couponMap[code] = v; couponMap[code] = v;
} }
#ifdef TEST
for(int i=0; i<5; i++) {
QString strI = QString::number(i);
Coupon c(QString::fromLocal8Bit("测试不可用")+strI, strI, i, 0, false);
QVariant v;
v.setValue(c);
couponMap[strI] = v;
}
FMP_INFO() << "Test coupon: " << couponMap;
#endif
session()->addData(PosProps.CouponMap, couponMap); session()->addData(PosProps.CouponMap, couponMap);
} }
_window->accept(); _window->accept();
......
#include "taskothers.h" #include "taskothers.h"
#include "fmp_logger_i.h"
/// 优惠券查询 /// 优惠券查询
TaskCoupon::TaskCoupon(QJsonObject &jsonObj, Session *session, QObject *parent) TaskCoupon::TaskCoupon(QJsonObject &jsonObj, Session *session, QObject *parent)
...@@ -50,11 +50,24 @@ void TaskCoupon::packagePOSRsp() ...@@ -50,11 +50,24 @@ void TaskCoupon::packagePOSRsp()
double amount = couponOb[ServerProps(PosProps.Coupon_disAmount)].toInt() / 100.0; double amount = couponOb[ServerProps(PosProps.Coupon_disAmount)].toInt() / 100.0;
QString desc = couponOb[ServerProps(PosProps.Coupon_desc)].toString(); QString desc = couponOb[ServerProps(PosProps.Coupon_desc)].toString();
Coupon c(desc, code, amount); Coupon c(desc, code, amount, 0, false);
QVariant v; QVariant v;
v.setValue(c); v.setValue(c);
couponMap[code] = v; couponMap[code] = v;
} }
#ifdef TEST
for(int i=0; i<5; i++) {
QString strI = QString::number(i);
Coupon c(strI, strI, i, 0, false);
QVariant v;
v.setValue(c);
couponMap[strI] = v;
}
FMP_INFO() << "Test coupon: " << couponMap;
#endif
session()->addData(PosProps.CouponMap, couponMap); session()->addData(PosProps.CouponMap, couponMap);
} }
......
...@@ -117,20 +117,21 @@ void FMVipOrder::on_coupon_page_clicked(const QModelIndex &index) ...@@ -117,20 +117,21 @@ void FMVipOrder::on_coupon_page_clicked(const QModelIndex &index)
if(selectionModel->selectedIndexes().length() == 1) { if(selectionModel->selectedIndexes().length() == 1) {
QModelIndex firstIndex = selectionModel->selectedIndexes().first(); QModelIndex firstIndex = selectionModel->selectedIndexes().first();
if(!couponModel->coupon(firstIndex).isCompatible()) { if(!couponModel->coupon(firstIndex).isCompatible()) {
FMMsgWnd::FailureWnd(QString::fromLocal8Bit("已经选中了一张不可叠加券,不能再选用其他代金券")); // FMMsgWnd::FailureWnd(QString::fromLocal8Bit("已经选中了一张不可叠加券,不能再选用其他代金券"), this);
return; // return;
selectionModel->clear();
} }
} }
Coupon coupon = couponModel->coupon(index); Coupon coupon = couponModel->coupon(index);
// 判断是否满足使用条件 // 判断是否满足使用条件
if(orderInfo->getMaxDisAmount() < coupon.limitAmount()) { if(orderInfo->getMaxDisAmount() < coupon.limitAmount()) {
FMMsgWnd::FailureWnd(QString::fromLocal8Bit("该代金券不满足使用条件")); FMMsgWnd::FailureWnd(QString::fromLocal8Bit("该代金券不满足使用条件"), this);
return; return;
} }
// 处理不可叠加券 // 处理不可叠加券
if(!coupon.isCompatible()) { if(!coupon.isCompatible()) {
if(!selectionModel->selectedIndexes().isEmpty()) { if(!selectionModel->selectedIndexes().isEmpty()) {
FMMsgWnd::FailureWnd("该代金券不可与其他代金券叠加使用,请取消选中其他代金券"); FMMsgWnd::FailureWnd("该代金券不可与其他代金券叠加使用,请取消选中其他代金券", this);
return; return;
} }
selectionModel->select(index, QItemSelectionModel::ClearAndSelect); selectionModel->select(index, QItemSelectionModel::ClearAndSelect);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">#label_logo <string notr="true">#label_logo
{ {
border-image: url(:/img/tip_ok.png);
}</string> }</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
......
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