Commit 68f5b16a by NitefullWind

1. 登录接口返回积分可抵扣金额。2 . 实现支付即会员,结算接口支付方式加入现金、非码支付。3 . 注释掉了读卡器相关的代码。4 .…

1. 登录接口返回积分可抵扣金额。2 . 实现支付即会员,结算接口支付方式加入现金、非码支付。3 . 注释掉了读卡器相关的代码。4 . 登录接口可由POS传入认证数据,并自动认证。 5. 充值界面优化。
parent 5bcf74f2
#include <QMenu>
#include <QMenu>
#include <QAction>
#include <QTimer>
#include <winsock2.h>
......@@ -48,7 +48,7 @@ BOOL FMVipDispatcher::Transfer(LPSTR data, LPSTR &rsp, UINT &rsp_len)
void FMVipDispatcher::onDoTask()
{
qDebug() << "===============";
qDebug() << "Recv POS reqData: " << reqData;
qDebug() << "Recv POS reqData: " << QString::fromUtf8(reqData);
fmTask = TaskFactory::Task(reqData);
......@@ -57,7 +57,7 @@ void FMVipDispatcher::onDoTask()
} else {
rspData = fmTask->doTask();
}
qDebug() << "Send to pos: " << rspData.data();
qDebug() << "Send to pos: " << QString::fromUtf8(rspData);
qDebug() << "===============";
condition.wakeAll();
......
......@@ -102,6 +102,7 @@ struct{
const QString CanPay = "CanPay";
const QString Score = "score";
const QString Score_value = "score_value";
const QString StatusCode = "statusCode";
const QString Msg = "msg";
......@@ -125,7 +126,7 @@ struct{
const QString Pay_str = "pay_str";
const QString Paid_total_amount = "paid_total_amount";
const QString Pay_type = "third_pay_type";
const QString Pay_transId = "third_pay_trans_id";
const QString Pay_transId = "pay_transid";
const QString CouponList = "couponList"; // 代金券列表
const QString Coupon_code = "code"; // 优惠券 / 代金券编码
const QString Coupon_disAmount = "disAmount"; // 代金券抵扣金额
......
#include <QApplication>
#include <QApplication>
#include "fmvipdispatcher.h"
#include "fmsockserver.h"
#include "resend.h"
......@@ -23,10 +23,10 @@ int main(int argc, char *argv[])
auto reSend = new ReSend();
reSend->start();
// qInstallMessageHandler(customMessageHandler);
qInstallMessageHandler(customMessageHandler);
// 连接读卡器
Reader::instance()->connectReader();
// Reader::instance()->connectReader();
QWidget w;
w.show();
......
#include "fmtask.h"
#include "fmtask.h"
#include "fmapicfg.h"
#include "fmnetwork.h"
#include <QDateTime>
......
#include "taskfinal.h"
#include "taskfinal.h"
#include "fmbackup.h"
#include <QDateTime>
#include <QJsonDocument>
......@@ -24,18 +24,19 @@ void TaskFinal::packageServerReq()
// 储值金、积分、第三方、代金券
int codeAmount=0, scoreAmount=0, cashAmount=0, thirdAmount=0;
trans[ServerProps(PosProps.Pay_type)] = 4;
trans[ServerProps(PosProps.Pay_transId)] = "";
for(auto pay_v : getPosJsonValue(PosProps.Pay_ids).toArray())
{
QJsonObject pay_ob = pay_v.toObject();
QString type = pay_ob[PosProps.Pay_id].toString();
if(type == "24") {
if(type == "01") {
cashAmount = pay_ob[PosProps.Paid_total_amount].toInt();
} else if(type == "24") {
codeAmount = pay_ob[PosProps.Paid_total_amount].toInt();
} else if(type == "25") {
scoreAmount = pay_ob[PosProps.Paid_total_amount].toInt();
} else if(type == "77") { // 代金券
coupons.append(pay_ob[PosProps.Coupon_code].toString());
} else if(type == "72" || type == "73") {
} else if(type == "72" || type == "73" || type == "12") {
thirdAmount = pay_ob[PosProps.Paid_total_amount].toInt();
trans[ServerProps(PosProps.Pay_transId)] = pay_ob[PosProps.Pay_transId];
......@@ -43,12 +44,14 @@ void TaskFinal::packageServerReq()
trans[ServerProps(PosProps.Pay_type)] = 1;
} else if(type == "73") { // 微信
trans[ServerProps(PosProps.Pay_type)] = 2;
} else if(type == "12") { // 非码支付
trans[ServerProps(PosProps.Pay_type)] = 5;
}
} else {
qDebug() << QString("未知的Pay Type: %1").arg(type);
}
}
trans[ServerProps(PosProps.Coupons)] = coupons;
cashAmount = getPosJsonValue(PosProps.PaidAmount).toInt() - codeAmount -scoreAmount - thirdAmount;
trans[ServerProps(PosProps.CodeAmount)] = codeAmount;
trans[ServerProps(PosProps.ScoreAmount)] = scoreAmount;
trans[ServerProps(PosProps.CashAmount)] = cashAmount;
......
......@@ -10,8 +10,10 @@ void TaskLogin::setWindow()
{
_window = new FMVipLogin;
connect(this, &TaskLogin::starReader, qobject_cast<FMVipLogin*>(_window), &FMVipLogin::onstartreader);
connect(qobject_cast<FMVipLogin*>(_window), FMVipLogin::login, this, TaskLogin::onLogin);
QString member_sign = getPosJsonValue(PosProps.Member_sign).toString("");
session()->addData(PosProps.Member_sign, member_sign);
}
void TaskLogin::packageServerReq()
......@@ -40,14 +42,17 @@ void TaskLogin::onLogin()
// 认证失败
if(getServerJsonValue(PosProps.StatusCode).toInt() != FM_API_SUCCESS) {
setError(FM_API_SERVERERROR, serverRspJsonObj[ServerProps(PosProps.StatusCode)].toInt(), serverRspJsonObj[ServerProps(PosProps.Msg)].toString());
FMMsgWnd::FailureWnd(serverRspJsonObj[ServerProps(PosProps.Msg)].toString());
emit starReader();
if(session()->data(PosProps.Member_type).toInt() == Member_Type::EntityCard) {
closeWindow();
}
}
// 认证成功但限制用支付码
// else if((session()->data(PosProps.FM_Type).toInt() == FM_Pay) &&
// (getServerJsonValue(PosProps.CanPay).toInt() != 1)) {
// FMMsgWnd::FailureWnd(ErrorNeedPayCode);
// }
else if((session()->data(PosProps.FM_Type).toInt() == FM_Pay) &&
(getServerJsonValue(PosProps.CanPay).toInt() != 1)) {
FMMsgWnd::FailureWnd(ErrorNeedPayCode);
}
// 认证成功
else {
QString fm_unique_id = getServerJsonValue(PosProps.Fm_unique_id).toString();
......@@ -70,6 +75,7 @@ void TaskLogin::onLogin()
session()->addData(PosProps.Account, account); //服务端接口中的account字段(PosProps.Fm_open_id)
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.Score_value, getServerJsonValue(PosProps.Score_value).toInt());
session()->addData(PosProps.IsActive, getServerJsonValue(PosProps.IsActive).toInt());
closeWindow();
}
......
......@@ -32,7 +32,6 @@ QByteArray TaskPay::doTask()
void TaskPay::onGetCoupons(Session* session)
{
couponThread->exit();
del_p(couponThread);
_session->addData(PosProps.CouponMap, session->getCouponMap(PosProps.CouponMap));
if(_window != nullptr) {
......
......@@ -10,12 +10,10 @@ FMVipFund::FMVipFund(QDialog *parent) :
{
numpad = NULL;
ui->setupUi(this);
_digit_group->addButton(ui->half);
_digit_group->addButton(ui->one);
_digit_group->addButton(ui->two);
_digit_group->addButton(ui->five);
_digit_group->addButton(ui->ten);
_digit_group->addButton(ui->twenty);
connect(_digit_group, SIGNAL(buttonClicked(QAbstractButton*)), SLOT(onDigitChecked(QAbstractButton*)));
}
......@@ -50,6 +48,7 @@ void FMVipFund::initWnd(Session *session)
ui->balance_label->setText(show_amount_str);
ui->name_label->setText(name);
ui->bir_label->setText(birthday);
ui->point_label->setText(QString::number(session->data(PosProps.Score).toInt()));
ui->fund_btn->setFocus();
}
......
......@@ -3,9 +3,10 @@
#include "fmvippanel.h"
#include <QFile>
#include <QMutex>
#include <QTimer>
#include "fmloading.h"
#include "fmnumpad.h"
#include "reader.h"
//#include "reader.h"
FMVipLogin::FMVipLogin(QDialog *parent) :
FMVipWnd(parent),
......@@ -13,24 +14,26 @@ FMVipLogin::FMVipLogin(QDialog *parent) :
{
numpad = NULL;
ui->setupUi(this);
connect(this, &FMVipLogin::startreader, Reader::instance(), &Reader::readVipNO);
connect(Reader::instance(), &Reader::getVipNO, this, &FMVipLogin::readVipNO);
connect(Reader::instance(), &Reader::needActivate, this, &FMVipLogin::onNeedActivate);
connect(Reader::instance(), &Reader::activateFinished, this, &FMVipLogin::onActivateFinished);
emit startreader();
// connect(this, &FMVipLogin::startreader, Reader::instance(), &Reader::readVipNO);
// connect(Reader::instance(), &Reader::getVipNO, this, &FMVipLogin::readVipNO);
// connect(Reader::instance(), &Reader::needActivate, this, &FMVipLogin::onNeedActivate);
// connect(Reader::instance(), &Reader::activateFinished, this, &FMVipLogin::onActivateFinished);
// emit startreader();
ui->login_edit->setFocus();
qDebug() << "main:" <<QThread::currentThreadId();
autoLoginTimer.setSingleShot(true);
autoLoginTimer.setInterval(100);
connect(&autoLoginTimer, &QTimer::timeout, this, &FMVipLogin::on_login_btn_clicked);
}
FMVipLogin::~FMVipLogin()
{
qDebug() << "des FMVipLogin";
delete ui;
if(numpad != NULL)
{
delete numpad;
numpad = NULL;
}
delete ui;
}
void FMVipLogin::onstartreader()
......@@ -75,13 +78,25 @@ void FMVipLogin::initWnd(Session *session)
QString placeText;
if(session->data(PosProps.FM_Type).toInt() == FM_Pay) {
placeText = "输入支付码";
placeText = "输入支付码/刷实体卡";
} else {
placeText = "输入手机号/会员码/支付码";
placeText = "输入手机号/支付码/刷实体卡";
}
ui->operator_label->setText(session->data(PosProps.OperatorId).toString());
ui->bd_label->setText(session->data(PosProps.BussinessDate).toString());
ui->login_edit->setPlaceholderText(placeText);
QString member_sign = session->data(PosProps.Member_sign).toString();
if(member_sign.length() >= 16) {
// 16位之后是内码
session->addData(PosProps.Inner_code, member_sign.mid(16));
session->addData(PosProps.Member_type, Member_Type::EntityCard);
session->addData(PosProps.Member_sign, member_sign.mid(0, 16));
ui->login_edit->setText(member_sign.mid(0, 16));
autoLoginTimer.start();
} else {
qDebug() << "fmv:会员账号格式错误: " << member_sign;
}
}
QString FMVipLogin::getVersionInfo()
......@@ -102,23 +117,28 @@ void FMVipLogin::on_login_btn_clicked()
{
QString id = ui->login_edit->text();
switch (id.length()) {
case 20:
session()->addData(PosProps.Member_type, Member_Type::PayCode);
break;
case 11:
session()->addData(PosProps.Member_type, Member_Type::Phone);
break;
case 10:
session()->addData(PosProps.Member_type, Member_Type::Account);
break;
default:
session()->addData(PosProps.Member_type, Member_Type::Unknow);
break;
if(session()->data(PosProps.Member_type).toInt() != Member_Type::EntityCard) {
switch (id.length()) {
case 20:
session()->addData(PosProps.Member_type, Member_Type::PayCode);
break;
case 16:
session()->addData(PosProps.Member_type, Member_Type::EntityCard);
break;
case 11:
session()->addData(PosProps.Member_type, Member_Type::Phone);
break;
case 10:
session()->addData(PosProps.Member_type, Member_Type::Account);
break;
default:
session()->addData(PosProps.Member_type, Member_Type::Unknow);
break;
}
_session->addData(PosProps.Member_sign, id);
}
_session->addData(PosProps.Member_sign, id);
this->setEnabled(false);
setIsBusy(true);
......
#ifndef FMVIPLOGIN_H
#define FMVIPLOGIN_H
#include <QTimer>
#include "fmvipwnd.h"
#include "fmmsgwnd.h"
......@@ -46,6 +47,7 @@ private:
Ui::FMVipLogin *ui;
FMNumPad *numpad;
FMMsgWnd *activateInfoWnd;
QTimer autoLoginTimer;
};
#endif // FMVIPLOGIN_H
......@@ -41,7 +41,8 @@ void FMVipOrder::initWnd(Session *session)
QString needPay_str = QString::number(needPay);
double standard_amount = session->data(PosProps.StandardAmount).toInt() / 100.0;
orderInfo = new FMVipOrder::OrderInfo(amount_str, score_str, needPay_str);
int socre_value = session->data(PosProps.Score_value).toInt();
orderInfo = new FMVipOrder::OrderInfo(amount_str, socre_value, needPay_str);
ui->operator_label->setText(operator_id);
ui->bd_label->setText(business_date);
......
#ifndef FMVIPORDER_H
#ifndef FMVIPORDER_H
#define FMVIPORDER_H
#include <QListWidgetItem>
#include "fmvipwnd.h"
......@@ -52,18 +52,16 @@ private:
public:
OrderInfo()
{
_amountStr = _scoreStr = _needPayStr = "";
_amountStr = _needPayStr = "";
_amount = _score = _needPay = _maxWillPay = _useScore = _couponAmount = 0;
}
OrderInfo(QString amountStr, QString scoreStr, QString needPayStr)
OrderInfo(QString amountStr, int score, QString needPayStr)
{
this->_amountStr = amountStr;
this->_scoreStr = scoreStr;
this->_needPayStr = needPayStr;
_amount = _amountStr.toInt() / 100.0;
_score = _scoreStr.toInt() / 100.0;
// _score = (_scoreStr.toInt()/10) / 10.0; // 不计分
_score = score / 100.0;
_needPay = _needPayStr.toInt() / 100.0;
_maxWillPay = _useScore = _couponAmount = 0;
......@@ -142,7 +140,7 @@ private:
QMap<QString, Coupon> selectCouponMap;
private:
QString _amountStr, _scoreStr, _needPayStr;
QString _amountStr, _needPayStr;
double _amount, _score, _needPay;
QMap<QString, Coupon> _couponMap;
int _maxPage, _nowPage;
......
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