예제 #1
0
        public void Test4()
        {
            IList <string> list = new List <string>();


            try
            {
                using (TransactionManager manager = new TransactionManager())
                {
                    manager.Create(() => { AddName1(list); }, () => { RollbackName1(list); });
                    manager.Create(() => { AddName2(list, true); }, () => { RollbackName2(list); });

                    manager.Commit();
                }
            }
            catch
            {
            }
            bool isContainName1 = list.Contains(NAME_1);

            bool isContainName2 = list.Contains(NAME_2);

            bool status = (!isContainName1 && !isContainName2);

            Assert.IsTrue(status);
        }
예제 #2
0
 public static bool ValidateCustomerPhone(string cellNumber, string confimKey, Point point)
 {
     using (var tran = TransactionManager.Create())
     {
         if (CustomerDA.ValidateCustomerPhone(cellNumber, confimKey) == false)
         {
             return(false);
         }
         PointFilter filter = new PointFilter
         {
             CustomerSysNo    = point.CustomerSysNo,
             ObtainType       = point.ObtainType,
             LanguageCode     = ConstValue.LanguageCode,
             CompanyCode      = ConstValue.CompanyCode,
             CurrencyCode     = ConstValue.CurrencySysNo.ToString(),
             StoreCompanyCode = ConstValue.StoreCompanyCode
         };
         if (CommonDA.ExistsPoint(filter) <= 0)
         {
             CommonFacade.AddPoint(point);
         }
         tran.Complete();
         return(true);
     }
 }
예제 #3
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="article">数据实体</param>
 public void Update(ArticleVO articleVO)
 {
     using (ITransaction transaction = TransactionManager.Create())
     {
         ArticleEntity article = articleVO.ToArticleEntity();
         this.CheckEntity(article);
         if ((articleVO.ArticleDepartmentList == null || articleVO.ArticleDepartmentList.Count == 0) &&
             string.IsNullOrEmpty(articleVO.UserIds))
         {
             throw new BusinessException("请选择推文对象或填写推送用户");
         }
         ArticleDA.Update(article);
         // 插入用户id数据
         if (!string.IsNullOrEmpty(articleVO.UserIds))
         {
             List <ArticleUser> articleUsers = articleVO.UserIds.Split(new char[] { '|' }).Select(p => new ArticleUser()
             {
                 ArticleId = articleVO.BusinessId, UserId = p
             }).ToList();
             ArticleDA.BatchInserArticleUser(articleUsers);
         }
         // 插入分发得公司
         transaction.Complete();
     }
 }
예제 #4
0
        /// <summary>
        /// 批量修改文章状态
        /// </summary>
        /// <param name="?"></param>
        /// <param name="status"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool BatchUpdateTopicStatus(List <int> topicSysNoList, TopicStatus status, CurrentUser user)
        {
            //AjaxResult ajaxResult = new AjaxResult() { Success = true, Message = string.Empty };
            List <TopicInfo> topicList = new List <TopicInfo>();

            #region check
            foreach (int topicSysNo in topicSysNoList)
            {
                var topic = LoadTopicInfoBySysNo(topicSysNo);
                if (status == TopicStatus.Published && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline)
                {
                    throw new BusinessException(LangHelper.GetText("只有草稿和撤下状态才能发布!"));
                    //ajaxResult.Success = false;
                    //ajaxResult.Message = "只有草稿和撤下状态才能发布!";
                    //return ajaxResult;
                }
                if (status == TopicStatus.Void && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline)
                {
                    throw new BusinessException(LangHelper.GetText("只有草稿和撤下状态才能作废!"));
                    //ajaxResult.Success = false;
                    //ajaxResult.Message = "只有草稿和撤下状态才能发布!";
                    //return ajaxResult;
                }
                if (status == TopicStatus.Delete && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline && topic.TopicStatus != TopicStatus.Void)
                {
                    throw new BusinessException(LangHelper.GetText("只有草稿,撤下以及作废状态才能删除!"));
                    //ajaxResult.Success = false;
                    //ajaxResult.Message = "只有草稿和撤下状态才能发布!";
                    //return ajaxResult;
                }
                topicList.Add(new TopicInfo()
                {
                    SysNo         = topicSysNo,
                    TopicStatus   = status,
                    EditUserSysNo = user.UserSysNo,
                    EditUserName  = user.UserDisplayName,
                    EditDate      = DateTime.Now
                });
            }

            #endregion

            using (ITransaction transaction = TransactionManager.Create())
            {
                foreach (var topic in topicList)
                {
                    if (status == TopicStatus.Published)
                    {
                        TopicDA.PublishTopic(topic);
                    }
                    else
                    {
                        TopicDA.UpdateTopicStatus(topic);
                    }
                }
                transaction.Complete();
            }

            return(true);
        }
