Ejemplo n.º 1
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();

            InnerObject.State = PointGiftStates.Normal;
            HttpContext context = HttpContext.Current;

            if (Photo != null && Photo.File != null)
            {
                var name = Guid.NewGuid().ToString("N") + ".jpg";
                InnerObject.Photo = name;
                var fileName = context.Server.MapPath("~/content/pointgiftphotos/" + name);
                Moonlit.IO.DirectoryEnsure.EnsureFromFile(fileName);
                Photo.File.SaveAs(fileName);
            }

            TransactionHelper.BeginTransaction();
            base.OnSave(InnerObject);
            PointGiftService.Create(InnerObject);

            AddMessage("success", DisplayName);
            Logger.LogWithSerialNo(LogTypes.PointGiftCreate, serialNo, InnerObject.PointGiftId, DisplayName);

            return(TransactionHelper.CommitAndReturn(this));
        }
Ejemplo n.º 2
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();
            var roles    = MembershipService.QueryRoles(new RoleRequest {
                Name = RoleNames.ShopOwner
            }).ToList();

            TransactionHelper.BeginTransaction();
            OnSave(InnerObject, Owner);
            Owner.SetPassword(Password);
            InnerObject.State          = States.Normal;
            InnerObject.RechargeAmount = RechargeAmount;
            Owner.State = States.Normal;
            ShopService.Create(InnerObject);
            Owner.ShopId = InnerObject.ShopId;
            MembershipService.CreateUser(Owner);
            MembershipService.AssignRoles(Owner, roles.Select(x => x.RoleId).ToArray());
            ShopDealLog log = new ShopDealLog(serialNo, DealTypes.Open, 0, null, null, null, InnerObject, 0);

            ShopDealLogService.Create(log);
            AddMessage("success", ShopName);
            Logger.LogWithSerialNo(LogTypes.ShopCreate, serialNo, InnerObject.ShopId, ShopName);
            CacheService.Refresh(CacheKeys.PosKey);
            return(TransactionHelper.CommitAndReturn(this));
        }
Ejemplo n.º 3
0
        public void Execute(User currentUser)
        {
            using (var tran = TransactionHelper.BeginTransaction())
            {
                var liquidate = this.LiquidateService.GetById(LiquidateId);
                if (liquidate == null || liquidate.State != LiquidateStates.Processing)
                {
                    throw new Exception("没有找到相关的清算记录");
                }

                this.LiquidateService.Delete(liquidate);
                var ids = liquidate.DealIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                if (liquidate.Count != ShopDealLogService.UpdateLiquidateId(ids, 0, liquidate.LiquidateId, ShopId))
                {
                    throw new Exception("清算数据冲突");
                }
                var dealLogIds = ShopDealLogService.GetAddins(ids.ToArray());
                if (liquidate.Count != dealLogIds.Count)
                {
                    throw new Exception("清算数据冲突");
                }
                if (liquidate.Count != DealLogService.UpdateLiquidateId(dealLogIds, 0, liquidate.LiquidateId, ShopId))
                {
                    throw new Exception("清算数据冲突");
                }
                tran.Commit();
            }
        }
