/// <summary> /// 关闭或开启同步 /// </summary> /// <returns></returns> public ActionResult OpenSyncData() { _agentDistributionRelationBLL = new AgentDistributionRelationBLL(); _returnData = new Return_Msg(); int id = Context.GetRequestInt("id", 0); int opensyncState = Context.GetRequestInt("opensyncstate", 0); if (id <= 0) { _returnData.Msg = "参数错误"; return(Json(_returnData)); } AgentDistributionRelation model = _agentDistributionRelationBLL.GetModel(id); if (model == null) { _returnData.Msg = "数据过期,请刷新重试"; return(Json(_returnData)); } model.UpdateTime = DateTime.Now; model.OpenSyncData = opensyncState; _returnData.isok = _agentDistributionRelationBLL.Update(model, "OpenSyncData,UpdateTime"); _returnData.Msg = _returnData.isok ? "保存成功" : "保存失败"; return(Json(_returnData)); }
public bool SaveLog(List <CrmData> crmdata, CrmApiData modelConfig) { TransactionModel tran = new TransactionModel(); AgentDistributionRelationBLL agentDistributionRelationBLL = new AgentDistributionRelationBLL(); if (modelConfig == null) { return(false); } if (crmdata == null || crmdata.Count <= 0) { UpdateCrmApiData(modelConfig); return(false); } string phones = "'" + string.Join("','", crmdata.Select(s => s.phone).Distinct()) + "'"; List <Account> accountList = AccountBLL.SingleModel.GetListByPhones(phones); if (accountList == null || accountList.Count <= 0) { UpdateCrmApiData(modelConfig); return(false); } string accountids = "'" + string.Join("','", accountList.Select(s => s.Id).Distinct()) + "'"; List <AgentDistributionRelation> agentdistributionlist = agentDistributionRelationBLL.GetListByAgent(accountids); if (agentdistributionlist == null || agentdistributionlist.Count <= 0) { UpdateCrmApiData(modelConfig); return(false); } foreach (CrmData item in crmdata) { Account accountitem = accountList.FirstOrDefault(f => f.ConsigneePhone == item.phone); if (accountitem == null) { continue; } AgentDistributionRelation adbitem = agentdistributionlist.FirstOrDefault(f => f.UserAccountId == accountitem.Id.ToString()); if (adbitem == null) { continue; } AgentFollowLog followlog = new AgentFollowLog(); followlog.AddTime = item.AddTime; followlog.UpdateTime = item.AddTime; followlog.State = 1; followlog.Type = 1; followlog.SouceFrom = 1; followlog.AgentDistributionRelatioinId = adbitem.Id; followlog.Desc = "业务员:" + item.name + ",跟进状态:" + item.statecontent + ",备注:" + item.content; tran.Add($"insert into AgentFollowLog(agentdistributionrelatioinid,`desc`,state,addtime,updatetime,type,writer,soucefrom) values ({followlog.AgentDistributionRelatioinId},'{followlog.Desc}',{followlog.State},'{followlog.AddTime.ToString("yyyy-MM-dd HH:mm:ss")}','{followlog.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}',{followlog.Type},'',{followlog.SouceFrom})"); } if (tran.sqlArray.Length > 0) { bool isok = base.ExecuteTransaction(tran.sqlArray); if (isok) { UpdateCrmApiData(modelConfig); } return(isok); } //else //{ // if (DateTime.Now.CompareTo(DateTime.Parse(modelConfig.CurrentTime).AddDays(1)) > 0) // { // string columns = "pageindex,TotalPageSize,CurrentTime"; // modelConfig.PageIndex = 1; // modelConfig.TotalPageSize = 0; // modelConfig.CurrentTime = DateTime.Parse(modelConfig.CurrentTime).AddDays(1).ToShortDateString(); // base.Update(modelConfig, columns); // } //} return(false); }
public ActionResult SaveAgentBack() { msg = new Return_Msg(); int id = Context.GetRequestInt("id", 0); string bankaccount = Context.GetRequest("bankaccount", ""); string aliaccount = Context.GetRequest("aliaccount", ""); if (dzaccount == null) { msg.Msg = "登陆过期,请重新登陆!"; return(Json(msg)); } if (id <= 0) { msg.Msg = "参数错误"; return(Json(msg)); } if (string.IsNullOrEmpty(bankaccount)) { msg.Msg = "请输入银行账号"; return(Json(msg)); } if (string.IsNullOrEmpty(aliaccount)) { msg.Msg = "请输入支付宝账号"; return(Json(msg)); } List <AgentCustomerRelation> customerRelatioin = AgentCustomerRelationBLL.SingleModel.GetListByAccountId(dzaccount.Id.ToString()); if (customerRelatioin == null || customerRelatioin.Count <= 0) { msg.Msg = "权限不足"; return(Json(msg)); } string qrcodeids = string.Join(",", customerRelatioin.Where(w => w.QrcodeId > 0)?.Select(s => s.QrcodeId).Distinct()); AgentDistributionRelation agentrelationmodel = _agentDistributionRelationBLL.GetModel(id); if (agentrelationmodel == null || !qrcodeids.Contains(agentrelationmodel.QrCodeId.ToString())) { msg.Msg = "操作权限不足"; return(Json(msg)); } AgentCaseBack agentcasebackgmodel = new AgentCaseBack(); agentcasebackgmodel.AgentDistributionRelatioinId = id; agentcasebackgmodel.AddTime = DateTime.Now; agentcasebackgmodel.UpdateTime = DateTime.Now; agentcasebackgmodel.Invoice = 0; agentcasebackgmodel.AlipayAccount = aliaccount; agentcasebackgmodel.ImgUrl = ""; agentcasebackgmodel.BankAccount = bankaccount; agentcasebackgmodel.CourierNumber = ""; agentcasebackgmodel.State = 0; agentcasebackgmodel.DataType = 1; //分销用户信息 List <DistributionUserInfo> duserinfo = _agentDistributionRelationBLL.GetDistributionUserInfo(id); if (duserinfo != null && duserinfo.Count > 0) { agentcasebackgmodel.DUserInfo = JsonConvert.SerializeObject(duserinfo); } agentcasebackgmodel.Id = Convert.ToInt32(AgentCaseBackBLL.SingleModel.Add(agentcasebackgmodel)); msg.isok = agentcasebackgmodel.Id > 0; msg.Msg = msg.isok ? "保存成功" : "保存失败"; foreach (AgentCustomerRelation item in customerRelatioin) { AgentCaseBackBLL.SingleModel.RemoveCache(item.agentid); } return(Json(msg)); }