Commit 5bcf74f2 by NitefullWind

1. 新增支付前判断账号是否是激活状态。 2. 删除激活/锁定相关代码。 3. 修复获取代金券线程崩溃问题。

parent e7c9bf01
......@@ -57,6 +57,11 @@ void TaskLogin::onLogin()
if(session()->data(PosProps.FM_Type).toInt() == FM_Login) {
FMMsgWnd::LoginSuccess(account,name,birthday);
closeWindow();
} else if(session()->data(PosProps.FM_Type).toInt() == FM_Pay && getServerJsonValue(PosProps.IsActive).toInt() == 0) {
QString msg("该账号未激活!");
qDebug() << msg;
FMMsgWnd::FailureWnd(msg);
} else {
session()->addData(PosProps.Name, name);
session()->addData(PosProps.Amount, getServerJsonValue(PosProps.Amount).toInt());
......@@ -66,24 +71,10 @@ void TaskLogin::onLogin()
session()->addData(PosProps.Fm_open_id, fm_unique_id); //其实是认证接口中返回的fm_unique_id(PosProps.Fm_unique_id)
session()->addData(PosProps.Score, getServerJsonValue(PosProps.Score).toInt());
session()->addData(PosProps.IsActive, getServerJsonValue(PosProps.IsActive).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();
// Coupon c{code, amount, desc};
// QVariant v;
// v.setValue(c);
// couponMap[code] = v;
// }
// session()->addData(PosProps.CouponMap, couponMap);
closeWindow();
}
closeWindow();
}
if(_window!=nullptr) {
_window->resetWnd();
}
......
......@@ -37,8 +37,6 @@ void TaskManage::setWindow()
auto manageWindow = new FMVipPanel;
connect(manageWindow, SIGNAL(fund()), this, SLOT(onFund()));
connect(manageWindow, SIGNAL(lock()), this, SLOT(onLock()));
connect(manageWindow, SIGNAL(activate()), this, SLOT(onActivate()));
_window = manageWindow;
}
......@@ -57,23 +55,6 @@ void TaskManage::onFund()
doChildTask();
}
void TaskManage::onLock()
{
// childTask = new TaskCardLock(posReqJsonObj, this->session());
// doChildTask();
}
void TaskManage::onActivate()
{
// bool isOk = Reader::instance()->activateCard();
// if(!isOk) {
// FMMsgWnd::FailureWnd("fmv: 激活卡时写卡失败!");
// return;
// }
// childTask = new TaskCardActive(posReqJsonObj, this->session());
// doChildTask();
}
void TaskManage::doChildTask()
{
childTask->doTask();
......
#ifndef TASKMANAGE_H
#ifndef TASKMANAGE_H
#define TASKMANAGE_H
#include "fmtask.h"
......@@ -19,8 +19,6 @@ public:
public slots:
void onFund();
void onLock();
void onActivate();
private:
FMTask *childTask;
......
#include "taskothers.h"
#include "taskothers.h"
#include "reader.h"
/// 优惠券查询
......@@ -94,51 +94,3 @@ void TaskRefundOrder::packagePOSRsp()
}
posRspJsonObj[PosProps.Prompt] = 1;
}
/// 锁定
TaskCardLock::TaskCardLock(QJsonObject &jsonObj, Session *session, QObject *parent) :
FMTaskNoWnd(jsonObj, FM_Card_Lock, session, parent)
{
}
void TaskCardLock::packageServerReq()
{
serverReqJsonObj[ServerProps(PosProps.TransId)] = createTransId();
serverReqJsonObj[ServerProps(PosProps.CardNo)] = session()->data(PosProps.Member_sign).toString();
serverReqJsonObj[ServerProps(PosProps.Passward)] = "";
}
void TaskCardLock::packagePOSRsp()
{
if(getServerJsonValue(PosProps.StatusCode) == FM_API_SUCCESS) {
FMMsgWnd::SuccessWnd("锁定成功\n卡状态:"+getServerJsonValue(PosProps.CardStatusDesc).toString());
} else {
FMMsgWnd::FailureWnd("锁定失败\n"+getServerJsonValue(PosProps.Msg).toString());
}
}
/// 激活
TaskCardActive::TaskCardActive(QJsonObject &jsonObj, Session *session, QObject *parent) :
FMTaskNoWnd(jsonObj, FM_Card_Active, session, parent)
{
}
void TaskCardActive::packageServerReq()
{
serverReqJsonObj[ServerProps(PosProps.TransId)] = createTransId();
serverReqJsonObj[ServerProps(PosProps.CardNo)] = session()->data(PosProps.Member_sign).toString();
serverReqJsonObj[ServerProps(PosProps.Passward)] = "";
}
void TaskCardActive::packagePOSRsp()
{
if(getServerJsonValue(PosProps.StatusCode) == FM_API_SUCCESS) {
FMMsgWnd::SuccessWnd("激活成功\n卡状态:"+getServerJsonValue(PosProps.CardStatusDesc).toString());
} else {
FMMsgWnd::FailureWnd("激活失败\n"+getServerJsonValue(PosProps.Msg).toString());
}
}
#ifndef TASKOTHERS_H
#ifndef TASKOTHERS_H
#define TASKOTHERS_H
#include "fmtasknownd.h"
......@@ -32,25 +32,4 @@ public:
void packageServerReq();
void packagePOSRsp();
};
// 账号锁定
class TaskCardLock : public FMTaskNoWnd
{
Q_OBJECT
public:
explicit TaskCardLock(QJsonObject &jsonObj, Session *session, QObject *parent = 0);
void packageServerReq();
void packagePOSRsp();
};
// 账号激活
class TaskCardActive : public FMTaskNoWnd
{
Q_OBJECT
public:
explicit TaskCardActive(QJsonObject &jsonObj, Session *session, QObject *parent = 0);
void packageServerReq();
void packagePOSRsp();
};
#endif // TASKOTHERS_H
#include "taskpay.h"
#include "taskpay.h"
#include "fmviporder.h"
#include "tasklogin.h"
#include "taskothers.h"
......@@ -9,6 +9,10 @@ TaskPay::TaskPay(QJsonObject &jsonObj, QObject *parent)
posReqJsonObj[PosProps.TransId] = createTransId();
}
TaskPay::~TaskPay()
{
}
QByteArray TaskPay::doTask()
{
preTask = new TaskLogin(posReqJsonObj, _session, this);
......@@ -19,14 +23,17 @@ QByteArray TaskPay::doTask()
}
this->_session = preTask->session();
TaskCouponThread couponThread(posReqJsonObj, _session, this);
couponThread.start();
connect(&couponThread, SIGNAL(finished(Session*)), SLOT(onGetCoupons(Session*)));
couponThread = new TaskCouponThread(posReqJsonObj, _session, this);
couponThread->start();
connect(couponThread, SIGNAL(finished(Session*)), SLOT(onGetCoupons(Session*)));
return FMTask::doTask();
}
void TaskPay::onGetCoupons(Session* session)
{
couponThread->exit();
del_p(couponThread);
_session->addData(PosProps.CouponMap, session->getCouponMap(PosProps.CouponMap));
if(_window != nullptr) {
qobject_cast<FMVipOrder*>(_window)->initCouponItems();
......
#ifndef TASKPAY_H
#ifndef TASKPAY_H
#define TASKPAY_H
#include "fmtask.h"
#include <QThread>
#include "taskothers.h"
class TaskCouponThread;
class TaskPay : public FMTask
{
Q_OBJECT
public:
explicit TaskPay(QJsonObject &jsonObj, QObject* parent=0);
~TaskPay();
QByteArray doTask();
void setWindow();
......@@ -18,6 +21,9 @@ public:
private slots:
void onPay();
void onGetCoupons(Session *session);
private:
TaskCouponThread *couponThread;
};
// 加载代金券的线程类
......@@ -31,7 +37,6 @@ public:
}
~TaskCouponThread() {
del_p(task);
del_p(_session);
}
void run() {
......
......@@ -129,6 +129,8 @@ void FMVipOrder::initCouponItems()
if(ui->coupon_page->count() > 0) {
connect(ui->coupon_page, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*)));
}
ui->pay_edit->setFocus();
ui->pay_edit->selectAll();
}
void FMVipOrder::setWillPayText()
......
......@@ -43,13 +43,3 @@ void FMVipPanel::on_fund_btn_clicked()
{
emit fund();
}
void FMVipPanel::on_lock_btn_clicked()
{
emit lock();
}
void FMVipPanel::on_activate_btn_clicked()
{
emit activate();
}
#ifndef FMVIPPANEL_H
#ifndef FMVIPPANEL_H
#define FMVIPPANEL_H
#include <fmvipwnd.h>
......@@ -19,13 +19,9 @@ public:
public slots:
void on_fund_btn_clicked();
void on_lock_btn_clicked();
void on_activate_btn_clicked();
signals:
void fund();
void lock();
void activate();
private:
Ui::FMVipPanel *ui;
......
......@@ -939,6 +939,16 @@ font: 13px &quot;微软雅黑&quot;;
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>pay_edit</tabstop>
<tabstop>pay_btn</tabstop>
<tabstop>coupon_next_btn</tabstop>
<tabstop>coupon_page</tabstop>
<tabstop>coupon_prev_btn</tabstop>
<tabstop>close_btn</tabstop>
<tabstop>pay_key</tabstop>
<tabstop>pay_chk</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
......@@ -107,6 +107,7 @@ QWidget {
#fund_btn {
background: rgb(255,85,85);
max-width: 400px;
}
#new_btn {
......@@ -434,29 +435,7 @@ QWidget {
<property name="spacing">
<number>6</number>
</property>
<item row="4" column="1">
<widget class="QPushButton" name="lock_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>会员锁定</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="6" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -469,7 +448,7 @@ QWidget {
</property>
</spacer>
</item>
<item row="0" column="1">
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -482,7 +461,7 @@ QWidget {
</property>
</spacer>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QPushButton" name="fund_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
......@@ -504,28 +483,6 @@ QWidget {
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="activate_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>会员激活</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
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