Exemplo n.º 1
0
    /// <summary>
    /// 查看是否启用微信支付或者支付宝支付
    /// </summary>
    public ResultPayInfo GetPayInfo(string JSon, string version)
    {
        string    disID           = string.Empty;
        string    UserID          = string.Empty;
        string    OrderType       = string.Empty;
        string    ReceiptNo       = string.Empty;
        string    PayPrice        = string.Empty;
        string    PayIDJSon       = string.Empty;
        string    partner         = string.Empty;
        string    seller          = string.Empty;
        string    private_key     = string.Empty;
        string    subject         = string.Empty; //提示内容
        string    GoodsName       = string.Empty; //订单所有商品的名称
        string    OrderNumberJSon = string.Empty; //订单支付流水号的json
        string    OrderNumber     = string.Empty; //订单支付流水号
        string    orderInfo       = string.Empty; //订单信息
        string    OrderCode       = string.Empty; //企业订单号
        DataTable dt_order        = null;


        Hi.BLL.BD_Distributor bll_dis   = new Hi.BLL.BD_Distributor();
        Hi.BLL.BD_Company     bll_comp  = new Hi.BLL.BD_Company();
        Hi.BLL.DIS_Order      bll_order = new Hi.BLL.DIS_Order();
        ResultPayInfo         payinfo   = new ResultPayInfo();
        Common comm = new Common();

        try
        {
            #region//JSon取值
            JsonData JInfo = null;
            JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString().Trim() != "" && JInfo["ResellerID"].ToString().Trim() != "" && JInfo["OrderType"].ToString().Trim() != "" &&
                JInfo["PayPrice"].ToString().Trim() != "" && JInfo["PayIDJson"].ToString().Trim() != "")
            {
                UserID = JInfo["UserID"].ToString();

                disID     = JInfo["ResellerID"].ToString();
                OrderType = JInfo["OrderType"].ToString();
                PayPrice  = JInfo["PayPrice"].ToString();
                PayIDJSon = JInfo["PayIDJson"].ToString();
            }
            else
            {
                return(new ResultPayInfo()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            if (OrderType == "0")
            {
                if (JInfo["ReceiptNo"].ToString().Trim() != "")
                {
                    ReceiptNo = JInfo["ReceiptNo"].ToString();
                }
                else
                {
                    return(new ResultPayInfo()
                    {
                        Result = "F", Description = "参数异常"
                    });
                }
            }
            #endregion

            //判断登录信息是否正确
            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out user, 0, int.Parse(disID == "" ? "0" : disID)))
            {
                return new ResultPayInfo()
                       {
                           Result = "F", Description = "用户异常"
                       }
            }
            ;
            //判断经销商信息是否异常
            Hi.Model.BD_Distributor dis = bll_dis.GetModel(Convert.ToInt32(disID));
            if (dis == null || dis.dr == 1 || dis.AuditState == 0 || dis.IsEnabled == 0)
            {
                return new ResultPayInfo()
                       {
                           Result = "F", Description = "经销商异常"
                       }
            }
            ;
            //判断经销商对应的核心企业是否异常
            Hi.Model.BD_Company comp = bll_comp.GetModel(dis.CompID);
            if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0)
            {
                return new ResultPayInfo()
                       {
                           Result = "F", Description = "核心企业异常"
                       }
            }
            ;
            //判断此订单的信息是否异常,是否可支付
            //根据订单号,取出订单数据放入dt中
            if (OrderType == "0")
            {
                dt_order = bll_order.GetData(ReceiptNo).Tables[0];

                if (Convert.ToInt32(dt_order.Rows[0]["OState"]) == (int)Enums.OrderState.待审核 ||
                    Convert.ToInt32(dt_order.Rows[0]["OState"]) == (int)Enums.OrderState.已作废 ||
                    Convert.ToInt32(dt_order.Rows[0]["PayState"]) == (int)Enums.PayState.已支付)
                {
                    return new ResultPayInfo()
                           {
                               Result = "F", Description = "订单信息异常"
                           }
                }
                ;
            }

            //获取Pay_PayWxandAli表的实体
            Hi.Model.Pay_PayWxandAli payali = Common.GetPayWxandAli(comp.ID);
            if (payali == null || ClsSystem.gnvl(payali.ali_isno, "0") == "0")
            {
                return new ResultPayInfo()
                       {
                           Result = "F", Description = "核心企业无可用的支付宝收款账户"
                       }
            }
            ;
            //对数据库中数据进行解密
            //partner = Common.DesDecrypt(payali.ali_partner, Common.EncryptKey);
            //seller = Common.DesDecrypt(payali.ali_seller_email, Common.EncryptKey);
            //private_key = Common.DesDecrypt(payali.ali_key, Common.EncryptKey);
            partner     = payali.ali_partner;
            seller      = payali.ali_seller_email;
            private_key = payali.ali_RSAkey;
            //订单支付跟预付款充值的提示信息(两种请款下的提示信息是不同的)
            if (OrderType == "0")
            {
                subject = "医站通订单-" + ReceiptNo;
            }
            else
            {
                subject = "医站通预付款充值";
            }
            //订单所有商品明细

            if (OrderType == "0")
            {
                DataTable l = new Hi.BLL.DIS_OrderDetail().GetOrderDe("", " IsNUll(o.dr,0)=0 and o.OrderId=" + Convert.ToInt32(dt_order.Rows[0]["ID"]));
                foreach (DataRow dr in l.Rows)
                {
                    GoodsName += dr["GoodsName"] + ",";
                }
                GoodsName = GoodsName.Substring(0, GoodsName.Length - 1);//去掉最后一个逗号
                if (GoodsName.Length > 15)
                {
                    GoodsName = GoodsName.Substring(0, 10) + "...";
                }
            }

            //获取订单支付时的支付流水号
            if (OrderType == "0")
            {
                OrderNumberJSon = new OrderPay().GetPayID(PayIDJSon);
                //解析返回的订单支付流水号的JSon
                JInfo = JsonMapper.ToObject(OrderNumberJSon);
                if (JInfo["Result"].ToString().Trim() == "F" || JInfo["PayNumb"].ToString().Trim() == "" || JInfo["Result"].ToString().Trim() == "" ||
                    JInfo["OrderCode"].ToString().Trim() == "")
                {
                    return(new ResultPayInfo()
                    {
                        Result = "F", Description = "获取支付流水号异常"
                    });
                }
                else
                {
                    OrderNumber = JInfo["PayNumb"].ToString();
                    OrderCode   = JInfo["OrderCode"].ToString();
                }
            }
            else//钱包充值时的流水号跟企业订单号
            {
                List <string> list = new List <string>();
                list        = Getpayidyfk(user.ID, comp.ID, dis.ID, PayPrice);
                OrderNumber = list[0];
                OrderCode   = list[1];
                if (OrderNumber == "" || OrderCode == "")
                {
                    return new ResultPayInfo()
                           {
                               Result = "F", Description = "获取支付流水号异常"
                           }
                }
                ;
            }
            //创建订单信息
            orderInfo = comm.getOrderInfo(subject, GoodsName, PayPrice, OrderNumber, partner, seller);
            // 对订单做RSA 签名
            //private_key = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANDptrV3pWWdbnr6wT8lPkZ6kbRgsjf8CfXpQNrJyOsmktOaX8DQRh5nd0lSFTtbfeGV4oWXi26bv+1Vt+CfAsYssf+futRj0l6Cxx0psJapK7QEXq3HqjB0tM11M9ym75WFFvTSZs1DysUkRV35g5rXuRtBOWR2sqm9JRAen+29AgMBAAECgYEAzZ+L1xb5c4e960uOE1Hb9tDDQs/9+j6XqzQ3QmFj4Zeo4p9KaeRVb62U6lThUvgdcYDuYWEkuuyPvtEk1/CKb61AvEW69ehwLeDXOy9AzEgQpGFPb1bgJ+kU8YCpgcOGR9G55iVc0ZW7B2iyx111Wvij8pc+A2ZeuByAG1f8PoECQQD7wvCyBJRNb7Gv7iHF+zx2lDxG6LTX2rCAZdr8FyWVjZEBfL6uPI+/2J2AqtFPaLa25+jQc3b74r4wuGKsvxBhAkEA1G4aDQovfB9RO/c4I+NX4mmitpNt66IuqKp0a9pOL/YfpNtr5GBgmK4LMVASqIG74bw5wAV7zJkunlGGPusK3QJBALLiUm/KvS1AXbqpsymfV9jRfvrLQiPVaW/x72ULdVMMIaoy3rGiqmkgGtlfhhWsS5cutMfYIwTamVS4zrP7lkECQFTvDJVoHCI5d0ZNivG2ZR4OdFMhURKkTpl7RX8V0qsUcgR9An9WFWkWNT1rMXqUHGWd100yJBRirqP4Hn+rhDUCQBPVgm4jNd5WjKD0Oj39FmF5D89OviTgQK4xYxYUIfqLBhuGZ3kWDvAmeE6uRgVXjQncv/c68W8pS2huT0syom4=";
            //private_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB";
            string sign = Com.Alipay.RSAFromPkcs8.sign(orderInfo, private_key, "utf-8");
            //string sign = RSAFromPkcs8.sign(orderInfo, private_key, "utf-8");
            sign = HttpUtility.UrlEncode(sign, Encoding.UTF8);
            //返回实体
            // 完整的符合支付宝参数规范的订单信息
            payinfo.Result      = "T";
            payinfo.Description = "返回成功";
            payinfo.InfoString  = orderInfo + "&sign=\"" + sign + "\"&"
                                  + comm.getSignType();
            payinfo.OrderCode = OrderCode;
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetPayInfo:" + JSon);
            return(new ResultPayInfo()
            {
                Result = "F", Description = "参数异常"
            });
        }
        return(payinfo);
    }