예제 #5
0
        /// <summary>
        /// 创建新闻类别
        /// </summary>
        /// <param name="topicCategory"></param>
        /// <returns></returns>
        public static int InsertTopicCategory(TopicCategory topicCategory, CurrentUser user)
        {
            int sysNo = 0;

            using (ITransaction transaction = TransactionManager.Create())
            {
                bool nameExist = TopicDA.CheckNameIsExist(topicCategory);
                if (nameExist)
                {
                    throw new BusinessException(LangHelper.GetText("类别名称已存在!"));
                }
                string pCategoryID = string.IsNullOrEmpty(topicCategory.ParentCategoryID) ? "" : topicCategory.ParentCategoryID;
                string categoryID  = pCategoryID + "01";

                List <TopicCategory> list = QueryAllTopicCategoryListByParentID(pCategoryID);

                if (list != null && list.Count > 0)
                {
                    TopicCategory tc    = list.OrderByDescending(p => p.SysNo).FirstOrDefault();
                    int           index = int.Parse(tc.CategoryID.Substring(tc.CategoryID.Length - 2, 2)) + 1;
                    categoryID = pCategoryID + (index < 10 ? "0" + index.ToString() : index.ToString());
                }

                topicCategory.ParentCategoryID = pCategoryID;
                topicCategory.CategoryID       = categoryID;
                sysNo = TopicDA.InsertTopicCategory(topicCategory);
                transaction.Complete();
            }
            return(sysNo);
        }
예제 #6
0
        public JsonResult AjaxDoUpdateRole(Guid?roleId, string roleName, string roleDesc, string users, string permissions)
        {
            if (roleId.HasValue == false)
            {
                throw new ApplicationException("roleId不能为空!");
            }

            List <Guid>   staffUserIds   = Utility.ConvertStringToGuidList(users);
            List <string> permissionList = this.ParsePermissions(permissions);

            using (var tran = TransactionManager.Create())
            {
                Api <IStaffRoleApi> .Instance.Update(roleId.Value, roleName, roleDesc);

                Api <IStaffRoleApi> .Instance.SetPermissionKeys(roleId.Value, permissionList);

                Api <IStaffRoleApi> .Instance.SetUsers(roleId.Value, staffUserIds);

                tran.Complete();
            }

            string url = LinkUrl("StaffUser/RoleDetail", new { id = roleId });

            return(Json(new { url = url }));
        }
예제 #7
0
        public static void UpdateUser(UserInfo user)
        {
            if (user == null || string.IsNullOrEmpty(user.UserID))
            {
                throw new BusinessException("输入不正确");
            }
            if (string.IsNullOrEmpty(user.UserName))
            {
                throw new BusinessException("用户名不能为空");
            }
            if (UserDA.CountUserID(user.UserID, user.SysNo.Value) > 0)
            {
                throw new BusinessException("登录用户名重复,请重新输入");
            }

            using (ITransaction transaction = TransactionManager.Create())
            {
                UserDA.UpdateVendorUser(user);
                UserDA.DeleteVendorUser_User_Role(user.SysNo.Value);
                foreach (var item in user.Roles)
                {
                    item.UserSysNo = user.SysNo;
                    UserDA.InsertVendorUser_User_Role(item);
                }
                transaction.Complete();
            }
        }
