...
|
...
|
@@ -2,6 +2,8 @@ |
|
|
|
|
|
import ReactNative from 'react-native';
|
|
|
import InstallmentService from '../../services/InstallmentService';
|
|
|
import * as _ from 'lodash';
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
...
|
...
|
@@ -15,6 +17,11 @@ GET_ORDER_DETAIL_FAILURE, |
|
|
GET_ORDER_DETAIL_SUCCESS,
|
|
|
|
|
|
SET_BANK_SAFE_PAY_VIEW_STATUS,
|
|
|
SET_SHOW_CONFIRM_PAY_VIEW_STATUS,
|
|
|
UPDATE_ORDER_INFO_AND_FORMATE_DATA,
|
|
|
SET_BANK_CARDS_LIST_AND_PAY_CARD,
|
|
|
UPDATE_REPAY_TERM_LIST,
|
|
|
UPDATE_PREPAY_SUCCESS_PARAM,
|
|
|
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
...
|
...
|
@@ -48,7 +55,7 @@ export function getOrderDetailSuccess(json){ |
|
|
|
|
|
|
|
|
|
|
|
export function getOrderDetail(orderCode) {
|
|
|
export function getOrderDetail() {
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
|
let {app, myOrderDetail} = getState();
|
...
|
...
|
@@ -96,6 +103,167 @@ export function setTipMessage(message){ |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function setBankCardslistAndPayCard(list){
|
|
|
return {
|
|
|
type: SET_BANK_CARDS_LIST_AND_PAY_CARD,
|
|
|
payload: list,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
function processBankCardsInfo(list) {
|
|
|
if (list && list.length > 0) {
|
|
|
_.forEach(list, (data) => {
|
|
|
let cardNo = data.cardNo;
|
|
|
data.outBankNameNumb = data.bankName +'(' + cardNo.substring(cardNo.length - 4) +')';
|
|
|
data.outMobile = data.mobile.substring(data.mobile.length - 6);
|
|
|
});
|
|
|
return list;
|
|
|
}
|
|
|
return [];
|
|
|
}
|
|
|
|
|
|
export function getBankCards() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app} = getState();
|
|
|
let queryBankCards = (uid) => {
|
|
|
return new InstallmentService(app.host).getBankCards(uid)
|
|
|
.then(json => {
|
|
|
let bankCardsInfo = processBankCardsInfo(json);
|
|
|
dispatch(setBankCardslistAndPayCard(bankCardsInfo));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(setTipMessage(error.message || '暂未获取到数据'));
|
|
|
});
|
|
|
};
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
queryBankCards(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
|
|
.then(uid => {
|
|
|
queryBankCards(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
//计算金额和费用
|
|
|
function amtAndFeeCount(list) {
|
|
|
let formateData = {
|
|
|
currAmtCount: 0,
|
|
|
currFeeCount: 0
|
|
|
};
|
|
|
let checkAbleCount = 0;
|
|
|
let checkedCount = 0
|
|
|
if (list) {
|
|
|
_.forEach(list, (data) => {
|
|
|
if (data.isChecked) {
|
|
|
checkedCount++;
|
|
|
formateData.currAmtCount = formateData.currAmtCount + parseFloat(data.curr_amt);
|
|
|
formateData.currFeeCount += formateData.currFeeCount + parseFloat(data.curr_fee_amt);
|
|
|
}
|
|
|
|
|
|
if(data.status == 1 || data.status == 3){
|
|
|
checkAbleCount++;
|
|
|
}
|
|
|
});
|
|
|
if (checkedCount == checkAbleCount) {
|
|
|
formateData.isAllChecked = true;
|
|
|
}else{
|
|
|
formateData.isAllChecked = false;
|
|
|
}
|
|
|
if (formateData.currFeeCount > 0) {
|
|
|
formateData.isCurrFee = true;
|
|
|
} else {
|
|
|
formateData.isCurrFee = false;
|
|
|
}
|
|
|
return formateData;
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// onPressRepaylistCell
|
|
|
export function onPressCheckboxCell(curIndex) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, myOrderDetail} = getState();
|
|
|
let {orderInfo} = myOrderDetail;
|
|
|
let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toJS() : [];
|
|
|
let formateData;
|
|
|
let tipMessage = '';
|
|
|
|
|
|
curIndex = parseInt(curIndex);
|
|
|
if (curIndex == 0) {
|
|
|
if (package_list[curIndex+1].isChecked) {
|
|
|
tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
|
|
|
dispatch(setTipMessage(tipMessage));
|
|
|
}else {
|
|
|
package_list[curIndex].isChecked = !package_list[curIndex].isChecked;
|
|
|
formateData = amtAndFeeCount(package_list);
|
|
|
dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
|
|
|
}
|
|
|
}else if (curIndex == package_list.length - 1) {
|
|
|
if (!package_list[curIndex-1].isChecked && (package_list[curIndex-1].status == 1 || package_list[curIndex-1].status == 3)) {
|
|
|
tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
|
|
|
dispatch(setTipMessage(tipMessage));
|
|
|
}else {
|
|
|
package_list[curIndex].isChecked = !package_list[curIndex].isChecked;
|
|
|
formateData = amtAndFeeCount(package_list);
|
|
|
dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
|
|
|
}
|
|
|
}else {
|
|
|
let preCell = package_list[curIndex - 1];
|
|
|
let nextCell = package_list[curIndex + 1];
|
|
|
|
|
|
//上一个应付款未选中或者下一个已选中
|
|
|
if(((preCell.status == 1 || preCell.status == 3) && !preCell.isChecked) || (nextCell && nextCell.isChecked)){
|
|
|
tipMessage = '同一个分期订单不能跨期还款,请按时间顺序还款';
|
|
|
dispatch(setTipMessage(tipMessage));
|
|
|
}else {
|
|
|
package_list[curIndex].isChecked = !package_list[curIndex].isChecked;
|
|
|
formateData = amtAndFeeCount(package_list);
|
|
|
dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
export function onPressCheckboxAll() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, myOrderDetail} = getState();
|
|
|
let {orderInfo,formateData} = myOrderDetail;
|
|
|
let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toJS() : [];
|
|
|
|
|
|
formateData = formateData.toJS();
|
|
|
formateData.isAllChecked = !formateData.isAllChecked;
|
|
|
_.forEach(package_list, (data) => {
|
|
|
data.isChecked = formateData.isAllChecked;
|
|
|
});
|
|
|
formateData = amtAndFeeCount(package_list);
|
|
|
dispatch(updatOrderInfoAndFormateData({package_list,formateData}));
|
|
|
|
|
|
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
export function updatOrderInfoAndFormateData(object){
|
|
|
return {
|
|
|
type: UPDATE_ORDER_INFO_AND_FORMATE_DATA,
|
|
|
payload: object,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function setBankSafePayViewStatus(status){
|
...
|
...
|
@@ -105,28 +273,177 @@ export function setBankSafePayViewStatus(status){ |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function setShowConfirmPayViewStatus(status) {
|
|
|
return {
|
|
|
type: SET_SHOW_CONFIRM_PAY_VIEW_STATUS,
|
|
|
payload: status,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// onPressPayNow
|
|
|
export function onPressPayNow() {
|
|
|
return (dispatch, getState) => {
|
|
|
// dispatch(getBankCards());
|
|
|
dispatch(getBankCards());
|
|
|
dispatch(setBankSafePayViewStatus(true));
|
|
|
// let {app, repayList} = getState();
|
|
|
// let {repaymentList,queryDays,formateData} = repayList;
|
|
|
// repaymentList = repaymentList.toJS();
|
|
|
// formateData = formateData.toJS();
|
|
|
// let termsList = [];
|
|
|
// _.forEach(repaymentList, (data) => {
|
|
|
// if (data.isChecked) {
|
|
|
// termsList.push({
|
|
|
// index: data.key,
|
|
|
// orderCode: data.billNo,
|
|
|
// termNo: data.currTerm
|
|
|
// });
|
|
|
// }
|
|
|
// });
|
|
|
// dispatch(updateRepayTermList(termsList));
|
|
|
let {app, myOrderDetail} = getState();
|
|
|
let {orderInfo, formateData} = myOrderDetail;
|
|
|
let package_list = orderInfo.get("package_list") ? orderInfo.get("package_list").toJS() : [];
|
|
|
let orderCode = orderInfo.get("order_code");
|
|
|
|
|
|
formateData = formateData.toJS();
|
|
|
let termsList = [];
|
|
|
_.forEach(package_list, (data) => {
|
|
|
if (data.isChecked) {
|
|
|
termsList.push({
|
|
|
index: data.sort_id,
|
|
|
orderCode: orderCode,
|
|
|
termNo: data.sort_id
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
dispatch(updateRepayTermList(termsList));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function bankSafePayNow() {
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
|
let bankSafePayNowAction = (uid) => {
|
|
|
let {app, myOrderDetail} = getState();
|
|
|
let {formateData,repayTermList,payCard} = myOrderDetail;
|
|
|
formateData = formateData.toJS();
|
|
|
repayTermList = repayTermList.toJS();
|
|
|
payCard = payCard.toJS();
|
|
|
let params = {
|
|
|
uid,
|
|
|
repay_amount: formateData.currAmtCount,
|
|
|
repayTermList:JSON.stringify(repayTermList),
|
|
|
bankcard_IdNo: payCard.cardIdNo,
|
|
|
terminal_type: 'mobile',
|
|
|
user_ip: '',
|
|
|
terminal_info: '',
|
|
|
card_id: payCard.cardIdNo,
|
|
|
}
|
|
|
return new InstallmentService(app.host).getPrerePay(params)
|
|
|
.then(json => {
|
|
|
if (json && json.isRepaySuccess == 'Y') {
|
|
|
dispatch(updatePrepaySuccessParam(json));
|
|
|
} else {
|
|
|
let tipMessage = json.message || '暂未获取到数据';
|
|
|
dispatch(setTipMessage(tipMessage));
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(setTipMessage(error.message || '暂未获取到数据'));
|
|
|
});
|
|
|
};
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
bankSafePayNowAction(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
|
|
.then(uid => {
|
|
|
bankSafePayNowAction(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function updatePrepaySuccessParam(param) {
|
|
|
return {
|
|
|
type: UPDATE_PREPAY_SUCCESS_PARAM,
|
|
|
payload: param,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function updateRepayTermList(list) {
|
|
|
return {
|
|
|
type: UPDATE_REPAY_TERM_LIST,
|
|
|
payload: list,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//
|
|
|
export function reSendConfirmPaySnsCode() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, myOrderDetail} = getState();
|
|
|
let resendSnsCode = (uid) => {
|
|
|
let {prePaySuccessParam} = myOrderDetail;
|
|
|
prePaySuccessParam = prePaySuccessParam.toJS();
|
|
|
let params = {
|
|
|
uid,
|
|
|
orderNo: prePaySuccessParam.crfRepayOrderNo,
|
|
|
prepayNo: prePaySuccessParam.repayOrderCode,
|
|
|
}
|
|
|
return new InstallmentService(app.host).reSendConfirmPaySnsCode(params)
|
|
|
.then(json => {
|
|
|
if (json && json.code && json.code !== 200) {
|
|
|
let tipMessage = json.message || '暂未获取到数据';
|
|
|
dispatch(setTipMessage(tipMessage));
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(setTipMessage(error.message || '暂未获取到数据'));
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
ReactNative.NativeModules.YH_CommonHelper.uid()
|
|
|
.then(uid => {
|
|
|
resendSnsCode(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommonHelper.login()
|
|
|
.then(uid => {
|
|
|
resendSnsCode(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
//
|
|
|
export function confirmPayAction(snsCode) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, myOrderDetail} = getState();
|
|
|
let {payCard,repayTermList,formateData,prePaySuccessParam} = myOrderDetail;
|
|
|
payCard = payCard.toJS();
|
|
|
repayTermList = repayTermList.toJS();
|
|
|
formateData = formateData.toJS();
|
|
|
prePaySuccessParam = prePaySuccessParam.toJS();
|
|
|
let params = prePaySuccessParam;
|
|
|
delete params.isRepaySuccess;
|
|
|
params.phoneNumber = payCard.mobile;
|
|
|
params.smsCode = snsCode;
|
|
|
params.repayTermList = JSON.stringify(repayTermList);
|
|
|
params.terminal_type = 'mobile';
|
|
|
|
|
|
return new InstallmentService(app.host).confirmRepay(params)
|
|
|
.then(json => {
|
|
|
if (json.isPaySuccess == 'Y') {
|
|
|
//刷新页面数据
|
|
|
dispatch(setShowConfirmPayViewStatus(false));
|
|
|
dispatch(setBankSafePayViewStatus(false));
|
|
|
dispatch(getOrderDetail());
|
|
|
}else {
|
|
|
dispatch(setTipMessage(json.message || '暂未获取到数据'));
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(setTipMessage(error.message || '暂未获取到数据'));
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|