public int InsertDownConnectorRelation(int downConnectorId, int upConnectorId) { int val = 0; //快马接口查询 int upBuyerId = 0; //检查信息是否存在 ConnectorEntity downConnector = (ConnectorEntity) new ConnectorBusiness().GetEntity("Id=" + downConnectorId); if (downConnector == null || Utils.ToInt(downConnector.Id) == 0) { return(-2); } RelationEntity entRelation = (RelationEntity) new RelationBusiness().GetEntity("DownConnectorId=" + downConnectorId); if (entRelation != null && Utils.ToInt(entRelation.Id) != 0) { return(-1); } RelationEntity ent = new RelationEntity(); ent.UpConnectorId = upConnectorId; ent.UpBuyerId = upBuyerId; ent.DownConnectorId = downConnector.Id; ent.Status = 0;//0待处理 ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; ent.InvitedFrom = 1; val = DbAccess.ExecuteInsert(TableName, ent); return(val); }
/// <summary> /// 插入合作商信息 /// </summary> /// <returns>大于0成功,否则失败</returns> /// <remarks> /// <list type="bullet"> /// </list> /// </remarks> public int Insert(Dictionary <string, object> datajson) { ClearCache(); int val = 0; ConnectorEntity ent = new ConnectorEntity(); ent.SetValues(datajson); //检查信息是否存在 Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("GroupId", ent.GroupId); dic.Add("SellerId", ent.SellerId); dic.Add("Name", ent.Name); ConnectorEntity entConnector = DbAccess.GetEntity <ConnectorEntity>(TableName, dic); if (entConnector != null && Utils.ToInt(entConnector.Id) != 0) { return(-1); } ent.Status = 1; ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; val = DbAccess.ExecuteInsert(TableName, ent); return(val); }
public IResultResponse ChangeIsOpen(int connectorId, int id, int status) { try { int val = 0; ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null || Utils.ToInt(connector.Id) == 0) { return(ResultResponse.ExceptionResult("不存在该上游")); } RelationEntity entRelation = (RelationEntity) new RelationBusiness(_dapperFactory).GetEntity("Id=" + id); if (entRelation == null || Utils.ToInt(entRelation.Id) == 0) { return(ResultResponse.ExceptionResult("不存在合作关系")); } entRelation.IsOpen = status; val = DbAccess.ExecuteUpdate(TableName, entRelation, new string[] { "Id" }); if (val > 0) { return(ResultResponse.GetSuccessResult(1)); } else { return(ResultResponse.ExceptionResult("修改权限失败")); } } catch (Exception ex) { return(ResultResponse.ExceptionResult(ex)); } }
/// <summary> /// 交换token /// </summary> /// <param name="dic"></param> /// <returns></returns> public IResultResponse ExchangeToken(int fk_id, int db_id) { DataTable dt = DbAccess.GetDataTable(string.Format(CommandConstant.ConnectorAuth, fk_id, db_id)); if (dt != null && dt.Rows.Count > 0) { ConnectorEntity entity = new ConnectorEntity(); entity.SetValues(dt.Rows[0]); AccessToken accessToken = new AccessToken(Utils.ToInt(entity.Id), Utils.ToInt(entity.SellerId), entity.Name, entity.Mobile, entity.Domain, Utils.ToInt(entity.GroupId), Utils.ToInt(entity.DBId), Utils.ToInt(entity.UpConnectorId) ); Dictionary <string, object> authDic = dt.Rows[0].ToDictionary(); authDic.Add("Token", accessToken.ToTokenString()); authDic.Add("Qr", ECF.Security.AES.Encode(entity.Id.ToString())); authDic.Add("Expire", Utils.ToUnixTime(DateTime.Now.AddDays(1))); return(ResultResponse.GetSuccessResult(authDic)); } else { return(ResultResponse.ExceptionResult("", null, 201)); } }
/// <summary> /// Set the Key to hold the value. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public Task <bool> InsertAsync(ConnectorEntity connectorEntity) { DeleteAsync(connectorEntity.Key); var insert = Insert(connectorEntity); return(Task.FromResult(insert)); }
/// <summary> /// 更新合作商 /// </summary> /// <param name="xmlDoc">xmlDoc格式的合作商数据.</param> /// <param name="id">待更新的Id.</param> /// <returns> /// System.Int32,大于0成功,否则失败 /// </returns> /// <remarks> /// <list type="bullet"> /// <item></item> /// </list> /// </remarks> public int Update(Dictionary <string, object> datajson) { try { ClearCache(); int val = 0; ConnectorEntity ent = new ConnectorEntity(); ent.SetValues(datajson); //检查信息是否存在 Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("Id", ent.Id); ConnectorEntity entConnector = DbAccess.GetEntity <ConnectorEntity>(TableName, dic); if (entConnector == null || entConnector.Id == null || entConnector.Id < 1) { return(-1); } entConnector.Name = ent.Name; entConnector.SellerId = ent.SellerId; entConnector.Logo = ent.Logo; entConnector.Mobile = ent.Mobile; entConnector.GroupId = ent.GroupId; entConnector.Remark = ent.Remark; entConnector.Status = ent.Status; entConnector.UpdateTime = DateTime.Now; val = DbAccess.ExecuteUpdate(TableName, entConnector, new string[] { "Id" }); return(val); } catch (Exception ex) { new Exceptions(ex.Message, ex); } return(0); }
/// <summary> /// Set the Key to hold the value. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public Task <bool> InsertAsync(ConnectorEntity connectorEntity) { DeleteAsync(connectorEntity.Key); var insert = _mongoDbAccess.Collection.InsertOneAsync(connectorEntity); return(Task.FromResult(insert.IsCompletedSuccessfully)); }
public async Task <bool> SavePage([FromBody] ConnectorEntity page, [FromUri] string jobId, [FromUri] string tenantId) { Expression <Func <PageJobEntity, bool> > filter = (entity => entity.RowKey == $"{jobId}"); PageJobMappingTable = azureTableProviderInstance.GetAzureTableReference(Settings.PageJobMappingTableName); List <PageJobEntity> pageJobEntityList = await azureTableProviderInstance.QueryEntitiesAsync <PageJobEntity>(PageJobMappingTable, filter); PageJobEntity pageJobEntity = pageJobEntityList?[0]; Trace.TraceInformation("Job Setup complete page succesfully saved for jobId: {0}", jobId); try { Trace.TraceInformation("Job with JobId: {0} subscribing to webhook", jobId); bool subscribed = await sourceProvider.Subscribe(pageJobEntity.SourceInfo); Trace.TraceInformation("Job with JobId: {0} successfully subscribed to webhook", jobId); } catch (Exception e) { Trace.TraceInformation("Job with JobId: {0} subscribed to webhook failed with error: {1}", jobId, e.Message); return(false); } return(true); }
public IResultResponse GetOrderInfo(int connectorId, string oddNumber) { ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null || connector.Id == null) { return(ResultResponse.ExceptionResult("下游不存在")); } GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); if (group == null || group.Id == null) { return(ResultResponse.ExceptionResult("上游不存在")); } Dictionary <string, string> dic = new Dictionary <string, string>() { { "OddNumber", oddNumber }, { "FromFKId", connector.SellerId.ToString() }, { "FromFKFlag", "2" }, { "IsBuyer", "False" }, }; string msg = ""; string datajson = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "order.trade.getorderinfo", dic, out msg); var dict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(ResultResponse.ExceptionResult(msg)); } ArrayList content = dict["Content"] as ArrayList; return(ResultResponse.GetSuccessResult(content)); }
/// <summary> /// 通过授权id获取网站库信息 /// </summary> /// <param name="id">授权ID</param> /// <returns>大于0成功,否则失败</returns> /// <remarks> /// <list type="bullet"> /// <item></item> /// </list> /// </remarks> public ArrayList GetAuthSiteById(int connectorId, int pageType) { string str = string.Format("select * from {0} where DownConnectorId={1} limit 1", RelationBusiness._TableName, connectorId); DataTable relation = DbAccess.GetDataTable(str); if (relation == null || relation.Rows.Count == 0) { return(null); } int upConnectorId = Utils.ToInt(relation.Rows[0]["UpConnectorId"]); ConnectorEntity upConnector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + upConnectorId); DataTable dt = DBTable("ConnectorId=" + upConnectorId + " and PageType=" + pageType); string selectIds = ""; if (dt != null && dt.Rows.Count > 0) { selectIds = Utils.ToString(dt.Rows[0]["PageIds"]); } //快马接口获取数据 GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + upConnector.GroupId); if (group == null) { return(null); } Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("FKId", upConnector.SellerId.ToString()); dic.Add("Ids", selectIds); string param = dic.ToJson(); string msg = ""; string datajson = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "theme.import.webpagesbyids", dic, out msg); var dict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(null); } ArrayList content = dict["Content"] as ArrayList; if (content.Count <= 0) { return(null); } foreach (Dictionary <string, object> item in content) { item.Add("ConnectorId", upConnectorId); item.Add("Supplier", upConnector.Name); } //DataTable webpage = new DataTable(); //webpage.Columns.Add("ConnectorId"); //if (webpage == null || webpage.Rows.Count == 0) return webpage; //foreach (DataRow dr in webpage.Rows) //{ // dr["ConnectorId"] = upConnectorId; //} return(content); }
/// <summary> /// Updates the specified Key. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public Task <bool> UpdateAsync(ConnectorEntity connectorEntity) { var filter = Builders <ConnectorEntity> .Filter.Eq("Key", connectorEntity.Key); var update = Builders <ConnectorEntity> .Update.Set("Payload", connectorEntity.Payload); return(Task.FromResult(_mongoDbAccess.Collection.UpdateOneAsync(filter, update).IsCompletedSuccessfully)); }
/// <summary> /// Updates the specified Key. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public bool Update(ConnectorEntity connectorEntity) { var filter = Builders <ConnectorEntity> .Filter.Eq("Key", connectorEntity.Key); var update = Builders <ConnectorEntity> .Update.Set("Payload", connectorEntity.Payload); return(_mongoDbAccess.Collection.UpdateOne(filter, update).IsAcknowledged); }
/// <summary> /// Updates the specified Key. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public bool Update(ConnectorEntity connectorEntity) { var seconds = connectorEntity.Expiration?.Seconds ?? 0; return(_memcachedAccess.MemcachedClient.Replace(connectorEntity.Key, JsonConvert.SerializeObject(connectorEntity), seconds)); }
/// <summary> /// Set the Key to hold the value. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public Task <bool> InsertAsync(ConnectorEntity connectorEntity) { var seconds = connectorEntity.Expiration?.Seconds ?? 0; return(_memcachedAccess.MemcachedClient.AddAsync(connectorEntity.Key, JsonConvert.SerializeObject(connectorEntity), seconds)); }
public PagingResult UpConnectorAuthList(PagingQuery pagingQuery, int connectorId) { PagingResult productList = new PagingResult() { PageIndex = pagingQuery.PageIndex, PageSize = pagingQuery.PageSize }; string str = string.Format("select * from {0} where DownConnectorId={1} and Status=1 limit 1", RelationBusiness._TableName, connectorId); DataTable relation = DbAccess.GetDataTable(str); if (relation == null || relation.Rows.Count == 0) { return(productList); } int upConnectorId = Utils.ToInt(relation.Rows[0]["UpConnectorId"]); ConnectorEntity upConnector = (ConnectorEntity) new ConnectorBusiness().GetEntity("Id=" + upConnectorId); GroupEntity upGroup = (GroupEntity) new GroupBusiness().GetEntity("Id=" + upConnector.GroupId); productList = GetAuthProductList(pagingQuery, upConnectorId, true); if (productList.Data != null) { string sql = string.Format("select * from {0} where UpConnectorId={1} and DownConnectorId={2} and Status=1", ProductRelationBusiness._TableName, upConnectorId, connectorId); DataTable dt = DbAccess.GetDataTable(sql); string selectIds; if (dt == null || dt.Rows.Count <= 0) { selectIds = ""; } else { selectIds = string.Join(",", dt.AsEnumerable().Select(dr => Utils.ToString(dr["UpProductId"]))); selectIds = "," + selectIds + ","; } foreach (Dictionary <string, object> item in (ArrayList)productList.Data) { item.Add("ConnectorId", upConnectorId); string preview = upGroup.Domain + "/Supplier/Product/Product.aspx?p=" + upConnector.VirtualDir + "&pid=" + Utils.ToString(item["ProductId"]) + "&sid=" + upConnector.SellerId; item.Add("Preview", preview); if (!string.IsNullOrEmpty(selectIds)) { if (selectIds.Contains("," + Utils.ToString(item["ProductId"]) + ",")) { item.Add("Imported", true); } else { item.Add("Imported", false); } } else { item.Add("Imported", false); } } } return(productList); }
/// <summary> /// Set the Key to hold the value. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public bool Insert(ConnectorEntity connectorEntity) { using (var session = _ravenDbAccess.Store.OpenSession()) { session.Store(connectorEntity, connectorEntity.Key); session.SaveChanges(); } return(true); }
/// <summary> /// Updates the specified Key. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public bool Update(ConnectorEntity connectorEntity) { using (var session = _ravenDbAccess.Store.OpenSession()) { var entity = session.Load <ConnectorEntity>(connectorEntity.Key); entity.Payload = connectorEntity.Payload; entity.Expiration = connectorEntity.Expiration; session.SaveChanges(); } return(true); }
public IResultResponse ValidateCode(int connectorId, int upConnectorId, string validateCode) { ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null || connector.Id == null || connector.Id < 1) { return(ResultResponse.ExceptionResult("您尚未成为连接器合作商")); } string mobile = DES.Encode(string.Format("{0}|{1}|{2}|{3}|{4}|{5}", connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile)); GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); IResultResponse res = ApiRequest.GetResponse(group.Domain, "vast.account.supplier.validatecode.validate", new Dictionary <string, string>() { { "Mobile", mobile }, { "ValidateCode", validateCode }, { "ProprietorId", connector.SellerId.ToString() }, }); if (res.Success) { int co = Utils.ToInt(DbAccess.GetValue(TableName, "count(0) as co", "upconnectorId=" + upConnectorId + " and status<>-1")); if (co >= 1000) { return(ResultResponse.ExceptionResult("已经达到最大限制,请联系上游")); } int val = 0; //ConnectorEntity upConnector = (ConnectorEntity)new ConnectorBusiness().GetEntity("Id=" + upConnectorId); RelationEntity myRelation = (RelationEntity) new RelationBusiness(_dapperFactory).GetEntity("DownConnectorId=" + connectorId + " and UpConnectorId=" + upConnectorId); if (myRelation != null && Utils.ToInt(myRelation.Id) != 0) { myRelation.Status = 0; myRelation.InvitedFrom = 0; val = DbAccess.ExecuteUpdate(TableName, myRelation, new string[] { "Id" }); } else { RelationEntity ent = new RelationEntity(); ent.UpConnectorId = upConnectorId; ent.UpBuyerId = 0; ent.DownConnectorId = connectorId; ent.Status = 0;//0待处理 ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; ent.InvitedFrom = 0; val = DbAccess.ExecuteInsert(TableName, ent); } if (val > 0) { return(ResultResponse.GetSuccessResult("您已成功申请成为该商家的下游合作商,请等待审核")); } } return(ResultResponse.ExceptionResult(res.Message)); }
public IResultResponse InsertDownConnectorRelation(int downConnectorId, int upConnectorId) { int val = 0; //快马接口查询 int upBuyerId = 0; //检查信息是否存在 ConnectorEntity downConnector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + downConnectorId); if (downConnector == null || Utils.ToInt(downConnector.Id) == 0) { return(ResultResponse.ExceptionResult("不存在该合作商")); } DataTable allRecord = DBTable("DownConnectorId=" + downConnectorId + " and Status=1"); if (allRecord != null && allRecord.Rows.Count > 0) { return(ResultResponse.ExceptionResult("该合作商已存在上游合作商")); } int co = Utils.ToInt(DbAccess.GetValue(TableName, "count(0) as co", "upconnectorId=" + upConnectorId + " and status<>-1")); if (co >= 1000) { return(ResultResponse.ExceptionResult("已经达到最大限制,您不能再发出邀请")); } RelationEntity myRelation = (RelationEntity) new RelationBusiness(_dapperFactory).GetEntity("DownConnectorId=" + downConnectorId + " and UpConnectorId=" + upConnectorId); if (myRelation != null && Utils.ToInt(myRelation.Id) != 0) { myRelation.Status = 0; myRelation.InvitedFrom = 1; val = DbAccess.ExecuteUpdate(TableName, myRelation, new string[] { "Id" }); } else { RelationEntity ent = new RelationEntity(); ent.UpConnectorId = upConnectorId; ent.UpBuyerId = upBuyerId; ent.DownConnectorId = downConnector.Id; ent.Status = 0;//0待处理 ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; ent.InvitedFrom = 1; val = DbAccess.ExecuteInsert(TableName, ent); } if (val > 0) { return(ResultResponse.GetSuccessResult(1)); } return(ResultResponse.ExceptionResult("添加合作商失败")); }
/// <summary> /// 入驻 /// </summary> /// <param name="dic"></param> /// <returns></returns> public IResultResponse Join(Dictionary <string, object> dic) { if (dic == null) { return(ResultResponse.ExceptionResult("对像为空")); } ConnectorEntity entity = new ConnectorEntity(); entity.SetValues(dic); entity.Status = 1; entity.AddTime = DateTime.Now; GroupEntity groupEntity = new GroupEntity(); groupEntity.SetValues(dic); groupEntity.Status = 1; groupEntity.AddTime = DateTime.Now; IResultResponse resultResponse = null; using (IDTService dbHandler = DbAccess.DtService) { try { dbHandler.BeginTransaction(); //保存主表 int id = Utils.ToInt(dbHandler.ExecuteScalar(DbProvider.InsertCommandText(groupEntity, GroupBusiness._TableName))); if (id == 0) { throw new Exception("操作失败"); } entity.GroupId = id; dbHandler.ExecuteScalar(DbProvider.InsertCommandText(entity, TableName)); dbHandler.CommitTransaction(); resultResponse = ResultResponse.GetSuccessResult(1); } catch (Exception ex) { dbHandler.RollbackTransaction(); resultResponse = ResultResponse.ExceptionResult(ex.Message); } } return(resultResponse); }
/// <summary> /// 插入授权关系信息 /// </summary> /// <returns>大于0成功,否则失败</returns> /// <remarks> /// <list type="bullet"> /// </list> /// </remarks> public int InsertUpConnectorRelation(string mobile, int downConnectorId) { int val = 0; //快马接口查询 int upBuyerId = 0; //检查信息是否存在 Dictionary <string, object> dic1 = new Dictionary <string, object>(); dic1.Add("Mobile", mobile); ConnectorEntity entConnector = DbAccess.GetEntity <ConnectorEntity>(ConnectorBusiness._TableName, dic1); if (entConnector == null) { return(-2); } if (entConnector.Id == downConnectorId) { return(-1); } Dictionary <string, object> dic2 = new Dictionary <string, object>(); //dic2.Add("UpConnectorId", entConnector.Id); //dic2.Add("UpBuyerId", upBuyerId); dic2.Add("DownConnectorId", downConnectorId); RelationEntity entRelation = DbAccess.GetEntity <RelationEntity>(TableName, dic2); if (entRelation != null && entRelation.UpConnectorId != 0) { return(-1); } RelationEntity ent = new RelationEntity(); ent.UpConnectorId = entConnector.Id; ent.UpBuyerId = upBuyerId; ent.DownConnectorId = downConnectorId; ent.Status = 0;//0待处理 ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; ent.InvitedFrom = 0; val = DbAccess.ExecuteInsert(TableName, ent); return(val); }
public IResultResponse ValidateCode(int connectorId, int upConnectorId, string validateCode) { ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness().GetEntity("Id=" + connectorId); if (connector == null || connector.Id == null || connector.Id < 1) { return(ResultResponse.ExceptionResult("您尚未成为连接器合作商")); } string mobile = DES.Encode(string.Format("{0}|{1}|{2}|{3}|{4}|{5}", connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile)); GroupEntity group = (GroupEntity) new GroupBusiness().GetEntity("Id=" + connector.GroupId); IResultResponse res = ApiRequest.GetResponse(group.Domain, "vast.account.supplier.validatecode.validate", new Dictionary <string, string>() { { "Mobile", mobile }, { "ValidateCode", validateCode }, { "ProprietorId", connector.SellerId.ToString() }, }); if (res.Success) { ConnectorEntity upConnector = (ConnectorEntity) new ConnectorBusiness().GetEntity("Id=" + upConnectorId); RelationEntity ent = new RelationEntity(); ent.UpConnectorId = upConnectorId; ent.UpBuyerId = 0; ent.DownConnectorId = connectorId; ent.Status = 0;//0待处理 ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; ent.InvitedFrom = 0; int val = DbAccess.ExecuteInsert(TableName, ent); if (val > 0) { return(ResultResponse.GetSuccessResult("您已成功申请成为该商家的下游合作商,请等待审核")); } } return(ResultResponse.ExceptionResult(res.Message)); }
public IResultResponse GetValidateCode(int connectorId, string codeToken, string verifyCode) { ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null || connector.Id == null || connector.Id < 1) { return(ResultResponse.ExceptionResult("您尚未成为连接器合作商")); } GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); string mobile = DES.Encode(string.Format("{0}|{1}|{2}|{3}|{4}|{5}", connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile, connector.Mobile)); IResultResponse res = ApiRequest.GetResponse(group.Domain, "vast.account.supplier.validatecode.get", new Dictionary <string, string>() { { "mobile", mobile }, { "VerifyCode", verifyCode }, { "CodeToken", codeToken }, { "ProprietorId", connector.SellerId.ToString() }, }); if (res.Success) { return(ResultResponse.GetSuccessResult(1)); } return(ResultResponse.ExceptionResult(res.Message)); }
/// <summary> /// 通过条件获取授权商品信息 /// </summary> /// <remarks> /// <list type="bullet"> /// <item></item> /// </list> /// </remarks> public PagingResult GetAuthProductList(PagingQuery pagingQuery, int connectorId, bool auth = true) { PagingResult result = new PagingResult() { PageIndex = pagingQuery.PageIndex, PageSize = pagingQuery.PageSize }; result.PageIndex = pagingQuery.PageIndex; result.PageSize = pagingQuery.PageSize; result.Data = new DataTable(); ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness().GetEntity("Id=" + connectorId); if (connector == null) { return(result); } GroupEntity group = (GroupEntity) new GroupBusiness().GetEntity("Id=" + connector.GroupId); if (group == null) { return(result); } AuthBrandEntity brands = (AuthBrandEntity) new AuthBrandBusiness().GetEntity("ConnectorId=" + connectorId); AuthCategoryEntity categorys = (AuthCategoryEntity) new AuthCategoryBusiness().GetEntity("ConnectorId=" + connectorId); DataTable dt = DBTable("ConnectorId=" + connectorId); string ids; if (dt == null || dt.Rows.Count == 0) { ids = ""; } ids = string.Join(",", dt.AsEnumerable().Select(dr => Utils.ToString(dr["ProductId"]))); string condition = ""; if (auth) { condition += "<ProductId Oper=\"notin\">" + ids + "</ProductId><droitbrandids>" + brands.BrandIds + "</droitbrandids><droitcategoryids>" + categorys.CategoryIds + "</droitcategoryids>"; } else { if (string.IsNullOrWhiteSpace(ids)) { return(result); } //未授权商品 condition += "<ProductId>" + ids + "</ProductId>"; } Dictionary <string, string> dic = new Dictionary <string, string>(); //遍历所有子节点 foreach (Condition c in pagingQuery.Condition) { if (!string.IsNullOrEmpty(c.Value)) { switch (c.Name.ToLower()) { case "keywords": dic.Add("Keywords", c.Value); break; case "brandid": dic.Add("brandId", c.Value); break; case "categoryid": dic.Add("cid", c.Value); break; case "productcode": condition += "<ProductCode>" + c.Value + "</ProductCode>"; break; case "productname": condition += "<ProductName>" + c.Value + "</ProductName>"; break; case "Bbarcode": condition += "<BarCode>" + c.Value + "</BarCode>"; break; } } } dic.Add("FKId", connector.SellerId.ToString()); dic.Add("ProprietorId", connector.SellerId.ToString()); dic.Add("Proprietor", "2"); //dic.Add("UserId", connector.SellerId.ToString()); dic.Add("FKFlag", "2"); dic.Add("Condition", HttpUtility.UrlEncode(condition)); dic.Add("PageIndex", pagingQuery.PageIndex.ToString()); dic.Add("PageSize", pagingQuery.PageSize.ToString()); string msg = ""; string datajson = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "vast.mall.product.page", dic, out msg); var jss = new JavaScriptSerializer(); var dict = jss.Deserialize <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(null); } Dictionary <string, object> content = dict["Content"] as Dictionary <string, object>; if (content == null || content.Count <= 0) { return(result); } result.TotalCount = Utils.ToInt(content["TotalCount"]); if (content["Data"] != null) { result.Data = content["Data"]; } return(result); }
/// <summary> /// 通过条件获取授权品牌信息 /// </summary> /// <remarks> /// <list type="bullet"> /// <item></item> /// </list> /// </remarks> public ArrayList GetAuthBrandList(int connectorId, string firstSpell, string keyword, bool showAll = true) { DataTable dt = DBTable("ConnectorId=" + connectorId); string selectIds = ""; if (dt != null && dt.Rows.Count > 0) { selectIds = Utils.ToString(dt.Rows[0]["BrandIds"]); } //快马接口获取 ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null) { return(null); } GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); if (group == null) { return(null); } Dictionary <string, string> dic = new Dictionary <string, string>(); if (!showAll) { if (!string.IsNullOrWhiteSpace(selectIds)) { string condition = "<Id Oper=\"in\">" + selectIds + "</Id>"; dic.Add("Condition", HttpUtility.UrlEncode(condition)); } else { return(null); } } if (keyword != "") { string condition = "<Name Oper=\"like\">" + keyword + "</Name>"; dic.Add("Condition", HttpUtility.UrlEncode(condition)); } dic.Add("FKId", connector.SellerId.ToString()); dic.Add("FKFlag", "2"); dic.Add("ProprietorId", connector.SellerId.ToString()); dic.Add("TypeId", "0"); dic.Add("FirstSpell", firstSpell); string msg = ""; string datajson = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "vast.mall.product.brands", dic, out msg); selectIds = "," + selectIds + ","; var dict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(null); } ArrayList content = dict["Content"] as ArrayList; if (content == null || content.Count <= 0) { return(null); } foreach (Dictionary <string, object> item in content) { ArrayList brands = item["brands"] as ArrayList; foreach (Dictionary <string, object> brand in brands) { brand.Add("ConnectorId", connectorId); if (!string.IsNullOrEmpty(selectIds)) { if (selectIds.Contains("," + Utils.ToString(brand["Id"]) + ",")) { brand.Add("Checked", true); } else { brand.Add("Checked", false); } } } } return(content); }
/// <summary> /// Updates the specified Key. /// </summary> /// <param name="connectorEntity">The ConnectorEntity to store.</param> /// <returns></returns> public Task <bool> UpdateAsync(ConnectorEntity connectorEntity) { var update = Update(connectorEntity); return(Task.FromResult(update)); }
public int ImportPage(int connectorId, int upConnectorId, int pageType, int pageId) { int val = 0; ConnectorEntity upConnector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + upConnectorId); if (upConnector == null) { return(val); } GroupEntity upGroup = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + upConnector.GroupId); if (upGroup == null) { return(val); } Dictionary <string, string> dic1 = new Dictionary <string, string>(); dic1.Add("FKId", upConnector.SellerId.ToString()); string msg = ""; string datajson = ApiRequest.GetRemoteContent(upGroup.Domain + "/Route.axd", "theme.pagewidget.list", dic1, out msg); if (string.IsNullOrEmpty(datajson)) { return(val); } var dict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(val); } ArrayList content = dict["Content"] as ArrayList; XElement el = new XElement("Styles"); foreach (Dictionary <string, object> item in content) { XElement itemxml = new XElement("Style"); itemxml.Add( item.Select(kv => new XElement(kv.Key, kv.Value))); el.Add(itemxml); } //string json = content.ToJson(); ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null) { return(val); } GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); if (group == null) { return(val); } Dictionary <string, string> dic2 = new Dictionary <string, string>(); dic2.Add("WebPages", el.ToString()); dic2.Add("ProprietorId", connector.SellerId.ToString()); //string result = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "theme.webpage.add", dic2, out msg); //Dictionary<string, string> dic2 = new Dictionary<string, string>(); //dic2.Add("FKId", connector.SellerId.ToString()); //dic2.Add("content", json.ToString()); //string result = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "theme.import.importpagedata", dic2, out msg); //if (string.IsNullOrEmpty(datajson)) //{ // return val; //} //var jss2 = new JavaScriptSerializer(); //var dict2 = jss.Deserialize<Dictionary<string, object>>(result); //if (!Utils.ToBool(dict2["Success"])) //{ // return val; //} //val = Utils.ToInt(dict2["Content"]); return(val); }
/// <summary> ///获取授权页面装修信息 /// </summary> /// <remarks> /// <list type="bullet"> /// <item></item> /// </list> /// </remarks> public ArrayList GetAuthSitePageList(int siteType, int connectorId) { string sql = string.Format("select * from {0} where ConnectorId={1} and PageType={2} order by Id desc;", TableName, connectorId, siteType); DataTable dt = DbAccess.GetDataTable(sql); //if (dt == null || dt.Rows.Count == 0) return null; //快马接口获取装修列表 ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null) { return(null); } GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); if (group == null) { return(null); } Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("FKId", connector.SellerId.ToString()); dic.Add("SiteType", siteType.ToString()); string msg = ""; string datajson = ApiRequest.GetRemoteContent(group.Domain + "/Route.axd", "theme.import.webpageslist", dic, out msg); string selectIds = ""; if (dt != null && dt.Rows.Count > 0) { selectIds = Utils.ToString(dt.Rows[0]["PageIds"]); } selectIds = "," + selectIds + ","; var dict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(null); } ArrayList content = dict["Content"] as ArrayList; if (content.Count <= 0) { return(null); } foreach (Dictionary <string, object> item in content) { item.Add("ConnectorId", connectorId); if (!string.IsNullOrEmpty(selectIds)) { if (selectIds.Contains("," + Utils.ToString(item["Id"]) + ",")) { item.Add("Checked", true); } else { item.Add("Checked", false); } } } return(content); }
public IResultResponse ImportProduct(int connectorId, int upConnectorId, int productId) { int val = 0; ConnectorEntity upConnector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + upConnectorId); if (upConnector == null || upConnector.Id == null) { return(ResultResponse.ExceptionResult("上游不存在")); } GroupEntity upGroup = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + upConnector.GroupId); if (upGroup == null || upGroup.Id == null) { return(ResultResponse.ExceptionResult("上游不存在")); } ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + connectorId); if (connector == null || connector.Id == null) { return(ResultResponse.ExceptionResult("下游不存在")); } GroupEntity downGroup = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); if (downGroup == null || downGroup.Id == null) { return(ResultResponse.ExceptionResult("下游不存在")); } Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("FKId", upConnector.SellerId.ToString()); dic.Add("ProprietorId", upConnector.SellerId.ToString()); dic.Add("Proprietor", "2"); dic.Add("FKFlag", "2"); dic.Add("ProductId", productId.ToString()); string msg = ""; string datajson = ApiRequest.GetRemoteContent(upGroup.Domain + "/Route.axd", "mall.product.pullinfo", dic, out msg); if (string.IsNullOrEmpty(datajson)) { return(ResultResponse.ExceptionResult("拉取数据为空")); } var dict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(datajson); if (!Utils.ToBool(dict["Success"])) { return(ResultResponse.ExceptionResult(Utils.ToString(dict["Message"])));; } #region 处理数据 Dictionary <string, object> content = dict["Content"] as Dictionary <string, object>; Dictionary <string, object> importData = new Dictionary <string, object>(); List <Dictionary <string, string> > picList = new List <Dictionary <string, string> >(); if (content.ContainsKey("Product")) { Dictionary <string, object> product = content["Product"] as Dictionary <string, object>; importData = product; int id = Utils.ToInt(product["ProductId"]); importData.Remove("ProductId"); importData.Add("ThirdId", id); importData["BrandId"] = 0; importData["CategoryId"] = 0; importData["TypeId"] = 0; importData.Add("Marketable", true); importData.Remove("FootIntro"); importData.Remove("HeadIntro"); importData.Remove("ShowstandIntro"); importData.Remove("DefaultUnitId"); importData.Add("DefaultSaleUnitId", 0); importData.Remove("BrandName"); importData.Remove("CustomCateId"); } ArrayList goods = new ArrayList(); if (content.ContainsKey("Goods")) { goods = content["Goods"] as ArrayList; foreach (Dictionary <string, object> item in goods) { int id = Utils.ToInt(item["GoodsId"]); item.Remove("GoodsId"); item.Remove("ProductId"); item.Add("ThirdId", id); string name = item["SpecValueText"].ToString(); item.Add("Name", name); item.Remove("SpecValueText"); if (item.ContainsKey("SpecValue")) { ArrayList specValue = item["SpecValue"] as ArrayList; foreach (Dictionary <string, object> specItem in specValue) { specItem["Id"] = 0; specItem.Add("Name", specItem["SpecName"].ToString()); specItem.Remove("SpecName"); string pic = specItem.ContainsKey("ImagePath") ? specItem["ImagePath"].ToString() : ""; if (pic.IndexOf("?") > -1) { pic = pic.Substring(0, pic.IndexOf("?")); } if (pic != "") { specItem["ImagePath"] = "/UserFiles/Supplier" + connector.SellerId + "/" + DateTime.Now.Date.ToString("yyyMMdd") + "/Images/" + Path.GetFileName(pic); Dictionary <string, string> pickv = new Dictionary <string, string>() { { "old", pic }, { "new", specItem["ImagePath"].ToString() } }; picList.Add(pickv); } specItem.Remove("SpecId"); } } if (item.ContainsKey("Pics")) { ArrayList pics = item["Pics"] as ArrayList; foreach (Dictionary <string, object> picItem in pics) { string pic = picItem.ContainsKey("VirtualPath") ? picItem["VirtualPath"].ToString() : ""; if (pic.IndexOf("?") > -1) { pic = pic.Substring(0, pic.IndexOf("?")); } if (pic != "") { picItem["ImagePath"] = "/UserFiles/Supplier" + connector.SellerId + "/" + DateTime.Now.Date.ToString("yyyMMdd") + "/Images/" + Path.GetFileName(pic); Dictionary <string, string> pickv = new Dictionary <string, string>() { { "old", pic }, { "new", picItem["ImagePath"].ToString() } }; picList.Add(pickv); } } } } } importData.Add("Goods", goods); ArrayList auxiliaryUnit = new ArrayList(); if (content.ContainsKey("AuxiliaryUnits")) { auxiliaryUnit = content["AuxiliaryUnits"] as ArrayList; foreach (Dictionary <string, object> unitItem in auxiliaryUnit) { unitItem["Id"] = 0; } } importData.Add("AuxiliaryUnit", auxiliaryUnit); importData.Add("ViceCatalogIds", content["ViceCatalogIds"]); ArrayList picsList = new ArrayList(); if (content.ContainsKey("Pics")) { picsList = content["Pics"] as ArrayList; foreach (Dictionary <string, object> picItem in picsList) { picItem.Remove("Id"); picItem.Remove("VirtualPath"); string picContent = picItem["Content"].ToString(); if (picContent.IndexOf("?") > -1) { picContent = picContent.Substring(0, picContent.IndexOf("?")); } if (picContent != "") { picItem["Content"] = "/UserFiles/Supplier" + connector.SellerId + "/" + DateTime.Now.Date.ToString("yyyMMdd") + "/Images/" + Path.GetFileName(picContent); Dictionary <string, string> pickv = new Dictionary <string, string>() { { "old", picContent }, { "new", picItem["Content"].ToString() } }; picList.Add(pickv); } } } importData.Add("Pics", picsList); if (content.ContainsKey("Video")) { Dictionary <string, object> video = content["Video"] as Dictionary <string, object>; video.Remove("Id"); video.Remove("GoodsId"); video.Remove("FileType"); video.Remove("Reorder"); video.Remove("HasVideo"); importData.Add("Video", video); } ArrayList specification = new ArrayList(); if (content.ContainsKey("Specification")) { specification = content["Specification"] as ArrayList; foreach (Dictionary <string, object> specItem in specification) { specItem["Id"] = 0; } } importData.Add("Specification", specification); importData.Add("Extends", content["Extends"]); importData.Add("Params", content["Params"]); importData.Add("SEO", content["SEO"]); #endregion List <Dictionary <string, object> > list = new List <Dictionary <string, object> >(); list.Add(importData); string data = JsonMapper.ToJson(list); IResultResponse result = ApiRequest.GetResponse(downGroup.Domain, "mall.product.push", new Dictionary <string, string>() { { "ProprietorId", connector.SellerId.ToString() }, { "FKId", connector.SellerId.ToString() }, { "FKFlag", "2" }, { "Products", HttpUtility.UrlEncode(data) }, }); if (result.Success) { DataTable dt = result.Content as DataTable; if (dt == null || dt.Rows.Count == 0) { return(ResultResponse.ExceptionResult("转换异常错误")); } StringBuilder sb = new StringBuilder(); string error = string.Empty; foreach (DataRow dr in dt.Rows) { var success = Utils.ToString(dr["Success"]) == "True"; if (!success) { error = (Utils.ToString(dt.Rows[0]["Message"])); continue; } Dictionary <string, object> output = dt.Rows[0]["Content"] as Dictionary <string, object>; if (output.ContainsKey("Goods")) { foreach (Object good in output["Goods"] as Object[]) { Dictionary <string, object> item = good as Dictionary <string, object>; ProductRelationEntity ent = new ProductRelationEntity(); ent.UpConnectorId = upConnectorId; ent.UpProductId = productId; ent.UpGoodsId = Utils.ToInt(item["ThirdId"]); ent.DownConnectorId = connectorId; ent.DownProductId = Utils.ToInt(output["Id"]); ent.DownGoodsId = Utils.ToInt(item["Id"]); sb.AppendLine(DbAccess.Provider.InsertCommandText(ent, TableName)); } } } if (sb.Length > 0) { val = DbAccess.ExecuteNonQuery(sb.ToString()); #region 导入图片数据 StringBuilder picsb = new StringBuilder(); foreach (Dictionary <string, string> item in picList) { if (item["old"].IndexOf("http://") > -1 || item["old"].IndexOf("https://") > -1) { picsb.Append(string.Format("<Image><Path>{0}</Path><Url>{1}</Url></Image>", item["new"], item["old"])); } else { picsb.Append(string.Format("<Image><Path>{0}</Path><Url>{2}{1}</Url></Image>", item["new"], item["old"], downGroup.ImageDomain)); } } Task.Run(() => { string bucketName = string.Empty; IResultResponse resBucket = ApiRequest.GetResponse(upGroup.Domain, "material.oss.bucket.name", new Dictionary <string, string>() { }); if (resBucket != null && resBucket.Success) { bucketName = Utils.ToString(resBucket.Content); } IResultResponse pic = ApiRequest.GetResponse(downGroup.Domain, "material.upload.saveremoteimage", new Dictionary <string, string>() { { "Module", "Product" }, { "FKId", connector.SellerId.ToString() }, { "FKFlag", "2" }, { "Images", (picsb.ToString()) }, { "BucketName", bucketName } }); }); #endregion } else { return(ResultResponse.ExceptionResult(error)); } return(ResultResponse.GetSuccessResult(val)); } else { return(result); } }
public IResultResponse CheckUpConnector(int downConnectorId, int id, int status) { try { ClearCache(); int val = 0; ConnectorEntity downConnector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + downConnectorId); if (downConnector == null || Utils.ToInt(downConnector.Id) == 0) { return(ResultResponse.ExceptionResult("不存在该下游")); } RelationEntity entRelation = (RelationEntity) new RelationBusiness(_dapperFactory).GetEntity("Id=" + id + " and DownConnectorId=" + downConnectorId); if (entRelation == null || Utils.ToInt(entRelation.Id) == 0) { return(ResultResponse.ExceptionResult("不存在合作关系")); } ConnectorEntity connector = (ConnectorEntity) new ConnectorBusiness(_dapperFactory).GetEntity("Id=" + entRelation.UpConnectorId); if (connector == null || Utils.ToInt(connector.Id) == 0) { return(ResultResponse.ExceptionResult("不存在该上游")); } GroupEntity group = (GroupEntity) new GroupBusiness(_dapperFactory).GetEntity("Id=" + connector.GroupId); if (group == null || Utils.ToInt(group.Id) == 0) { return(ResultResponse.ExceptionResult("不存在该上游机组")); } if (status == 1 && entRelation.UpBuyerId == 0) { DataTable allRecord = DBTable("DownConnectorId=" + downConnectorId + " and Status=1"); if (allRecord != null && allRecord.Rows.Count > 0) { return(ResultResponse.ExceptionResult("已存在上游合作商")); } //快马上游插入下游客户账户 long ts = Utils.ToUnixTime(DateTime.Now.AddMinutes(1)); Dictionary <string, string> dic = new Dictionary <string, string>() { { "fk_id", connector.SellerId.ToString() }, { "expire", ts.ToString() }, { "mobile", downConnector.Mobile } }; string json = dic.ToJson(); string token = ECF.Security.AES.Encode(json); IResultResponse result = ApiRequest.GetResponse(group.Domain, "account.add.downconnector", new Dictionary <string, string>() { { "exchange_token", HttpUtility.UrlEncode(token) }, }); if (result.Success) { Dictionary <string, object> content = result.Content as Dictionary <string, object>; int storeId = content.ToInt("StoreId", 0); entRelation.IsDefault = 1; entRelation.UpBuyerId = storeId; } else { return(ResultResponse.ExceptionResult("上游零售商关联失败,请稍后在试")); } } entRelation.IsDefault = 1; entRelation.Status = status; entRelation.UpdateTime = DateTime.Now; val = DbAccess.ExecuteUpdate(TableName, entRelation, new string[] { "Id" }); if (val > 0) { return(ResultResponse.GetSuccessResult(1)); } return(ResultResponse.ExceptionResult("接受邀请失败")); } catch (Exception ex) { return(ResultResponse.ExceptionResult(ex)); } }