客户基础资料WEBAPI接口有所差异,
原因是客户有 联系人, 如果联系人必录,则在调用客户WEBAPI接口时,需要先保存联系人
参考代码如下:
#region 这个地方需要先写入联系人数据,然后再重新关联客户数据
JSONArray FT_BD_CUSTLOCATION = publicClass.list(1109954, HttpUtil.CUSTLOCATION__List, 1, 100, 0, Convert.ToInt32(dataId), "text_2", "equal");
JObject linepesonModel = new JObject();
for (int i = 0; i < FT_BD_CUSTLOCATION.Count; i++)
{
JSONObject FT_BD_CUSTLOCATIONs = JSONObject.Parse(FT_BD_CUSTLOCATION.GetJsonString(i));
JSONObject CUSTLOCATION1 = FT_BD_CUSTLOCATIONs.GetJSONObject("data");
JObject CUSTLOCATION = new JObject();
CUSTLOCATION.Add("FName", Convert.ToString(CUSTLOCATION1.Get("text_1")));//联系人
JSONArray subForm_1 = JSONArray.Parse(CUSTLOCATION1.Get("subForm_1").ToString());
JSONObject mobiles = JSONObject.Parse(subForm_1.GetJsonString(0));
string mobilescname = Convert.ToString(mobiles.Get("text_1"));
if (mobilescname.Equals("2"))
{
CUSTLOCATION.Add("FMobile", Convert.ToString(mobiles.Get("text_2")));//电话
}
CUSTLOCATION["FCompanyType"] = "BD_Customer";
CUSTLOCATION["FIsDefaultContact"] = "false";
CUSTLOCATION["FIsDefaultConsignee"] = "false";
JObject FCustId = new JObject();
FCustId.Add("FNUMBER", serialNo);
CUSTLOCATION["FCustId"] = FCustId;
JObject FCompany = new JObject();
FCompany.Add("FNUMBER", "100");
CUSTLOCATION["FCompany"] = FCompany;
CUSTLOCATION["FCreateDate"] = addTime;
CUSTLOCATION["FModifyDate"] = addTime;
linepesonModel["Model"] = CUSTLOCATION;
string linepesonsstr = JsonConvert.SerializeObject(linepesonModel);
string linepesonsformId1 = "BD_CommonContact";//单据标识 联系人
object linepesonretAdd = WebApiServiceCall.Save(ctx, linepesonsformId1, linepesonsstr);
#region 返回结果