コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public System.Model.facility_port GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, fid, no, qrimg, statuses, pudate, isdel, toid, sid, identitycode, isEmploy  ");
            strSql.Append("  from facility_port ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            System.Model.facility_port model = new System.Model.facility_port();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["fid"].ToString() != "")
                {
                    model.fid = int.Parse(ds.Tables[0].Rows[0]["fid"].ToString());
                }
                model.no    = ds.Tables[0].Rows[0]["no"].ToString();
                model.qrimg = ds.Tables[0].Rows[0]["qrimg"].ToString();
                if (ds.Tables[0].Rows[0]["statuses"].ToString() != "")
                {
                    model.statuses = int.Parse(ds.Tables[0].Rows[0]["statuses"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pudate"].ToString() != "")
                {
                    model.pudate = DateTime.Parse(ds.Tables[0].Rows[0]["pudate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["isdel"].ToString() != "")
                {
                    model.isdel = int.Parse(ds.Tables[0].Rows[0]["isdel"].ToString());
                }
                model.toid = ds.Tables[0].Rows[0]["toid"].ToString();
                if (ds.Tables[0].Rows[0]["sid"].ToString() != "")
                {
                    model.sid = int.Parse(ds.Tables[0].Rows[0]["sid"].ToString());
                }
                model.identitycode = ds.Tables[0].Rows[0]["identitycode"].ToString();
                if (ds.Tables[0].Rows[0]["isEmploy"].ToString() != "")
                {
                    model.isEmploy = int.Parse(ds.Tables[0].Rows[0]["isEmploy"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(System.Model.facility_port model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update facility_port set ");

            strSql.Append(" fid = @fid , ");
            strSql.Append(" no = @no , ");
            strSql.Append(" qrimg = @qrimg , ");
            strSql.Append(" statuses = @statuses , ");
            strSql.Append(" pudate = @pudate , ");
            strSql.Append(" isdel = @isdel , ");
            strSql.Append(" toid = @toid , ");
            strSql.Append(" sid = @sid , ");
            strSql.Append(" identitycode = @identitycode , ");
            strSql.Append(" isEmploy = @isEmploy  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",           SqlDbType.Int,         4),
                new SqlParameter("@fid",          SqlDbType.Int,         4),
                new SqlParameter("@no",           SqlDbType.NVarChar,   50),
                new SqlParameter("@qrimg",        SqlDbType.NVarChar,  500),
                new SqlParameter("@statuses",     SqlDbType.Int,         4),
                new SqlParameter("@pudate",       SqlDbType.DateTime),
                new SqlParameter("@isdel",        SqlDbType.Int,         4),
                new SqlParameter("@toid",         SqlDbType.NVarChar,   50),
                new SqlParameter("@sid",          SqlDbType.Int,         4),
                new SqlParameter("@identitycode", SqlDbType.NVarChar,   50),
                new SqlParameter("@isEmploy",     SqlDbType.Int, 4)
            };

            parameters[0].Value  = model.id;
            parameters[1].Value  = model.fid;
            parameters[2].Value  = model.no;
            parameters[3].Value  = model.qrimg;
            parameters[4].Value  = model.statuses;
            parameters[5].Value  = model.pudate;
            parameters[6].Value  = model.isdel;
            parameters[7].Value  = model.toid;
            parameters[8].Value  = model.sid;
            parameters[9].Value  = model.identitycode;
            parameters[10].Value = model.isEmploy;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <System.Model.facility_port> DataTableToList(DataTable dt)
        {
            List <System.Model.facility_port> modelList = new List <System.Model.facility_port>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                System.Model.facility_port model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new System.Model.facility_port();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["fid"].ToString() != "")
                    {
                        model.fid = int.Parse(dt.Rows[n]["fid"].ToString());
                    }
                    model.no    = dt.Rows[n]["no"].ToString();
                    model.qrimg = dt.Rows[n]["qrimg"].ToString();
                    if (dt.Rows[n]["statuses"].ToString() != "")
                    {
                        model.statuses = int.Parse(dt.Rows[n]["statuses"].ToString());
                    }
                    if (dt.Rows[n]["pudate"].ToString() != "")
                    {
                        model.pudate = DateTime.Parse(dt.Rows[n]["pudate"].ToString());
                    }
                    if (dt.Rows[n]["isdel"].ToString() != "")
                    {
                        model.isdel = int.Parse(dt.Rows[n]["isdel"].ToString());
                    }
                    model.toid = dt.Rows[n]["toid"].ToString();
                    if (dt.Rows[n]["sid"].ToString() != "")
                    {
                        model.sid = int.Parse(dt.Rows[n]["sid"].ToString());
                    }
                    model.identitycode = dt.Rows[n]["identitycode"].ToString();
                    if (dt.Rows[n]["isEmploy"].ToString() != "")
                    {
                        model.isEmploy = int.Parse(dt.Rows[n]["isEmploy"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(System.Model.facility_port model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into facility_port(");
            strSql.Append("fid,no,qrimg,statuses,pudate,isdel,toid,sid,identitycode,isEmploy");
            strSql.Append(") values (");
            strSql.Append("@fid,@no,@qrimg,@statuses,@pudate,@isdel,@toid,@sid,@identitycode,@isEmploy");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fid",          SqlDbType.Int,         4),
                new SqlParameter("@no",           SqlDbType.NVarChar,   50),
                new SqlParameter("@qrimg",        SqlDbType.NVarChar,  500),
                new SqlParameter("@statuses",     SqlDbType.Int,         4),
                new SqlParameter("@pudate",       SqlDbType.DateTime),
                new SqlParameter("@isdel",        SqlDbType.Int,         4),
                new SqlParameter("@toid",         SqlDbType.NVarChar,   50),
                new SqlParameter("@sid",          SqlDbType.Int,         4),
                new SqlParameter("@identitycode", SqlDbType.NVarChar,   50),
                new SqlParameter("@isEmploy",     SqlDbType.Int, 4)
            };

            parameters[0].Value = model.fid;
            parameters[1].Value = model.no;
            parameters[2].Value = model.qrimg;
            parameters[3].Value = model.statuses;
            parameters[4].Value = model.pudate;
            parameters[5].Value = model.isdel;
            parameters[6].Value = model.toid;
            parameters[7].Value = model.sid;
            parameters[8].Value = model.identitycode;
            parameters[9].Value = model.isEmploy;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #5
0
        protected void btnBc_Click(object sender, EventArgs e)
        {
            try
            {
                string id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    System.Model.facility_port fs = _bll.fpbll.GetModel(Utility.Helper.gerInt(id));

                    if (fs != null)
                    {
                        fs.statuses = Utility.Helper.gerInt(this.ddlstatuses.SelectedValue);
                        fs.fid      = Utility.Helper.gerInt(this.facility.SelectedValue);
                        fs.sid      = Utility.Helper.gerInt(this.stipple.SelectedValue);

                        //string toid = fs.toid;
                        //fs.qrimg = Utility.QrImg.CreateCode_Simple("{'portid':'" + toid + "'}", Server.MapPath("/Upload/qr/"));

                        if (fs.identitycode == this.txtno.Text)
                        {
                            fs.identitycode = this.txtno.Text;
                            if (_bll.fpbll.Update(fs))
                            {
                                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑成功!');window.location.href='admin_port.aspx';", true);
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑失败!');window.location.href='admin_port.aspx';", true);
                            }
                        }
                        else
                        {
                            DataTable tab = bll.getDataSet(" select identitycode from facility_port where identitycode ='" + this.txtno.Text + "' ").Tables[0];
                            if (tab.Rows.Count == 0)
                            {
                                fs.identitycode = this.txtno.Text;
                                if (_bll.fpbll.Update(fs))
                                {
                                    ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑成功!');window.location.href='admin_port.aspx';", true);
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑失败!');window.location.href='admin_port.aspx';", true);
                                }
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑失败,充电枪标识已存在!');window.location.href='admin_port.aspx';", true);
                            }
                        }
                    }
                }
                else
                {
                    string strwheres = "  identitycode='" + this.txtno.Text + "' ";
                    List <System.Model.facility_port> fplist = _bll.fpbll.GetModelList(strwheres);
                    if (fplist.Count == 0)
                    {
                        string toid = System.Guid.NewGuid().ToString();
                        System.Model.facility_port fs = new System.Model.facility_port();
                        fs.statuses = Utility.Helper.gerInt(this.ddlstatuses.SelectedValue);
                        fs.fid      = Utility.Helper.gerInt(this.facility.SelectedValue);
                        int nos = _bll.fpbll.GetMaxId();
                        fs.no           = (100000000 + 1 + nos).ToString();
                        fs.toid         = toid;
                        fs.sid          = Utility.Helper.gerInt(this.stipple.SelectedValue);
                        fs.qrimg        = Utility.QrImg.CreateCode_Simple("{'portid':'" + toid + "'}", Server.MapPath("/Upload/qr/"));
                        fs.identitycode = this.txtno.Text;
                        fs.isdel        = 0;
                        fs.pudate       = System.DateTime.Now;
                        if (_bll.fpbll.Add(fs) > 0)
                        {
                            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('添加成功!');window.location.href='admin_port.aspx';", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('添加失败!');window.location.href='admin_port.aspx';", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('充电枪标识已存在!');window.location.href='admin_port.aspx';", true);
                    }
                }
            }
            catch
            {
                Response.Redirect(ConfigurationManager.AppSettings["VirturlPath"] + "/error500.aspx?menu1=2&menu2=4");
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string res = "";


            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(this.Request.InputStream);
                System.Xml.XmlNodeList nodelist = doc.SelectNodes("//xml");//匹配所有xml节点

                //errordetail = doc.InnerXml;
                if (nodelist.Count > 0)
                {
                    System.Xml.XmlNode msgNode = nodelist[0];
                    if (msgNode != null)
                    {
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        //请在这里加上商户的业务逻辑程序代码


                        //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——

                        //交易状态
                        string result = msgNode.SelectSingleNode("return_code").InnerText;
                        if (result == "SUCCESS")
                        {
                            //判断该笔订单是否在商户网站中已经做过处理
                            //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                            //如果有做过处理,不执行商户的业务程序

                            //商户订单号
                            string out_trade_no = msgNode.SelectSingleNode("out_trade_no").InnerText;

                            //微信交易号
                            string trade_no = msgNode.SelectSingleNode("transaction_id").InnerText;

                            lock (lockWechatPayObj)
                            {
                                //查询支付订单是否支付
                                string strwhere = " serialNumber='" + out_trade_no + "' and paystatus=1 ";

                                List <System.Model.Member_Charge_Withdraw> mcwlist = _bll.mcwbll.GetModelList(strwhere);

                                if (mcwlist.Count == 1)
                                {
                                    System.Model.Member_Charge_Withdraw mcw = mcwlist[0];

                                    mcw.paydate        = System.DateTime.Now.ToString();
                                    mcw.paystatus      = 2;
                                    mcw.paytype        = 2;//微信
                                    mcw.statusname     = "已支付";
                                    mcw.typename       = "微信";
                                    mcw.tpSerialNumber = trade_no;
                                    _bll.mcwbll.Update(mcw);

                                    //订单付款
                                    if (mcw.types == 1)
                                    {
                                        strwhere = " serialNumber='" + out_trade_no + "'  ";

                                        List <System.Model.order_info> oilist = _bll.oibll.GetModelList(strwhere);

                                        if (oilist.Count == 1)
                                        {
                                            System.Model.order_info oi = oilist[0];
                                            oi.statuses = 2;
                                            _bll.oibll.Update(oi);
                                            //锁定设备
                                            System.Model.facility_port ports = _bll.fpbll.GetModel(oi.port);
                                            ports.isEmploy = 1;
                                            _bll.fpbll.Update(ports);
                                            //通知设备开始充电
                                            System.Model.facility fa = _bll.fbll.GetModel(oi.facility);
                                            open.opens(fa.identitycode, ports.identitycode, oi.customid, out_trade_no);
                                        }
                                        else
                                        {
                                        }
                                    }
                                    //充值

                                    //
                                }
                                else
                                {
                                    //订单未找到或者已支付
                                }
                            }
                        }
                        else
                        {
                        }
                        //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    }
                    else//验证失败
                    {
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
            }
            Response.Write(res);
        }
コード例 #7
0
        /// <summary>
        /// 返回结果
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string   res        = "";
                JsonData jsonResult = new JsonData();
                try
                {
                    //结果类型
                    string resulttype = Request["resulttype"] != null?Utility.Helper.Checkstr(Request["resulttype"]) : "";

                    //结果
                    string result = Request["result"] != null?Utility.Helper.Checkstr(Request["result"]) : "";

                    //标识
                    string identify = Request["identify"] != null?Utility.Helper.Checkstr(Request["identify"]) : "";

                    //接口标识
                    string requestCode = Request["requetCode"] != null?Utility.Helper.Checkstr(Request["requetCode"]) : "";

                    //requestCode = Request.Form.ToString();
                    //
                    //log.setlog("地址", Request.Url.ToString());
                    //log.setlog("地址", Request.RawUrl);
                    #region 提供服务回调

                    if (!string.IsNullOrEmpty(resulttype) && !string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(identify))
                    {
                        log.setlog("服务回调", "resulttype:" + resulttype + "  result:" + result + "  identify:" + identify + "  requestCode:" + requestCode);



                        //标识
                        string             resultNO = result;
                        List <checkStatus> sd       = publicData.orderlist;
                        log.setlog("静态变量数据量", sd.Count.ToString());

                        try
                        {
                            if (sd.Count > 0)
                            {
                                sd = (from s in sd
                                      where s.identifying == requestCode
                                      select s).ToList();



                                if (sd.Count > 0)
                                {
                                    checkStatus sd_0 = sd[0];
                                    if (sd_0.types == 0)
                                    {
                                        #region 自检结果

                                        string customId = sd_0.customId;
                                        System.Model.facility_port fp = _bll.fpbll.GetModel(sd_0.portid);

                                        System.Model.facility_stipple fs = new System.Model.facility_stipple();
                                        System.Model.facility         fa = new System.Model.facility();

                                        if (resultNO == "2")
                                        //if (resultNO == "0")
                                        //if (true)
                                        {
                                            fa = _bll.fbll.GetModel(sd[0].facilityid);

                                            //查询网点
                                            fs = _bll.fsbll.GetModel(fa.fid);
                                            //查询设备 折扣
                                            System.Model.facility_type ftype = _bll.ftbll.GetModel(fa.types);

                                            //生成订单
                                            string serialNumber = System.DateTime.Now.ToString("yyyyMMddHHmmss") + Utility.Helper.rnds(8);
                                            //折后价
                                            decimal prices = ftype.price * ftype.discount;

                                            System.Model.order_info oi = new System.Model.order_info();

                                            oi.customid     = customId;
                                            oi.serialNumber = serialNumber;
                                            oi.discount     = ftype.discount;

                                            oi.price = prices;

                                            oi.port      = fp.id;
                                            oi.pudate    = System.DateTime.Now;
                                            oi.statuses  = 1;
                                            oi.facility  = Utility.Helper.gerInt(fa.id);
                                            oi.duration  = ftype.time;
                                            oi.stippleid = fs.id;
                                            oi.types     = 1;//1快充
                                            if (_bll.oibll.Add(oi) > 0)
                                            {
                                                //生成支付信息

                                                System.Model.Member_Charge_Withdraw mcw = new System.Model.Member_Charge_Withdraw();

                                                mcw.memberid     = customId;
                                                mcw.moneyes      = prices;
                                                mcw.serialNumber = serialNumber;
                                                mcw.paystatus    = 1;
                                                mcw.statusname   = "未支付";
                                                //mcw.paytype = "";//支付方式 支付宝 微信 钱包
                                                //paystatus 1 未支付 2已支付
                                                //types  1订单 2充值 3......
                                                mcw.types  = 1;
                                                mcw.pudate = System.DateTime.Now;
                                                if (_bll.mcwbll.Add(mcw) > 0)
                                                {
                                                    for (int i = 0; i < publicData.orderlist.Count; i++)
                                                    {
                                                        if (publicData.orderlist[i].identifying == requestCode)
                                                        {
                                                            publicData.orderlist[i].orderid = serialNumber;
                                                            log.setlog("订单产生成功", publicData.orderlist[i].orderid);
                                                        }
                                                    }
                                                    //jsonResult["res"] = (int)MyEnum.ResultEnum.成功;
                                                    //jsonResult["msg"] = "下单成功";
                                                    //jsonResult["code"] = "";
                                                    //
                                                    //jsonResult["stipplename"] = fs.name;
                                                    //jsonResult["servertype"] = "快充";
                                                    //jsonResult["price"] = Math.Round(prices, 2).ToString();
                                                    //jsonResult["serialnumber"] = serialNumber;//订单号
                                                }
                                                else
                                                {
                                                    //jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                                    //jsonResult["msg"] = "错误";
                                                    //jsonResult["code"] = "下单失败";
                                                }
                                            }
                                            else
                                            {
                                                //jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                                //jsonResult["msg"] = "错误";
                                                //jsonResult["code"] = "下单失败";
                                            }
                                        }
                                        else
                                        {
                                            //错误
                                            //添加自检错误记录
                                            //
                                            System.Model.self_test st = new System.Model.self_test();

                                            string name = "";
                                            string typeno;
                                            switch (resultNO)
                                            {
                                            case "0":
                                                name   = "正常";
                                                typeno = "0";
                                                break;

                                            case "2":
                                                name   = "充电桩和充电枪运行正常";
                                                typeno = "2";
                                                break;

                                            case "3":
                                                name   = "充电桩运行异常";
                                                typeno = "3";
                                                break;

                                            case "4":
                                                name   = "充电枪运行异常";
                                                typeno = "4";
                                                break;

                                            case "5":
                                                name   = "外网电压工作异常";
                                                typeno = "5";
                                                break;

                                            case "6":
                                                name   = "电池工作不正常";
                                                typeno = "6";
                                                break;

                                            case "7":
                                                name   = "充电枪与电池接触良";
                                                typeno = "7";
                                                break;

                                            default:
                                                name   = "系统未知错误";
                                                typeno = "xxxx";
                                                break;
                                            }

                                            st.facility  = Utility.Helper.gerInt(fa.id);
                                            st.isdispose = 0;
                                            st.port      = Utility.Helper.gerInt(fp.fid);
                                            st.errortype = "1";
                                            st.stipple   = Utility.Helper.gerInt(fs.id);
                                            st.pudate    = System.DateTime.Now;
                                            _bll.stbll.Add(st);


                                            //jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                            //jsonResult["msg"] = "设备故障";
                                            //jsonResult["code"] = "设备故障";
                                        }



                                        #endregion
                                    }
                                    else if (sd_0.types == 1)
                                    {
                                        #region 充电是否开始

                                        if (!string.IsNullOrEmpty(sd_0.orderid))
                                        {
                                            //修改订单充电状态
                                            //开始充电
                                            string strwhere = " serialNumber='" + sd_0.orderid + "'  ";

                                            List <System.Model.order_info> oilist = _bll.oibll.GetModelList(strwhere);

                                            if (oilist.Count == 1)
                                            {
                                                System.Model.order_info oi = oilist[0];
                                                oi.statuses = 2;//充电中
                                                _bll.oibll.Update(oi);
                                            }
                                            else
                                            {
                                            }
                                        }
                                        #endregion
                                    }
                                    else if (sd_0.types == 2)
                                    {
                                        #region 充电是否结束

                                        if (!string.IsNullOrEmpty(sd_0.orderid))
                                        {
                                            //修改订单充电状态
                                            //结束充电
                                            string strwhere = " serialNumber='" + sd_0.orderid + "'  ";

                                            List <System.Model.order_info> oilist = _bll.oibll.GetModelList(strwhere);
                                            if (oilist.Count == 1)
                                            {
                                                System.Model.order_info oi = oilist[0];
                                                oi.statuses = 3;//已完成充电
                                                _bll.oibll.Update(oi);
                                            }
                                            else
                                            {
                                            }
                                        }

                                        #endregion
                                    }
                                    else if (sd_0.types == 3)
                                    {
                                        #region 系统故障类型

                                        #endregion
                                    }
                                    else if (sd_0.types == 4)
                                    {
                                        #region 充电数据


                                        #endregion
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            log.setlog("错误", ex.Message);
                        }
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.成功;
                        jsonResult["msg"]  = "";
                        jsonResult["code"] = "";
                    }
                    else
                    {
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                        jsonResult["msg"]  = "";
                        jsonResult["code"] = "参数缺失";
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    jsonResult["result"] = (int)MyEnum.ResultEnum.系统错误;
                    jsonResult["msg"]    = "服务器繁忙,请稍后再试";
                    jsonResult["code"]   = ex.Message;
                    log.setlog("错误", ex.Message);
                }
                res = JsonMapper.ToJson(jsonResult);
                res = MyString.UnicodeToString(res);
                Response.Write(res);
            }
        }
コード例 #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(System.Model.facility_port model)
 {
     return(dal.Update(model));
 }
コード例 #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(System.Model.facility_port model)
 {
     return(dal.Add(model));
 }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //log.setlog("", "回调成功");
            try
            {
                SortedDictionary <string, string> sPara = GetRequestPost();

                if (sPara.Count > 0)//判断是否有带返回参数
                {
                    Notify aliNotify = new Notify();
                    //bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);
                    bool verifyResult = AlipaySignature.RSACheckV1(sPara, Com.Alipay.Config.Public_key, "UTF-8", Config.Sign_type, false);
                    //log.setlog("是否回调成功", verifyResult.ToString());
                    if (verifyResult)//验证成功
                    {
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        //请在这里加上商户的业务逻辑程序代码


                        //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                        //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                        //商户订单号

                        string out_trade_no = Request.Form["out_trade_no"];

                        //支付宝交易号

                        string trade_no = Request.Form["trade_no"];

                        //支付的金额
                        string price = Request.Form["price"];

                        //交易状态
                        string trade_status = Request.Form["trade_status"];


                        //log.setlog("支付信息", trade_no + "---" + price + "---" + out_trade_no + "---" + trade_status);


                        lock (lockAlipayObj)
                        {
                            if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                            {
                                //查询支付订单是否支付
                                string strwhere = " serialNumber='" + out_trade_no + "' and paystatus=1 ";

                                List <System.Model.Member_Charge_Withdraw> mcwlist = _bll.mcwbll.GetModelList(strwhere);

                                if (mcwlist.Count == 1)
                                {
                                    System.Model.Member_Charge_Withdraw mcw = mcwlist[0];

                                    mcw.paydate        = System.DateTime.Now.ToString();
                                    mcw.paystatus      = 2;
                                    mcw.paytype        = 1;
                                    mcw.statusname     = "已支付";
                                    mcw.typename       = "支付宝";
                                    mcw.tpSerialNumber = trade_no;
                                    _bll.mcwbll.Update(mcw);


                                    //订单付款
                                    if (mcw.types == 1)
                                    {
                                        strwhere = " serialNumber='" + out_trade_no + "'  ";

                                        List <System.Model.order_info> oilist = _bll.oibll.GetModelList(strwhere);

                                        if (oilist.Count == 1)
                                        {
                                            System.Model.order_info oi = oilist[0];
                                            oi.statuses = 2;
                                            _bll.oibll.Update(oi);
                                            //锁定设备
                                            System.Model.facility_port ports = _bll.fpbll.GetModel(oi.port);
                                            ports.isEmploy = 1;
                                            _bll.fpbll.Update(ports);

                                            //通知设备开始充电
                                            System.Model.facility fa = _bll.fbll.GetModel(oi.facility);
                                            open.opens(fa.identitycode, ports.identitycode, oi.customid, out_trade_no);
                                        }
                                        else
                                        {
                                        }
                                    }
                                    //充值

                                    //
                                }
                                else
                                {
                                    //订单未找到或者已支付
                                }


                                //查询是否支付

                                //查询 订单是否支付

                                //修改订单状态

                                //业务逻辑

                                //判断该笔订单是否在商户网站中已经做过处理
                                //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                                //如果有做过处理,不执行商户的业务程序

                                //注意:
                                //该种交易状态只在两种情况下出现
                                //1、开通了普通即时到账,买家付款成功后。
                                //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。
                            }
                            else if (Request.Form["trade_status"] == "TRADE_SUCCESS")
                            {
                                //判断该笔订单是否在商户网站中已经做过处理
                                //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                                //如果有做过处理,不执行商户的业务程序

                                //注意:
                                //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。

                                //log.setlog("B", "");
                            }
                            else
                            {
                                //log.setlog("C", "");
                            }
                        }

                        //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                        Response.Write("success");  //请不要修改或删除

                        //ms.Dispose();

                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    }
                    else//验证失败
                    {
                        Response.Write("fail");
                    }
                }
                else
                {
                    Response.Write("无通知参数");
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #11
0
        //开始扫一扫
        protected void Page_Load(object sender, EventArgs e)
        {
            //网点id
            //string stippleid = Request["stippleid"] != null ? Utility.Helper.Checkstr(Request["stippleid"]) : "";
            //设备id
            //string facilityid = Request["facilityid"] != null ? Utility.Helper.Checkstr(Request["stippleid"]) : "";

            //网点编号
            //string stippleno = Request["stippleno"] != null ? Utility.Helper.Checkstr(Request["stippleno"]) : "";
            //设备编号
            //string facilityno = Request["facilityno"] != null ? Utility.Helper.Checkstr(Request["facilityno"]) : "";
            //接口编号
            //string portno = Request["portno"] != null ? Utility.Helper.Checkstr(Request["portno"]) : "";

            if (!IsPostBack)
            {
                string   res        = "";
                JsonData jsonResult = new JsonData();
                try
                {
                    //接口id
                    string portid = Request["portid"] != null?Utility.Helper.Checkstr(Request["portid"]) : "";


                    //用户编号
                    string customId = _bll.getUserToke(Utility.Helper.gerString(Request["memberid"]));

                    #region 扫一扫
                    if (!string.IsNullOrEmpty(customId))
                    {
                        //充电中的 3天以内的订单
                        string strwhere = " customid='" + customId + "' and statuses=2  and pudate >DATEADD( DAY,-1,GETDATE()) ";
                        List <System.Model.order_info> orlist = _bll.oibll.GetModelList(strwhere);
                        //没有以上条件订单的用户可以下单
                        if (orlist.Count == 0)
                        {
                            //接口
                            System.Model.facility_port fp = new System.Model.facility_port();
                            //设备
                            System.Model.facility fa = new System.Model.facility();
                            //网点
                            System.Model.facility_stipple fs = new System.Model.facility_stipple();

                            strwhere = " toid='" + portid + "' and isdel=0  ";
                            List <System.Model.facility_port> fplist = _bll.fpbll.GetModelList(strwhere);

                            if (fplist.Count > 0)
                            {
                                fp = fplist[0];

                                #region 获取充电桩设备数据信息,验证
                                //正常  充电设备正常并且设备没有被使用
                                if (fp != null && fp.isEmploy == 0)
                                {
                                    fa = _bll.fbll.GetModel(fp.fid);
                                    if (fa != null)
                                    {
                                        #region 检测设备是否正常
                                        bool isUsable = false;

                                        //调用设备检测接口
                                        var    manager = new ApiManager();
                                        string jsonstr = manager.GetChargingPileInfo(fa.identitycode);

                                        ChargingPileStatusResult jsond = JsonMapper.ToObject <ChargingPileStatusResult>(jsonstr);
                                        if (jsond != null)
                                        {
                                            List <RechargShotStatusResult> statuslist = jsond.RechargeShotStatus;

                                            statuslist = (from s in statuslist
                                                          where s.Identity == fp.identitycode
                                                          select s).ToList();

                                            if (statuslist.Count > 0 && Convert.ToInt32(statuslist[0].Status) == Convert.ToInt32(RunningStatus.OnLine))
                                            {
                                                #region 发送设备自检
                                                //发送设备自检
                                                var dic = new Dictionary <string, string>();
                                                dic.Add("ShotIndentity", fp.identitycode);
                                                var parsStr       = JsonConvert.SerializeObject(dic);
                                                var selfTestModel = new CommandPostViewModel();
                                                selfTestModel.CommandName    = "SelfTest";
                                                selfTestModel.TargetIdentity = fa.identitycode;
                                                selfTestModel.Pars           = parsStr;

                                                //添加标识
                                                checkStatus cs = new checkStatus();
                                                //自检编号
                                                cs.identifying = manager.PostCommand(selfTestModel).Replace("\"", "");
                                                //状态
                                                cs.status = false;
                                                //类型
                                                cs.types = 0;
                                                //是否产生订单
                                                cs.orderid  = "";
                                                cs.datetime = System.DateTime.Now;

                                                cs.portid     = fp.id;
                                                cs.porttoid   = fp.toid;
                                                cs.facilityid = fp.fid;
                                                cs.customId   = customId;
                                                //log.setlog("设备自检", cs.identifying);
                                                publicData.orderlist.Add(cs);

                                                isUsable = true;

                                                //等待回调

                                                #endregion

                                                jsonResult["res"]         = (int)MyEnum.ResultEnum.成功;
                                                jsonResult["identifying"] = cs.identifying;
                                                jsonResult["msg"]         = "发送自检成功";
                                                jsonResult["code"]        = "发送自检成功";
                                            }
                                            else
                                            {
                                                jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                                                jsonResult["msg"]  = "错误";
                                                jsonResult["code"] = "自检失败";
                                            }
                                        }
                                        else
                                        {
                                            jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                                            jsonResult["msg"]  = "错误";
                                            jsonResult["code"] = "自检失败";
                                        }

                                        #endregion


                                        //返回设备自检标示

                                        #region 注释
                                        //if (isUsable)
                                        //{
                                        //    //查询网点
                                        //    fs = _bll.fsbll.GetModel(fa.fid);
                                        //    //查询设备 折扣
                                        //    System.Model.facility_type ftype = _bll.ftbll.GetModel(fa.types);
                                        //
                                        //    //生成订单
                                        //    string serialNumber = System.DateTime.Now.ToString("yyyyMMddHHmmss") + Utility.Helper.rnds(8);
                                        //    //折后价
                                        //    decimal prices = ftype.price * ftype.discount;
                                        //
                                        //    System.Model.order_info oi = new System.Model.order_info();
                                        //
                                        //    oi.customid = customId;
                                        //    oi.serialNumber = serialNumber;
                                        //    oi.discount = ftype.discount;
                                        //
                                        //    oi.price = prices;
                                        //
                                        //    oi.port = fp.id;
                                        //    oi.pudate = System.DateTime.Now;
                                        //    oi.statuses = 1;
                                        //    oi.facility = Utility.Helper.gerInt(fa.id);
                                        //    oi.duration = ftype.time;
                                        //    oi.stippleid = fs.id;
                                        //    oi.types = 1;//1快充
                                        //    if (_bll.oibll.Add(oi) > 0)
                                        //    {
                                        //        //生成支付信息
                                        //
                                        //        System.Model.Member_Charge_Withdraw mcw = new System.Model.Member_Charge_Withdraw();
                                        //
                                        //        mcw.memberid = customId;
                                        //        mcw.moneyes = prices;
                                        //        mcw.serialNumber = serialNumber;
                                        //        mcw.paystatus = 1;
                                        //        mcw.statusname = "未支付";
                                        //        //mcw.paytype = "";//支付方式 支付宝 微信 钱包
                                        //        //paystatus 1 未支付 2已支付
                                        //        //types  1订单 2充值 3......
                                        //        mcw.types = 1;
                                        //        mcw.pudate = System.DateTime.Now;
                                        //        if (_bll.mcwbll.Add(mcw) > 0)
                                        //        {
                                        //            jsonResult["res"] = (int)MyEnum.ResultEnum.成功;
                                        //            jsonResult["msg"] = "下单成功";
                                        //            jsonResult["code"] = "";
                                        //
                                        //            jsonResult["stipplename"] = fs.name;
                                        //            jsonResult["servertype"] = "快充";
                                        //            jsonResult["price"] = Math.Round(prices, 2).ToString();
                                        //            jsonResult["serialnumber"] = serialNumber;//订单号
                                        //        }
                                        //        else
                                        //        {
                                        //            jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                        //            jsonResult["msg"] = "错误";
                                        //            jsonResult["code"] = "下单失败";
                                        //        }
                                        //    }
                                        //    else
                                        //    {
                                        //        jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                        //        jsonResult["msg"] = "错误";
                                        //        jsonResult["code"] = "下单失败";
                                        //    }
                                        //}
                                        //else
                                        //{
                                        //    //错误
                                        //    //添加自检错误记录
                                        //    //
                                        //    System.Model.self_test st = new System.Model.self_test();
                                        //
                                        //    st.ername = "";
                                        //    st.errortype = "";
                                        //    st.facility = Utility.Helper.gerInt(fa.id);
                                        //    st.isdispose = 0;
                                        //    st.port = Utility.Helper.gerInt(portid);
                                        //    st.errortype = "1";
                                        //    st.stipple = Utility.Helper.gerInt(fs.id);
                                        //    st.pudate = System.DateTime.Now;
                                        //    _bll.stbll.Add(st);
                                        //
                                        //
                                        //    jsonResult["res"] = (int)MyEnum.ResultEnum.失败;
                                        //    jsonResult["msg"] = "设备故障";
                                        //    jsonResult["code"] = "设备故障";
                                        //}
                                        #endregion
                                    }
                                    else
                                    {
                                        jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                                        jsonResult["msg"]  = "错误";
                                        jsonResult["code"] = "自检失败";
                                    }
                                }
                                else
                                {
                                    jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                                    jsonResult["msg"]  = "设备故障或设备已被使用";
                                    jsonResult["code"] = "设备故障或设备已被使用";
                                }
                                #endregion

                                //提示支付
                            }
                            else
                            {
                                jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                                jsonResult["msg"]  = "设备已不可用";
                                jsonResult["code"] = "未找到该设备信息";
                            }
                        }
                        else
                        {
                            jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                            jsonResult["msg"]  = "用户有订单未完成";
                            jsonResult["code"] = "";
                        }
                    }
                    else
                    {
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                        jsonResult["msg"]  = "错误";
                        jsonResult["code"] = "参数有误";
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    jsonResult["res"]  = (int)MyEnum.ResultEnum.系统错误;
                    jsonResult["msg"]  = "服务器繁忙,请稍后再试";
                    jsonResult["code"] = ex.Message;
                }
                res = JsonMapper.ToJson(jsonResult);
                res = MyString.UnicodeToString(res);
                Response.Write(res);
            }
        }
コード例 #12
0
        /// <summary>
        /// 设备列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string   res        = "";
                JsonData jsonResult = new JsonData();
                try
                {
                    //设备nodeid
                    string nodeid = Request["nodeid"] != null?Utility.Helper.Checkstr(Request["nodeid"]) : "";

                    #region 提供设备信息

                    if (!string.IsNullOrEmpty(nodeid))
                    {
                        string strwhere = " no='" + nodeid + "' ";

                        List <System.Model.facility> flist = _bll.fbll.GetModelList(strwhere);


                        if (flist.Count == 1)
                        {
                            System.Model.facility fac = flist[0];

                            jsonResult["res"]          = (int)MyEnum.ResultEnum.成功;
                            jsonResult["msg"]          = "";
                            jsonResult["code"]         = "";
                            jsonResult["nodeid"]       = fac.no;
                            jsonResult["identitycode"] = fac.identitycode;

                            jsonResult["port"] = JsonMapper.ToObject("[]");

                            strwhere = " fid=" + fac.id + " order by id asc ";

                            List <System.Model.facility_port> fplist = _bll.fpbll.GetModelList(strwhere);
                            if (fplist.Count > 0)
                            {
                                JsonData jsonport = new JsonData();
                                for (int i = 0; i < fplist.Count; i++)
                                {
                                    JsonData json = new JsonData();
                                    System.Model.facility_port fp = fplist[i];

                                    json["index"]        = i + 1;
                                    json["identitycode"] = fp.identitycode;
                                    json["qrimg"]        = "{'portid':'" + fp.toid + "'}";
                                    jsonport.Add(json);
                                }

                                jsonResult["port"] = jsonport;
                            }
                        }
                        else
                        {
                            jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                            jsonResult["msg"]  = "未找到该设备";
                            jsonResult["code"] = "设备信息异常";
                        }
                    }
                    else
                    {
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                        jsonResult["msg"]  = "";
                        jsonResult["code"] = "参数缺失";
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    jsonResult["result"] = (int)MyEnum.ResultEnum.系统错误;
                    jsonResult["msg"]    = "服务器繁忙,请稍后再试";
                    jsonResult["code"]   = ex.Message;
                }
                res = JsonMapper.ToJson(jsonResult);
                res = MyString.UnicodeToString(res);
                Response.Write(res);
            }
        }