Beispiel #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);
    }
Beispiel #2
0
    /// <summary>
    /// 获取企业产品分类列表
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ResultGoodsCategory GetResellerProductClassifyList(string JSon)
    {
        try
        {
            string   userID    = string.Empty;
            string   disID     = string.Empty;
            string   companyID = string.Empty; //绑定的企业ID(目前只绑定一家,默认传入0)
            JsonData JInfo     = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" &&
                JInfo["CompanyID"].ToString() != "")
            {
                userID    = JInfo["UserID"].ToString();
                disID     = JInfo["ResellerID"].ToString();
                companyID = JInfo["CompanyID"].ToString();
            }
            else
            {
                return(new ResultGoodsCategory()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(userID), out user, int.Parse(companyID), int.Parse(disID == "" ? "0" : disID)))
            {
                return new ResultGoodsCategory()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;

            Hi.Model.BD_Company comp = new Hi.Model.BD_Company();
            if (companyID.Trim() == "0")//经销商分类:compID传0
            {
                Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(int.Parse(disID.Trim()));

                if (dis == null || dis.dr == 1 || dis.IsEnabled == 0)
                {
                    return new ResultGoodsCategory()
                           {
                               Result = "F", Description = "经销商信息异常"
                           }
                }
                ;
                comp = new Hi.BLL.BD_Company().GetModel(dis.CompID);
            }
            else //企业分类
            {
                comp = new Hi.BLL.BD_Company().GetModel(int.Parse(companyID.Trim()));
            }
            if (comp == null || comp.dr == 1 || comp.IsEnabled == 0)
            {
                return new ResultGoodsCategory()
                       {
                           Result = "T", Description = "企业异常"
                       }
            }
            ;



            string strsql = "select GoodsTypeID as ClassifyID, CategoryCode as ClassifyCode,CategoryName as ClassifyName,";
            strsql = strsql + "ParentID,SortIndex from BD_GoodsCategory ";
            strsql = strsql + "where CompID='" + comp.ID + "' and ISNULL(dr,0)=0 and IsEnabled = 1 ";
            DataTable dt = SqlAccess.ExecuteSqlDataTable(strsql, ConfigurationSettings.AppSettings["ConnectionString"].ToString());


            List <ProductClassify> pList = new List <ProductClassify>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ProductClassify pClassifies = new ProductClassify();
                pClassifies.ClassifyID   = ClsSystem.gnvl(dt.Rows[i]["ClassifyID"], "");
                pClassifies.ClassifyName = ClsSystem.gnvl(dt.Rows[i]["ClassifyName"], "");
                pClassifies.ParentID     = ClsSystem.gnvl(dt.Rows[i]["ParentID"], "");
                pClassifies.SortIndex    = ClsSystem.gnvl(dt.Rows[i]["SortIndex"], "");
                pList.Add(pClassifies);
            }

            ProductClassify classifies = new ProductClassify();
            classifies.ClassifyID   = "-1";
            classifies.ClassifyName = "全部分类";
            classifies.ParentID     = "0";
            classifies.SortIndex    = "0";
            pList.Add(classifies);

            return(new ResultGoodsCategory()
            {
                Result = "T",
                Description = "获取成功",
                CompanyID = comp.ID.ToString(),
                CompanyName = comp.CompName,
                ProductClassifyList = pList
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetResellerProductClassifyList :" + JSon);
            return(new ResultGoodsCategory()
            {
                Result = "F", Description = "异常"
            });
        }
    }
Beispiel #3
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);
    }
Beispiel #4
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);
    }
Beispiel #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.BD_Company model)
 {
     return(dal.Update(model));
 }
Beispiel #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_Company model)
 {
     return(dal.Add(model));
 }