예제 #8
0
        public static RMARefundInfo Reject(int rmaRefundSysNo, LoginUser operateUser)
        {
            RMARefundInfo info = LoadWithRefundSysNo(rmaRefundSysNo, operateUser.SellerSysNo);

            if (info == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退款单", rmaRefundSysNo));
            }
            if (info.Status != RMARefundStatus.WaitingAudit)
            {
                throw new BusinessException(L("退款单不是“待审核”,不能审核拒绝"));
            }

            info.Status         = RMARefundStatus.Abandon;
            info.SOIncomeStatus = SOIncomeStatus.Abandon;
            using (ITransaction ts = TransactionManager.Create())
            {
                RMARefundDA.Update(info);
                RMARefundDA.BatchUpdateRegisterRefundStatusAndStatus(info.SysNo.Value, RMARefundStatus.Abandon, RMARequestStatus.Complete);

                var rmaRequstSysNoList = RMARefundDA.QueryRMARequsetSysNoByRefundSysNo(info.SysNo.Value);
                if (rmaRequstSysNoList != null && rmaRequstSysNoList.Count > 0)
                {
                    foreach (var rmaRequestSysNo in rmaRequstSysNoList)
                    {
                        RMARequestService.RefreshRequestStatus(rmaRequestSysNo, operateUser.SellerSysNo);
                    }
                }

                ts.Complete();
            }

            return(info);
        }
예제 #9
0
 public static int SaveStoreAttachment(List <StoreAttachment> attas)
 {
     if (attas.Count <= 0)
     {
         return(0);
     }
     using (var trans = TransactionManager.Create())
     {
         //StoreDA.DeleteAttachmentBySellerSysNo(attas[0].SellerSysNo.Value);
         foreach (var item in attas)
         {
             if (item.SysNo.HasValue)
             {
                 //TODO update
                 StoreDA.UpdateStoreAttachment(item);
             }
             else
             {
                 StoreDA.InsertStoreAttachment(item);
             }
         }
         trans.Complete();
     }
     return(1);
 }
예제 #10
0
        /// <summary>
        /// 保存备注
        /// </summary>
        /// <param name="item">The item.</param>
        public static void SaveProductReviewRemark(ProductReviewInfo item)
        {
            using (ITransaction transaction = TransactionManager.Create())
            {
                if (item.IsIndexHotReview == "Y")//操作首页热评,更新或新建
                {
                    ProductReviewDA.UpdateHomepageForProductReview(item.SysNo.Value, "H");
                }
                else
                {
                    ProductReviewDA.DeleteHomepageForProductReview(item.SysNo.Value, "H");
                }
                if (item.IsServiceHotReview == "Y")//操作首页服务热评,更新或新建
                {
                    ProductReviewDA.UpdateHomepageForProductReview(item.SysNo.Value, "S");
                }
                else
                {
                    ProductReviewDA.DeleteHomepageForProductReview(item.SysNo.Value, "S");
                }


                ProductReviewDA.UpdateProductReview(item);

                transaction.Complete();
            }
        }
예제 #11
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="user">数据实体</param>
        public void Insert(UserEntity user, AuthUserModel authUserModel)
        {
            if (authUserModel == null)
            {
                throw new BusinessException("未获取到当前登录用户信息");
            }
            this.CheckUserEntity(user);
            var hasExitsLoginName = UserDA.CheckUserLoginNameExist(user.LoginName, 0);

            if (hasExitsLoginName)
            {
                throw new BusinessException(string.Format("{0}用户名已存在", user.LoginName));
            }
            using (ITransaction transaction = TransactionManager.Create())
            {
                this.BindBasisInfo(user, authUserModel);
                int userId = UserDA.Insert(user);
                // 写入角色关联
                if (user.RoleId.HasValue)
                {
                    RoleUserService.Insert(new AuthCenter.Entity.Entity.RoleUserEntity()
                    {
                        RoleId  = user.RoleId.Value,
                        UserId  = userId,
                        Creator = authUserModel.UserSysNo
                    });
                }
                transaction.Complete();
            }
        }
예제 #12
0
파일: SODA.cs 프로젝트: sanlonezhang/ql
 public static void SOUpdate(SOUpdateInfo soUpdateInfo)
 {
     using (var tx = TransactionManager.Create())
     {
         SOUpdateMaster(soUpdateInfo);
         SOUpdateItems(soUpdateInfo);
         tx.Complete();
     }
 }
예제 #13
0
 public static void BathUpdateRoleStatus(List <RoleInfo> list)
 {
     using (ITransaction transaction = TransactionManager.Create())
     {
         foreach (var item in list)
         {
             UserDA.UpdateRoleStatus(item);
         }
         transaction.Complete();
     }
 }
