/**
* @author QiaoChu
* @codeName 根据银行回款信息自动获取金额和客户名称
* @description 根据银行回款信息自动获取金额和客户名称
* @createTime 2024-10-22
* @函数需求编号
*/
//原始银行回款信息
String repayment_info = context.data["repayment_info__c"] as String
//获取银行回款信息
def resultInfo = extractRepaymentInfo(repayment_info)
//客户名称
String payer_account_name = resultInfo['payer_account_name']
//到款金额
String amount_received = resultInfo['amount_received']
//付款方银行
String payer_bank = resultInfo['payer_bank']
def extractRepaymentInfo(String info) {
String payer_account_name = ''
String amount_received = ''
String payer_bank = ''
// 根据银行类型提取不同信息
if (info =~ /(?s).*【建设银行】.*/) {
def matchAccountName = (info =~ /(?s).*对方户名:(.+?)。.*/)
def matchAmount = (info =~ /(?s).*收入人民币(.+?)元.*/)
if (matchAccountName.find() && matchAmount.find()) {
payer_account_name = matchAccountName.group(1).trim() // 使用 group(1)
amount_received = matchAmount.group(1).trim() // 使用 group(1)
payer_bank = "建设银行"
}
} else if (info =~ /(?s).*【中国农业银行】.*/) {
def matchAccountName = (info =~ /(?s).*([^\s]+)于.*/)
def matchAmount = (info =~ /(?s).*金额为(.+?).*/)
if (matchAccountName.find() && matchAmount.find()) {
payer_account_name = matchAccountName.group(1).trim() // 使用 group(1)
amount_received = matchAmount.group(1).trim() // 使用 group(1)
payer_bank = "中国农业银行"
}
} else if (info =~ /(?s).*【交通银行】.*/) {
def matchAccountName = (info =~ /(?s).*对方户名:(.+?),.*/)
def matchAmount = (info =~ /(?s).*转入资金(.+?)元.*/)
if (matchAccountName.find() && matchAmount.find()) {
payer_account_name = matchAccountName.group(1).trim() // 使用 group(1)
amount_received = matchAmount.group(1).trim() // 使用 group(1)
payer_bank = "交通银行"
}
} else {
// 对于不支持的银行类型,返回空字符串
payer_account_name = ''
amount_received = ''
payer_bank = ''
}
// 使用 Map 返回结果
return [payer_account_name: payer_account_name, amount_received: amount_received, payer_bank: payer_bank]
}
UIEvent event = UIEvent.build(context) {
//主对象修改数据
editMaster("payer_account_name": payer_account_name, "amount_received": amount_received, "payer_bank": payer_bank)
}
return event
二、数据更新事件
2.1.字段事件。在新建/编辑页,当某一字段修改(值改变且失焦)时,触发自定义函数来更新主对象或从对象的数据。
参考:
配置步骤 | 纷享销客 | 帮助中心