Exemplo n.º 2
0
    public ResultWX Result_WX(string JSon, string version)
    {
        string disID  = string.Empty;
        string UserID = string.Empty;

        Hi.BLL.BD_Distributor bll_dis  = new Hi.BLL.BD_Distributor();
        Hi.BLL.BD_Company     bll_comp = new Hi.BLL.BD_Company();
        ResultWX result = new ResultWX();
        string   appid  = string.Empty;
        string   mchid  = string.Empty;
        string   key    = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString().Trim() != "" && JInfo["ResellerID"].ToString().Trim() != "")
            {
                disID  = JInfo["ResellerID"].ToString();
                UserID = JInfo["UserID"].ToString();
            }
            else
            {
                return(new ResultWX()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            #endregion
            //判断登录信息是否正确
            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out user, 0, int.Parse(disID == "" ? "0" : disID)))
            {
                return new ResultWX()
                       {
                           Result = "F", Description = "用户异常"
                       }
            }
            ;
            //判断经销商信息是否异常
            Hi.Model.BD_Distributor dis = bll_dis.GetModel(Convert.ToInt32(disID));
            if (dis == null || dis.dr == 1 || dis.AuditState == 0 || dis.IsEnabled == 0)
            {
                return new ResultWX()
                       {
                           Result = "F", Description = "经销商异常"
                       }
            }
            ;
            //判断经销商对应的核心企业是否异常
            Hi.Model.BD_Company comp = bll_comp.GetModel(dis.CompID);
            if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0)
            {
                return new ResultWX()
                       {
                           Result = "F", Description = "核心企业异常"
                       }
            }
            ;
            //获取Pay_PayWxandAli表的实体
            Hi.Model.Pay_PayWxandAli paywx = Common.GetPayWxandAli(comp.ID);
            if (paywx == null || ClsSystem.gnvl(paywx.wx_Isno, "0") == "0")
            {
                return new ResultWX()
                       {
                           Result = "F", Description = "核心企业无可用的微信收款账户"
                       }
            }
            ;
            #region //返回参数
            result.Result      = "T";
            result.Description = "返回成功";
            //对数据库中取出的值进行解密
            appid = Common.DesDecrypt(paywx.wx_appid, Common.EncryptKey);
            mchid = Common.DesDecrypt(paywx.wx_mchid, Common.EncryptKey);
            key   = Common.DesDecrypt(paywx.wx_key, Common.EncryptKey);
            //对解密过的字段,用我们这边的方法重新加密
            appid = AESHelper.Encrpt_string(appid);
            mchid = AESHelper.Encrpt_string(mchid);
            key   = AESHelper.Encrpt_string(key);
            //将加密完的值赋给返回实体
            result.AppID = appid;
            result.Mchid = mchid;
            //result.AppSecret = paywx.wx_appsechet;
            result.APPkey = key;

            #endregion
            //return result;
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "Result_WX:" + JSon);
            return(new ResultWX()
            {
                Result = "F", Description = "参数异常"
            });
        }
        return(result);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 返回选择的代理商
    /// </summary>
    /// <param name="l"></param>
    private void AddMaterial(List <Hi.Model.BD_Distributor> dbutorList)
    {
        if (dbutorList.Count > 0)
        {
            DataTable dt = null;

            foreach (var item in dbutorList)
            {
                if (ViewState["Distributor"] == null)
                {
                    dt = new DataTable();
                    dt.Columns.Add("ID", typeof(string));
                    dt.Columns.Add("DisName", typeof(string));
                    dt.Columns.Add("DisCode", typeof(string));
                    dt.Columns.Add("DisLevel", typeof(string));
                    dt.Columns.Add("Address", typeof(string));
                    dt.Columns.Add("Principal", typeof(string));
                    dt.Columns.Add("AreaID", typeof(int));//区域

                    DataRow dr1 = dt.NewRow();
                    dr1["Id"] = item.ID;
                    Hi.Model.BD_Distributor dbutorModel = BDdbutorbll.GetModel(item.ID);
                    if (dbutorModel != null)
                    {
                        dr1["DisName"]   = dbutorModel.DisName;
                        dr1["DisCode"]   = dbutorModel.DisCode;
                        dr1["DisLevel"]  = dbutorModel.DisLevel;
                        dr1["Address"]   = dbutorModel.Address;
                        dr1["Principal"] = dbutorModel.Principal;
                        dr1["AreaID"]    = dbutorModel.AreaID;
                    }

                    dt.Rows.Add(dr1);
                }
                else
                {
                    dt = ViewState["Distributor"] as DataTable;
                    DataRow dr2 = dt.NewRow();
                    dr2["Id"] = item.ID;
                    Hi.Model.BD_Distributor dbutorModel = BDdbutorbll.GetModel(item.ID);
                    if (dbutorModel != null)
                    {
                        dr2["DisName"]   = dbutorModel.DisName;
                        dr2["DisCode"]   = dbutorModel.DisCode;
                        dr2["DisLevel"]  = dbutorModel.DisLevel;
                        dr2["Address"]   = dbutorModel.Address;
                        dr2["Principal"] = dbutorModel.Principal;
                        dr2["AreaID"]    = dbutorModel.AreaID;
                    }
                    dt.Rows.Add(dr2);
                }
                ViewState["Distributor"] = dt;
            }

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    dt.DefaultView.Sort = "ID desc"; //dt排序
                }
            }

            this.gvDtl.DataSource = dt;
            this.gvDtl.DataBind();
        }
    }
