Beispiel #1
0
        /// <summary>
        /// 获取订单总金额
        /// </summary>
        /// <param name="total_amount"></param>
        protected void getTotalAmount()
        {
            total_amount  = 0M;
            coupon_amount = 0M;
            refund_amount = 0M;
            if (datetime == null)
            {
                BLL.orders bll = new BLL.orders();
                DataTable  dt;
                if (this.outlet_id > 0)
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99 and store_id=" + this.outlet_id, " add_time desc,id desc").Tables[0];
                }
                else if (this.city_id > 0)
                {
                    BLL.openarea   open    = new BLL.openarea();
                    Model.openarea openm   = open.GetModel(this.city_id);
                    StringBuilder  strTemp = new StringBuilder();
                    if (openm != null)
                    {
                        BLL.outlet outlet = new BLL.outlet();
                        DataTable  dts    = outlet.GetList(0, " city='" + openm.city + "'", " id").Tables[0];
                        if (dts.Rows.Count > 0)
                        {
                            StringBuilder st = new StringBuilder();
                            string        ss = string.Empty;
                            st.Append("(");
                            foreach (DataRow item in dts.Rows)
                            {
                                st.Append(item["id"] + ",");
                            }
                            if (st.ToString().Trim() != "(")
                            {
                                ss = DelLastComma(st.ToString().Trim());
                                st.Append(")");
                            }
                            strTemp.Append(" and store_id in" + ss + ")");
                        }
                        else
                        {
                            strTemp.Append(" and store_id in(null)");
                        }
                    }
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99" + strTemp, " add_time desc,id desc").Tables[0];
                }
                else
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99", " add_time desc,id desc").Tables[0];
                }
                foreach (DataRow row in dt.Rows)
                {
                    total_amount += decimal.Parse(row["order_amount"].ToString());
                    if (row["refund_status"].ToString() != "" && int.Parse(row["refund_status"].ToString()) == 3) //统计退款
                    {
                        refund_amount += decimal.Parse(row["order_amount"].ToString());
                    }
                    BLL.user_coupon_log couponbll = new BLL.user_coupon_log();//统计优惠券
                    if (row["str_code"].ToString() != "")
                    {
                        Model.user_coupon_log couponmodel = couponbll.GetModel(row["str_code"].ToString());
                        if (couponmodel != null && couponmodel.status == 2)
                        {
                            BLL.user_coupon   copbl = new BLL.user_coupon();
                            Model.user_coupon copmo = copbl.GetModel(couponmodel.coupon_id);
                            if (copmo != null)
                            {
                                if (copmo.amount > decimal.Parse(row["order_amount"].ToString()))
                                {
                                    coupon_amount += decimal.Parse(row["order_amount"].ToString());
                                }
                                else
                                {
                                    coupon_amount += copmo.amount;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                BLL.orders bll = new BLL.orders();

                DataTable dt;
                if (this.outlet_id > 0)
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99 and store_id=" + this.outlet_id, " add_time desc,id desc").Tables[0];
                }
                else
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99", " add_time desc,id desc").Tables[0];
                }

                //DataTable dt = bll.GetOrderAmount(0, " status!=1 and status!=99 and datediff(dd,add_time,'" + datetime + "')=0", " add_time desc,id desc").Tables[0];
                foreach (DataRow row in dt.Rows)
                {
                    total_amount += decimal.Parse(row["order_amount"].ToString());
                    if (row["refund_status"].ToString() != "" && int.Parse(row["refund_status"].ToString()) == 3)
                    {
                        refund_amount += decimal.Parse(row["order_amount"].ToString());
                    }
                    BLL.user_coupon_log couponbll = new BLL.user_coupon_log();//统计优惠券
                    if (row["str_code"].ToString() != "")
                    {
                        Model.user_coupon_log couponmodel = couponbll.GetModel(row["str_code"].ToString());
                        if (couponmodel != null && couponmodel.status == 2)
                        {
                            BLL.user_coupon   copbl = new BLL.user_coupon();
                            Model.user_coupon copmo = copbl.GetModel(couponmodel.coupon_id);
                            if (copmo != null)
                            {
                                if (copmo.amount > decimal.Parse(row["order_amount"].ToString()))
                                {
                                    coupon_amount += decimal.Parse(row["order_amount"].ToString());
                                }
                                else
                                {
                                    coupon_amount += copmo.amount;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 获取订单总金额
 /// </summary>
 /// <param name="total_amount"></param>
 protected void getTotalAmount()
 {
     total_amount  = 0M;
     coupon_amount = 0M;
     refund_amount = 0M;
     if (date == null || date == "")
     {
         BLL.orders bll = new BLL.orders();
         DataTable  dt  = bll.GetOrderAmount(0, " status!=1 and status!=99", " add_time desc,id desc").Tables[0];
         foreach (DataRow row in dt.Rows)
         {
             total_amount += decimal.Parse(row["order_amount"].ToString());
             if (row["refund_status"].ToString() != "" && int.Parse(row["refund_status"].ToString()) == 3) //统计退款
             {
                 refund_amount += decimal.Parse(row["order_amount"].ToString());
             }
             BLL.user_coupon_log couponbll = new BLL.user_coupon_log();//统计优惠券
             if (row["str_code"].ToString() != "")
             {
                 Model.user_coupon_log couponmodel = couponbll.GetModel(row["str_code"].ToString());
                 if (couponmodel != null && couponmodel.status == 2)
                 {
                     BLL.user_coupon   copbl = new BLL.user_coupon();
                     Model.user_coupon copmo = copbl.GetModel(couponmodel.coupon_id);
                     if (copmo != null)
                     {
                         if (copmo.amount > decimal.Parse(row["order_amount"].ToString()))
                         {
                             coupon_amount += decimal.Parse(row["order_amount"].ToString());
                         }
                         else
                         {
                             coupon_amount += copmo.amount;
                         }
                     }
                 }
             }
         }
     }
     else
     {
         BLL.orders bll = new BLL.orders();
         DataTable  dt  = bll.GetOrderAmount(0, " status!=1 and status!=99 and datediff(dd,add_time,'" + date + "')=0", " add_time desc,id desc").Tables[0];
         foreach (DataRow row in dt.Rows)
         {
             total_amount += decimal.Parse(row["order_amount"].ToString());
             if (row["refund_status"].ToString() != "" && int.Parse(row["refund_status"].ToString()) == 3)
             {
                 refund_amount += decimal.Parse(row["order_amount"].ToString());
             }
             BLL.user_coupon_log couponbll = new BLL.user_coupon_log();//统计优惠券
             if (row["str_code"].ToString() != "")
             {
                 Model.user_coupon_log couponmodel = couponbll.GetModel(row["str_code"].ToString());
                 if (couponmodel != null && couponmodel.status == 2)
                 {
                     BLL.user_coupon   copbl = new BLL.user_coupon();
                     Model.user_coupon copmo = copbl.GetModel(couponmodel.coupon_id);
                     if (copmo != null)
                     {
                         if (copmo.amount > decimal.Parse(row["order_amount"].ToString()))
                         {
                             coupon_amount += decimal.Parse(row["order_amount"].ToString());
                         }
                         else
                         {
                             coupon_amount += copmo.amount;
                         }
                     }
                 }
             }
         }
     }
 }