Exemple #1
0
        public DataAjaxResult Print()
        {
            try
            {
                IPasswordService passwordService = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType);
                var password = passwordService.Decrypto(this.Password);

                if (string.IsNullOrWhiteSpace(this.HostSite.TicketTemplateOfDeal))
                {
                    return(new DataAjaxResult(Localize("nonTemplateOfDeal", "请先设置消费打印模板")));
                }
                var shopDealLog = this.ShopDealLogService.GetById(Id);
                if (shopDealLog == null)
                {
                    return(new DataAjaxResult(Localize("nonShopDealLog", "指定商户交易未找到")));
                }
                var deallog = this.DealLogService.GetById(shopDealLog.Addin);
                if (deallog == null)
                {
                    return(new DataAjaxResult(Localize("nonShopDealLog", "指定会员交易未找到")));
                }
                var account = this.AccountService.GetById(deallog.AccountId);
                if (account == null)
                {
                    return(new DataAjaxResult(Localize("nonAccount", "指定会员未找到")));
                }
                if (User.SaltAndHash(password, account.PasswordSalt) != account.Password)
                {
                    return(new DataAjaxResult(Localize("invalidPassword", "密码错误")));
                }
                var shop = this.ShopService.GetById(deallog.ShopId);
                if (shop == null)
                {
                    return(new DataAjaxResult(Localize("nonShop", "指定商户未找到")));
                }
                var dealWay = this.DealWayService.GetById(shop.DealWayId);
                if (dealWay == null)
                {
                    return(new DataAjaxResult(Localize("nonDealWay", "指定支付渠道未找到")));
                }

                var msg = this.HostSite.TicketTemplateOfDeal.Trim();
                msg = MessageFormator.FormatTickForDeal(msg, HostSite, deallog, account, ShopService.GetById(deallog.ShopId), PosEndPointService.GetById(deallog.SourcePosId), SecurityHelper.GetCurrentUser());
                return(new DataAjaxResult()
                {
                    Data1 = msg
                });
            }
            catch (System.Exception ex)
            {
                return(new DataAjaxResult(ex.Message));
            }
        }
Exemple #2
0
        public void Init(AccountServiceResponse rsp, int dealType)
        {
            Code  = rsp.Code;
            Error = ModelHelper.GetBoundText(this, x => x.Code);
            if (Code == ResponseCode.Success)
            {
                var dealLog = DealLogService.GetById(Convert.ToInt32(rsp.SerialServerNo));
                ShopName       = dealLog.ShopName;
                PosName        = dealLog.SourcePosName;
                AccountName    = dealLog.AccountName;
                Amount         = dealLog.Amount;
                SerialNo       = dealLog.SerialNo;
                ServerSerialNo = dealLog.SerialServerNo;

                if (Code == ResponseCode.Success)
                {
                    var account     = AccountService.GetByName(AccountName);
                    var shop        = ShopService.GetByName(ShopName);
                    var pos         = PosService.GetById(dealLog.SourcePosId);
                    var currentUser = SecurityHelper.GetCurrentUser().CurrentUser;
                    switch (dealType)
                    {
                    case DealTypes.Deal:

                        if (!string.IsNullOrWhiteSpace(HostSite.TicketTemplateOfDeal))
                        {
                            this.Ticket = MessageFormator.FormatTickForDeal(HostSite.TicketTemplateOfDeal, HostSite, dealLog, account, shop, pos, currentUser);
                        }
                        break;

                    case DealTypes.CancelDeal:
                        if (!string.IsNullOrWhiteSpace(HostSite.TicketTemplateOfCancelDeal))
                        {
                            this.Ticket = MessageFormator.FormatTickForDeal(HostSite.TicketTemplateOfCancelDeal, HostSite, dealLog, account, shop, pos, currentUser);
                        }
                        break;
                    }
                }
            }
        }