Exemplo n.º 4
0
    public ResultAli Result_Ali(string JSon, string version)
    {
        string disID  = string.Empty;
        string UserID = string.Empty;

        Hi.BLL.BD_Distributor bll_dis  = new Hi.BLL.BD_Distributor();
        Hi.BLL.BD_Company     bll_comp = new Hi.BLL.BD_Company();
        ResultAli             result   = new ResultAli();
        string partner     = string.Empty;
        string seller      = string.Empty;
        string private_key = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString().Trim() != "" && JInfo["ResellerID"].ToString().Trim() != "")
            {
                disID = JInfo["ResellerID"].ToString();

                UserID = JInfo["UserID"].ToString();
            }
            else
            {
                return(new ResultAli()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            #endregion
            //判断登录信息是否正确
            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out user, 0, int.Parse(disID == "" ? "0" : disID)))
            {
                return new ResultAli()
                       {
                           Result = "F", Description = "用户异常"
                       }
            }
            ;
            //判断经销商信息是否异常
            Hi.Model.BD_Distributor dis = bll_dis.GetModel(Convert.ToInt32(disID));
            if (dis == null || dis.dr == 1 || dis.AuditState == 0 || dis.IsEnabled == 0)
            {
                return new ResultAli()
                       {
                           Result = "F", Description = "经销商异常"
                       }
            }
            ;
            //判断经销商对应的核心企业是否异常
            Hi.Model.BD_Company comp = bll_comp.GetModel(dis.CompID);
            if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0)
            {
                return new ResultAli()
                       {
                           Result = "F", Description = "核心企业异常"
                       }
            }
            ;
            //获取Pay_PayWxandAli表的实体
            Hi.Model.Pay_PayWxandAli payali = Common.GetPayWxandAli(comp.ID);
            if (payali == null || ClsSystem.gnvl(payali.ali_isno, "0") == "0")
            {
                return new ResultAli()
                       {
                           Result = "F", Description = "核心企业无可用的支付宝收款账户"
                       }
            }
            ;
            #region //返回参数

            result.Result      = "T";
            result.Description = "返回成功";
            //对数据库中数据进行解密
            partner     = Common.DesDecrypt(payali.ali_partner, Common.EncryptKey);
            seller      = Common.DesDecrypt(payali.ali_seller_email, Common.EncryptKey);
            private_key = Common.DesDecrypt(payali.ali_key, Common.EncryptKey);
            //对解密过的数据,再用我们的加密方法进行加密
            partner     = AESHelper.Encrpt_string(partner);
            seller      = AESHelper.Encrpt_string(seller);
            private_key = AESHelper.Encrpt_string(private_key);
            //将我们这边加密完的数据,赋值给返回实体
            result.PARTNER     = partner;
            result.SELLER      = seller;
            result.RSA_PRIVATE = private_key;
            #endregion
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "Result_Ali:" + JSon);
            return(new ResultAli()
            {
                Result = "F", Description = "参数异常"
            });
        }
        return(result);
    }
