Exemplo n.º 1
0
        /// <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));
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取上游供应商的首页
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static IResultResponse GetUpDefalutUrl(SysParameter para)
        {
            IResultResponse resultResponse = OpsUtil.VerifyAccessToken(para);

            if (!resultResponse.Success)
            {
                return(resultResponse);
            }

            Sdk.AccessToken accessToken = resultResponse.Content as Sdk.AccessToken;
            try
            {
                ConnectorRelation connectorRelation = new ConnectorBusiness(para.dapperFactory).GetUpConnector(Utils.ToInt(accessToken.Id));
                if (connectorRelation.VirtualDir != null)
                {
                    Dictionary <string, string> dic = new Dictionary <string, string>()
                    {
                        { "method", "linker.login" },
                        { "userId", "0" },
                        { "storeId", connectorRelation.UpBuyerId.ToString() },
                        { "virtualdir", connectorRelation.VirtualDir },
                    };
                    var param = ApiRequest.GetPaySign(dic);
                    return(ResultResponse.GetSuccessResult($"{connectorRelation.Domain}/linker.axd?{param}"));
                }
                return(ResultResponse.ExceptionResult("你没有上游供应商"));
            }
            catch (Exception ex)
            {
                return(ResultResponse.ExceptionResult(ex, 500));
            }
        }