Ejemplo n.º 4
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                TransactionHelper.BeginTransaction();
                var distributor = DistributorService.GetById(id);
                if (distributor != null)
                {
                    //把下属经销商的上级设为要删除的经销商的上级。
                    List <Distributor> list = DistributorService.GetByParentId(id);
                    foreach (var item in list)
                    {
                        if (item != null)
                        {
                            //var user1 = MembershipService.GetUserById(item.UserId);
                            item.ParentId = distributor.ParentId;
                            //TransactionHelper.BeginTransaction();
                            // MembershipService.DeleteUser(user1);
                            DistributorService.Update(item);

                            Logger.LogWithSerialNo(LogTypes.DistributorEdit, SerialNoHelper.Create(), id, item.Name);
                            AddMessage("update.success", item.Name);
                            //TransactionHelper.Commit();

                            CacheService.Refresh(CacheKeys.DistributorKey);
                        }
                    }
                    var accounts = AccountService.Query(new AccountRequest()).Where(x => x.DistributorId == id);
                    foreach (var account in accounts)
                    {
                        account.DistributorId = distributor.ParentId;
                        AccountService.Update(account);
                    }
                    var user = MembershipService.GetUserById(distributor.UserId);
                    MembershipService.DeleteUser(user);
                    DistributorService.Delete(distributor);

                    Logger.LogWithSerialNo(LogTypes.DistributorDelete, SerialNoHelper.Create(), id, user.Name);
                    //AddMessage("delete.success", user.Name);
                    msg.Code     = 1;
                    msg.CodeText = "删除 " + user.DisplayName + " 成功";
                    TransactionHelper.Commit();

                    CacheService.Refresh(CacheKeys.PosKey);
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到经销商";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("删除经销商", ex);
                return(msg);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 装车
        /// </summary>
        /// <returns></returns>
        public string Loading(DataRow dr, int num, string slabwhCode, string shift, string group, string remark)
        {
            string result = "1";

            try
            {
                TransactionHelper.BeginTransaction();

                string   strUserID = RV.UI.UserInfo.userID;
                DateTime time      = RV.UI.ServerTime.timeNow();

                DataTable billet = new DataTable();
                if (dal.UpdateLodingType(dr["C_STOVE"].ToString(), dr["C_STL_GRD"].ToString(), dr["C_SPEC"].ToString(), dr["C_STD_CODE"].ToString(), dr["C_MAT_CODE"].ToString(), num, slabwhCode, shift, group, strUserID, time, out billet, dr["C_BATCH_NO"].ToString(), remark) != num)
                {
                    TransactionHelper.RollBack();
                    return("装车失败");
                }


                TransactionHelper.Commit();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                return(ex.Message);
            }

            return(result);
        }
Ejemplo n.º 6
0
        public void Save()
        {
            var serialNo  = SerialNoHelper.Create();
            var oldUser   = MembershipService.GetUserById(InnerObject.UserId);
            var adminUser = oldUser as AdminUser;

            if (adminUser == null)
            {
                return;
            }
            TransactionHelper.BeginTransaction();

            adminUser.Email       = Email;
            adminUser.DisplayName = DisplayName;
            if (!string.IsNullOrEmpty(Password))
            {
                adminUser.SetPassword(Password);
            }
            adminUser.BirthDate = BirthDate;
            adminUser.Mobile    = Mobile;
            //adminUser.IsSale = IsSale;
            var roleIds = Roles.GetCheckedIds();

            MembershipService.UpdateUser(adminUser);
            OnSaved(adminUser);
            MembershipService.DeleteRolesForUser(adminUser.UserId);
            MembershipService.AssignRoles(adminUser, roleIds);
            AddMessage("success", oldUser.Name);
            Logger.LogWithSerialNo(LogTypes.AdminUserEdit, serialNo, adminUser.UserId, oldUser.Name);
            TransactionHelper.Commit();
        }
Ejemplo n.º 7
0
        public IMessageProvider Edit()
        {
            var newObject = OrderService.QueryOrder(new Services.OrderRequest()
            {
                OrderId = InnerObject.OrderId
            }).FirstOrDefault();

            if (newObject != null)
            {
                var serialNo = SerialNoHelper.Create();
                TransactionHelper.BeginTransaction();
                //InnerObject.AccountId = AccountID;
                //InnerObject.State = MyState;
                //newObject.Address = Address;
                newObject.Phone = AccountPhone;
                //newObject.SubmitTime = DateTime.Now;
                base.OnSave(newObject);
                OrderService.UpdateOrder(newObject);
                OrderService.DeleteOrderDetials(InnerObject.OrderId);
                foreach (var item in this.Detials)
                {
                    item.OrderId = OrderId;
                    OrderService.AddOrderDetial(item);
                }
                AddMessage("Edit.success", InnerObject.OrderId);
                Logger.LogWithSerialNo(LogTypes.EditOrder, serialNo, InnerObject.Serialnumber, InnerObject.OrderId);
                return(TransactionHelper.CommitAndReturn(this));
            }
            else
            {
                AddError(LogTypes.EditOrder, "无此订单!", null);
                return(this);
            }
        }
Ejemplo n.º 8
0
        public IMessageProvider Save()
        {
            var serialNo = SerialNoHelper.Create();

            TransactionHelper.BeginTransaction();
            var role = MembershipService.GetRoleById(InnerObject.RoleId);

            if (role == null)
            {
                return(this);
            }

            role.DisplayName = DisplayName;
            if (Users != null && !role.BuildIn)
            {
                var roleIds = Users.GetCheckedIds();
                //role.Users = MembershipService.QueryUsers<User>(new UserRequest() { Ids = roleIds }).ToList();

                MembershipService.DeleteUsersForRole(role.RoleId);
                MembershipService.AssignUsers(role, roleIds);
            }
            var ids         = this.Permissions.GetCheckedIds();
            var permissions = PermissionService.QueryPermissions(this.UserType).Where(x => ids.Contains(x.PermissionId)).Select(x => x.Name).ToArray();

            role.Permissions = string.Join(",", permissions);
            MembershipService.UpdateRole(role);
            this.Logger.LogWithSerialNo(LogTypes.RoleEdit, serialNo, role.RoleId, InnerObject.Name);
            AddMessage("success", InnerObject.Name);
            return(TransactionHelper.CommitAndReturn(this));
        }
Ejemplo n.º 9
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();

            TransactionHelper.BeginTransaction();
            string str = "S" + DateTime.Now.ToString("yyyyMMdd");

            InnerObject.OrderId   = str + "-" + OrderService.GetOrderSerialnumber();
            InnerObject.AccountId = AccountId;
            InnerObject.Phone     = Phone;
            var user = SecurityHelper.GetCurrentUser();

            InnerObject.Creater    = user.CurrentUser.DisplayName;
            InnerObject.CreaterId  = user.CurrentUser.UserId;
            InnerObject.createDate = DateTime.Now;
            base.OnSave(InnerObject);
            OrderService.CreateOrder(InnerObject);
            foreach (var item in this.Detials)
            {
                item.OrderId = InnerObject.OrderId;
                OrderService.AddOrderDetial(item);
            }
            AddMessage("success", InnerObject.OrderId);
            Logger.LogWithSerialNo(LogTypes.AddOrder, serialNo, 0);
            return(TransactionHelper.CommitAndReturn(this));
        }
