exports.main = async (event, context) => {
await db.collection('test').add({ data: { event, rmb: '退款操作' } })
let { outTradeNo, refundStatus, returnCode } = event
console.log( outTradeNo, refundStatus, returnCode );
if (refundStatus == 'SUCCESS' && returnCode == 'SUCCESS') {
let goodsData = await db.collection('goods').where({ outTradeNo }).update({ data: { refund: 1 } })
console.log(goodsData);
if (goodsData.stats.updated == 1) {
return { errcode: 0, errmsg: 'SUCCESS' }
} else {
return { errcode: 0, errmsg: 'FAIL' }
}
} else {
return { errcode: 1, errmsg: 'FAIL' }
}
}
我现在根据 refundStatus, returnCode 好像不执行更新操作 本地调试可以 把回调的结果写进数据库 refundStatus, returnCode都为SUCCESS 就是更新数据库更新不了 好像不执行
退款请求成功不代表退款成功,还是应以查单或者异步通知结果为准,看refund_status字段