Example #1
0
        /// <summary>
        /// 删除报单信息
        /// </summary>
        /// <param name="strId">报单编号</param>
        /// <param name="maxExcept">当前期数</param>
        /// <returns></returns>
        public string DelMembersDeclaration(string number, int maxExcept, string orderId, string storeId, double lackproductmoney)
        {
            OrderDAL orderDAL = new OrderDAL();
            string   info     = null;

            MemberOrderModel order = MemberOrderDAL.GetMemberOrder(orderId);

            BLL.CommonClass.ChangeLogs cl_h_info  = new BLL.CommonClass.ChangeLogs("memberinfo", "number");   //申明日志对象
            BLL.CommonClass.ChangeLogs cl_h_order = new BLL.CommonClass.ChangeLogs("MemberOrder", "orderId"); //申明日志对象
            using (SqlConnection conn = new SqlConnection(DBHelper.connString))
            {
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    //判断会员下是否有安置
                    //全球统一可以删除有下级的会员,如果有两个下级则注销,有一个下级则紧缩
                    info = new AddOrderBLL().GetHavePlace(number, tran);
                    if (info != null)
                    {
                        tran.Rollback();
                        conn.Close();
                        return(info);
                    }
                    ////判断会员下是否有推荐
                    info = new AddOrderBLL().GetHaveDirect(number, tran);
                    if (info != null)
                    {
                        tran.Rollback();
                        conn.Close();
                        return(info);
                    }

                    int cnt = new AddOrderBLL().GetHaveStore(number, tran);
                    if (cnt > 0)
                    {
                        info = this.GetTran("007097", "抱歉!该会员已经注册店铺,不可以删除!");// "抱歉!该会员有重复消费请先删除重复消费!";
                        tran.Rollback();
                        conn.Close();
                        return(info);
                    }
                    //判断该会员是否有复效单
                    int result = browsememberordersDAL.GetHasOrderAgain(number);
                    if (result > 0)
                    {
                        info = this.GetTran("000976", "抱歉!该会员有重复消费请先删除重复消费!");// "抱歉!该会员有重复消费请先删除重复消费!";
                        tran.Rollback();
                        conn.Close();
                        return(info);
                    }
                    else
                    {
                        string electronicaccountid = order.ElectronicaccountId;;
                        int    defrayState         = order.DefrayState;
                        int    defrayType          = order.DefrayType;
                        //if (defrayState == 1)
                        //{
                        //    if (lackproductmoney > 0)
                        //    {
                        //        int deliveryflag = BLL.Logistics.D_AccountBLL.GetDeliveryflag(orderId, tran);
                        //        if (deliveryflag == 0)
                        //        {
                        //            if (defrayType == 2)
                        //            {
                        //                IsElecPay(tran, order);
                        //                BLL.Logistics.D_AccountBLL.AddAccount(storeId, lackproductmoney, D_AccountSftype.StoreType, D_AccountKmtype.OrderDelete, DirectionEnum.AccountsIncreased, "会员【" + number + "】报单删除现金返还,订单号为【" + orderId + "】", tran);
                        //                BLL.Logistics.D_AccountBLL.AddAccount(electronicaccountid, lackproductmoney, D_AccountSftype.MemberType, D_AccountKmtype.OrderDelete, DirectionEnum.AccountsIncreased, "会员【" + number + "】报单删除现金返还,订单号为【" + orderId + "】", tran);
                        //            }
                        //            else if (defrayType == 1)
                        //            {
                        //                BLL.Logistics.D_AccountBLL.AddAccount(storeId, lackproductmoney, D_AccountSftype.StoreType, D_AccountKmtype.OrderDelete, DirectionEnum.AccountsIncreased, "会员【" + number + "】报单删除现金扣添加,订单号为【" + orderId + "】", tran);
                        //            }
                        //        }
                        //    }
                        //}



                        // cl_h_info.DeletedIntoLogstran(tran, CommonClass.ChangeCategory.Order, storeId, BLL.CommonClass.ENUM_USERTYPE.objecttype5);
                        browsememberordersDAL.DelNew(number, maxExcept, tran);

                        //添加日志
                        cl_h_info.AddRecordtran(tran, number);
                        cl_h_order.AddRecordtran(tran, orderId);
                        cl_h_order.DeletedIntoLogstran(tran, CommonClass.ChangeCategory.Order, storeId, BLL.CommonClass.ENUM_USERTYPE.objecttype5);

                        addOrderDataDAL.Del_Horder(tran, orderId, storeId, CommonDataBLL.OperateBh, CommonDataBLL.OperateIP);

                        ///删除后,把推荐或安置是他的err赋上值
                        int checkResult = addOrderDataDAL.Check_WhenDelete(tran, number);
                    }

                    tran.Commit();
                }
                catch (Exception ext)
                {
                    info = this.GetTran("000985", "抱歉!系统异常");// "抱歉!系统异常";
                    tran.Rollback();
                    conn.Close();
                    return(info);
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
            return(info);
        }