Ejemplo n.º 10
0
 public SimpleAjaxResult Save(int accountId)
 {
     try
     {
         var    serialNo = SerialNoHelper.Create();
         var    passwordService = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType);
         string password1, password2;
         passwordService.Decrypto(this.Password, this.PasswordConfirm, out password1, out password2);
         if (password1 != password2)
         {
             return(new SimpleAjaxResult(Localize("passwordNotEquals")));
         }
         Account account = AccountService.GetById(accountId);
         if (account == null || (account.State != AccountStates.Normal && account.State != AccountStates.Invalid))
         {
             return(new SimpleAjaxResult(Localize("accountNoExisting")));
         }
         account.SetPassword(password1);
         TransactionHelper.BeginTransaction();
         AccountService.Update(account);
         Logger.LogWithSerialNo(LogTypes.AccountChangePassword, serialNo, account.AccountId, AccountName);
         AddMessage("success");
         TransactionHelper.CommitAndReturn(this);
         return(new SimpleAjaxResult());
     }
     catch (System.Exception ex)
     {
         Logger.Error(LogTypes.AccountChangePassword, ex);
         return(new SimpleAjaxResult(ex.Message));
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 删除修磨记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string DelRegroundHandler(string id, string regroundid, string xmbz, string qua)
        {
            string result = "1";

            TransactionHelper.BeginTransaction();
            try
            {
                string columnName = General.NameType[xmbz];
                if (!dal.DelRegroundHandler(id))
                {
                    return("0");
                }
                if (!dal.UpdateRegroundProcedure(regroundid, columnName, int.Parse(qua), 2))
                {
                    return("0");
                }
                TransactionHelper.Commit();
                dal.UpdateRegroundType();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                return("0");
            }
            dal.ResetRegroundQua();
            return(result);
        }
Ejemplo n.º 12
0
        public IMessageProvider Done()
        {
            this.Ready();
            if (this.ShouldPayAmount < this.Amount)
            {
                AddError(LogTypes.CashDealLogDone, "amountInvalidate", ShouldPayAmount, Amount);
                return(this);
            }
            var serialNo = SerialNoHelper.Create();
            var user     = SecurityHelper.GetCurrentUser().CurrentUser;
            var amount   = Amount;

            using (var tran = TransactionHelper.BeginTransaction())
            {
                // InnerObject.AccountLevel = AccountLevel;
                InnerObject.DealType   = CashDealLogTypes.EmployeeDeposit;
                InnerObject.UserId     = user.UserId;
                InnerObject.OwnerId    = OwnerId;
                InnerObject.Amount     = -amount;
                InnerObject.SubmitTime = DateTime.Now;
                InnerObject.SubmitDate = this.SubmitDate;
                CashDealLogService.Create(InnerObject);
                AddMessage("success", ShouldPayAmount, amount);
                Logger.LogWithSerialNo(LogTypes.CashDealLogDone, serialNo, InnerObject.CashDealLogId /*, InnerObject.DisplayName*/);
                Amount = amount;
                tran.Commit();
                return(this);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 删除购物车
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ResultMessage DelShoppingCartById(int[] ids)
        {
            var tran = TransactionHelper.BeginTransaction();

            try
            {
                foreach (var item in ids)
                {
                    var DelModel = ShoppingCartService.GetById(item);
                    if (DelModel != null)
                    {
                        ShoppingCartService.Delete(DelModel);
                    }
                }


                tran.Commit();
                //TransactionHelper.Commit();

                return(new ResultMessage()
                {
                    Code = 0, Msg = "购物车已清除"
                });
            }
            catch (Exception ex)
            {
                tran.Dispose();
                logService.Insert(ex);
                return(new ResultMessage()
                {
                    Code = -1, Msg = "购物车清除失败-网络错误,请稍后重试..."
                });
            }
        }
Ejemplo n.º 14
0
        public void Complete(int id)
        {
            //完成订单。

            TransactionHelper.BeginTransaction();
            var serialNo = SerialNoHelper.Create();
            var item     = this.OrderService.QueryOrder(new OrderRequest()
            {
                Serialnumber = id
            }).FirstOrDefault();

            if (item != null)
            {
                if (item.State == OrderState.Partially || item.State == OrderState.Carry)
                {
                    item.State = OrderState.Completed;
                    OrderService.UpdateOrder(item);
                    Logger.LogWithSerialNo(LogTypes.EditOrder, serialNo, item.Serialnumber, item.OrderId);
                    AddMessage("Update.success", item.OrderId);
                }
                else
                {
                    AddError("当前状态不能进入完成状态", item.OrderId);
                }
            }
            TransactionHelper.Commit();
        }
Ejemplo n.º 15
0
        public object OpenReceipt(int id)
        {
            try
            {
                SystemDealLog dealLog = SystemDealLogService.GetById(id);
                if (dealLog != null && !dealLog.HasReceipt && dealLog.DealType == SystemDealLogTypes.Recharge && dealLog.Amount > 0 && dealLog.State == SystemDealLogStates.Normal)
                {
                    dealLog.HasReceipt = true;

                    TransactionHelper.BeginTransaction();

                    SystemDealLogService.Update(dealLog);
                    LogHelper.LogWithSerialNo(LogTypes.SystemDealLogOpenReceipt, SerialNoHelper.Create(), dealLog.SystemDealLogId, dealLog.SerialNo);
                    AddMessage(Localize("OpenReceipt.success"), dealLog.SystemDealLogId);

                    SendMessage(dealLog);
                    return(TransactionHelper.CommitAndReturn(new SimpleAjaxResult()));
                }
                return(new SimpleAjaxResult(Localize("OpenReceipt.failed", "原交易不存在")));
            }
            catch (Exception ex)
            {
                Logger.Error(LogTypes.SystemDealLogOpenReceipt, ex);
                return(new SimpleAjaxResult(ex.Message));
            }
        }
Ejemplo n.º 16
0
        public void Carry(int orderId, int senderId)
        {
            //派送。

            TransactionHelper.BeginTransaction();
            var serialNo = SerialNoHelper.Create();
            var item     = this.OrderService.QueryOrder(new OrderRequest()
            {
                Serialnumber = orderId
            }).FirstOrDefault();

            if (item != null)
            {
                if (item.State == OrderState.Normal)
                {
                    var user = MembershipService.GetUserById(senderId);
                    item.State      = OrderState.Carry;
                    item.SenderId   = senderId;
                    item.Sender     = user.DisplayName;
                    item.SubmitTime = DateTime.Now;
                    OrderService.UpdateOrder(item);
                    Logger.LogWithSerialNo(LogTypes.EditOrder, serialNo, item.Serialnumber, item.OrderId);
                    AddMessage("Update.success", item.OrderId);
                }
                else
                {
                    AddError("当前状态不能进入派送阶段", item.OrderId);
                }
            }
            TransactionHelper.Commit();
        }
Ejemplo n.º 17
0
 public bool AddOrder(ClientOrder order)
 {
     if (order.Detials.Any(x => x.Amount < 1) || order.Detials.Any(y => y.Price <= 0))
     {
         return(false);
     }
     try
     {
         OrderBase createOrder = new OrderBase();
         createOrder.AccountId  = order.AccountId;
         createOrder.Address    = order.Address;
         createOrder.Creater    = order.Creater;
         createOrder.OrderId    = GetOrderSerialnumber();
         createOrder.State      = OrderState.Normal;
         createOrder.SubmitTime = DateTime.Now;
         createOrder.TotalMoney = order.Detials.Sum(x => x.Amount * x.Price);
         transactionHelper.BeginTransaction();
         foreach (var item in order.Detials)
         {
             OrderDetialBase detial = new OrderDetialBase();
             detial.Amount  = item.Amount;
             detial.GoodId  = item.CommodityId;
             detial.OrderId = createOrder.OrderId;
             detial.price   = item.Price;
             _databaseInstance.Insert(detial, OrderTable);
         }
         _databaseInstance.Insert(createOrder, OrderDetialTable);
         return(transactionHelper.CommitAndReturn(true));
     }
     catch
     { return(false); }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 修磨确认
        /// </summary>
        /// <param name="id">主键</param>
        ///  <param name="num">总支数</param>
        /// <param name="factNum">修磨支数</param>
        /// <param name="xmbz">修磨标准</param>
        /// <param name="sta">工位</param>
        /// <param name="remark">说明</param>
        /// <param name="emp">修磨人</param>
        /// <param name="hg">货管</param>
        /// <param name="batchNo">批次号</param>
        /// <param name="slbwhCode">仓库编码</param>
        /// <param name="grinWheel">砂轮</param>
        /// <returns></returns>
        public string RegroundConfirm(string id, string num, string factNum, string xmbz,
                                      string sta, string remark, string emp, string hg, string batchNo, string quality, string hw,
                                      string slbwhCode, string grinWheel, string group, string shift, DateTime operation, string area)
        {
            string result = "1";

            TransactionHelper.BeginTransaction();
            try
            {
                Mod_TRC_PLAN_REGROUND_HANDLER model = new Mod_TRC_PLAN_REGROUND_HANDLER();
                model.C_REGROUND_ID    = id;
                model.C_EMP_NAME       = emp;
                model.C_STA_ID         = sta;
                model.C_XMBZ           = xmbz;
                model.N_TOTAL_QUA      = int.Parse(num);
                model.N_QUA            = int.Parse(factNum);
                model.C_BATCH_NO       = batchNo;
                model.C_QUALITY        = quality;
                model.C_HW             = hw;
                model.C_HG             = hg;
                model.N_STATUS         = 1;
                model.C_CAUSE          = remark;
                model.C_GRINDING_WHEEL = grinWheel;
                model.C_SHIFT          = shift;
                model.C_GROUP          = group;
                model.D_DT             = operation;
                if (!handlerDal.Add(model))
                {
                    TransactionHelper.RollBack();
                    return("0");
                }


                string columnName = "";
                if (area == "1")
                {
                    columnName = General.NameType[xmbz];
                }
                else
                {
                    columnName = General.NameTypes[xmbz];
                }

                if (!dal.UpdateRegroundProcedure(id, columnName, int.Parse(factNum), 1))
                {
                    TransactionHelper.RollBack();
                    return("0");
                }

                TransactionHelper.Commit();

                dal.UpdateRegroundType();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                return("0");
            }
            return(result);
        }
Ejemplo n.º 19
0
        public ResultMessage Refund(string orderNo)
        {
            Load();
            if (UserInformation == null)
            {
                return new ResultMessage()
                       {
                           Code = -1, Msg = "请重新登录"
                       }
            }
            ;
            TransactionHelper.BeginTransaction();
            var order = OrderService.GetOrderNo(orderNo);

            if (order == null)
            {
                return new ResultMessage()
                       {
                           Code = -1, Msg = "订单不存在"
                       }
            }
            ;
            if (order.orderState != OrderStates.complete && order.orderState != OrderStates.paid)
            {
                return new ResultMessage()
                       {
                           Code = -1, Msg = "订单状态不正确"
                       }
            }
            ;
            order.orderState = OrderStates.applyRefund;
            //if (Account != null)
            //{
            //    if (Account.salerId > 0)
            //    {
            //        var salerAccount = AccountService.GetByUserId(Account.salerId);
            //        if (salerAccount != null)
            //        {
            //            var amount = order.payAmount * RebateRatio;
            //            salerAccount.activatePoint += amount;
            //            OperationPointLog log = new OperationPointLog();
            //            log.account = "activatePoint";
            //            log.point = amount;
            //            log.remark = string.Format("{0}消费", UserInformation.Name);
            //            log.submitTime = DateTime.Now;
            //            log.userId = UserInformation.UserId;
            //            OperationPointLogService.Insert(log);
            //        }
            //    }
            //}
            OrderService.Update(order);
            TransactionHelper.Commit();
            return(new ResultMessage()
            {
                Code = 0
            });
        }
    }
}
        /// <summary>
        /// 撤销轧钢计划(中间表撤回)
        /// </summary>
        /// <param name="strID">trp_plan_roll_item_info表主键</param>
        public string BackPlan(string strID)
        {
            try
            {
                string result = "1";

                TransactionHelper.BeginTransaction();

                Mod_TRP_PLAN_ROLL_ITEM_INFO modItemInfo = dal.GetModel(strID);
                if (modItemInfo != null)
                {
                    if (modItemInfo.N_STATUS != 1)
                    {
                        TransactionHelper.RollBack();
                        return("撤销失败!");
                    }

                    if (!dal.Delete_Trans(strID))
                    {
                        TransactionHelper.RollBack();
                        return("撤销失败!");
                    }

                    Mod_TRP_PLAN_ROLL modPlan = dalTrpPlanRoll.GetModel(modItemInfo.C_PLAN_ROLL_ID);
                    if (modPlan == null)
                    {
                        TransactionHelper.RollBack();
                        return("撤销失败!");
                    }
                    else
                    {
                        modPlan.N_STATUS    = 0;
                        modPlan.N_ISSUE_WGT = modPlan.N_ISSUE_WGT - Convert.ToDecimal(modItemInfo.N_ISSUE_WGT);

                        if (!dalTrpPlanRoll.Update_Trans(modPlan))
                        {
                            TransactionHelper.RollBack();
                            return("撤销失败!");
                        }
                    }
                }
                else
                {
                    TransactionHelper.RollBack();
                    return("撤销失败!");
                }

                TransactionHelper.Commit();

                return(result);
            }
            catch
            {
                TransactionHelper.RollBack();
                return("撤销失败!");
            }
        }
Ejemplo n.º 21
0
 public RollbackType Rollback(int id)
 {
     try
     {
         using (var tran = TransactionHelper.BeginTransaction())
         {
             var serialNo    = SerialNoHelper.Create();
             var shopDealLog = this.ShopDealLogService.GetById(id);
             if (shopDealLog == null)
             {
                 throw new Exception(Localize("nofoundDeal"));
             }
             var dealLog = this.DealLogService.GetById(shopDealLog.Addin);
             if (dealLog == null)
             {
                 throw new Exception(Localize("nofoundDeal"));
             }
             var account = AccountService.GetById(dealLog.AccountId);
             if (account == null)
             {
                 throw new Exception(Localize("nofoundAccount"));
             }
             AccountServiceResponse rsp = null;
             RollbackType           r   = RollbackType.None;
             if (dealLog.SubmitTime.Date != DateTime.Now.Date)
             {
                 rsp = AccountDealService.CancelPay(new CancelPayRequest(dealLog.AccountName, "", dealLog.SourcePosName, Math.Abs(dealLog.Amount), serialNo, dealLog.SerialNo, account.AccountToken,
                                                                         dealLog.SourceShopName)
                 {
                     IsForce = true
                 });
                 r = RollbackType.Cancel;
             }
             else
             {
                 rsp = AccountDealService.Roolback(new PayRequest_(dealLog.AccountName, "", dealLog.SourcePosName, Math.Abs(dealLog.Amount), serialNo, dealLog.SerialNo, account.AccountToken,
                                                                   dealLog.SourceShopName)
                 {
                     IsForce = true
                 });
                 r = RollbackType.Undo;
             }
             if (rsp.Code != ResponseCode.Success)
             {
                 throw new Exception(string.Format("{0}", ModelHelper.GetBoundText(rsp, x => x.Code)));
             }
             LogHelper.LogWithSerialNo(LogTypes.DealLogRollback, serialNo, dealLog.DealLogId, dealLog.SerialServerNo, dealLog.SerialNo);
             tran.Commit();
             return(r);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(LogTypes.DealLogRollback, ex);
         return(RollbackType.None);
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        ///撤销调拨处理
        /// </summary>
        /// <returns></returns>
        public string BackAllotHandler(string staID, string stove, string grd, string spec, string std,
                                       string matCode, int num)
        {
            string result = "1";

            try
            {
                TransactionHelper.BeginTransaction();

                DataTable billet = new DataTable();
                if (dal.BackAllotGrdType(staID, stove, grd, spec, std, matCode, num, out billet) != num)
                {
                    TransactionHelper.RollBack();
                    return("0");
                }

                if (dal.BackAllotUpdateCenter(billet) != num)
                {
                    TransactionHelper.RollBack();
                    return("0");
                }

                if (billet != null && billet.Rows.Count > 0)
                {
                    DateTime time = DateTime.Now;
                    foreach (DataRow item in billet.Rows)
                    {
                        Mod_TSC_ALLOT_LOG model = new Mod_TSC_ALLOT_LOG();
                        model.C_STL_GRD      = grd;
                        model.C_SPEC         = spec;
                        model.C_STD_CODE     = std;
                        model.C_MAT_CODE     = matCode;
                        model.C_STOVE        = stove;
                        model.C_SLAB_MAIN_ID = item["C_ID"].ToString();
                        model.C_STA_ID       = staID;
                        model.N_TYPE         = 3;
                        model.D_MOD_DT       = time;
                        model.C_EMP_ID       = RV.UI.UserInfo.userID;
                        if (!logDal.Add(model))
                        {
                            TransactionHelper.RollBack();
                            return("0");
                        }
                    }
                }

                TransactionHelper.Commit();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                return("0");
            }

            return(result);
        }
Ejemplo n.º 23
0
        public void Execute(User currentUser)
        {
            var serialNo = SerialNoHelper.Create();

            using (var tran = TransactionHelper.BeginTransaction())
            {
                var liquidate = this.LiquidateService.GetById(LiquidateId);
                if (liquidate == null || liquidate.State != LiquidateStates.Processing)
                {
                    throw new Exception("没有找到相关的清算记录");
                }
                liquidate.State = LiquidateStates.Done;
                LiquidateService.Update(liquidate);

                var shop       = ShopService.GetById(ShopId);
                var rate       = shop.ShopDealLogChargeRate ?? HostSite.ShopDealLogChargeRate;
                var rateAmount = (liquidate.DealAmount * rate);
                var amount     = liquidate.DealAmount - liquidate.CancelAmount;

                var systemDealLog = new SystemDealLog(serialNo, currentUser)
                {
                    Addin     = liquidate.LiquidateId.ToString(),
                    Amount    = -amount,
                    DealType  = SystemDealLogTypes.ShopDealLogDone,
                    DealWayId = DealWayId,
                };
                SystemDealLogService.Create(systemDealLog);

                shop.Amount -= amount;
                var shopDealLog = new ShopDealLog(serialNo, DealTypes.ShopDealLogDone, -amount, null, null, null, shop,
                                                  systemDealLog.SystemDealLogId);
                ShopDealLogService.Create(shopDealLog);

                systemDealLog = new SystemDealLog(serialNo, currentUser)
                {
                    Addin     = liquidate.LiquidateId.ToString(),
                    Amount    = rateAmount,
                    DealType  = SystemDealLogTypes.ShopDealLogCharging,
                    DealWayId = DealWayId,
                };
                SystemDealLogService.Create(systemDealLog);

                shop.RechargingAmount += rateAmount;
                shopDealLog            = new ShopDealLog(serialNo, DealTypes.ShopDealLogDone, rateAmount, null, null, null, shop,
                                                         systemDealLog.SystemDealLogId);
                ShopDealLogService.Create(shopDealLog);

                var dealWay = DealWayService.GetById(this.DealWayId);
                if (dealWay.IsCash)
                {
                    CashDealLogService.Create(new CashDealLog(amount - rateAmount, currentUser.UserId, currentUser.UserId, CashDealLogTypes.ShopDealLogDone));
                }
                ShopService.Update(shop);
                tran.Commit();
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 入库处理
        /// </summary>
        /// <param name="stove">炉号</param>
        /// <param name="num">支数</param>
        /// <param name="grd">钢种</param>
        /// <param name="std">执行标准</param>
        /// <param name="spec">规格</param>
        /// <param name="matCode">物料编码</param>
        /// <param name="area">区域</param>
        /// <param name="loc">库位</param>
        /// <param name="tier">层</param>
        /// <param name="shift">班次</param>
        /// <param name="group">班组</param>
        /// <param name="slabwhCode">仓库编码</param>
        /// <returns></returns>
        public string PutStoreHandler(string stove, int num, string grd, string std, string spec,
                                      string matCode, string area, string loc, string tier, string shift, string group, string slabwhCode)
        {
            string    result = "1";
            DataTable dt     = dal.GetPutData(stove, num, grd, std, spec, matCode, slabwhCode).Tables[0];

            try
            {
                TransactionHelper.BeginTransaction();

                if (dt == null && dt.Rows.Count == 0)
                {
                    return("0");
                }

                if (dal.AllotPutUpdateCenter(dt, slabwhCode, area, loc, tier) != num)
                {
                    TransactionHelper.RollBack();
                    return("0");
                }

                if (dal.AllotPutUpdateSlab(dt, slabwhCode, area, loc, tier, shift, group) != num)
                {
                    TransactionHelper.RollBack();
                    return("0");
                }

                DateTime time = DateTime.Now;
                foreach (DataRow item in dt.Rows)
                {
                    Mod_TSC_ALLOT_LOG model = new Mod_TSC_ALLOT_LOG();
                    model.C_STL_GRD      = grd;
                    model.C_SPEC         = spec;
                    model.C_STD_CODE     = std;
                    model.C_MAT_CODE     = matCode;
                    model.C_STOVE        = stove;
                    model.C_SLAB_MAIN_ID = item["C_SLAB_MAIN_ID"].ToString();
                    model.N_TYPE         = 2;
                    model.D_MOD_DT       = time;
                    model.C_EMP_ID       = RV.UI.UserInfo.userID;
                    if (!logDal.Add(model))
                    {
                        TransactionHelper.RollBack();
                        return("0");
                    }
                }
                TransactionHelper.Commit();
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                return("0");
            }

            return(result);
        }
Ejemplo n.º 25
0
        public object Save()
        {
            try
            {
                var           serialNo = SerialNoHelper.Create();
                SystemDealLog dealLog  = SystemDealLogService.GetById(Id);
                if (dealLog != null && dealLog.CanCancel(SystemDealLogTypes.Recharge, CurrentSite))
                {
                    var account = AccountService.GetById(Convert.ToInt32(dealLog.Addin));
                    if (account == null || account.State != AccountStates.Normal)
                    {
                        return(new DataAjaxResult(Localize("NoAccount", "会员信息未找到")));
                    }

                    var passwordService = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType);
                    var password        = passwordService.Decrypto(Password);

                    if (User.SaltAndHash(password, account.PasswordSalt) != account.Password)
                    {
                        return(new DataAjaxResult(Localize("error.Password", "密码错误")));
                    }

                    dealLog.State   = SystemDealLogStates.Closed;
                    account.Amount -= dealLog.Amount;
                    var logItem = DealLogService.GetByAddin(dealLog.SystemDealLogId);
                    TransactionHelper.BeginTransaction();
                    if (logItem != null)
                    {
                        logItem.State = DealLogStates.Cancel;
                        DealLogService.Update(logItem);
                        DealLogService.Create(new DealLog(serialNo)
                        {
                            Account    = account,
                            Amount     = dealLog.Amount,
                            SubmitTime = DateTime.Now,
                            State      = DealLogStates.Normal,
                            DealType   = DealTypes.CancelRecharging,
                            Addin      = logItem.DealLogId,
                        });
                    }

                    SystemDealLogService.Update(dealLog);
                    AccountService.Update(account);
                    LogHelper.LogWithSerialNo(LogTypes.SystemDealLogCloseRecharging, serialNo, dealLog.SystemDealLogId, dealLog.SystemDealLogId, account.Name);
                    AddMessage(Localize("CloseRecharging.success"), dealLog.SystemDealLogId);

                    return(TransactionHelper.CommitAndReturn(new SimpleAjaxResult()));
                }
                return(new SimpleAjaxResult(Localize("OpenReceipt.failed", "原交易不存在")));
            }
            catch (Exception ex)
            {
                Logger.Error(LogTypes.SystemDealLogCloseRecharging, ex);
                return(new SimpleAjaxResult(ex.Message));
            }
        }
Ejemplo n.º 26
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();

            TransactionHelper.BeginTransaction();
            base.OnSave(InnerObject);
            OrderService.CreateGood(InnerObject);
            AddMessage("success", InnerObject.GoodName);
            Logger.LogWithSerialNo(LogTypes.EditGood, serialNo, InnerObject.GoodId, InnerObject.GoodName);
            return(TransactionHelper.CommitAndReturn(this));
        }
Ejemplo n.º 27
0
        public IMessageProvider Save()
        {
            TransactionHelper.BeginTransaction();
            var serialNo    = SerialNoHelper.Create();
            var pointRebate = PointRebateService.GetById(this.PointRebate);

            if (pointRebate == null)
            {
                AddError(LogTypes.AccountRebate, "NoPointRebate");
                return(this);
            }
            var account = AccountService.GetById(AccountId);

            if (account == null || account.Point < pointRebate.Point)
            {
                AddError(LogTypes.AccountRebate, "NoPointRebate");
                return(this);
            }

            var accountLevel =
                AccountLevelPolicyService.Query().FirstOrDefault(
                    x => x.State == AccountLevelPolicyStates.Normal && x.Level == account.AccountLevel && x.AccountTypeId == account.AccountTypeId);

            var owner        = (AccountUser)(_innerObject.OwnerId.HasValue ? this.MembershipService.GetUserById(_innerObject.OwnerId.Value) : null);
            var pointRebates = PointRebateService.Query().Where(x => x.IsFor(account, owner, accountLevel, DateTime.Now) && x.Point < account.Point).ToList();

            if (pointRebates.Count == 0)
            {
                AddError(LogTypes.AccountRebate, "NoPointRebate");
                return(this);
            }

            if (!pointRebates.Any(x => x.PointRebateId == pointRebate.PointRebateId))
            {
                AddError(LogTypes.AccountRebate, "NoPointRebate");
                return(this);
            }

            account.Amount += pointRebate.Amount;
            account.Point  -= pointRebate.Point;

            AccountService.Update(account);
            var dealLog = new DealLog(serialNo, DealTypes.Rebate, -pointRebate.Amount, -pointRebate.Point, null, null, account, null, pointRebate.PointRebateId);

            DealLogService.Create(dealLog);
            SystemDealLogService.Create(new SystemDealLog(serialNo, SecurityHelper.GetCurrentUser())
            {
                Amount = pointRebate.Amount, DealType = SystemDealLogTypes.Rebate, Addin = dealLog.DealLogId.ToString()
            });
            Logger.LogWithSerialNo(LogTypes.AccountRebate, serialNo, account.AccountId, account.Name, pointRebate.DisplayName);
            PointRebateLogService.Create(new PointRebateLog(serialNo, account, SecurityHelper.GetCurrentUser().CurrentUser, pointRebate));
            AddMessage("success", pointRebate.Amount, pointRebate.Point);
            return(TransactionHelper.CommitAndReturn(this));
        }
Ejemplo n.º 28
0
        public IMessageProvider Create()
        {
            var serialNo = SerialNoHelper.Create();

            TransactionHelper.BeginTransaction();
            base.OnSave(InnerObject);
            DealWayService.Create(InnerObject);
            AddMessage("success", InnerObject.DisplayName);
            Logger.LogWithSerialNo(LogTypes.DealWayCreate, serialNo, InnerObject.DealWayId, InnerObject.DisplayName);
            return(TransactionHelper.CommitAndReturn(this));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 确认结算,如果这条消费记录的卡号不属于自己的,则给下级经销商生成结算请求
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public void Close(int id)
        {
            TransactionHelper.BeginTransaction();
            var item = DistributorBrokerageService.GetDistributorBrokerageById(id);

            if (item == null)
            {
                return;
            }
            var user      = this.SecurityHelper.GetCurrentUser();
            int currentId = -1;

            if (user is DistributorUserModel)
            {
                currentId = DistributorService.GetByUserId(user.CurrentUser.Id).DistributorId;
            }
            if (item.settlementDistributorId == currentId && item.status == false)
            {
                item.status = true;
                DistributorBrokerageService.UpdateDistributorBrokerage(item);
                //增加经销商的余额
                var distributor1 = DistributorService.GetById(item.settlementDistributorId);
                distributor1.Amount += item.brokerage;
                DistributorService.Update(distributor1);
                if (item.DistributorId != item.settlementDistributorId)
                {
                    //归属他下属的卡消费,他要跟下属结算。
                    //如果是多级还要找到他的直接下属,只能向他的直接下属发起结算请求。
                    int underId = GetDirectlyUnder(item.settlementDistributorId, item.DistributorId);
                    if (underId != 0)
                    {
                        var distributor            = DistributorService.GetAccountLevelPolicyRates(underId).FirstOrDefault();
                        DistributorBrokerage model = new DistributorBrokerage();
                        model.DistributorId           = item.DistributorId;
                        model.AccountId               = item.AccountId;
                        model.Bdate                   = item.Bdate;
                        model.consume                 = item.consume;
                        model.Edate                   = item.Edate;
                        model.settlementDistributorId = underId;
                        model.Rate      = distributor.Rate;
                        model.brokerage = item.consume * distributor.Rate;
                        model.status    = false;
                        DistributorBrokerageService.CreateDistributorBrokerage(model);
                    }
                    AddMessage("update.success", item.Id);
                }
            }
            else
            {
                AddError("不是结算经销商", item.Id);
            }
            TransactionHelper.Commit();
        }
Ejemplo n.º 30
0
 public SimpleAjaxResult Ready()
 {
     try
     {
         var serialNo = SerialNoHelper.Create();
         var account  = AccountService.GetByName(AccountName);
         if (account == null || !string.Equals(account.AccountToken, AccountToken, StringComparison.OrdinalIgnoreCase))
         {
             throw new Exception(string.Format("会员 '{0}' 未找到", AccountName));
         }
         using (var tran = TransactionHelper.BeginTransaction())
         {
             account.LimiteAmount = LimitAmount;
             LimitAmountCommand cmd = new LimitAmountCommand(account.AccountId, LimitAmount);
             UnityContainer.BuildUp(cmd);
             Helper h = new Helper(cmd.Validate());
             if (h.Code != 0)
             {
                 this.AddError(LogTypes.AccountLimit, "error", ModelHelper.GetBoundText(h, x => x.Code));
                 return(new SimpleAjaxResult(ModelHelper.GetBoundText(h, x => x.Code)));
             }
             if (HostSite.IsLimiteAmountApprove)
             {
                 //var tasks= TaskService.Query(new TaskRequest()
                 //                       {
                 //                           CommandTypeName = Task.GetCommandType(typeof (LimitAmountCommand)),
                 //                           State = TaskStates.Normal,
                 //                           AccountId = account.AccountId,
                 //                       }).ToList();
                 //foreach (var task in tasks)
                 //{
                 //    TaskService.Delete(task);
                 //}
                 TaskService.Create(new Task(cmd, SecurityHelper.GetCurrentUser().CurrentUser.UserId)
                 {
                     Amount = LimitAmount, AccountId = account.AccountId
                 });
             }
             else
             {
                 cmd.Execute(SecurityHelper.GetCurrentUser().CurrentUser);
             }
             Logger.LogWithSerialNo(LogTypes.AccountLimit, serialNo, account.AccountId, account.Name, LimitAmount);
             tran.Commit();
             return(new SimpleAjaxResult());
         }
     }
     catch (Exception ex)
     {
         Logger.Error(LogTypes.AccountLimit, ex);
         return(new SimpleAjaxResult(string.Format("内部错误: '{0}'", ex.Message)));
     }
 }