예제 #14
0
 public static void InsertAddressManager(List <int> users, string code, int companySysNo)
 {
     using (ITransaction transaction = TransactionManager.Create())
     {
         AddressDA.DeleteAddressManagerByCode(code, companySysNo);
         if (users != null && users.Count > 0)
         {
             AddressDA.InsertAddressManager(users, code, companySysNo);
         }
         transaction.Complete();
     }
 }
예제 #15
0
 public static bool ValidateCustomerPhoneWithoutPoint(string cellNumber, string confimKey)
 {
     using (var tran = TransactionManager.Create())
     {
         if (CustomerDA.ValidateCustomerPhone(cellNumber, confimKey) == false)
         {
             return(false);
         }
         tran.Complete();
         return(true);
     }
 }
예제 #16
0
        public static void AdjustPrePay(CustomerPrepayLog adjustInfo)
        {
            CustomerBasicInfo original = GetCustomerInfo(adjustInfo.CustomerSysNo.Value);

            using (ITransaction tran = TransactionManager.Create())
            {
                //1.更新余额
                CustomerDA.UpdatePrepay(adjustInfo.CustomerSysNo.Value, adjustInfo.AdjustAmount.Value);
                //2.记录业务日志
                CustomerDA.CreatePrepayLog(adjustInfo);
                tran.Complete();
            }
        }
        /// <summary>
        /// 删除MsgTemplate信息
        /// </summary>
        public bool DeleteMsgTemplate(int sysNo, CurrentUser user)
        {
            bool result = false;

            using (ITransaction transaction = TransactionManager.Create())
            {
                result = MessageCenter.Server.SMSBusinessServer.DeleteMsgTemplate(sysNo);
                //记录操作日志
                //OperationLogProcessor.WriteLog(BizObjectType.MsgTemplate, BizOperationType.Delete, sysNo.ToString(), user, LangHelper.GetText("删除消息模板"));
                transaction.Complete();
            }
            return(result);
        }
예제 #18
0
 public static int SaveCertification(CertificationInfo certificaiton)
 {
     if (certificaiton == null)
     {
         return(0);
     }
     using (var trans = TransactionManager.Create())
     {
         StoreDA.InsertApplication(certificaiton);
         StoreDA.InsertCertificationAttachment(certificaiton);
         trans.Complete();
     }
     return(1);
 }
예제 #19
0
        /// <summary>
        /// publish store page
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public static int PublishStorePage(StorePage page)
        {
            using (var trans = TransactionManager.Create())
            {
                //step 1 save drafts
                var sysNo = SaveStorePage(page);
                page.SysNo = sysNo;
                //StoreDA.SaveStorePageDraft(page);
                //step 2 publish
                StoreDA.PublishStorePage(page);

                trans.Complete();
            }
            return(1);
        }
        /// <summary>
        /// 更新MsgTemplate信息
        /// </summary>
        public bool UpdateMsgTemplate(MsgTemplate entity, CurrentUser user)
        {
            //return MsgTemplateProcessor.UpdateMsgTemplate(entity,user);
            CheckMsgTemplate(entity, false);
            bool result = false;

            using (ITransaction transaction = TransactionManager.Create())
            {
                result = MessageCenter.Server.SMSBusinessServer.UpdateMsgTemplate(entity);
                //记录操作日志
                //OperationLogProcessor.WriteLog(BizObjectType.MsgTemplate, BizOperationType.Update, entity.SysNo.ToString(), user, LangHelper.GetText("修改消息模板"), entity);
                transaction.Complete();
            }
            return(result);
        }
