ComplianceServer/oldcode/WX.CRM.DataSynFactory/Cmd/Server_UniteCustomer_IMP.cs

40 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Dapper;
using System;
using WX.CRM.Common;
using WX.CRM.DataSynFactory.Dao;
using WX.CRM.DataSynFactory.Templates;
namespace WX.CRM.DataSynFactory.Cmd
{
public class Server_UniteCustomer_IMP : Interfaces.IDataImportSvr<Server_UniteCustomer>
{
public bool GenerateBusinessOne(Server_UniteCustomer t)
{
try
{
using (var db = ZxdStore.GetConnection())
{
var arr = t.oldCustomerId.Split(',');
foreach (var item in arr)
{
var sql = "update res_customer set customerid = @customerid where resid = @resid";
db.Execute(sql, new { customerid = t.newCustomerId, resid = item });
if (t.newCustomerId != item)
db.Execute("update res_customerdetail set isprimarynum = 0 where resid = @resid and isprimarynum = 1", new { resid = item });
if (t.newCustomerId == item)
db.Execute("update res_customerdetail set isprimarynum = 1 where resid = @resid and isprimarynum = 0", new { resid = item });
}
}
return true;
}
catch (Exception ex)
{
LogHelper.Error("处理合并客户ID异常,Server_UniteCustomer_IMP" + ex.ToString());
return false;
}
}
}
}