Пример #1
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));
        }
Пример #2
0
 public void NotifyCode(Shop shop, Shop shopTo, ShopDealLog shopDealLog, string shopNameTo)
 {
     foreach (var tracker in _trackers)
     {
         tracker.NotifyCode(shop, shopTo, shopDealLog, shopNameTo);
     }
 }
Пример #3
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();
            }
        }
Пример #4
0
 public void Save(ShopDealLog shopDealLog)
 {
     if (shopDealLog.ShopDealLogId > 0)
     {
         _databaseInstance.Update(shopDealLog, "ShopDealLogs");
     }
     else
     {
         _databaseInstance.Insert(shopDealLog, "ShopDealLogs");
     }
 }
Пример #5
0
        public void NotifyCode(Shop shop, Shop shopTo, ShopDealLog shopDealLog, string shopNameTo)
        {
            try
            {
                var site = _siteService.GetSite();

                if (site != null && !string.IsNullOrWhiteSpace(site.MessageTemplateOfDealCode) && !string.IsNullOrWhiteSpace(shopNameTo) && Regex.IsMatch(shopNameTo, @"^\d{11}$"))
                {
                    var text = site.MessageTemplateOfDealCode;

                    text = MessageFormator.Format(text, shopTo);
                    text = text.Replace("#code#", shopDealLog.Code);

                    _smsHelper.Send(shopNameTo, text);
                    _log.Info("send sms for " + shopNameTo);
                }
            }
            catch (Exception ex)
            {
                _log.Error("send message failed!", ex);
            }
        }
Пример #6
0
 public void NotifyCode(Shop shop, Shop shopTo, ShopDealLog shopDealLog, string shopNameTo)
 {
 }
Пример #7
0
 public ListShopDealLog(ShopDealLog adminUser)
 {
     _innerObject = adminUser;
 }
Пример #8
0
 public ListShopDealLog()
 {
     _innerObject = new ShopDealLog();
 }
Пример #9
0
 public void Delete(ShopDealLog item)
 {
     _databaseInstance.Delete(item, TableName);
 }
Пример #10
0
 public void Update(ShopDealLog item)
 {
     _databaseInstance.Update(item, TableName);
 }
Пример #11
0
 public void Create(ShopDealLog item)
 {
     item.ShopDealLogId = _databaseInstance.Insert(item, TableName);
 }
Пример #12
0
 public ListShopDealLog(ShopDealLog innerObject)
 {
     InnerObject = innerObject;
 }
Пример #13
0
 public ListShopRollback(RollbackShopDealLog rollback, ShopDealLog shopDealLog)
 {
     _rollback    = rollback;
     _shopDealLog = shopDealLog;
 }