예제 #21
0
        public static RMARefundInfo Valid(int rmaRefundSysNo, LoginUser operateUser)
        {
            RMARefundInfo info = LoadWithRefundSysNo(rmaRefundSysNo, operateUser.SellerSysNo);

            if (info == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退款单", rmaRefundSysNo));
            }
            if (info.Status != RMARefundStatus.WaitingAudit)
            {
                throw new BusinessException(L("退款单不是“待审核”,不能审核通过"));
            }

            //info.Status = RMARefundStatus.WaitingRefund;
            info.Status         = RMARefundStatus.Refunded;
            info.SOIncomeStatus = SOIncomeStatus.Origin;
            info.AuditUserSysNo = operateUser.UserSysNo;
            info.AuditUserName  = operateUser.UserDisplayName;
            info.AuditDate      = DateTime.Now;

            using (ITransaction ts = TransactionManager.Create())
            {
                RMARefundDA.Update(info);
                //更新BankInfoStatus的为审核通过
                RMARefundDA.AuditSOIncomeRefund(info.SysNo.Value, (int)info.OrderType, (int)RefundStatus.Refunded, operateUser.UserSysNo, operateUser.UserDisplayName);
                RMARefundDA.BatchUpdateRegisterRefundStatus(info.SysNo.Value, RMARefundStatus.WaitingRefund);
                //写入退款单
                SOIncomeInfo soIncomeInfo = new SOIncomeInfo()
                {
                    OrderType      = SOIncomeOrderType.RO,
                    OrderSysNo     = info.SysNo,
                    OrderAmt       = -1 * info.CashAmt,
                    IncomeStyle    = SOIncomeOrderStyle.RO,
                    IncomeAmt      = -1 * info.CashAmt,
                    PayAmount      = -1 * info.CashAmt,
                    InUserSysNo    = operateUser.UserSysNo,
                    InUserName     = operateUser.UserDisplayName,
                    Status         = SOIncomeStatus.Origin,
                    PointPay       = info.PointPay,
                    GiftCardPayAmt = info.GiftCardAmt,
                };
                RMARefundDA.CreateRefundSOIncome(soIncomeInfo);

                ts.Complete();
            }

            return(info);
        }
예제 #22
0
        /// <summary>
        /// 批量设置产品评论的状态
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="status">The status.</param>
        public static void BatchSetProductReviewReplyStatus(List <int> items, string status)
        {
            using (ITransaction transaction = TransactionManager.Create())
            {
                foreach (int sysNo in items)
                {
                    DataCommand dataCommand = DataCommandManager.GetDataCommand("ProductReview_UpdateProductReviewStatusForUpdateReplyStatus");
                    dataCommand.SetParameterValue("@SysNo", sysNo);
                    dataCommand.SetParameterValue("@Status", status);
                    dataCommand.SetParameterValueAsCurrentUserAcct("EditUser");

                    dataCommand.ExecuteNonQuery();
                }

                transaction.Complete();
            }
        }
예제 #23
0
        public JsonResult AjaxDoCreateUser(string userName, string displayName, string password, string password2, string email, string mobile, string roles)
        {
            if (string.IsNullOrWhiteSpace(userName))
            {
                throw new BizException("登录名不能为空!");
            }

            if (string.IsNullOrWhiteSpace(displayName))
            {
                throw new BizException("显示名不能为空!");
            }

            if (string.IsNullOrWhiteSpace(password))
            {
                throw new BizException("密码不能为空!");
            }

            if (string.IsNullOrWhiteSpace(password2))
            {
                throw new BizException("确认密码不能为空!");
            }

            if (password != password2)
            {
                throw new BizException("密码和确认密码不同!");
            }

            List <Guid> roleList = Utility.ConvertStringToGuidList(roles);

            Guid uid = Guid.Empty;

            using (var tran = TransactionManager.Create())
            {
                uid = Api <IStaffUserApi> .Instance.Create(userName, displayName, password, email, mobile);

                Api <IStaffUserApi> .Instance.SetRoles(uid, roleList);

                tran.Complete();
            }

            //long? idnumber = Api<IStaffUserApi>.Instance.GetIdNumber(uid);
            string url = LinkUrl("StaffUser/UserDetail", new { id = uid });

            return(Json(new { url = url }));
        }
