Commit c8da3eb8 by 修福龙

收银系统刷脸支付兼容余额支付

parent 46a1ef94
...@@ -93,5 +93,8 @@ export default { ...@@ -93,5 +93,8 @@ export default {
*payscoreinfo(action, {call}) { *payscoreinfo(action, {call}) {
return yield call(api.payscoreinfo, action); return yield call(api.payscoreinfo, action);
}, },
*balancePay(action, {call}) {
return yield call(api.balancePay, action);
},
}, },
}; };
...@@ -18,6 +18,7 @@ import RedPacketModal from '../components/RedPacketModal'; ...@@ -18,6 +18,7 @@ import RedPacketModal from '../components/RedPacketModal';
import {width, height, scaleSize} from '../utils/screen'; import {width, height, scaleSize} from '../utils/screen';
import EnterEvent from '../utils/EnterEvent'; import EnterEvent from '../utils/EnterEvent';
import Printer from '../utils/Printer'; import Printer from '../utils/Printer';
import AutoClick from '../utils/AutoClick';
window.RN = RN; window.RN = RN;
window.Toast = Toast; window.Toast = Toast;
...@@ -365,9 +366,11 @@ const CounterMixins = ComposeComponent => { ...@@ -365,9 +366,11 @@ const CounterMixins = ComposeComponent => {
return '门店设置已解锁'; return '门店设置已解锁';
}; };
successPay = async () => { successPay = async balance => {
Toast.hide(); Toast.hide();
const msg = '付款成功,祝您生活愉快~'; const msg = balance
? '余额付款成功,祝您生活愉快~'
: '付款成功,祝您生活愉快~';
this.props.dispatch({ this.props.dispatch({
// 购物完成步骤 // 购物完成步骤
type: 'app/step', type: 'app/step',
...@@ -771,6 +774,33 @@ const CounterMixins = ComposeComponent => { ...@@ -771,6 +774,33 @@ const CounterMixins = ComposeComponent => {
return true; return true;
}; };
balancePay = async openid => {
if (this.barcodeBusy) {
return true;
}
Toast.loading('正在付款,请稍后~');
this.barcodeBusy = true;
const {ids, noBarcode} = this.getGoods();
const {data} = await this.props.dispatch({
type: 'goods/balancePay',
ids,
noBarcode,
openid,
});
if (data.code === 1) {
// 付款成功
this.orderId = data.data.orderId;
this.successPay(true);
await AutoClick.clickBackKey();
await wait(1200);
await this.setState({voiceModal: false});
this.barcodeBusy = false;
return data;
}
this.barcodeBusy = false;
return data;
};
selectUserModal = () => selectUserModal = () =>
new Promise(async resolve => { new Promise(async resolve => {
this.barcodeResolve = resolve; this.barcodeResolve = resolve;
...@@ -955,6 +985,7 @@ const CounterMixins = ComposeComponent => { ...@@ -955,6 +985,7 @@ const CounterMixins = ComposeComponent => {
dropUp={this.dropUp} dropUp={this.dropUp}
dropDown={this.dropDown} dropDown={this.dropDown}
speak={this.speak} speak={this.speak}
balancePay={this.balancePay}
/> />
</View> </View>
); );
......
...@@ -236,11 +236,10 @@ class VerticalPage extends Component { ...@@ -236,11 +236,10 @@ class VerticalPage extends Component {
res = await WxFacepay.facepay(params); res = await WxFacepay.facepay(params);
} }
if (res.face_code) { if (res.face_code) {
await this.props.barcodepay(res.face_code, true, res.sub_openid); const data = await this.props.balancePay(res.sub_openid);
// const ret = await this.props.barcodepay(res.face_code, true); if (data.code !== 1) {
// const result = { ...params, payresult: ret }; await this.props.barcodepay(res.face_code, true, res.sub_openid);
// if (ret !== 'SUCCESS') result.payresult = 'ERROR'; }
// WxFacepay.update(result);
this.faceRetry = false; this.faceRetry = false;
} }
}; };
...@@ -266,7 +265,17 @@ class VerticalPage extends Component { ...@@ -266,7 +265,17 @@ class VerticalPage extends Component {
Toast.show(res.msg); Toast.show(res.msg);
return; return;
} }
await this.props.barcodepay(res.fToken, true, null, res.fToken, res.uid); const balanceData = await this.props.balancePay(res.uid);
if (balanceData.code !== 1) {
await this.props.barcodepay(
res.fToken,
true,
null,
res.fToken,
res.uid,
);
}
// await this.props.barcodepay(res.fToken, true, null, res.fToken, res.uid);
} }
}; };
......
...@@ -70,3 +70,7 @@ export function wxauthinfo({rawdata}) { ...@@ -70,3 +70,7 @@ export function wxauthinfo({rawdata}) {
export function payscoreinfo() { export function payscoreinfo() {
return axios.post('/store/goods/payscore/info'); return axios.post('/store/goods/payscore/info');
} }
export function balancePay(action) {
return axios.post('/store/goods/balancePay', qs.stringify(action));
}
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