Beispiel #7
0
    public string billys    = string.Empty; //本月账单应收

    /// <summary>
    /// 企业统计数据
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ResultJSC GetCompNum(string JSon)
    {
        try
        {
            #region JSon取值

            string UserID = string.Empty;
            string CompID = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["CompID"].ToString() != "")
            {
                UserID = JInfo["UserID"].ToString();
                CompID = JInfo["CompID"].ToString();
            }
            else
            {
                return(new ResultJSC()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            if (!new Common().IsLegitUser(int.Parse(UserID), out user, int.Parse(CompID)))
            {
                return new ResultJSC()
                       {
                           Result = "F", Description = "未找到用户信息"
                       }
            }
            ;

            comp = new Hi.BLL.BD_Company().GetModel(Convert.ToInt32(CompID));
            if (comp == null)
            {
                return new ResultJSC()
                       {
                           Result = "F", Description = "未找到企业信息"
                       }
            }
            ;


            #endregion

            //获取当前时间
            DateTime date = DateTime.Now;
            //当天的0点0分
            DateTime day0 = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
            //当月第一天
            DateTime day1 = new DateTime(date.Year, date.Month, 1);
            //获取当前时间加一天
            DateTime Sday = date.AddDays(1);

            #region 销售订单

            //销售订单
            List <Hi.Model.DIS_Order> orderl = OrderBll.GetList("", " isnull(dr,0)=0 and Otype!=9 and CompID=" + comp.ID,
                                                                "");
            if (orderl != null)
            {
                if (orderl.Count > 0)
                {
                    //待审核订单个数
                    NotCount = orderl.FindAll(p => p.OState == (int)Enums.OrderState.待审核).Count;

                    //待发货订单个数
                    DeliveryCount =
                        orderl.FindAll(
                            p =>
                            p.OState == (int)Enums.OrderState.已审 && p.ReturnState == (int)Enums.ReturnState.未退货 &&
                            (p.PayState == (int)Enums.PayState.已支付 || p.PayState == (int)Enums.PayState.部分支付 ||
                             (p.PayState == (int)Enums.PayState.未支付 && p.Otype == (int)Enums.OType.赊销订单))).Count;

                    //当日订单数
                    DayOrderCount = orderl.FindAll(order =>
                                                   (order.ReturnState == (int)Enums.ReturnState.未退货 &&
                                                    order.OState >= (int)Enums.OrderState.待审核 &&
                                                    order.CreateDate >= day0)
                                                   ).Count;

                    //本月订单数
                    OrderCount =
                        orderl.FindAll(
                            p =>
                            p.ReturnState == (int)Enums.ReturnState.未退货 &&
                            (p.OState == (int)Enums.OrderState.已审 || p.OState == (int)Enums.OrderState.已发货 ||
                             p.OState == (int)Enums.OrderState.已到货) && p.CreateDate >= day1 && p.CreateDate <= Sday)
                        .Count;
                    //待收款订单
                    //PayOrder = orderl.FindAll(p => (p.OState == (int)Enums.OrderState.已审 || p.OState == (int)Enums.OrderState.已到货 || p.OState == (int)Enums.OrderState.已发货) && p.PayState == (int)Enums.PayState.未支付).Count;

                    PayOrder =
                        orderl.FindAll(
                            p =>
                            ((p.OState == (int)Enums.OrderState.已审 || p.OState == (int)Enums.OrderState.已到货 ||
                              p.OState == (int)Enums.OrderState.已发货) &&
                             (p.PayState == (int)Enums.PayState.未支付 || p.PayState == (int)Enums.PayState.部分支付) &&
                             p.Otype == (int)Enums.OType.赊销订单) ||
                            ((p.OState == (int)Enums.OrderState.已审 || p.OState == (int)Enums.OrderState.已到货 ||
                              p.OState == (int)Enums.OrderState.已发货) &&
                             (p.PayState == (int)Enums.PayState.未支付 || p.PayState == (int)Enums.PayState.部分支付) &&
                             p.Otype != (int)Enums.OType.赊销订单)).Count;
                }
            }

            #endregion

            #region 退货订单

            List <Hi.Model.DIS_OrderReturn> rOl = OrderReturnBll.GetList("", " isnull(dr,0)=0 and CompID=" + comp.ID,
                                                                         "");
            if (rOl != null)
            {
                if (rOl.Count > 0)
                {
                    //退货待审订单个数
                    ReturnCount = rOl.FindAll(R => R.ReturnState == 1).Count;
                    ReturnMoney = rOl.FindAll(R => R.ReturnState == 2).Count;
                }
            }

            #endregion

            #region 企业钱包审核

            List <Hi.Model.PAY_PrePayment> Exa = PaymentBLL.GetList("", " isnull(dr,0)=0 and CompID=" + comp.ID, "");
            if (Exa != null)
            {
                if (Exa.Count > 0)
                {
                    PaymentCount = Exa.FindAll(E => E.AuditState == 0 && E.Start == 1).Count;
                }
            }

            #endregion

            #region 经销商审核

            List <Hi.Model.BD_Distributor> disList = disBll.GetList("", " isnull(dr,0)=0 and CompID=" + comp.ID, "");

            if (disList != null)
            {
                if (disList.Count > 0)
                {
                    //经销商待审核个数
                    disCount = disList.FindAll(D => D.AuditState == 0).Count;

                    //总经销商总个数
                    CountSum = disList.Count;

                    //新增经销商个数
                    CountNew =
                        disList.FindAll(D => D.CreateDate >= day1 && D.CreateDate <= Sday && D.AuditState == 2).Count;
                }
            }

            #endregion

            #region 当天收款  当天销售额

            //收款
            string strDay =
                "SELECT SUM(Price) as Price FROM [dbo].[CompCollection_view] where OrderID not in(select ID from Dis_Order where ISNULL(dr,0)=0 and Otype=9 and CompID=" +
                comp.ID + ") and CompID=" + comp.ID +
                " and Date>='" + day0 + "' and Date<='" + Sday + "'";

            DataTable dtDay = SqlHelper.Query(SqlHelper.LocalSqlServer, strDay).Tables[0];
            if (dtDay != null)
            {
                if (dtDay.Rows.Count > 0)
                {
                    decimal Price = dtDay.Rows[0]["Price"].ToString() == ""
                        ? sum.ToString().ToDecimal()
                        : Convert.ToDecimal(dtDay.Rows[0]["Price"]);
                    dayPaggerSum = (Price / 10000).ToString();
                }
            }

            //销售额
            string daysql = "SELECT SUM(sumAmount) as sumAmount FROM [dbo].[MonthSaleRpt_view] where CompID=" +
                            comp.ID + " and CreateDate>='" + day0 + "' and CreateDate<='" + Sday +
                            "' and OState in (2,4,5)";

            DataTable dayDt = SqlHelper.Query(SqlHelper.LocalSqlServer, daysql).Tables[0];
            if (dayDt != null)
            {
                if (dayDt.Rows.Count > 0)
                {
                    decimal sumAmount = dayDt.Rows[0]["sumAmount"].ToString() == ""
                        ? sum.ToString().ToDecimal()
                        : Convert.ToDecimal(dayDt.Rows[0]["sumAmount"]);

                    DaySum = (sumAmount / 10000).ToString();
                }
            }


            #endregion

            #region 本月收款  本月应收  本月销售额

            //本月收款
            string paggersql =
                "SELECT SUM(Price) as Price FROM [dbo].[CompCollection_view] where OrderID not in(select ID from Dis_Order where ISNULL(dr,0)=0 and Otype=9 and CompID=" +
                comp.ID + ") and CompID=" + comp.ID +
                " and Date>='" + day1 + "' and Date<='" + Sday + "'";

            DataTable paggerdt = SqlHelper.Query(SqlHelper.LocalSqlServer, paggersql).Tables[0];
            if (paggerdt != null)
            {
                if (paggerdt.Rows.Count > 0)
                {
                    decimal Price = paggerdt.Rows[0]["Price"].ToString() == ""
                        ? sum.ToString().ToDecimal()
                        : Convert.ToDecimal(paggerdt.Rows[0]["Price"]);
                    paggerSum = (Price / 10000).ToString();
                }
            }

            //本月应收
            string ArrearageSql =
                "SELECT SUM(AuditAmount-PayedAmount) as AuditAmount FROM [dbo].[ArrearageRpt_view] where Otype!=9 and CompID=" +
                comp.ID +
                " and CreateDate>='" + day1 + "' and CreateDate<='" + Sday + "'";

            DataTable ArrearageDt = SqlHelper.Query(SqlHelper.LocalSqlServer, ArrearageSql).Tables[0];
            if (ArrearageDt != null)
            {
                if (ArrearageDt.Rows.Count > 0)
                {
                    decimal AuditAmount = ArrearageDt.Rows[0]["AuditAmount"].ToString() == ""
                        ? sum.ToString().ToDecimal()
                        : Convert.ToDecimal(ArrearageDt.Rows[0]["AuditAmount"]);
                    ArrearageSum = (AuditAmount / 10000).ToString();
                }
            }

            //本月销售额
            string monthsql = "SELECT SUM(sumAmount) as sumAmount FROM [dbo].[MonthSaleRpt_view] where  CompID=" +
                              comp.ID + " and CreateDate>='" + day1 + "' and CreateDate<='" + Sday +
                              "' and OState in(2,4,5)";

            DataTable monthDt = SqlHelper.Query(SqlHelper.LocalSqlServer, monthsql).Tables[0];
            if (monthDt != null)
            {
                if (monthDt.Rows.Count > 0)
                {
                    decimal sumAmount = monthDt.Rows[0]["sumAmount"].ToString() == ""
                        ? sum.ToString().ToDecimal()
                        : Convert.ToDecimal(monthDt.Rows[0]["sumAmount"]);

                    MonthSum = (sumAmount / 10000).ToString();
                }
            }


            #endregion

            #region 待回复留言

            List <Hi.Model.DIS_Suggest> LDis = new Hi.BLL.DIS_Suggest().GetList("",
                                                                                " isnull(dr,0)=0 and compid=" + comp.ID, "");

            if (LDis.Count > 0)
            {
                SuggectCount = LDis.FindAll(S => S.IsAnswer == 0).Count;
            }

            #endregion

            #region 本月账单收款,本月账单应收

            //账单收款
            string billsksql = string.Format(@"SELECT sum(Price)  as price FROM [dbo].[CompCollection_view] 
                             where OrderID  in(select ID from Dis_Order 
                             where ISNULL(dr,0)=0 and Otype=9 and CompID={0}) and CompID={0}", comp.ID);

            DataTable billskdt = SqlHelper.Query(SqlHelper.LocalSqlServer, billsksql).Tables[0];
            if (billskdt != null)
            {
                if (billskdt.Rows.Count > 0)
                {
                    decimal Price = billskdt.Rows[0]["Price"].ToString() == ""
                        ? sum.ToString().ToDecimal()
                        : Convert.ToDecimal(billskdt.Rows[0]["Price"]);
                    billskSum = (Price / 10000).ToString("N");
                }
            }
            //账单应收
            string billyssql =
                string.Format(
                    @"select sum(AuditAmount-PayedAmount) AuditAmount from(select * from [dbo].[ArrearageRpt_view] where  CompID={0} and Otype=9 )M  where compID={0}",
                    comp.ID);
            DataTable billysdt = SqlHelper.Query(SqlHelper.LocalSqlServer, billyssql).Tables[0];
            if (billysdt != null)
            {
                if (billysdt.Rows.Count > 0)
                {
                    decimal Price = billysdt.Rows[0]["AuditAmount"].ToString() == ""
                        ? sum.ToString().ToDecimal()
                        : Convert.ToDecimal(billysdt.Rows[0]["AuditAmount"]);
                    billys = (Price / 10000).ToString("N");
                }
            }

            #endregion

            return(new ResultJSC()
            {
                Result = "T",
                Description = "返回正确",
                MonthSum = MonthSum,
                OrderCount = OrderCount.ToString(),
                PaggerSum = paggerSum,
                ArrearageSum = ArrearageSum,
                CountSum = CountSum.ToString(),
                CountNew = CountNew.ToString(),
                DayPaggerSum = dayPaggerSum,
                DaySum = DaySum,
                DayCount = DayOrderCount.ToString(),
                billskSum = billskSum,
                billys = billys
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetCompNum:" + JSon);
            return(null);
        }
    }
Beispiel #8
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (KeyID > 0)
        {
            bool Audit = false;
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
            if (comp != null)
            {
                if (comp.dr == 1)
                {
                    JScript.AlertMsg(this, "厂商不存在!。");
                    return;
                }
                string         str  = string.Empty;
                SqlTransaction Tran = null;
                try
                {
                    if (comp.AuditState == 2)
                    {
                        Audit = true;
                    }
                    if (Common.CompExistsAttribute("CompName", txtCompName.Value.Trim(), KeyID.ToString()))
                    {
                        JScript.AlertMsg(this, "该厂商名称已存在。");
                        return;
                    }
                    string CompAddr = hidProvince.Value.Trim();
                    if (!string.IsNullOrWhiteSpace(hidCity.Value.Trim()) && hidCity.Value.Trim() != "选择市")
                    {
                        CompAddr += "-" + hidCity.Value.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(hidArea.Value.Trim()) && hidArea.Value.Trim() != "选择区")
                    {
                        CompAddr += "-" + hidArea.Value.Trim();
                    }
                    comp.CompAddr = CompAddr;
                    comp.CompName = Common.NoHTML(txtCompName.Value.Trim());
                    comp.Capital  = Capital.Value.Trim();
                    comp.CompType = Convert.ToInt32(CompType.SelectedValue);
                    comp.Tel      = Common.NoHTML(txtTel.Value.Trim());
                    if (txtPrincipal.Value.Trim() != "")
                    {
                        comp.Principal = Common.NoHTML(txtPrincipal.Value.Trim());
                    }
                    else
                    {
                        comp.Principal = Common.NoHTML(txtUserTrueName.Value.Trim());
                    }
                    comp.Legal = Common.NoHTML(txtLegal.Value.Trim());
                    if (txtPhone.Value.Trim() != "")
                    {
                        comp.Phone = Common.NoHTML(txtPhone.Value.Trim());
                    }
                    else
                    {
                        comp.Phone = Common.NoHTML(txtUserPhone.Value.Trim());
                    }
                    comp.ShortName  = Common.NoHTML(txtShotName.Value.Trim());
                    comp.Zip        = Common.NoHTML(txtZip.Value.Trim());
                    comp.Identitys  = Common.NoHTML(txtIdentitys.Value.Trim());
                    comp.Licence    = Common.NoHTML(txtLicence.Value.Trim());
                    comp.LegalTel   = Common.NoHTML(txtLegalTel.Value.Trim());
                    comp.ManageInfo = Common.NoHTML(txtInfo.Value.Trim());
                    comp.Fax        = Common.NoHTML(txtFax.Value.Trim());
                    comp.Account    = Common.NoHTML(txtAccount.Value.Trim());
                    comp.Address    = Common.NoHTML(txtAddress.Value.Trim());
                    comp.IndID      = txtIndusName.SelectedValue.ToInt(0);
                    comp.Trade      = txtIndusName.Items[txtIndusName.SelectedIndex].Text;
                    comp.AuditState = 2;
                    comp.AuditDate  = DateTime.Now;//add by hgh 审核日期
                    comp.AuditUser  = UserID.ToString();

                    comp.ts               = DateTime.Now;
                    comp.modifyuser       = UserID;
                    comp.OrganizationCode = Common.NoHTML(txtOrcode.Value.Trim());
                    comp.IsEnabled        = rdEbleYes.Checked ? 1 : 0;
                    comp.HotShow          = rdHotShowYes.Checked ? 1 : 0;
                    comp.FirstShow        = Convert.ToInt32(ddlChkShow.SelectedValue);// rdFirstShowYes.Checked ? 1 : 0;
                    comp.Remark           = Common.NoHTML(txtRemark.Value.Trim());
                    comp.Erptype          = ddlErptype.SelectedValue.ToInt(0);
                    //企业编号  add by hgh
                    comp.CompCode = Common.CreateCode(KeyID);
                    if (HidFfileName.Value != "")
                    {
                        if (string.IsNullOrEmpty(comp.Attachment))
                        {
                            comp.Attachment = HidFfileName.Value;
                        }
                        else
                        {
                            comp.Attachment += "," + HidFfileName.Value;
                        }
                    }
                    List <Hi.Model.SYS_CompUser> ListComp = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and Ctype=1 and Utype=4 and CompID=" + KeyID + "", "");
                    if (ListComp.Count > 0)
                    {
                        Tran  = DBUtility.SqlHelper.CreateStoreTranSaction();
                        Audit = ListComp[0].IsAudit == 2;
                        if (Audit)
                        {
                            List <Hi.Model.BD_Distributor> dis = new Hi.BLL.BD_Distributor().GetList("", " isnull(dr,0)=0 and compid=" + KeyID + "", "");
                            foreach (Hi.Model.BD_Distributor model2 in dis)
                            {
                                model2.IsEnabled  = comp.IsEnabled;
                                model2.ts         = DateTime.Now;
                                model2.modifyuser = UserID;
                                new Hi.BLL.BD_Distributor().Update(model2, Tran);
                            }
                            new Hi.BLL.BD_Company().Update(comp, Tran);
                            List <Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and id=" + ListComp[0].UserID + " ", "");
                            if (user.Count > 0)
                            {
                                user[0].TrueName   = Common.NoHTML(txtUserTrueName.Value.Trim());
                                user[0].ts         = DateTime.Now;
                                user[0].modifyuser = UserID;
                                new Hi.BLL.SYS_Users().Update(user[0], Tran);
                            }
                            Tran.Commit();
                            Response.Redirect("CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5", false);
                        }
                        else
                        {
                            if (UserType == 3 || UserType == 4)
                            {
                                comp.OrgID      = OrgID;
                                comp.SalesManID = SalesManID;
                            }
                            if ((new Hi.BLL.BD_Company().Update(comp, Tran)))
                            {
                                //新增数据字典
                                Hi.Model.BD_DefDoc doc = new Hi.Model.BD_DefDoc();
                                doc.CompID     = KeyID;
                                doc.AtCode     = "";
                                doc.AtName     = "计量单位";
                                doc.ts         = DateTime.Now;
                                doc.modifyuser = UserID;
                                doc.dr         = 0;
                                List <Hi.Model.BD_DefDoc> ll = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='计量单位'", "", Tran);
                                if (ll.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc, Tran);
                                }

                                //代理商加盟是否需要审核
                                Hi.Model.SYS_SysName sysname = new Hi.Model.SYS_SysName();
                                sysname.CompID     = KeyID;
                                sysname.Code       = "";
                                sysname.Name       = "代理商加盟是否需要审核";
                                sysname.Value      = "0";
                                sysname.ts         = DateTime.Now;
                                sysname.modifyuser = UserID;
                                List <Hi.Model.SYS_SysName> sysl = new Hi.BLL.SYS_SysName().GetList("", "Name='代理商加盟是否需要审核' and CompID=" + KeyID, "", Tran);
                                if (sysl != null && sysl.Count == 0)
                                {
                                    new Hi.BLL.SYS_SysName().Add(sysname, Tran);
                                }

                                //费用科目
                                Hi.Model.BD_DefDoc doc1 = new Hi.Model.BD_DefDoc();
                                doc1.CompID     = KeyID;
                                doc1.AtCode     = "";
                                doc1.AtName     = "费用科目";
                                doc1.ts         = DateTime.Now;
                                doc1.modifyuser = UserID;
                                doc1.dr         = 0;
                                List <Hi.Model.BD_DefDoc> ll1 = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='费用科目'", "", Tran);
                                if (ll1.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc1, Tran);
                                }


                                doc.CompID     = KeyID;
                                doc.AtCode     = "";
                                doc.AtName     = "代理商等级";
                                doc.ts         = DateTime.Now;
                                doc.modifyuser = UserID;
                                doc.dr         = 0;
                                List <Hi.Model.BD_DefDoc> lll = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='代理商等级'", "", Tran);
                                if (lll.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc, Tran);
                                }
                                List <Hi.Model.SYS_Role> l = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and isenabled=1 and compid=" + KeyID + " and RoleName='企业管理员'", "");
                                if (l.Count == 0)
                                {
                                    //新增角色(企业管理员)
                                    Hi.Model.SYS_Role role = new Hi.Model.SYS_Role();
                                    role.CompID       = KeyID;
                                    role.RoleName     = "企业管理员";
                                    role.IsEnabled    = 1;
                                    role.SortIndex    = "1";
                                    role.CreateDate   = DateTime.Now;
                                    role.CreateUserID = UserID;
                                    role.ts           = DateTime.Now;
                                    role.modifyuser   = UserID;
                                    role.dr           = 0;
                                    int Roid = new Hi.BLL.SYS_Role().Add(role, Tran);

                                    //新增角色用户
                                    Hi.Model.SYS_RoleUser RoleUser = new Hi.Model.SYS_RoleUser();
                                    RoleUser.FunType    = 1;
                                    RoleUser.UserID     = ListComp[0].UserID;
                                    RoleUser.RoleID     = Roid;
                                    RoleUser.IsEnabled  = true;
                                    RoleUser.CreateUser = this.UserID.ToString();
                                    RoleUser.CreateDate = DateTime.Now;
                                    RoleUser.ts         = DateTime.Now;
                                    RoleUser.dr         = 0;
                                    new Hi.BLL.SYS_RoleUser().Add(RoleUser, Tran);

                                    //修改用户对应的角色
                                    List <Hi.Model.SYS_Users> ListUser = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and id=" + ListComp[0].UserID + " ", "");
                                    if (ListUser.Count > 0)
                                    {
                                        ListUser[0].TrueName   = Common.NoHTML(txtUserTrueName.Value.Trim());
                                        ListUser[0].ts         = DateTime.Now;
                                        ListUser[0].modifyuser = UserID;
                                        ListUser[0].AuditState = 2;
                                        new Hi.BLL.SYS_Users().Update(ListUser[0], Tran);
                                    }
                                    ListComp[0].IsAudit    = 2;
                                    ListComp[0].modifyuser = UserID;
                                    ListComp[0].ts         = DateTime.Now;
                                    ListComp[0].RoleID     = Roid;
                                    new Hi.BLL.SYS_CompUser().Update(ListComp[0], Tran);

                                    Hi.Model.BD_CompNews CNew = new Hi.Model.BD_CompNews();
                                    CNew.NewsTitle    = "欢迎登录" + ConfigurationManager.AppSettings["PhoneSendName"].ToString() + "平台";
                                    CNew.NewsContents = "”" + ConfigurationManager.AppSettings["PhoneSendName"].ToString() + "”平台为企业和代理商之间搭建了电子商务平台,通过企业入驻及代理商的加盟,形成覆盖全行业的线上销售网络。同时,充分利用平台信息化整合优势,帮助入驻企业销售模式电商化改造,以及为代理商信息化建设提供有力支持。另外,还将为供应链上的相关各方提供全渠道的结算服务以及授信融资等多项互联网金融服务。";
                                    CNew.IsEnabled    = 1;
                                    CNew.IsTop        = 0;
                                    CNew.NewsType     = 2;
                                    CNew.ShowType     = "1,2";
                                    CNew.CompID       = KeyID;
                                    CNew.CreateDate   = DateTime.Now;
                                    CNew.CreateUserID = UserID;
                                    CNew.ts           = DateTime.Now;
                                    CNew.modifyuser   = UserID;
                                    new Hi.BLL.BD_CompNews().Add(CNew, Tran);

                                    //新增角色权限表
                                    Hi.Model.SYS_RoleSysFun rolesys = null;
                                    //add by hgh   增加了:and funcode<>'1030'
                                    List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=1 and funcode<>'1030'", "");
                                    foreach (Hi.Model.SYS_SysFun sys in funList)
                                    {
                                        rolesys              = new Hi.Model.SYS_RoleSysFun();
                                        rolesys.CompID       = KeyID;
                                        rolesys.RoleID       = Roid;
                                        rolesys.FunCode      = sys.FunCode;
                                        rolesys.FunName      = sys.FunName;
                                        rolesys.IsEnabled    = 1;
                                        rolesys.CreateUserID = UserID;
                                        rolesys.CreateDate   = DateTime.Now;
                                        rolesys.ts           = DateTime.Now;
                                        rolesys.modifyuser   = UserID;
                                        new Hi.BLL.SYS_RoleSysFun().Add(rolesys, Tran);
                                    }

                                    //新增代理商分类
                                    Hi.Model.BD_DisType distype = new Hi.Model.BD_DisType();
                                    distype.CompID       = KeyID;
                                    distype.TypeName     = "全部";
                                    distype.ParentId     = 0;
                                    distype.TypeCode     = "1001";
                                    distype.SortIndex    = "1000";
                                    distype.IsEnabled    = 0;
                                    distype.CreateUserID = UserID;
                                    distype.CreateDate   = DateTime.Now;
                                    distype.ts           = DateTime.Now;
                                    distype.modifyuser   = UserID;
                                    distype.dr           = 0;
                                    new Hi.BLL.BD_DisType().Add(distype, Tran);
                                    Tran.Commit();

                                    //审核成功   添加一条默认的商品分类 -开始

                                    string Typecode = "";//商品大类
                                    //Hi.Model.SYS_GType gtype = new Hi.BLL.SYS_GType().GetList(" top 1 *", " Deep=3  and FullCode like '"+ Typecode + "-%' and IsEnabled=1 and dr=0 ", " parentid,ID")[0];
                                    //Hi.Model.BD_GoodsCategory DisType = new Hi.Model.BD_GoodsCategory();

                                    //DisType.Code = NewCategoryCode("1");
                                    //DisType.Deep = 1;
                                    //DisType.ParCode = "";
                                    //DisType.ParentId = 0;
                                    //DisType.CompID = KeyID;
                                    //DisType.CategoryName = "默认";
                                    //DisType.GoodsTypeID = gtype.ID;
                                    //DisType.SortIndex = "1000";
                                    //DisType.CreateDate = DateTime.Now;
                                    //DisType.CreateUserID = 0;
                                    //DisType.IsEnabled = 1;
                                    //DisType.ts = DateTime.Now;
                                    //DisType.modifyuser = 0;
                                    //SqlTransaction trans = SqlHelper.CreateStoreTranSaction();
                                    //try
                                    //{
                                    //    int countID = 0;
                                    //    if ((countID = new Hi.BLL.BD_GoodsCategory().Add(DisType, trans)) > 0)
                                    //    {
                                    //        List<Hi.Model.BD_Goods> gList = new Hi.BLL.BD_Goods().GetList("", " CategoryID=''", "");
                                    //        if (gList != null && gList.Count > 0)
                                    //        {
                                    //            foreach (var bdGoodse in gList)
                                    //            {
                                    //                bdGoodse.CategoryID = countID;
                                    //                new Hi.BLL.BD_Goods().Update(bdGoodse, trans);
                                    //            }
                                    //        }
                                    //        trans.Commit();

                                    //    }

                                    //}
                                    //catch (Exception ex)
                                    //{
                                    //    Tiannuo.LogHelper.LogHelper.Error("Error", ex);
                                    //    if (trans != null)
                                    //    {
                                    //        if (trans.Connection != null)
                                    //        {
                                    //            trans.Rollback();
                                    //        }
                                    //    }
                                    //    return;
                                    //}
                                    //finally
                                    //{
                                    //    SqlHelper.ConnectionClose();
                                    //    if (trans != null)
                                    //    {
                                    //        if (trans.Connection != null)
                                    //        {
                                    //            trans.Connection.Close();
                                    //        }
                                    //    }
                                    //}
                                    //审核成功   添加一条默认的商品分类 -结束



                                    DBUtility.GetPhoneCode getphonecode = new DBUtility.GetPhoneCode();
                                    str = getphonecode.ReturnSTRS(ListUser[0].Phone, comp.CompName, ListUser[0].UserName);
                                    if (str != "Success")
                                    {
                                        JScript.AlertMsgMo(this, "审核通过的通知短信发送失败!请自行发送短信通知企业。", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=" + Request.QueryString["type"] + "" + "'; }");
                                    }
                                    else
                                    {
                                        JScript.AlertMsgMo(this, "审核成功", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5'; }");
                                    }
                                }
                                else
                                {
                                    ListComp[0].IsAudit    = 2;
                                    ListComp[0].modifyuser = UserID;
                                    ListComp[0].ts         = DateTime.Now;
                                    new Hi.BLL.SYS_CompUser().Update(ListComp[0], Tran);
                                    Hi.Model.SYS_Users           user  = null;
                                    List <Hi.Model.SYS_CompUser> User2 = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and utype=4 and CompID=" + KeyID + "", "");
                                    if (User2.Count > 0)
                                    {
                                        user = new Hi.BLL.SYS_Users().GetModel(User2[0].UserID);
                                    }
                                    Tran.Commit();

                                    // 发短信通知
                                    DBUtility.GetPhoneCode getphonecode = new DBUtility.GetPhoneCode();
                                    getphonecode.GetUser(ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(), ConfigurationManager.AppSettings["PhoneCodePwd"].ToString());
                                    str = getphonecode.ReturnSTRS(user.Phone, comp.CompName, user.UserName);
                                    if (str != "Success")
                                    {
                                        JScript.AlertMsgMo(this, "审核通过的通知短信发送失败!请自行发送短信通知企业。", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=" + Request.QueryString["type"] + "" + "'; }");
                                    }
                                    else
                                    {
                                        JScript.AlertMsgMo(this, "审核成功", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5'; }");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        JScript.AlertMsg(this, "用户明细数据异常!。");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Tiannuo.LogHelper.LogHelper.Error("Error", ex);
                    if (Tran != null)
                    {
                        if (Tran.Connection != null)
                        {
                            Tran.Rollback();
                        }
                    }
                    JScript.AlertMsgMo(this, "审核失败", "function(){ window.location.href=window.location.href; }");
                }
                finally
                {
                    DBUtility.SqlHelper.ConnectionClose();
                }
            }
            else
            {
                JScript.AlertMsg(this, "厂商不存在!。");
                return;
            }


            //cust by ggh 20180327 begin  审核通过时,默认给核心企业设置手续费

            Settings(KeyID);

            //cust by ggh 20180327  end  审核通过时,默认给核心企业设置手续费
        }
        else
        {
            if (Common.GetUserExists(txtUsername.Value.Trim()))
            {
                JScript.AlertMsg(this, "该登录帐号已存在。");
                return;
            }
            if (Common.CompExistsAttribute("CompName", txtCompName.Value.Trim()))
            {
                JScript.AlertMsg(this, "该厂商名称已存在。");
                return;
            }
            Regex Phonereg = new Regex("^0?1[0-9]{10}$");
            if (!Phonereg.IsMatch(txtUserPhone.Value.Trim()))
            {
                JScript.AlertMsg(this, "手机号码格式错误!");
                return;
            }
            if (Common.GetUserExists("Phone", txtUserPhone.Value.Trim()))
            {
                JScript.AlertMsg(this, "手机号码已被注册!");
                return;
            }
            Hi.Model.BD_Company comp = new Hi.Model.BD_Company();
            if (UserType == 3 || UserType == 4)
            {
                comp.OrgID      = OrgID;
                comp.SalesManID = SalesManID;
            }
            comp.CompName = Common.NoHTML(txtCompName.Value.Trim());
            comp.Capital  = Capital.Value.Trim();
            comp.CompType = Convert.ToInt32(CompType.SelectedValue);
            comp.Tel      = Common.NoHTML(txtTel.Value.Trim());
            if (txtPrincipal.Value.Trim() != "")
            {
                comp.Principal = Common.NoHTML(txtPrincipal.Value.Trim());
            }
            else
            {
                comp.Principal = Common.NoHTML(txtUserTrueName.Value.Trim());
            }
            comp.Legal    = Common.NoHTML(txtLegal.Value.Trim());
            comp.LegalTel = Common.NoHTML(txtLegalTel.Value.Trim());
            if (txtPhone.Value.Trim() != "")
            {
                comp.Phone = Common.NoHTML(txtPhone.Value.Trim());
            }
            else
            {
                comp.Phone = Common.NoHTML(txtUserPhone.Value.Trim());
            }
            comp.ShortName        = Common.NoHTML(txtShotName.Value.Trim());
            comp.Zip              = Common.NoHTML(txtZip.Value.Trim());
            comp.Identitys        = Common.NoHTML(txtIdentitys.Value.Trim());
            comp.Licence          = Common.NoHTML(txtLicence.Value.Trim());
            comp.ManageInfo       = Common.NoHTML(txtInfo.Value.Trim());
            comp.Fax              = Common.NoHTML(txtFax.Value.Trim());
            comp.OrganizationCode = Common.NoHTML(txtOrcode.Value.Trim());
            comp.Trade            = txtIndusName.Items[txtIndusName.SelectedIndex].Text;
            comp.Account          = Common.NoHTML(txtAccount.Value.Trim());
            comp.Attachment       = HidFfileName.Value;
            comp.Address          = Common.NoHTML(txtAddress.Value.Trim());
            comp.CustomCompinfo   = "本公司产品种类丰富、质量优良、价格公道、服务周到。感谢您长期的支持与厚爱,您的满意是我们最高的追求,我们将竭诚为您提供优质、贴心的服务!";

            string CompAddr = hidProvince.Value.Trim();
            if (!string.IsNullOrWhiteSpace(hidCity.Value.Trim()) && hidCity.Value.Trim() != "选择市")
            {
                CompAddr += "-" + hidCity.Value.Trim();
            }
            if (!string.IsNullOrWhiteSpace(hidArea.Value.Trim()) && hidArea.Value.Trim() != "选择区")
            {
                CompAddr += "-" + hidArea.Value.Trim();
            }
            comp.CompAddr = CompAddr;

            comp.IndID        = txtIndusName.SelectedValue.ToInt(0);
            comp.CreateDate   = DateTime.Now;
            comp.CreateUserID = UserID;
            comp.ts           = DateTime.Now;
            comp.modifyuser   = UserID;
            comp.IsEnabled    = rdEbleYes.Checked ? 1 : 0;
            comp.HotShow      = rdHotShowYes.Checked ? 1 : 0;
            comp.FirstShow    = Convert.ToInt32(ddlChkShow.SelectedValue);// rdFirstShowYes.Checked ? 1 : 0;
            comp.SortIndex    = "001";
            comp.Remark       = Common.NoHTML(txtRemark.Value.Trim());
            comp.Erptype      = ddlErptype.SelectedValue.ToInt(0);
            comp.AuditState   = 0;
            int            comid = 0;
            SqlTransaction Tran  = DBUtility.SqlHelper.CreateStoreTranSaction();
            comid         = new Hi.BLL.BD_Company().Add(comp, Tran);
            comp.CompCode = Common.CreateCode(comid);
            comp.ID       = comid;
            new Hi.BLL.BD_Company().Update(comp, Tran);
            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            user.UserName     = Common.NoHTML(txtUsername.Value.Trim());
            user.TrueName     = Common.NoHTML(txtUserTrueName.Value.Trim());
            user.UserPwd      = Util.md5(txtUpwd.Text.Trim());
            user.Phone        = Common.NoHTML(txtUserPhone.Value.Trim());
            user.AuditState   = 2;
            user.IsEnabled    = 1;
            user.AuditUser    = UserID.ToString();
            user.CreateUserID = UserID;
            user.CreateDate   = DateTime.Now;
            user.ts           = DateTime.Now;
            user.modifyuser   = UserID;
            int userid = 0;
            userid = new Hi.BLL.SYS_Users().Add(user, Tran);
            Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
            CompUser.CompID       = comid;
            CompUser.DisID        = 0;
            CompUser.CreateDate   = DateTime.Now;
            CompUser.CreateUserID = UserID;
            CompUser.modifyuser   = UserID;
            CompUser.CType        = 1;
            CompUser.UType        = 4;
            CompUser.IsEnabled    = 1;
            CompUser.IsAudit      = 0;
            CompUser.ts           = DateTime.Now;
            CompUser.dr           = 0;
            CompUser.UserID       = userid;
            new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
            Tran.Commit();
            Response.Redirect("CompInfo.aspx?go=1&KeyID=" + comid, false);
        }
    }
Beispiel #9
0
    //public string GetPhoto()
    //{
    //    try
    //    {
    //        string code = CreateVerifyCode();
    //        Bitmap photo = CreateImageCode(code);
    //        byte[] b_photo = null;
    //        MemoryStream stream = new MemoryStream();
    //        using (photo)
    //        {
    //            photo.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
    //        }
    //        photo.Dispose();
    //        using (stream)
    //        {
    //            b_photo = stream.GetBuffer();
    //        }
    //        //stream.Dispose();
    //        stream.Close();
    //        string PhotoUrl = Convert.ToBase64String(b_photo, 0, b_photo.Length);
    //        return PhotoUrl;

    //    }
    //    catch (Exception ex)
    //    {
    //        return ex.ToString();
    //    }
    //}

    //public void write()
    //{
    //    string PhotoUrl = GetPhoto();
    //    byte[] b = Convert.FromBase64String(PhotoUrl);
    //    FileStream fs = new FileStream(@"F:/QQ文件/IMG_14.JPG",FileMode.Create,FileAccess.Write);
    //    fs.Write(b,0,b.Length);
    //    fs.Flush();
    //    fs.Close();
    //}


    //核心企业提交入驻申请
    #region
    public ResultCompEnter SendEnterRequest(string JSon, string version)
    {
        string PhoneNumb   = string.Empty;
        string LoginName   = string.Empty;
        string PassWord    = string.Empty;
        string CompanyName = string.Empty;
        string Captcha     = string.Empty;
        string SendId      = string.Empty;
        string Type        = string.Empty;
        int    compid      = 0;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["PhoneNumb"].ToString().Trim() != "" && JInfo["LoginName"].ToString().Trim() != "" && JInfo["Captcha"].ToString().Trim() != "" &&
                JInfo["PassWord"].ToString().Trim() != "" && JInfo["CompanyName"].ToString().Trim() != "" && JInfo["SendId"].ToString().Trim() != "" &&
                JInfo["Type"].ToString().Trim() != "")
            {
                PhoneNumb = Common.NoHTML(JInfo["PhoneNumb"].ToString());
                LoginName = Common.NoHTML(JInfo["LoginName"].ToString());
                if (LoginName != JInfo["LoginName"].ToString())
                {
                    return new ResultCompEnter()
                           {
                               Result = "F", Description = "用户名存在非法字符串"
                           }
                }
                ;
                PassWord    = JInfo["PassWord"].ToString();
                CompanyName = Common.NoHTML(JInfo["CompanyName"].ToString());
                Captcha     = JInfo["Captcha"].ToString();
                SendId      = JInfo["SendId"].ToString();
                Type        = JInfo["Type"].ToString();
            }
            else
            {
                return(new ResultCompEnter()
                {
                    Result = "F", Description = "参数异常"
                });
            }
            #endregion
            #region//验证验证码是否有效
            Hi.Model.SYS_PhoneCode code = new Hi.BLL.SYS_PhoneCode().GetModel(int.Parse(SendId));
            if (code != null && code.dr == 0)
            {
                if (code.ts.AddMinutes(30) < DateTime.Now || code.IsPast == 1)
                {
                    return new ResultCompEnter()
                           {
                               Result = "F", Description = "验证码过期"
                           }
                }
                ;

                if (code.PhoneCode != Captcha)
                {
                    return new ResultCompEnter()
                           {
                               Result = "F", Description = "验证码错误"
                           }
                }
                ;
            }
            else
            {
                return(new ResultCompEnter()
                {
                    Result = "F", Description = "验证码不可用"
                });
            }
            code.IsPast     = 1;
            code.ts         = DateTime.Now;
            code.modifyuser = 0;
            SqlConnection conn = new SqlConnection(SqlHelper.LocalSqlServer);
            if (conn.State.ToString().ToLower() != "open")
            {
                conn.Open();
            }
            SqlTransaction mytran = conn.BeginTransaction();

            #endregion
            //如果验证码正确的话,修改验证码状态
            try
            {
                if (new Hi.BLL.SYS_PhoneCode().Update(code, mytran))//验证码状态修改成功的话,开始进行注册流程
                {
                    if (Type == "distributor")
                    {
                        Boolean result = RegisterDistributor(CompanyName, PhoneNumb, PassWord, mytran);
                        if (result)
                        {
                            return(new ResultCompEnter()
                            {
                                Result = "T", Description = "注册成功"
                            });
                        }
                        else
                        {
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "注册用户失败"
                            });
                        }
                    }
                    else
                    {
                        //首先在bd_company表中新增一条数据
                        Hi.Model.BD_Company comp = new Hi.Model.BD_Company();
                        comp.CompName     = CompanyName;
                        comp.LegalTel     = PhoneNumb;
                        comp.Phone        = PhoneNumb;
                        comp.AuditState   = 0;
                        comp.IsEnabled    = 1;
                        comp.FirstShow    = 1;
                        comp.Erptype      = 0;
                        comp.SortIndex    = "001";
                        comp.HotShow      = 1;
                        comp.CreateDate   = DateTime.Now;
                        comp.CreateUserID = 0;
                        comp.ts           = DateTime.Now;
                        comp.modifyuser   = 0;
                        compid            = new Hi.BLL.BD_Company().Add(comp, mytran);
                        //bd_company表中数据新增成功后,在sys_users表中新增一条数据
                        if (compid <= 0)
                        {
                            mytran.Rollback();
                            conn.Close();
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "注册核心企业失败"
                            });
                        }
                        //在表sys_users表中新增一条数据
                        Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
                        user.UserName     = LoginName;
                        user.TrueName     = "";
                        user.UserPwd      = new GetPhoneCode().md5(PassWord);
                        user.Phone        = PhoneNumb;
                        user.CreateDate   = DateTime.Now;
                        user.CreateUserID = 0;
                        user.ts           = DateTime.Now;
                        user.modifyuser   = 0;
                        user.AuditState   = 2;
                        user.IsEnabled    = 1;
                        int userid = new Hi.BLL.SYS_Users().Add(user, mytran);
                        if (userid <= 0)
                        {
                            mytran.Rollback();
                            conn.Close();
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "注册用户失败"
                            });
                        }

                        //sys_users新增成功的话,在sys_compuser表中新增一条数据
                        Hi.Model.SYS_CompUser compuser = new Hi.Model.SYS_CompUser();
                        compuser.CompID       = compid;
                        compuser.DisID        = 0;
                        compuser.CreateDate   = DateTime.Now;
                        compuser.CreateUserID = 0;
                        compuser.ts           = DateTime.Now;
                        compuser.modifyuser   = 0;
                        compuser.CType        = 1;
                        compuser.UType        = 4;
                        compuser.dr           = 0;
                        compuser.IsAudit      = 0;
                        compuser.IsEnabled    = 1;
                        compuser.UserID       = userid;
                        int compuserid = new Hi.BLL.SYS_CompUser().Add(compuser, mytran);
                        if (compuserid <= 0)
                        {
                            mytran.Rollback();
                            conn.Close();
                            return(new ResultCompEnter()
                            {
                                Result = "F", Description = "用户与核心企业关联失败"
                            });
                        }
                        else
                        {
                            // 通知运营
                            string   SendRegiPhone = System.Configuration.ConfigurationManager.AppSettings["SendTels"].ToString();
                            string[] Phones        = SendRegiPhone.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (string tel in Phones)
                            {
                                GetPhoneCode phoneCode = new GetPhoneCode();
                                phoneCode.GetUser(
                                    System.Configuration.ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(),
                                    System.Configuration.ConfigurationManager.AppSettings["PhoneCodePwd"].ToString());
                                phoneCode.ReturnComp(tel, comp.CompName);
                            }
                        }
                    }
                }
                else
                {
                    mytran.Rollback();

                    conn.Close();
                    return(new ResultCompEnter()
                    {
                        Result = "F", Description = "验证码异常"
                    });
                }
            }
            catch
            {
                mytran.Rollback();
                conn.Close();
            }
            mytran.Commit();
            conn.Close();


            return(new ResultCompEnter()
            {
                Result = "T", Description = "注册成功", CompID = compid.ToString()
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "SendEnterRequest" + JSon);
            return(new ResultCompEnter()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }