CRM开票申请合并客户名称TO用友YS

String id = context.data._id as String
String account_id = context.data.account_id as String
String invoice_title = context.data.invoice_title as String
log.info(id)
log.info(account_id)
//log.info(context.data)
def (Boolean error, Map data, String errorMessage) = Fx.object.findById(
        "AccountObj",
        account_id,
        FQLAttribute.builder()
                .columns(["_id", "name", "customer_name__c"])
                .build(),
        SelectAttribute.builder()
                .build()
);
if (error) {
    log.info(errorMessage);
}
log.info(data)
// 定义变量并赋值
String name = data.name as String
String nameStr = data.customer_name__c == null ? "" : data.customer_name__c as String
List<String> nameList = []
// 添加名称到列表
nameList.add(name)
// 如果名称不包含发票抬头,则添加到列表
if (!name.contains(invoice_title)) {
    nameList.add(invoice_title)
}
// 如果 nameStr 不为空,则处理并添加到列表
if (nameStr) {
    // 检查 nameStr 是否包含分隔符 "/"
    if (nameStr.contains("/")) {
        List<String> nameStrList = nameStr.split("/").toList()
        nameStrList.each { customerName ->
            if (!name.contains(customerName)) {
                nameList.add(customerName)
            }
        }
    } else {
        if (!name.contains(nameStr)) {
            nameList.add(nameStr)
        }
    }
}
// 去重并打印
nameList = nameList.unique()
log.info(nameList)
// 将列表拼接成字符串
String nameNewStr = nameList.join("/")
log.info(nameNewStr)
//相关客户名称
def objectMap = ["customer_name__c": nameNewStr]
def result = Fx.object.update("AccountObj", account_id, objectMap, null, ActionAttribute.create()).result() as Map
log.info(result)
if (result) {
    //CRM-TO-YS:更新YS客户名称
    def (Boolean errorKh, HttpResult resultKh, String errorMessageKh) = Fx.http.get("http://ys.test.com/crmToYs?xkId=" + account_id)
    if (errorKh || resultKh.statusCode != 200) {
        log.info("error :" + errorMessageKh)
    } else {
        log.info(resultKh)
    }
}

参考:
1、Fx.object.findById
Fx.object | 纷享销客 | 帮助中心
2、Fx.object.update
Fx.object | 纷享销客 | 帮助中心
3、Fx.http.get
Fx.http | 纷享销客 | 帮助中心

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值