using WX.CRM.BLL.Base; using WX.CRM.Common; using WX.CRM.Model.Entity; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WX.CRM.CRMServices.ServicesModel { public class OpenedCustomer { private DataSet _ds; // private List fxh_customer; public OpenedCustomer(DataSet ds) { checkDataSet(ds); _ds = ds; } public List SetFxhCustomer() { List fxh_customers = new List(); BAS_INNERUSER_BL inneruser = new BAS_INNERUSER_BL(); List list = inneruser.GetList(); foreach (DataRow row in _ds.Tables[0].Rows) { string mobile = getString(row["mobile"]); if (!string.IsNullOrWhiteSpace(mobile)) { FXH_CUSTOMER fxh_customer = new FXH_CUSTOMER(); fxh_customer.TRADECODE = getString(row["tradeCode"]); fxh_customer.RESID = getMobile(mobile); fxh_customer.DEPTCDOE = "UJMD01"; fxh_customer.SALEUSERID = getUserIdbyEid(list, getDecimal(row["saleusereid"]).Value); fxh_customer.TRADERUSERID = getUserIdbyEid(list, getDecimal(row["tradeusereid"]).Value); fxh_customer.SCHEDULESTATUS = getDecimal(row["scheduleStatus"], true); fxh_customer.CREATIONACCOUNTDATE = getDatetime(row["creationAccountDate"]); fxh_customer.SIGNEDDATE = getDatetime(row["creationDate"]); fxh_customer.CLAIMTIME = getDatetime(row["ClaimEID"]); fxh_customer.CLAIMEID = getDecimal(row["ClaimEID"], true); fxh_customer.CTIME = DateTime.Now; fxh_customer.TRADENAME = getString(row["name"]); fxh_customers.Add(fxh_customer); } } return fxh_customers; } private void checkDataSet(DataSet ds) { if (ds == null) throw new ArgumentException("OpenedCustomer现货开户客户数据为空"); } private string getString(object value) { if (null == value) return ""; return value.ToString(); } private string getMobile(string mobile) { if (mobile.Length > 11 && mobile.Contains("T")) mobile = mobile.Substring(0, 11); mobile = ResUtil.CreateResId(mobile); return mobile; } private decimal? getDecimal(object value, bool returnnull = false) { if (null == value) return returnnull ? null : (decimal?)0; decimal id = 0; if (decimal.TryParse(value.ToString(), out id)) return id; return returnnull ? null : (decimal?)0; } private DateTime? getDatetime(object value) { if (null == value) return null; DateTime dt; if (DateTime.TryParse(value.ToString(), out dt)) return dt; return null; } private decimal getUserIdbyEid(List list, decimal eid) { if (list != null && list.Count > 0) { var model = list.FirstOrDefault(m => m.EID == eid); if (null != model) { return model.PKID; } } return 0; } } }