예제 #24
0
        public JsonResult AjaxDoUpdateUser(Guid adminUserId, string displayName, string password, string password2, string email, string mobile, string roles)
        {
            StaffUser adminUser = Api <IStaffUserApi> .Instance.Get(adminUserId);

            if (adminUser == null)
            {
                throw new BizException("ID为'{0}'的系统用户不存在!", adminUserId);
            }

            List <Guid> roleList = Utility.ConvertStringToGuidList(roles);

            if (string.IsNullOrWhiteSpace(password) == false)
            {
                if (string.IsNullOrWhiteSpace(password2))
                {
                    throw new BizException("确认密码不能为空!");
                }

                if (password != password2)
                {
                    throw new BizException("密码和确认密码不同!");
                }
            }

            using (var tran = TransactionManager.Create())
            {
                if (string.IsNullOrWhiteSpace(displayName) == false)
                {
                    Api <IStaffUserApi> .Instance.Update(adminUserId, displayName, email, mobile);
                }

                if (string.IsNullOrWhiteSpace(password) == false)
                {
                    Api <IStaffUserApi> .Instance.ChangePassword(adminUserId, password);
                }

                Api <IStaffUserApi> .Instance.SetRoles(adminUserId, roleList);

                tran.Complete();
            }

            string url = LinkUrl("StaffUser/UserDetail", new { id = adminUserId });

            return(Json(new { url = url }));
        }
예제 #25
0
        /// <summary>
        /// 退款
        /// </summary>
        /// <param name="rmaRequestSysNo">退换货申请单编号</param>
        /// <param name="refundInfo">退款信息</param>
        /// <param name="userSysNo">操作人用户</param>
        /// <returns></returns>
        public static RMARequestInfo Refund(int rmaRequestSysNo, RMARefundInfo refundInfo, LoginUser operateUser)
        {
            RMARequestInfo requestInfo = LoadWithRequestSysNo(rmaRequestSysNo, operateUser.SellerSysNo);

            if (requestInfo == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退换货申请单", rmaRequestSysNo));
            }
            if (requestInfo.Status != RMARequestStatus.Handling)
            {
                throw new BusinessException(L("不是“处理中”的申请单不能退款"));
            }
            if (refundInfo == null || !refundInfo.RefundPayType.HasValue)
            {
                throw new ArgumentException(L("退款信息为空"));
            }

            requestInfo.Registers = requestInfo.Registers.Where(g => g.RequestType == RMARequestType.Return &&
                                                                g.Status == RMARequestStatus.Handling).ToList();
            if (requestInfo.Registers.Count <= 0)
            {
                throw new ArgumentException(L("没有“待处理”的退货商品"));
            }

            refundInfo.SOSysNo       = requestInfo.SOSysNo;
            refundInfo.CustomerSysNo = requestInfo.CustomerSysNo;
            //计算退款金额
            CalcRefundAmount(refundInfo, requestInfo);

            using (ITransaction trans = TransactionManager.Create())
            {
                //创建退款单
                RMARefundService.Create(refundInfo, operateUser);
                //设置单件的退款状态为退款中
                foreach (var registerInfo in requestInfo.Registers)
                {
                    registerInfo.RefundStatus = RMARefundStatus.WaitingAudit;
                    RMARequestDA.UpdateRegisterStatus(registerInfo);
                }

                trans.Complete();
            }

            return(requestInfo);
        }
예제 #26
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="role">数据实体</param>
        public void Delete(int roleId)
        {
            var hasAassociationRoleUser = RoleUserService.HasExistUserRoleAssociation(roleId);

            if (hasAassociationRoleUser)
            {
                throw new BusinessException("该角色下已存在关联用户,不允许删除该角色");
            }
            using (ITransaction transaction = TransactionManager.Create())
            {
                // 删除角色 以及删除角色对应的功能权限数据
                RoleDA.Delete(new RoleEntity()
                {
                    Id = roleId, CommonStatus = CommonStatus.Deleted
                });
                RoleFunctionService.BatchDeleteFunction(roleId);
                transaction.Complete();
            }
        }