Exemplo n.º 4
0
Arquivo: Order.cs Projeto: tynr426/ict
 public static IResultResponse OrderCheck(SysParameter para)
 {
     try
     {
         int    sellerId  = para.ToInt("FKId");
         int    dbId      = para.ToInt("DBId");
         string orderInfo = para.ToValue("ProductInfo");
         int    orderId   = para.ToInt("OrderId");
         bool   result    = false;
         if (!String.IsNullOrEmpty(orderInfo) && sellerId != 0)
         {
             var xml = new XmlDocument();
             xml.LoadXml(orderInfo);
             //检测商品
             var res = new ProductRelationBusiness(para.dapperFactory).CheckProduct(sellerId, dbId, xml);
             if (!res.Success)
             {
                 return(res);
             }
             //检测订单
             bool check = new OrderRelationBusiness(para.dapperFactory).CheckOrder(sellerId, dbId, orderId);
             if (check)
             {
                 return(ResultResponse.ExceptionResult("你已经代下过单了"));
             }
             return(ResultResponse.GetSuccessResult(result));
         }
         return(ResultResponse.ExceptionResult("订单信息不全"));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 5
0
Arquivo: Order.cs Projeto: tynr426/ict
        /// <summary>
        /// 订单支付
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static IResultResponse OrderPay(SysParameter para)
        {
            int sellerId = para.ToInt("FKId");
            int dbId     = para.ToInt("DBId");
            int orderId  = para.ToInt("OrderId");

            try
            {
                ConnectorRelation connectorEntity = new ConnectorBusiness(para.dapperFactory).GetUpConnector(sellerId, dbId);
                if (connectorEntity.Id == null)
                {
                    return(ResultResponse.ExceptionResult("没有找到对应的上游"));
                }
                RelationMappingEntity orderMappingEntity = new OrderRelationBusiness(para.dapperFactory).GetUpOrder(sellerId, dbId, orderId);
                if (!orderMappingEntity.OrderMapping.ContainsKey(orderId))
                {
                    return(ResultResponse.ExceptionResult("没有找到对应的订单"));
                }
                Dictionary <string, string> p = new Dictionary <string, string>()
                {
                    { "domain", connectorEntity.Domain },
                    { "userId", connectorEntity.UpBuyerId.ToString() },
                    { "orderId", orderMappingEntity.OrderMapping[orderId].ToString() },
                };

                return(ResultResponse.GetSuccessResult(p));
            }
            catch (Exception ex)
            {
                return(ResultResponse.ExceptionResult(ex));
            }
        }
Exemplo n.º 6
0
        public static IResultResponse GetValidateCode(SysParameter para)
        {
            NetResponse response = null;
            string      domain   = para.ToValue("domain");

            if (domain == null)
            {
                return(ResultResponse.ExceptionResult("域名为空"));
            }
            NetRequest request = new NetRequest();

            request.SetTimeOut(8000);
            request.SetTryTimes(1);
            string url = domain + "/api/VerifyCode.axd?base64=1";
            string msg = string.Empty;

            response = request.Get(url, string.Empty, out msg);
            string content   = response.Content;
            string codeToken = response.Header["CodeToken"];
            Dictionary <string, string> result = new Dictionary <string, string>()
            {
                { "content", content },
                { "codeToken", codeToken },
            };

            return(ResultResponse.GetSuccessResult(result.ToJson()));
        }
Exemplo n.º 7
0
Arquivo: Order.cs Projeto: tynr426/ict
        /// <summary>
        /// 订单支付
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static IResultResponse OrderUpdate(SysParameter para)
        {
            int sellerId  = para.ToInt("FKId");
            int dbId      = para.ToInt("DBId");
            int orderId   = para.ToInt("OrderId");
            int upBuyerId = para.ToInt("BuyerId");

            try
            {
                ConnectorRelation connectorEntity = new ConnectorBusiness(para.dapperFactory).GetDownConnector(sellerId, upBuyerId, dbId);
                if (connectorEntity.Id == null)
                {
                    return(ResultResponse.ExceptionResult("没有找到对应的下游"));
                }
                RelationMappingEntity orderMappingEntity = new OrderRelationBusiness(para.dapperFactory).GetDownOrder(sellerId, dbId, orderId, upBuyerId);
                if (!orderMappingEntity.OrderMapping.ContainsKey(orderId))
                {
                    return(ResultResponse.ExceptionResult("没有找到对应的订单"));
                }

                new OrderRelationBusiness(para.dapperFactory).UpdateUpOrder(connectorEntity, para.ToDictionary());

                return(ResultResponse.GetSuccessResult(200));
            }
            catch (Exception ex)
            {
                return(ResultResponse.ExceptionResult(ex));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 返回response
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="actionName"></param>
        /// <param name="parameters"></param>
        /// <param name="header"></param>
        /// <returns></returns>
        public static IResultResponse GetResponse(string domain, string actionName, Dictionary <string, string> parameters, Dictionary <string, string> header = null)
        {
            IResultResponse result = null;

            try
            {
                string msg           = string.Empty;
                string reqParameters = GetSign(actionName, parameters, FormatType.Json);


                NetResponse response = null;

                NetRequest request = new NetRequest();
                request.SetTimeOut(10000);
                request.SetTryTimes(1);
                if (header != null)
                {
                    foreach (KeyValuePair <string, string> kv in header)
                    {
                        request.AddHeader(kv.Key, kv.Value);
                    }
                }

                if (!domain.StartsWith("http"))
                {
                    domain = "http://" + domain;
                }
                string url = domain + "/Route.axd";

                response = request.Post(url, reqParameters, string.Empty, out msg);

                if (response != null)
                {
                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        result = ParseResponseData(response.Content);
                    }
                    else
                    {
                        result = ResultResponse.ExceptionResult(response.StatusDescription);
                    }
                }
                else if (!msg.IsNullOrEmpty())
                {
                    result = ResultResponse.ExceptionResult("数据接口请求错误:" + msg + "; 请求接口名: " + actionName);
                    new Exceptions("数据接口请求错误:" + msg + "; 请求接口名: " + actionName);
                }
                else
                {
                    result = ResultResponse.ExceptionResult("数据接口请求错误,请求接口名: " + actionName);
                }
            }
            catch (Exception ex)
            {
                result = ResultResponse.ExceptionResult(ex, ex.Message);
                new Exceptions(ex.Message, ex);
            }

            return(result);
        }
Exemplo n.º 9
0
 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));
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// 执行接口
        /// </summary>
        /// <param name="para"></param>
        public IResultResponse Process(SysParameter para)
        {
            IResultResponse result = GetResultResponse(para);

            // 如果使用给定结果的方式返回可以直接输出二进制流
            return(result != null ? result : ResultResponse.ExceptionResult("提交参数不正确", "", 4001));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 代下单货品检查是否为已上货
        /// </summary>
        /// <param name="sellerId"></param>
        /// <param name="dbId"></param>
        /// <param name="productInfo"></param>
        /// <returns></returns>
        public IResultResponse CheckProduct(int sellerId, int dbId, XmlDocument xml)
        {
            IResultResponse       result = ResultResponse.GetSuccessResult(1);
            RelationMappingEntity relationMappingEntity = GetUpMappingEntity(sellerId, dbId);

            if (relationMappingEntity.GoodsMapping.Count == 0)
            {
                return(ResultResponse.ExceptionResult("上游的货品没有关联上"));
            }

            string      productInfo = xml.SelectSingleNode("ProductInfo").InnerText;
            XmlDocument doc         = new XmlDocument();

            doc.LoadXml("<root>" + productInfo + "</root>");
            foreach (XmlNode good in doc.DocumentElement.ChildNodes)
            {
                int goodsId   = Utils.ToInt(good.SelectSingleNode("GoodsId").InnerText);
                int productId = Utils.ToInt(good.SelectSingleNode("ProductId").InnerText);
                if (relationMappingEntity.ProductMapping.ContainsKey(productId) && relationMappingEntity.GoodsMapping.ContainsKey(goodsId))
                {
                    continue;
                }
                else
                {
                    //$"商品id={productId},货品id={goodsId} 不存在"
                    result = ResultResponse.ExceptionResult("商品不能代发");
                    break;
                }
            }
            return(result);
        }
Exemplo n.º 12
0
Arquivo: Order.cs Projeto: tynr426/ict
        /// <summary>
        /// 发货中转
        /// </summary>
        /// <param name="sellerId"></param>
        /// <param name="dbId"></param>
        /// <param name="dispatchId"></param>
        /// <param name="dispatchInfo"></param>
        /// <returns></returns>
        public static IResultResponse DispatchSubmit(SysParameter para)
        {
            IResultResponse result       = null;
            int             sellerId     = para.ToInt("FKId");
            int             dbId         = para.ToInt("DBId");
            string          dispatchInfo = para.ToValue("DispatchInfo");
            int             dispatchId   = para.ToInt("DispatchId");
            int             orderId      = para.ToInt("OrderId");
            int             upBuyerId    = para.ToInt("BuyerId");
            string          oddNumber    = para.ToValue("OddNumber");

            try
            {
                RelationMappingEntity productMappingEntity = new ProductRelationBusiness(para.dapperFactory).GetDownMappingEntity(sellerId, upBuyerId, dbId);
                if (productMappingEntity.GoodsMapping.Count == 0)
                {
                    return(ResultResponse.ExceptionResult("没有找到商品映射关系"));
                }

                RelationMappingEntity orderMappingEntity = new OrderRelationBusiness(para.dapperFactory).GetDownOrder(sellerId, dbId, orderId, upBuyerId);

                if (!orderMappingEntity.OrderMapping.ContainsKey(orderId) || !orderMappingEntity.OrderOddNumberMapping.ContainsKey(oddNumber))
                {
                    return(ResultResponse.ExceptionResult("没有找到订单映射关系"));
                }
                //替换orderid
                dispatchInfo = ReplaceIds(orderMappingEntity.OrderMapping, dispatchInfo, "OrderId");
                //替换商品oddnumbers
                dispatchInfo = ReplaceStr(orderMappingEntity.OrderOddNumberMapping, dispatchInfo, "OddNumber");
                //替换product
                dispatchInfo = ReplaceIds(productMappingEntity.ProductMapping, dispatchInfo, "ProductId");
                dispatchInfo = ReplaceIds(productMappingEntity.GoodsMapping, dispatchInfo, "GoodsId");

                //发送
                result = ApiRequest.GetResponse(productMappingEntity.ConnectorEntity.Domain, "order.dropshippingdispatch.submit", new Dictionary <string, string>()
                {
                    { "OrderId", orderMappingEntity.OrderMapping[orderId].ToString() },
                    { "DispatchInfo", dispatchInfo }
                });
                if (result.Success)
                {
                    //入库
                    var orderDic = result.Content as Dictionary <string, object>;
                    if (orderDic != null)
                    {
                        new DispatchRelationBusiness(para.dapperFactory).Insert(dispatchId, orderMappingEntity.OrderRelationEntity, orderDic);
                    }
                    return(ResultResponse.GetSuccessResult(dispatchId));
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                return(ResultResponse.ExceptionResult(ex));
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 授权登录
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static IResultResponse AuthLogin(SysParameter para)
        {
            try
            {
                string token = para.ToValue("exchange_token");
                if (token.IndexOf("%") > -1)
                {
                    token = HttpUtility.UrlDecode(token);
                }
                string sign     = para.ToValue("exhange_sign");
                string sign_new = Encrypt.MD532("rwxkj:" + token);
                if (sign_new != sign)
                {
                    return(ResultResponse.ExceptionResult("参数被篡改"));
                }
                string tokenStr = AES.Decode(token);

                var dic = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(tokenStr);

                if (dic == null || dic.Count() == 0)
                {
                    return(ResultResponse.ExceptionResult("交换token失败"));
                }
                int             fk_id          = dic.ToInt("fk_id", 0);
                int             db_id          = dic.ToInt("db_id", 0);
                IResultResponse resultResponse = new ConnectorBusiness(para.dapperFactory).ExchangeToken(fk_id, db_id);
                if (resultResponse.Success)
                {
                    return(resultResponse);
                }
                else
                {
                    string domain = dic.ToValue("domain");
                    string msg    = string.Empty;
                    resultResponse = ApiRequest.GetResponse(domain, "account.base.info", new Dictionary <string, string>()
                    {
                        { "exchange_token", HttpUtility.UrlEncode(token) },
                        { "exhange_sign", sign },
                    });
                    if (resultResponse.Success)
                    {
                        Dictionary <string, object> dic_content = resultResponse.Content as Dictionary <string, object>;
                        resultResponse = new ConnectorBusiness(para.dapperFactory).Join(dic_content);
                        if (!resultResponse.Success)
                        {
                            return(resultResponse);
                        }

                        resultResponse = new ConnectorBusiness(para.dapperFactory).ExchangeToken(fk_id, db_id);
                    }
                }
                return(resultResponse);
            }
            catch (Exception ex)
            {
                return(ResultResponse.ExceptionResult(ex, 500));
            }
        }
Exemplo n.º 14
0
Arquivo: Order.cs Projeto: tynr426/ict
        /// <summary>
        /// 代下单中转
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static IResultResponse OrderSubmit(SysParameter para)
        {
            try
            {
                int             sellerId     = para.ToInt("FKId");
                int             dbId         = para.ToInt("DBId");
                string          orderInfo    = para.ToValue("Order");
                int             orderId      = para.ToInt("OrderId");
                string          oddNumber    = para.ToValue("OddNumber");
                decimal         downPayables = para.ToDecimal("Payables");
                IResultResponse result       = null;
                if (String.IsNullOrEmpty(orderInfo) && sellerId != 0)
                {
                    return(ResultResponse.ExceptionResult("订单信息为空"));
                }
                RelationMappingEntity relationMappingEntity = new ProductRelationBusiness(para.dapperFactory).GetUpMappingEntity(sellerId, dbId);
                if (relationMappingEntity.GoodsMapping.Count == 0)
                {
                    return(ResultResponse.ExceptionResult("没有找到商品映射关系"));
                }
                //替换供应商ids
                orderInfo = ReplaceIds(relationMappingEntity.ConnectorMapping, orderInfo, "SupplierIds");
                orderInfo = ReplaceIds(relationMappingEntity.ConnectorMapping, orderInfo, "SupplierId");
                //替换商品ids
                orderInfo = ReplaceIds(relationMappingEntity.ProductMapping, orderInfo, "ProductIds");
                //替换productinfo里面的
                orderInfo = ReplaceIds(relationMappingEntity.ProductMapping, orderInfo, "ProductId");
                orderInfo = ReplaceIds(relationMappingEntity.GoodsMapping, orderInfo, "GoodsId");

                //发送
                result = ApiRequest.GetResponse(relationMappingEntity.ConnectorEntity.Domain, "order.dropshipping.submit", new Dictionary <string, string>()
                {
                    { "StoreId", relationMappingEntity.ConnectorEntity.UpBuyerId.ToString() },
                    { "Order", orderInfo }
                });
                if (result.Success)
                {
                    //入库
                    var orderDic = result.Content as Dictionary <string, object>;
                    if (orderDic != null)
                    {
                        new OrderRelationBusiness(para.dapperFactory).Insert(orderId, oddNumber, downPayables, relationMappingEntity.ConnectorEntity, orderDic);
                    }
                    return(ResultResponse.GetSuccessResult(orderId));
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                return(ResultResponse.ExceptionResult(ex, 500));
            }
        }
Exemplo n.º 15
0
        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));
        }
Exemplo n.º 16
0
        public IResultResponse search(int connectorId, string mobile)
        {
            if (connectorId == 0 || string.IsNullOrWhiteSpace(mobile))
            {
                return(ResultResponse.ExceptionResult("数据有误"));
            }
            string    sql = string.Format("select a.*,b.ImageDomain from {0} a inner join {1} b on a.GroupId=b.Id where a.Mobile='{2}' and a.Id<>{3}", TableName, GroupBusiness._TableName, mobile, connectorId);
            DataTable dt  = DbAccess.GetDataTable(sql);

            return(ResultResponse.GetSuccessResult(dt.ToJson()));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 推送克隆命令
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public static IResultResponse PushCloneCommand(SysParameter para)
        {
            IResultResponse resultResponse = OpsUtil.VerifyAccessToken(para);

            if (!resultResponse.Success)
            {
                return(resultResponse);
            }

            Sdk.AccessToken accessToken = resultResponse.Content as Sdk.AccessToken;
            if (accessToken.UpConnectorId == 0)
            {
                return(ResultResponse.ExceptionResult("上下游关系没生效,请重新登录!"));
            }
            try
            {
                string key = accessToken.Id + "_" + accessToken.UpConnectorId;

                if (!IsSendCmd(key))
                {
                    return(ResultResponse.ExceptionResult("三分钟之内发送次过多"));
                }
                //克隆权限
                var cloneAuthority = new ProductRelationBusiness(para.dapperFactory).CloneAuthority(accessToken.Id, accessToken.UpConnectorId);
                if (!cloneAuthority)
                {
                    return(ResultResponse.ExceptionResult("你已经克隆过了!"));
                }
                long re = DistributePubSub.RedisPub("product_clone", new Dictionary <string, int>()
                {
                    { "upId", accessToken.UpConnectorId },
                    { "downId", accessToken.Id },
                });
                //bool sendCmd = WebSocketClient.SendCommand("Clone", "data.clone.push.command", new object[] { accessToken.Id, accessToken.UpConnectorId }, true);
                if (re == -1)
                {
                    return(ResultResponse.ExceptionResult("命令已发送失败!"));
                }

                //插入发送记录
                new CloneResultBusiness(para.dapperFactory).Insert(accessToken);

                //设置发送时间
                SetSendCmd(key);

                return(ResultResponse.GetSuccessResult("命令已发送成功,请稍后!"));
            }
            catch (Exception ex)
            {
                new Exceptions(ex, "clone");
                return(ResultResponse.ExceptionResult(ex.Message));
            }
        }
Exemplo n.º 18
0
 public static IResultResponse Update(SysParameter para)
 {
     try
     {
         int result = new AccountBusiness(para.dapperFactory).Update(para.Properties);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 19
0
 public static IResultResponse Get(SysParameter para)
 {
     try
     {
         PagingQuery  query  = para.ToPagingQuery();
         PagingResult result = new AccountBusiness(para.dapperFactory).GetList(query);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 20
0
Arquivo: Order.cs Projeto: tynr426/ict
 public static IResultResponse GetOrderInfo(SysParameter para)
 {
     try
     {
         int    connectorId = para.ToInt("ConnectorId");
         string oddNumber   = para.ToValue("OddNumber");
         return(new OrderRelationBusiness(para.dapperFactory).GetOrderInfo(connectorId, oddNumber));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 21
0
        public static IResultResponse CheckDownConnector(SysParameter para)
        {
            string mobile        = para.ToValue("Mobile");
            int    upConnectorId = para.ToInt("UpConnectorId", 0);

            if (string.IsNullOrWhiteSpace(mobile))
            {
                return(ResultResponse.ExceptionResult("请输入正确手机号"));
            }
            IResultResponse result = new RelationBusiness(para.dapperFactory).CheckDownConnector(mobile, upConnectorId);

            return(result);
        }
Exemplo n.º 22
0
 public static IResultResponse Delete(SysParameter para)
 {
     try
     {
         int id     = para.ToInt("Id");
         int result = new ConnectorBusiness(para.dapperFactory).Delete(id);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 23
0
        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("添加合作商失败"));
        }
Exemplo n.º 24
0
 public static IResultResponse DeleteUnauthorized(SysParameter para)
 {
     try
     {
         string authProductIds = para.ToValue("AuthProductIds");
         int    connectorId    = para.ToInt("ConnectorId", 0);
         int    result         = new AuthProductBusiness(para.dapperFactory).Delete(authProductIds, connectorId);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 25
0
 public static IResultResponse GetList(SysParameter para)
 {
     try
     {
         string          mobile      = para.ToValue("Mobile");
         int             connectorId = para.ToInt("ConnectorId", 0);
         IResultResponse result      = new ConnectorBusiness(para.dapperFactory).search(connectorId, mobile);
         return(result);
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 26
0
 public static IResultResponse DownConnectorStock(SysParameter para)
 {
     try
     {
         PagingQuery  query       = para.ToPagingQuery();
         int          connectorId = para.ToInt("ConnectorId", 0);
         PagingResult result      = new ConnectorBusiness(para.dapperFactory).DownConnectorStock(connectorId, query);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 27
0
 public static IResultResponse GetUpProductList(SysParameter para)
 {
     try
     {
         PagingQuery  query       = para.ToPagingQuery();
         int          connectorId = para.ToInt("ConnectorId", 0);
         PagingResult result      = new AuthProductBusiness(para.dapperFactory).UpConnectorAuthList(query, connectorId);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 28
0
 public static IResultResponse AddAuth(SysParameter para)
 {
     try
     {
         int    connectorId = para.ToInt("ConnectorId", 0);
         string ids         = para.ToValue("CategoryIds");
         int    result      = new AuthCategoryBusiness(para.dapperFactory).Insert(connectorId, ids);
         return(ResultResponse.GetSuccessResult(result));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 29
0
 public static IResultResponse ImportProduct(SysParameter para)
 {
     try
     {
         int connectorId   = para.ToInt("ConnectorId");
         int productId     = para.ToInt("ProductId");
         int upConnectorId = para.ToInt("UpConnectorId");
         return(new ProductRelationBusiness(para.dapperFactory).ImportProduct(connectorId, upConnectorId, productId));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }
Exemplo n.º 30
0
 public static IResultResponse AddDownRelation(SysParameter para)
 {
     try
     {
         //string mobile = para.ToValue("Mobile");
         int connectorId     = para.ToInt("ConnectorId");
         int downConnectorId = para.ToInt("DownConnectorId");
         return(new RelationBusiness(para.dapperFactory).InsertDownConnectorRelation(downConnectorId, connectorId));
     }
     catch (Exception ex)
     {
         return(ResultResponse.ExceptionResult(ex, 500));
     }
 }