Пример #1
0
    /// <summary>
    /// 订单信息
    /// </summary>
    public void databind()
    {
        if (KeyID != 0)
        {
            //判断改该条数据代理商是否有操作权限
            if (!Common.PageDisOperable("Order", KeyID, DisID))
            {
                Response.Redirect("../NoOperable.aspx");
                return;
            }
            hidOrderID.Value = Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey);

            string where = "and isnull(o.dr,0)=0 and o.otype<>9 and o.DisID=" + DisID + " and o.ID= " + KeyID;

            DataTable dt = new Hi.BLL.DIS_Order().GetList("", where);

            if (dt != null && dt.Rows.Count > 0)
            {
                //再次购买
                buyagain.Visible = false;
                //订单修改
                modifyorder.Visible = false;
                //订单作废
                ordervoid.Visible = false;
                //申请退货
                //orderReturn.Visible = false;

                Digits = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", dt.Rows[0]["CompID"].ToString().ToInt(0));

                IsShow = OrderInfoType.rdoOrderAudit("订单明细是否显示店铺商品", 0).ToInt(0);
                IsInve = OrderInfoType.rdoOrderAudit("商品是否启用库存", dt.Rows[0]["CompID"].ToString().ToInt(0)).ToInt(0);

                hidDigits.Value = Digits;

                isbate = OrderInfoType.rdoOrderAudit("订单支付返利是否启用", dt.Rows[0]["CompID"].ToString().ToInt(0)).ToInt(0);
                if (isbate == 0)
                {
                    if (dt.Rows[0]["bateAmount"].ToString() == "" || dt.Rows[0]["bateAmount"].ToString() == "0.00")
                    {
                        this.trbate.Visible = false;
                        this.rebate.Visible = false;
                    }
                }

                // 订单编号
                lblReceiptNo.InnerText  = dt.Rows[0]["ReceiptNo"].ToString();
                lblCreateDate.InnerText = dt.Rows[0]["CreateDate"].ToString().ToDateTime().ToString("yyyy-MM-dd");
                lblOstate.InnerText     = OrderType.GetOState(dt.Rows[0]["OState"].ToString(), dt.Rows[0]["IsOutState"].ToString());
                hidOstate.Value         = dt.Rows[0]["OState"].ToString();

                lblCompID.InnerText = Common.Getcom(dt.Rows[0]["CompID"].ToString().ToInt(0), "CompName");
                orderCompId         = Convert.ToString(dt.Rows[0]["CompID"]);

                hidIsOutstate.Value = dt.Rows[0]["IsOutState"].ToString();

                OState       = dt.Rows[0]["OState"].ToString().ToInt(0);
                IsOutState   = dt.Rows[0]["IsOutState"].ToString().ToInt(0);
                payState     = dt.Rows[0]["PayState"].ToString().ToInt(0);
                ReturnState  = dt.Rows[0]["ReturnState"].ToString().ToInt(0);
                hidDts.Value = dt.Rows[0]["ts"].ToString();

                //订单流程
                lblTotalAmount.InnerText = dt.Rows[0]["TotalAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["TotalAmount"].ToString().ToDecimal().ToString("N");
                lblProAmount.InnerText   = dt.Rows[0]["ProAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["ProAmount"].ToString().ToDecimal().ToString("N");

                lblbateAmount.InnerText = dt.Rows[0]["bateAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["bateAmount"].ToString().ToDecimal().ToString("N");
                lblbate.InnerText       = dt.Rows[0]["bateAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["bateAmount"].ToString().ToDecimal().ToString("N");

                lblPostFee.InnerText     = dt.Rows[0]["PostFee"].ToString() == "" ? "0.00" : dt.Rows[0]["PostFee"].ToString().ToDecimal().ToString("0.00");
                lblAuditAmount.InnerText = dt.Rows[0]["AuditAmount"].ToString() == "" ? "0.00" : dt.Rows[0]["AuditAmount"].ToString().ToDecimal().ToString("N");

                //下单信息
                lblArriveDate.InnerText = dt.Rows[0]["ArriveDate"].ToString() == "" ? "" : dt.Rows[0]["ArriveDate"].ToString().ToDateTime().ToString("yyyy-MM-dd");
                lblGiveMode.InnerText   = dt.Rows[0]["GiveMode"].ToString();
                iRemark.InnerText       = dt.Rows[0]["Remark"].ToString();

                //收货地址
                lblPrincipal.InnerText = dt.Rows[0]["Principal"].ToString();
                lblPhone.InnerText     = dt.Rows[0]["Phone"].ToString();
                lblAddress.InnerText   = dt.Rows[0]["Address"].ToString();
                hidAddrID.Value        = dt.Rows[0]["AddrID"].ToString();

                //开票信息
                if (dt.Rows[0]["IsOBill"].ToString().ToInt(0) > 0)
                {
                    hidDisAccID.Value = dt.Rows[0]["DisAccID"].ToString();
                    hidval.Value      = dt.Rows[0]["IsOBill"].ToString();
                    string Billing = string.Empty;
                    Billing += "发票抬头:<label id=\"lblRise\" runat=\"server\">" + dt.Rows[0]["Rise"].ToString() + "</label>";
                    Billing += ",发票内容:<label id=\"lblContent\" runat=\"server\">" + dt.Rows[0]["Content"].ToString() + "</label>";
                    if (dt.Rows[0]["IsOBill"].ToString().ToInt(0) == 2)
                    {
                        Billing += ",开户银行:<label id=\"lblOBank\" runat=\"server\">" + dt.Rows[0]["OBank"].ToString() + "</label>";
                        Billing += ",开户账户:<label id=\"lblOAccount\" runat=\"server\">" + dt.Rows[0]["OAccount"].ToString() + "</label>";
                        Billing += ",纳税人登记号:<label id=\"lblTRNumber\" runat=\"server\">" + dt.Rows[0]["TRNumber"].ToString() + "</label>";
                    }
                    else
                    {
                        Billing += ",纳税人登记号:<label id=\"lblTRNumber\" runat=\"server\">" + dt.Rows[0]["TRNumber"].ToString() + "</label>";
                    }
                    iInvoice.InnerHtml = Billing;

                    //lblRise.InnerText = dt.Rows[0]["Rise"].ToString();
                    //lblContent.InnerText = dt.Rows[0]["Content"].ToString();
                    //lblOBank.InnerText = dt.Rows[0]["OBank"].ToString();
                    //lblOAccount.InnerText = dt.Rows[0]["OAccount"].ToString();
                    //lblTRNumber.InnerText = dt.Rows[0]["TRNumber"].ToString();
                }
                else
                {
                    this.iInvoice.InnerHtml = "不开发票";
                }

                //发票信息
                lblBillNo.InnerText  = dt.Rows[0]["BillNo"].ToString();
                lblIsBill.InnerText  = dt.Rows[0]["IsBill"].ToString() == "1" ? "是" : "否";
                this.hidisBill.Value = dt.Rows[0]["IsBill"].ToString();


                string msg  = string.Empty;
                bool   flag = Common.FCan(dt.Rows[0]["DisID"].ToString(), "1", out msg);
                if (flag)
                {
                    this.lblmsg.InnerText = msg;
                }

                decimal nopayAmount = OrderInfoType.GetSumAmount(dt.Rows[0]["DisID"].ToString(), dt.Rows[0]["CompID"].ToString(), KeyID);
                if (nopayAmount > 0)
                {
                    string promptmsg = "订单待支付金额为¥" + nopayAmount.ToString("0.00") + ",请尽快支付";
                    this.lblPrompt.InnerText = promptmsg;
                }
                else
                {
                    this.lblPrompt.Visible = false;
                }


                #region  订单支付信息

                TotalAmount = Convert.ToDecimal(dt.Rows[0]["AuditAmount"]).ToString("0.00");
                PayedAmount = Convert.ToDecimal(dt.Rows[0]["PayedAmount"]).ToString("0.00");

                //订单已支付不显示支付按钮(未审核、未支付完成)
                if (Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.未提交 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.待审核 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.待审核 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.已退货 || Convert.ToInt32(dt.Rows[0]["OState"]) == (int)Enums.OrderState.已作废 || (Convert.ToDecimal(dt.Rows[0]["AuditAmount"]) - Convert.ToDecimal(dt.Rows[0]["PayedAmount"]) == 0))
                {
                    btn_pay.Visible = false;
                }
                paymoney = (Convert.ToDecimal(dt.Rows[0]["AuditAmount"]) - Convert.ToDecimal(dt.Rows[0]["PayedAmount"])).ToString("0.00");

                //加密keyId
                desKeyID.Value = Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey);

                //绑定支付流水信息
                DataTable paytable = new Hi.BLL.PAY_PrePayment().GetPayedItem(KeyID);
                rptmessage.DataSource = paytable;
                rptmessage.DataBind();

                //初始值加载
                txtArriveDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
                DataTable dtpayment = new Hi.BLL.PAY_PrePayment().GetDate(" top 1   CreateDate, payName ,paycode ,paybank", "pay_payment", " DisID=" + DisID + " and vdef3=5 order by  CreateDate desc");
                foreach (DataRow dr in dtpayment.Rows)
                {
                    bankname.Value = Convert.ToString(dr["payName"]);
                    bankcode.Value = Convert.ToString(dr["paycode"]);
                    bank.Value     = Convert.ToString(dr["paybank"]);
                }


                //附件
                //if (dt.Rows[0]["Atta"].ToString() != "")
                //{
                //    StringBuilder li = new StringBuilder();
                //    string[] atta = dt.Rows[0]["Atta"].ToString().Split(new string[] { "$$&&" }, StringSplitOptions.RemoveEmptyEntries);
                //    if (atta.Length > 0)
                //    {
                //        foreach (var item in atta)
                //        {
                //            li.AppendFormat("<li> <a href=\"javascript:;\" class=\"name\">{0}</a><a href=\"javascript:;\"  class=\"bule del\" orderid=\"{1}\">删除</a><a href=\"javascript:;\" class=\"bule\">下载</a></li>", item, KeyID);

                //        }
                //    }
                // this.payulfile.InnerHtml = li.ToString();
                //}
                #endregion


                //附件
                if (dt.Rows[0]["Atta"].ToString() != "")
                {
                    StringBuilder li   = new StringBuilder();
                    string[]      atta = dt.Rows[0]["Atta"].ToString().Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (atta.Length > 0)
                    {
                        foreach (var item in atta)
                        {
                            string[] att = item.Split(new string[] { "^^" }, StringSplitOptions.RemoveEmptyEntries);

                            if (att.Length > 1)
                            {
                                li.AppendFormat("<li> <a href=\"{2}\" target=\"_blank\" class=\"name\">{0}(大小:{4}KB)</a><a href=\"javascript:;\"  class=\"bule del\" tip=\"{3}\" orderid=\"{1}\">删除</a><a href=\"{2}\" target=\"_blank\" class=\"bule\">下载</a></li>", att[0] + att[1].Substring(att[1].LastIndexOf(".")), KeyID, Common.GetWebConfigKey("ImgViewPath") + "OrderFJ/" + item, item, OrderType.GetSize(item));
                            }
                        }
                    }
                    ulAtta.InnerHtml     = li.ToString();
                    this.hrOrderFj.Value = dt.Rows[0]["Atta"].ToString();
                }

                #region 订单明细

                //订单所有商品明细
                DataTable l = new Hi.BLL.DIS_OrderDetail().GetOrderDe("", " IsNUll(o.dr,0)=0 and o.OrderId=" + KeyID);
                if (l != null && l.Rows.Count > 0)
                {
                    rptOrderD.DataSource = l;
                    rptOrderD.DataBind();

                    //待发货商品
                    DataTable lno = SelectGoodsInfo.SreeenDataTable(l, "isnull(IsOut,0)=0"); //l.Select(string.Format("IsOut={0}", 0));
                    if (lno != null && lno.Rows.Count > 0)
                    {
                        rptIsout.DataSource = lno;
                        rptIsout.DataBind();
                    }

                    //已发货商品
                    List <Hi.Model.DIS_OrderOutDetail> loud = new Hi.BLL.DIS_OrderOutDetail().GetList("", " isnull(dr,0)=0 and OrderID=" + KeyID, "");
                    //发货单 and o.IsAudit<>3
                    DataTable lo = new Hi.BLL.DIS_OrderOut().GetList("", " isnull(o.dr,0)=0 and o.OrderID=" + KeyID + " Order by o.IsAudit");

                    if (loud != null && loud.Count > 0)
                    {
                        //outbind(lo, l, loud);
                        outGoods.InnerHtml = SelectGoodsInfo.outbind(lo, l, loud, Digits, 0);
                    }

                    #region 流程时间控件

                    if (lo != null && lo.Rows.Count > 0)
                    {
                        if (((int)Enums.OrderState.已发货 <= OState || OState == (int)Enums.OrderState.退货处理) && (IsOutState == 3 || IsOutState == 4))
                        {
                            //订单发货时间
                            DataRow[] sendlo = lo.Select("IsAudit<>3");
                            DataRow[] dv     = sendlo.OrderByDescending(x => x["id"]).ToArray();
                            if (dv.Length > 0)
                            {
                                sendde = dv[0]["SendDate"].ToString() != "" ? dv[0]["SendDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                            }
                        }

                        if ((int)Enums.OrderState.已到货 <= OState || OState == (int)Enums.OrderState.退货处理)
                        {
                            //订单签收时间
                            DataRow[] signlo = lo.Select("IsAudit<>3 and IsSign=1");
                            DataRow[] dr     = signlo.OrderByDescending(x => x["id"]).ToArray();
                            if (dr.Length > 0)
                            {
                                signde = dr[0]["SignDate"].ToString() != "" ? dr[0]["SignDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                            }
                        }
                    }
                    #endregion
                }
                #endregion

                #region 流程时间控件
                //订单流程时间显示
                //订单提交时间
                CreateDate = dt.Rows[0]["CreateDate"].ToString() != "" ? dt.Rows[0]["CreateDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";

                //订单审核时间
                AuditDate = dt.Rows[0]["AuditDate"].ToString() != "" ? dt.Rows[0]["AuditDate"].ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm") : "";
                #endregion 流程时间控件

                #region 订单操作按钮

                switch (OState)
                {
                case (int)Enums.OrderState.待审核:
                    modifyorder.Visible = true;
                    buyagain.Visible    = true;
                    ordervoid.Visible   = true;
                    break;

                case (int)Enums.OrderState.已审:
                    //订单审核前,可以修改订单。
                    buyagain.Visible = true;
                    break;

                case (int)Enums.OrderState.退货处理:
                    //orderReturn.Visible = false;
                    buyagain.Visible = true;
                    btn_pay.Visible  = false;
                    fulfil           = signde;
                    break;

                case (int)Enums.OrderState.已发货:
                    modifyorder.Visible = false;
                    buyagain.Visible    = true;
                    break;

                case (int)Enums.OrderState.已到货:
                    modifyorder.Visible = false;
                    buyagain.Visible    = true;
                    if (dt.Rows[0]["CreateDate"].ToString().ToDateTime() > DateTime.Now.AddMonths(-3))
                    {
                        //三个月以内的订单可退货
                        //if (ReturnState < (int)Enums.ReturnState.申请退货)
                        //orderReturn.Visible = true;
                    }
                    if (ReturnState >= (int)Enums.ReturnState.申请退货)
                    {
                        btn_pay.Visible = false;
                    }
                    if (sendde == "" && signde == "" && AuditDate != "")
                    {
                        fulfil = AuditDate;
                    }
                    else if (AuditDate.ToString() == "")
                    {
                        fulfil = CreateDate;
                    }
                    else
                    {
                        fulfil = signde == "" ? sendde : signde;
                    }
                    break;

                case (int)Enums.OrderState.已作废:
                    modifyorder.Visible = false;
                    buyagain.Visible    = true;
                    fulfil = Convert.ToDateTime(dt.Rows[0]["ts"]).ToString("yyyy-MM-dd HH:mm");
                    break;

                case (int)Enums.OrderState.已退货:
                    buyagain.Visible = true;
                    btn_pay.Visible  = false;
                    fulfil           = signde;
                    break;

                default:
                    break;
                }

                #endregion

                //订单修改,再次购买
                if (!Common.HasRight(this.CompID, this.UserID, "1010", this.DisID))
                {
                    this.buyagain.Visible    = false;
                    this.modifyorder.Visible = false;
                }
                //订单作废
                if (!Common.HasRight(this.CompID, this.UserID, "2012", this.DisID))
                {
                    this.ordervoid.Visible = false;
                }
                //在线支付
                if (!Common.HasRight(this.CompID, this.UserID, "2014", this.DisID))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "btn_pay_xs", "<script> $('#btn_pay_xs').hide();</script>");
                }

                //线下支付
                if (!Common.HasRight(this.CompID, this.UserID, "2015", this.DisID))
                {
                    this.btn_pay_xx.Visible = false;
                }
                //申请退货
                //if (!Common.HasRight(this.CompID, this.UserID, "2311", this.DisID))
                //this.orderReturn.Visible = false;
                //确认收货
                if (!Common.HasRight(this.CompID, this.UserID, "2013", this.DisID))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "btnsign", "<script> $('.btnsign,.btnsigni').hide();</script>");
                }
            }
        }
        else
        {
            Response.Redirect("../NoOperable.aspx");
            return;
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.hidType2.Value = Request.QueryString["type"] + "";
            this.hidDisID.Value = this.DisID.ToString();
            this.hidKeyId.Value = KeyID.ToString();

            StringBuilder strwhere = new StringBuilder();
            Fanli = OrderInfoType.rdoOrderAudit("订单支付返利是否启用", CompID).ToInt(0);
            this.hidFanl.Value = Fanli.ToString();
            LoginModel logUser = Session["UserModel"] as LoginModel;
            Common.ListComps(this.ddrComp, this.UserID.ToString(), this.CompID.ToString());
            this.hidCompId.Value = this.ddrComp.Value.ToString();

            decimal CreditAmount = 0;
            if (BLL.Common.GetCredit(this.hidCompId.Value.ToString().ToInt(0), logUser.DisID, out CreditAmount))
            {
                decimal GetSumAmount = OrderInfoType.GetSumAmount(logUser.DisID.ToString(), this.hidCompId.Value.ToString(), KeyID);
                if (GetSumAmount >= CreditAmount)
                {
                    this.Msg.InnerHtml = "您的授信额度(" + CreditAmount + ")已用完或超出!无法下单";
                    this.Btn.InnerHtml = "<a href=\"javascript:; \" class=\"gray-btn2\">取消</a>";
                }
                else
                {
                    this.Msg.InnerHtml = "";
                }
            }
            else
            {
                this.Msg.InnerHtml = "";
            }
            // isbate = OrderInfoType.rdoOrderAudit("订单支付返利是否启用", CompID).ToInt(0);
            //if (Fanli == 0)
            //{
            //    this.trbate.Visible = false;
            //    this.rebate.Visible = false;
            //}
            //商品是否启用库存
            IsInve = OrderInfoType.rdoOrderAudit("商品是否启用库存", this.CompID).ToInt(0);
            if (IsInve == 0)
            {
                strwhere.AppendFormat("and info.Inventory>0");
            }
            DataTable dt = SqlHelper.Query(SqlHelper.LocalSqlServer, SelectGoodsInfo.Returnsql(CompID.ToString(), DisID.ToString(), strwhere.ToString(), "1")).Tables[0];

            List <int> infoidl = new List <int>();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    int id = item["ID"].ToString().ToInt(0);//BD_goodsInfo表的ID
                    infoidl.Add(id);
                }
            }

            //获取商品价格
            List <BLL.gDprice> l = BLL.Common.GetPrice(CompID, DisID, infoidl);

            if (l != null && l.Count > 0)
            {
                foreach (var item in l)
                {
                    DataRow[] dr = dt.Select(" ID=" + item.goodsInfoId);
                    if (dr.Length > 0)
                    {
                        //获取的价格大于促销价时、取促销价
                        dr[0]["pr"] = item.FinalPrice;
                        dr[0]["typeTinkerPrice"] = item.typePrice;
                        dr[0]["disTinkerPrice"]  = item.disPrice;
                        dr[0]["disProPr"]        = item.bpPrice;
                    }
                }
            }
            this.divGoodsName.InnerText = ConvertJson.ToJson2(dt);
            //代理商列表
            List <Hi.Model.BD_Distributor> list = new Hi.BLL.BD_Distributor().GetList("ID,DisName", "isnull(dr,0)=0 and compid=" + this.CompID, "");
            this.divDisList.InnerText = ConvertJson.ToJson(Common.FillDataTable(list));
            if (KeyID != 0)
            {
                if (Request.QueryString["type"] + "" != "2")
                {
                    Hi.Model.DIS_Order model = new Hi.BLL.DIS_Order().GetModel(KeyID);
                    //判断订单是否可以修改  企业下单订单已审未支付,代理商下单企业不能修改
                    if (model.OState > (int)Enums.OrderState.待审核)
                    {
                        JScript.AlertAndRedirect("订单已被其他人修改,请刷新后再重新操作!", "orderdetail.aspx?top=1&KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
                        return;
                    }
                }
                else
                {
                    this.hidType.Value = Request.QueryString["type"] + "";
                }
                Bind();
            }
            else
            {
                if ((Request.QueryString["type"] + "") == "1")
                {
                    this.hidType.Value = Request.QueryString["type"] + "";
                    ShopCart();
                }
            }
        }
    }