Exemplo n.º 5
0
    /// <summary>
    ///核心企业修改经销商信息
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ReseltResellerEdit EditReseller(string JSon)
    {
        string UserID = string.Empty;
        string CompID = string.Empty;
        string DisID  = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompID"].ToString().Trim() == "" || JInfo["Reseller"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;
            UserID = JInfo["UserID"].ToString();
            CompID = JInfo["CompID"].ToString();
            JsonData Reseller = JInfo["Reseller"];
            //判断登录信息是否异常
            Hi.Model.SYS_Users one = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out one, Int32.Parse(CompID)))
            {
                return(new ReseltResellerEdit()
                {
                    Result = "F", Description = "登录信息异常"
                });
            }
            //判断核心企业信息是否异常
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Int32.Parse(CompID));
            if (comp == null || comp.dr == 1 || comp.IsEnabled == 0 || comp.AuditState == 0)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "核心企业信息异常"
                       }
            }
            ;
            #endregion
            //判断经销商信息是否正常
            DisID = Reseller["ResellerID"].ToString();
            Hi.BLL.BD_Distributor   bll_dis = new Hi.BLL.BD_Distributor();
            Hi.Model.BD_Distributor dis     = bll_dis.GetModel(Int32.Parse(DisID));
            if (dis == null)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商信息异常"
                       }
            }
            ;
            if (dis.dr == 1)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商已被删除"
                       }
            }
            ;
            if (Reseller["ts"].ToString() != dis.ts.ToString())
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商信息已被他人修改,请稍后再试"
                       }
            }
            ;
            string resellername = Common.NoHTML(Reseller["ResellerName"].ToString().Trim());
            string resellercode = Common.NoHTML(Reseller["ResellerCode"].ToString().Trim());
            string address      = Common.NoHTML(Reseller["Address"].ToString().Trim());
            //判断经销商修改的必填项
            if (resellername == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商名称"
                       }
            }
            ;
            //判断经销商名字是否已存在
            //if (Common.DisExistsAttribute("DisName", Reseller["ResellerName"].ToString(), CompID.ToString()))
            //List<Hi.Model.BD_Distributor> list_dis = bll_dis.GetList("", "DisName = '" + resellername + "' and ID <> " + dis.ID + "", "");
            //if(list_dis!=null&&list_dis.Count>0)
            if (Common.DisExistsAttribute("DisName", resellername, CompID.ToString(), dis.ID.ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商名称已经存在"
                       }
            }
            ;
            if (Reseller["ResellerProvince"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的省"
                       }
            }
            ;
            if (Reseller["ResellerCity"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的市"
                       }
            }
            ;
            if (Reseller["ResellerArea"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的区"
                       }
            }
            ;
            if (address == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商地址中的详细地址"
                       }
            }
            ;
            //修改经销商信息
            dis.ts         = DateTime.Now;
            dis.modifyuser = one.ID;
            dis.DisCode    = resellercode;
            dis.DisName    = resellername;
            //Int32 classifyid= Reseller["ResellerClassifyID"].ToString().Trim() == "" ? 0 : Int32.Parse(Reseller["ResellerClassifyID"].ToString().Trim());
            //传入分类ID的话,判断分类ID是否正确
            if (Reseller["ResellerClassifyID"].ToString().Trim() != "" && Reseller["ResellerClassifyID"].ToString() != "0")
            {
                Hi.Model.BD_DisType distpye = new Hi.BLL.BD_DisType().GetModel(Int32.Parse(Reseller["ResellerClassifyID"].ToString().Trim()));

                if (distpye == null || distpye.CompID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商分类异常"
                           }
                }
                ;
                if (distpye.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商分类已被删除"
                           }
                }
                ;
                //if (distpye.IsEnabled !=0)
                //    return new ReseltResellerEdit() { Result = "F", Description = "此经销商分类已被禁用" };

                dis.DisTypeID = distpye.ID;
            }
            else
            {
                dis.DisTypeID = 0;
            }
            //dis.AreaID = Reseller["AreaID"].ToString().Trim() == "" ? 0 : Int32.Parse(Reseller["AreaID"].ToString().Trim());
            //传入区域ID的话,判断区域ID是否正确
            if (Reseller["AreaID"].ToString().Trim() != "" && Reseller["AreaID"].ToString() != "0")
            {
                Hi.Model.BD_DisArea disarea = new Hi.BLL.BD_DisArea().GetModel(Int32.Parse(Reseller["AreaID"].ToString().Trim()));
                if (disarea == null || disarea.CompanyID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商区域异常"
                           }
                }
                ;
                if (disarea.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商区域已被删除"
                           }
                }
                ;
                dis.AreaID = disarea.ID;
            }
            else
            {
                dis.AreaID = 0;
            }
            dis.Province = Reseller["ResellerProvince"].ToString();
            dis.City     = Reseller["ResellerCity"].ToString();
            dis.Area     = Reseller["ResellerArea"].ToString();
            dis.Address  = address;
            dis.Zip      = Common.NoHTML(Reseller["Zip"].ToString());
            dis.Tel      = Common.NoHTML(Reseller["Tel"].ToString());
            dis.Fax      = Common.NoHTML(Reseller["Fax"].ToString());
            string principal = Common.NoHTML(Reseller["Principal"].ToString().Trim());
            string phone     = Common.NoHTML(Reseller["Phone"].ToString().Trim());
            //如果联系人或联系人手机没输入,需要将登陆信息的联系人或手机号,赋值给联系人或手机
            if (principal == "" || phone == "")
            {
                //先获取sys_compuser表中disid对应的数据,一对一关系
                List <Hi.Model.SYS_CompUser> compuser = new Hi.BLL.SYS_CompUser().GetList("UserID",
                                                                                          "DisID=" + dis.ID + " and UType = 5 and isnull(dr,0)=0 and isnull(IsEnabled,0)=1 and isnull(IsAudit,0)=2", "");
                //通过Userid获取sys_users表数据
                Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(compuser[0].ID);
                if (user != null && user.AuditState == 2 && user.IsEnabled == 1 && user.dr == 0)
                {
                    //需要判断到底是传入的联系人为空,还是手机为空
                    if (principal == "")
                    {
                        dis.Principal = user.TrueName;
                    }
                    else
                    {
                        dis.Principal = principal;
                    }
                    if (phone == "")
                    {
                        dis.Phone = user.Phone;
                    }
                    else
                    {
                        dis.Phone = phone;
                    }
                }
            }
            else
            {
                dis.Principal = principal;
                dis.Phone     = phone;
            }
            //更新数据库
            if (bll_dis.Update(dis))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "T", Description = "修改成功"
                       }
            }
            ;
            else
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "修改失败"
                       }
            };
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "EditReseller:" + JSon);
            return(new ReseltResellerEdit()
            {
                Result = "F", Description = "修改失败"
            });
        }
    }