// 小程序后台数据
let miniProgramOrderData = [
{
"C1_ENTNAME":"江苏xxxxxxxx有限公司",
"SERIAL_NO":"SN20210902160436572557",
"AUDIT_STATUS":"0000",
"SOURCE_TYPE":"CREATIVE_E_RENT"
},
{
"C1_ENTNAME":"江苏xxxxxxxx有限公司",
"SERIAL_NO":"SN20210816173329444358",
"AUDIT_STATUS":"0000",
"SOURCE_TYPE":"CREATIVE_E_RENT"
},
{
"C1_ENTNAME":"江苏xxxxxxxx有限公司",
"SERIAL_NO":"SN20210812193940845210",
"AUDIT_STATUS":"0000",
"SOURCE_TYPE":"CREATIVE_E_RENT"
},
]
// 核心后台数据
let centerOrderData = [
{
"SERIAL_NO":"SN20210902160436572557",
"AUDIT_STATUS":"0004",
},
{
"SERIAL_NO":"SN20210816173329444358",
"AUDIT_STATUS":"0003",
},
{
"SERIAL_NO":"SN20210812193940845210",
"AUDIT_STATUS":"0002"
}
]
let isApplying = false // 提示订单正在申请
let canApplyAgain = true // 是否可以继续申请
let fanxianData = {} // 反显的数据
function changeOrderStatus(miniProgramOrderData,centerOrderData){
for(let i = 0 ;i< centerOrderData.length;i++) {
let obj = centerOrderData[i]
for(let p = 0;p<miniProgramOrderData.length;p++) {
let obj1 = miniProgramOrderData[p]
if(obj1.SERIAL_NO == obj.SERIAL_NO) {
// 将相同流水号的订单状态以核心为准
obj1.AUDIT_STATUS = obj.AUDIT_STATUS
}
}
}
// 使用for循环和break退出程序
for(let m =0;m<miniProgramOrderData.length;m++) {
let status = miniProgramOrderData[m].AUDIT_STATUS
let SOURCE_TYPE = miniProgramOrderData[m].SOURCE_TYPE
console.log(status,'--->status')
if(SOURCE_TYPE == 'CREATIVE_E_RENT') {
// 只有放款成功才可以再次申请 0004
if(status == '0004') {
isApplying = false
canApplyAgain = true
fanxianData = miniProgramOrderData[m]
console.log('-->用户可以继续申请创e租')
break
}
// 0002、0003都需要提示
else if( status == '0002' || status == '0003') {
isApplying = true
canApplyAgain = false
fanxianData = miniProgramOrderData[m]
console.log('-->用户已有订单正在申请中')
break;
}
else if(status == '0000'){
isApplying = true
canApplyAgain = false
fanxianData = miniProgramOrderData[m]
console.log('--->用户可以继续编辑订单申请信息')
break
}
}
}
}
changeOrderStatus(miniProgramOrderData,centerOrderData)
console.log(`是否正在申请:${isApplying},
是否可以再次申请:${canApplyAgain}`)
console.log(fanxianData)
console