示例#1
0
        /// <summary>
        /// 添加订单信息
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="memberOrderModel"></param>
        /// <param name="totalPv"></param>
        /// <param name="except"></param>
        /// <param name="memberDetailsModel"></param>
        /// <param name="storeInfoModel"></param>
        public static bool AddOrderData(bool isEdit, MemberOrderModel memberOrderModel, IList <MemberDetailsModel> list)
        {
            bool state = false;

            using (SqlConnection conn = new SqlConnection(DBHelper.connString))
            {
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    //如果是编辑
                    if (isEdit)
                    {
                        BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("memberorder", "orderid"); //实例日志类
                        cl_h_info.AddRecordtran(tran, memberOrderModel.OrderId);                                         //添加日志,修改前记录原来数据

                        MemberOrderModel order = MemberOrderBLL.GetMemberOrder(memberOrderModel.OrderId);

                        if (order.LackProductMoney > 0)
                        {
                            D_AccountBLL.AddAccount(order.StoreId, Convert.ToDouble(order.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.OrderUpdateIn, DirectionEnum.AccountsIncreased, "会员【" + order.Number + "】报单修改现金扣添加,订单号为【" + order.OrderId + "】", tran);
                            if (order.DefrayType == 2)
                            {
                                new Registration_declarations.MemberOrderAgainBLL().IsElecPay(tran, order);
                                D_AccountBLL.AddAccount(order.Number, Convert.ToDouble(order.LackProductMoney), D_AccountSftype.MemberType, D_AccountKmtype.OrderUpdateIn, DirectionEnum.AccountsIncreased, "会员【" + order.Number + "】报单修改现金扣添加,订单号为【" + order.OrderId + "】", tran);
                                D_AccountBLL.AddAccount(order.StoreId, Convert.ToDouble(order.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.OrderUpdateOut, DirectionEnum.AccountReduced, "会员【" + order.Number + "】报单修改现金添加扣,订单号为【" + order.OrderId + "】", tran, true);
                            }
                        }

                        int delResult = new AddOrderDataDAL().Del_Horder(tran, memberOrderModel.OrderId, memberOrderModel.StoreId, CommonDataBLL.OperateBh, CommonDataBLL.OperateIP);

                        if (memberOrderModel.DefrayState == 1)//店铺复消减去业绩
                        {
                            int js_delfuxiao_Result = new AddOrderDataDAL().Js_delfuxiao(memberOrderModel.Number, Convert.ToDouble(memberOrderModel.TotalPv), memberOrderModel.PayExpect, memberOrderModel.DefrayState, tran);
                        }

                        cl_h_info.ModifiedIntoLogstran(tran, ChangeCategory.Order, memberOrderModel.OrderId, ENUM_USERTYPE.objecttype5);//插入日志
                    }

                    //添加订单
                    new AddOrderBLL().SaveHOrder(tran, list, memberOrderModel);

                    //顾客购物业绩上传(注意支付money要改)
                    if (memberOrderModel.DefrayState == 1)
                    {
                        new AddOrderDataDAL().Js_addfuxiao(memberOrderModel.Number, Convert.ToDouble(memberOrderModel.TotalPv), memberOrderModel.PayExpect, memberOrderModel.DefrayState, tran);
                        CommonDataBLL.SetMemberLevel(tran, memberOrderModel.Number, memberOrderModel.OrderId);
                    }
                    state = true;
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }

            return(state);
        }
示例#2
0
        public static string UpdateMemberOrder(string OrderId, IList <MemberDetailsModel> list, MemberOrderModel memberOrderModel, string StoreID)
        {
            SqlConnection    conn  = new SqlConnection(DBHelper.connString);
            MemberOrderModel order = MemberOrderBLL.GetMemberOrder(memberOrderModel.OrderId);
            SqlTransaction   tran  = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();

                SqlCommand cmd = new SqlCommand();
                cmd.Transaction = tran;
                cmd.Connection  = conn;


                DataTable dhpv = DBHelper.ExecuteDataTable(tran, "select totalpv,LackProductMoney from MemberOrder where OrderID='" + OrderId + "'");

                if (memberOrderModel.PayExpect != -1 && memberOrderModel.DefrayState == 1)
                {
                    if (Convert.ToDecimal(dhpv.Rows[0]["totalpv"]) != memberOrderModel.TotalPv)
                    {
                        //修改后需重新结算
                        cmd.CommandText = "update config set jsflag='0' where ExpectNum>='" + memberOrderModel.PayExpect + "'";
                        cmd.CommandType = CommandType.Text;

                        cmd.ExecuteNonQuery();
                    }
                }

                if (memberOrderModel.DefrayState == 1)
                {
                    decimal oldlackproductmoney = Convert.ToDecimal(dhpv.Rows[0]["LackProductMoney"]);
                    if (memberOrderModel.LackProductMoney != oldlackproductmoney)
                    {
                        D_AccountBLL.AddAccount(StoreID, Convert.ToDouble(oldlackproductmoney), D_AccountSftype.StoreType, D_AccountKmtype.OrderUpdateIn, DirectionEnum.AccountsIncreased, "店铺[" + StoreID + "]修改订单[" + order.OrderId + "]退回钱[" + oldlackproductmoney + "]", tran);
                        //D_AccountBLL.AddAccount(StoreID, Convert.ToDouble(memberOrderModel.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.OrderUpdateOut, DirectionEnum.AccountReduced, "店铺[" + StoreID + "]修改订单[" + memberOrderModel.OrderId + "]扣除钱[" + memberOrderModel.LackProductMoney + "]", tran);

                        if (order.DefrayType == 2)
                        {
                            new MemberOrderBLL().IsElecPay(tran, order);
                            D_AccountBLL.AddAccount(order.Number, Convert.ToDouble(order.LackProductMoney), D_AccountSftype.MemberType, D_AccountKmtype.OrderUpdateIn, DirectionEnum.AccountsIncreased, "会员【" + order.Number + "】报单修改现金扣添加,订单号为【" + order.OrderId + "】", tran);
                            D_AccountBLL.AddAccount(order.StoreId, Convert.ToDouble(order.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.OrderUpdateOut, DirectionEnum.AccountReduced, "会员【" + order.Number + "】报单修改现金添加扣,订单号为【" + order.OrderId + "】", tran, true);
                        }
                    }
                }

                int res = 0;

                SqlParameter[] del_parm =
                {
                    new SqlParameter("@OrderID", OrderId),
                    new SqlParameter("@StoreID", StoreID),
                    new SqlParameter("@Type",                                 1),
                    new SqlParameter("@res",     res),
                    new SqlParameter("@opnum",   memberOrderModel.OperateNumber),
                    new SqlParameter("@opip",    memberOrderModel.OperateIp),
                };

                BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("MemberOrder", "ltrim(rtrim(OrderID))");
                cl_h_info.AddRecordtran(tran, OrderId);

                BLL.CommonClass.ChangeLogs cl_h_info1 = new BLL.CommonClass.ChangeLogs("MemberDetails", "ltrim(rtrim(OrderID))");
                cl_h_info1.AddRecordtran(tran, OrderId);

                DBHelper.ExecuteNonQuery(tran, "Delete_H_Order", del_parm, CommandType.StoredProcedure);

                if (Convert.ToInt32(del_parm[3].Value) == 0)
                {
                    //添加订单
                    new AddOrderBLL().SaveHOrder(tran, list, memberOrderModel);

                    cl_h_info.AddRecordtran(tran, OrderId);
                    cl_h_info1.AddRecordtran(tran, OrderId);

                    if (Convert.ToInt32(DAL.DBHelper.ExecuteScalar(tran, "select count(1) from MemberDetails where OrderId='" + OrderId + "'", CommandType.Text)) > 0)
                    {
                        cl_h_info.ModifiedIntoLogstran(tran, ChangeCategory.Order, OrderId, ENUM_USERTYPE.objecttype5);
                        cl_h_info1.ModifiedIntoLogstran(tran, ChangeCategory.Order, OrderId, ENUM_USERTYPE.objecttype5);
                    }

                    tran.Commit();
                    return("1");
                }
                else
                {
                    tran.Rollback();
                    return("-2");
                }
            }
            catch (Exception ee)
            {
                tran.Rollback();
                return("-2");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
示例#3
0
        /// <summary>
        /// 确认 当期,未支付的自由注册 信息
        /// </summary>
        /// <param name="Number"></param>
        /// <param name="OrderID"></param>
        /// <param name="StoreID"></param>
        /// <returns></returns>
        public string ConfirmCurretMemberinfo(string Number, string OrderID, string StoreID, string TotalPV, string TotalMoney, int DefrayType, string ElectronicAccountID)
        {
            //根据订单编号获得订单详细
            string info = "";

            //获取电子账号
            string elcAccountId = new AddOrderDataDAL().GerExcNuber(OrderID);
            //try
            //{
            BrowseMemberOrdersBLL browseMemberOrdersBLL = new BrowseMemberOrdersBLL();
            ViewFuXiaoBLL         viewFuXiaoBLL         = new ViewFuXiaoBLL();

            using (SqlConnection con = new SqlConnection(DAL.DBHelper.connString))
            {
                con.Open();
                SqlTransaction tran = con.BeginTransaction();

                //获得会员电子账户剩余金额
                object zhifumoney = CommonDataBLL.EctIsEnough(Number);
                //获得会员订单信息
                DataTable dt = BrowseMemberOrdersBLL.DeclarationProduct(StoreID, OrderID);


                if (DefrayType == 2)//支付类型,1是现金,2电子转帐,3网上支付,
                {
                    //电子钱包余额是否大于订单金额
                    if (Convert.ToDouble(zhifumoney) < Convert.ToDouble(TotalMoney))
                    {
                        info = BLL.Translation.Translate("000599", "会员") + ":" + Number + BLL.Translation.Translate("001736", "的电子帐户不够支付本报单!");
                        return(info);
                    }
                }

                //获得店铺不足货时可以报单的金额
                object memberordermoney = CommonDataBLL.StoreLaveAmount(StoreID);

                //获得该订单所以不足货所的报单的金额
                double sumNotenoughMoney = ViewFuXiaoBLL.GetNotEnoughMoney(OrderID, tran);

                // 店铺剩余可报单额是否大于订单金额
                if (Convert.ToDouble(memberordermoney) < sumNotenoughMoney)
                {
                    info = BLL.Translation.Translate("000388", "店铺") + ": " + StoreID + BLL.Translation.Translate("001739", "的可以用来报单的费用不足!");
                    return(info);
                }

                //是否是网上银行支付
                if (DefrayType == 3)
                {
                    //info = "网上银行支付";
                    ////Response.Write("<script>location.href='../Send.aspx?V_amount=" + Totalmoney.Value + "&V_oid=" + orderId + "';</script>");
                    //return info;
                }


                //获得最大期数(测试)
                int maxQs = CommonDataBLL.getMaxqishu();
                //更新会员订单信息
                if (!CommonDataBLL.ConfirmMembersOrder(tran, OrderID, maxQs))
                {
                    info = BLL.Translation.Translate("000979", "支付失败");
                    return(info);
                }
                //更新结算(需要修改存储过程)
                if (!BLL.CommonClass.CommonDataBLL.UPMemberInfoBalance(tran, Number, decimal.Parse(TotalPV), maxQs))
                {
                    info = BLL.Translation.Translate("001741", "结算失败");
                    return(info);
                }


                //更新店铺库存

                List <Model.MemberDetailsModel> list = ViewFuXiaoBLL.GetDetails(OrderID);


                int  result = 0;
                bool real   = true;
                foreach (Model.MemberDetailsModel memberDetailsModel in list)
                {
                    //循环根据订单明细跟新库存
                    if (memberDetailsModel.IsGroupItem == "" || memberDetailsModel.IsGroupItem == null)
                    {
                        if (memberDetailsModel.HasGroupItem == "true")
                        {
                            result = new AddMemberInfomDAL().updateStore11(StoreID, memberDetailsModel, tran);
                            real   = false;
                        }
                        else
                        {
                            result = ViewFuXiaoBLL.UptStock(tran, StoreID, memberDetailsModel.ProductId, memberDetailsModel.Quantity, memberDetailsModel.NotEnoughProduct);
                            real   = false;
                        }
                    }
                    if (result <= 0 && real == false)
                    {
                        if (browseMemberOrdersBLL.updateStore2(memberDetailsModel, tran) <= 0)
                        {
                            tran.Rollback();
                            con.Close();
                            return(info);
                        }
                    }
                }


                if (DefrayType == 2)
                {
                    //添加到店汇款表
                    int result3 = new AddOrderDataDAL().AddDataTORemittances(tran, MemberOrderBLL.GetMemberOrder(OrderID));
                    if (result3 > 0)
                    {
                        //跟新被转账会员的电子帐户
                        if (!BLL.CommonClass.CommonDataBLL.UPMemberEct(elcAccountId, Convert.ToDecimal(TotalMoney)))
                        {
                            tran.Rollback();
                            con.Close();
                            return(info);
                        }
                        ;
                        //更新店铺的汇款
                        int result2 = new AddOrderDataDAL().Add_Remittances(tran, Convert.ToDouble(TotalMoney), StoreID);
                    }
                    else
                    {
                        tran.Rollback();
                        con.Close();
                        return(info);
                    }
                }

                //更新店铺总保单额(累计)
                if (new AddOrderBLL().updateStore4(StoreID, tran, Convert.ToDouble(TotalMoney)) <= 0)
                {
                    tran.Rollback();
                    con.Close();
                    return(info);
                }
                //提交事务
                tran.Commit();
            }


            //}
            //catch
            //{

            //}
            info = BLL.Translation.Translate("001743", "确定完成!");

            return(info);
        }