예제 #27
0
        /// <summary>
        /// 换货
        /// </summary>
        /// <param name="rmaRequestSysNo"></param>
        /// <param name="userSysNo"></param>
        /// <returns></returns>
        public static RMARequestInfo Revert(int rmaRequestSysNo, LoginUser operateUser)
        {
            RMARequestInfo request = LoadWithRequestSysNo(rmaRequestSysNo, operateUser.SellerSysNo);

            if (request == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退换货申请单", rmaRequestSysNo));
            }
            if (request.Status != RMARequestStatus.Handling)
            {
                throw new BusinessException(L("不是“处理中”的申请单不能退货"));
            }

            var rmaRevertRegister = request.Registers.Where(g => g.RequestType == RMARequestType.Exchange &&
                                                            g.Status == RMARequestStatus.Handling);

            if (rmaRevertRegister.Count() <= 0)
            {
                throw new BusinessException(L("没有“待处理”的换货商品"));
            }

            using (ITransaction trans = TransactionManager.Create())
            {
                //如果所有的单件都处理完毕,自动关闭退款申请
                if (request.Registers.Count(g => g.RequestType == RMARequestType.Exchange)
                    == request.Registers.Count(g => g.Status == RMARequestStatus.Handling))
                {
                    request.Status = RMARequestStatus.Complete;
                    RMARequestDA.Update(request);
                }
                //关闭单件, 更新单件发还状态为已发还
                foreach (var registerInfo in rmaRevertRegister)
                {
                    registerInfo.RevertStatus = RMARevertStatus.Reverted;
                    registerInfo.Status       = RMARequestStatus.Complete;
                    RMARequestDA.UpdateRegisterStatus(registerInfo);
                }

                trans.Complete();
            }

            return(request);
        }
예제 #28
0
        /// <summary>
        /// 保存商家的基本信息
        /// 1.信息保存到ECStore.dbo.StoreBasicInfo
        /// 2.信息同步到IPP3.dbo.Vendor
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static int SaveStoreBasicInfo(StoreBasicInfo info)
        {
            using (var trans = TransactionManager.Create())
            {
                if (info.SysNo.HasValue)
                {
                    StoreDA.UpdateStoreBasicInfo(info);
                }
                else
                {
                    StoreDA.InsertStoreBasicInfo(info);
                }

                var basicInfo = StoreDA.QueryStoreBasicInfoBySellerSysNo(info.SellerSysNo.Value);

                StoreDA.SaveStoreBasicInfoToIPP3Vendor(ConvertStoreBasicToIPP3Vendor(basicInfo), info.InUserSysNo.Value);

                trans.Complete();
            }
            return(1);
        }
예제 #29
0
        /// <summary>
        /// 作废退换货申请单
        /// </summary>
        /// <param name="rmaRequestSysNo">退换货申请单编号</param>
        /// <param name="userSysNo">操作人用户</param>
        /// <returns></returns>
        public static RMARequestInfo Abandon(int rmaRequestSysNo, LoginUser operateUser)
        {
            RMARequestInfo request = LoadWithRequestSysNo(rmaRequestSysNo, operateUser.SellerSysNo);

            if (request == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退换货申请单", rmaRequestSysNo));
            }
            if (request.Status != RMARequestStatus.WaitingAudit && request.Status != RMARequestStatus.Origin)
            {
                throw new BusinessException(L("申请单不是“待审核”或“待处理”,不能作废"));
            }

            request.Status = RMARequestStatus.Abandon;
            using (ITransaction trans = TransactionManager.Create())
            {
                UpdateWithRegisters(request);
                trans.Complete();
            }
            return(request);
        }
예제 #30
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="user">数据实体</param>
        public void Update(UserEntity user, AuthUserModel authUserModel)
        {
            if (authUserModel == null)
            {
                throw new BusinessException("未获取到当前登录用户信息");
            }
            if (!user.BusinessId.HasValue)
            {
                throw new BusinessException("用户Id不允许为空");
            }
            user.Id = user.BusinessId.Value;
            this.CheckUserEntity(user);
            var hasExitsLoginName = UserDA.CheckUserLoginNameExist(user.LoginName, user.Id);

            if (hasExitsLoginName)
            {
                throw new BusinessException(string.Format("{0}用户名已存在", user.LoginName));
            }
            using (ITransaction transaction = TransactionManager.Create())
            {
                this.BindBasisInfo(user, authUserModel);
                UserDA.Update(user);
                // 删除当前用户关联的角色
                RoleUserService.DeleteByUserId(new AuthCenter.Entity.Entity.RoleUserEntity()
                {
                    UserId = user.Id
                });
                if (user.RoleId.HasValue)
                {
                    RoleUserService.Insert(new AuthCenter.Entity.Entity.RoleUserEntity()
                    {
                        RoleId  = user.RoleId.Value,
                        UserId  = user.Id,
                        Creator = authUserModel.UserSysNo
                    });
                }
                transaction.Complete();
            }
            // 更新角色关联
        }