/// <summary>
 /// 卡储值
 /// </summary>
 /// <param name="printData"></param>
 public void DoPrintCardStore(PrintMemberCard printData)
 {
     if (printData != null)
     {
         _printLayoutPath = _printCardStoreLayoutPath;
         _printData = printData;
         try
         {
             _printDocument.Print();
         }
         catch (Exception exception)
         {
             LogHelper.GetInstance().Error("DriverOrderPrint.DoPrintPrePayOrder error.", exception);
         }
     }
 }
Exemple #2
0
 private bool IsVipCardPaySuccess(out Dictionary<string, VIPCardPayment> dicCardPayment, out Dictionary<string, string> dicCardTradePayNo)
 {
     bool isSuccess = false;
     //key: cardNo
     dicCardPayment = new Dictionary<string, VIPCardPayment>();
     dicCardTradePayNo = new Dictionary<string, string>();
     foreach (KeyValuePair<string, OrderPayoff> item in dic)
     {
         if (item.Value.Quantity > 0 && item.Value.PayoffType == (int) PayoffWayMode.MembershipCard)
         {
             if (string.IsNullOrEmpty(item.Value.CardNo)) continue;
             string[] cardArr = item.Value.CardNo.Split('#');
             //会员卡支付
             string cardNo = cardArr[0];
             string cardPassword = cardArr[1];
             decimal payAmount = item.Value.AsPay * item.Value.Quantity - item.Value.NeedChangePay;
             const int payIntegral = 0;
             VIPCard card;
             int resultCode = VIPCardService.GetInstance().SearchVIPCard(cardNo, cardPassword, out card);
             if (card == null || resultCode != 1)
             {
                 continue;
             }
             VIPCardPayment cardPayment = new VIPCardPayment
             {
                 CardNo = cardNo,
                 CardPassword = cardPassword,
                 PayAmount = payAmount,
                 PayIntegral = payIntegral,
                 OrderNo = m_SalesOrder.order.OrderNo,
                 EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo,
                 DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo
             };
             string tradePayNo;
             int result = VIPCardTradeService.GetInstance().AddVIPCardPayment(cardPayment, out tradePayNo);
             if (result == 1)
             {
                 VIPCard card2;
                 int resultCode2 = VIPCardService.GetInstance().SearchVIPCard(cardNo, cardPassword, out card2);
                 if (card2 != null && resultCode2 == 1)
                 {
                     PrintMemberCard printCard = new PrintMemberCard
                     {
                         MemberVoucher = "会员消费凭单",
                         CardNo = cardNo,
                         ShopName = ConstantValuePool.CurrentShop.ShopName,
                         TradeType = "消费",
                         TranSequence = tradePayNo,
                         TradeTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                         PreConsumeAmount = card.Balance.ToString("f2"),
                         PostConsumeAmount = card2.Balance.ToString("f2"),
                         ConsumeAmount = payAmount.ToString("f2"),
                         ConsumePoints = payIntegral.ToString(),
                         AvailablePoints = card2.Integral.ToString(),
                         LastConsumeTime = card.LastConsumeTime == null ? string.Empty : ((DateTime)card.LastConsumeTime).ToString("yyyy/MM/dd HH:mm:ss"),
                         Operator = ConstantValuePool.CurrentEmployee.EmployeeNo,
                         Remark = string.Empty
                     };
                     int copies = ConstantValuePool.BizSettingConfig.printConfig.OrderCopies;
                     string paperWidth = ConstantValuePool.BizSettingConfig.printConfig.PaperWidth;
                     if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.DRIVER)
                     {
                         string printerName = ConstantValuePool.BizSettingConfig.printConfig.Name;
                         string paperName = ConstantValuePool.BizSettingConfig.printConfig.PaperName;
                         DriverCardPrint printer = DriverCardPrint.GetInstance(printerName, paperName, paperWidth);
                         for (int i = 0; i < copies; i++)
                         {
                             printer.DoPrintCardConsume(printCard);
                         }
                     }
                     //会员充值成功
                     dicCardPayment.Add(item.Value.CardNo, cardPayment);
                     dicCardTradePayNo.Add(item.Value.CardNo, tradePayNo);
                     isSuccess = true;
                 }
             }
             else if (result == 2)
             {
                 MessageBox.Show(string.Format("卡号'{0}'不存在,请确认输入的卡号是否正确!", item.Value.CardNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
             else if (result == 3)
             {
                 MessageBox.Show(string.Format("卡号'{0}'未开通,请先开卡!", item.Value.CardNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
             else if (result == 4)
             {
                 MessageBox.Show(string.Format("卡号'{0}'已挂失,不能充值!", item.Value.CardNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
             else if (result == 5)
             {
                 MessageBox.Show(string.Format("卡号'{0}'已锁卡,不能充值!", item.Value.CardNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
             else if (result == 6)
             {
                 MessageBox.Show(string.Format("卡号'{0}'已作废,不能充值!", item.Value.CardNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
             else if (result == 7)
             {
                 MessageBox.Show(string.Format("卡号'{0}'所属会员组没有储值功能!", item.Value.CardNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
             else if (result == 99)
             {
                 MessageBox.Show("会员卡号或者密码错误!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
             else
             {
                 MessageBox.Show("服务器出现错误,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 isSuccess = false;
                 break;
             }
         }
     }
     if (isSuccess)
     {
         return true;
     }
     if (dicCardPayment.Count > 0)
     {
         //取消会员卡支付
         foreach (KeyValuePair<string, VIPCardPayment> item in dicCardPayment)
         {
             string cardNo = item.Value.CardNo;
             //将支付成功的会员卡取消支付
             int returnValue = VIPCardTradeService.GetInstance().RefundVipCardPayment(cardNo, item.Value.CardPassword, dicCardTradePayNo[cardNo]);
             if (returnValue == 1) continue;
             if (returnValue == 2)
             {
                 MessageBox.Show(string.Format("交易流水号'{0}'不存在或者已作废", dicCardTradePayNo[cardNo]), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else if (returnValue == 99)
             {
                 MessageBox.Show(string.Format("'{0}'的会员卡号或者密码错误!", cardNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 MessageBox.Show("服务器出现错误,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             //保存到本地Sqlite
             CardRefundPay cardRefundPay = new CardRefundPay
             {
                 CardNo = cardNo, 
                 ShopID = ConstantValuePool.CurrentShop.ShopID.ToString(), 
                 TradePayNo = dicCardTradePayNo[cardNo], 
                 PayAmount = item.Value.PayAmount, 
                 EmployeeNo = item.Value.EmployeeNo, 
                 DeviceNo = item.Value.DeviceNo
             };
             CardRefundPayService refundPayService = new CardRefundPayService();
             refundPayService.AddRefundPayInfo(cardRefundPay);
         }
         dicCardPayment = new Dictionary<string, VIPCardPayment>();
         dicCardTradePayNo = new Dictionary<string, string>();
     }
     return false;
 }
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     string cardNo = txtCardNo.Text.Trim();
     if (string.IsNullOrEmpty(cardNo))
     {
         MessageBox.Show("请输入您的会员卡号!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(_cardPassword))
     {
         MessageBox.Show("请重新输入您的会员卡号!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(txtStoreAmout.Text.Trim()))
     {
         MessageBox.Show("请输入充值金额!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     decimal storeAmount;
     if (!decimal.TryParse(txtStoreAmout.Text.Trim(), out storeAmount))
     {
         MessageBox.Show("请输入正确的充值金额格式!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (_curPayoffWay == null)
     {
         MessageBox.Show("请选择充值付款方式!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     VIPCard card;
     int resultCode = VIPCardService.GetInstance().SearchVIPCard(cardNo, _cardPassword, out card);
     if (card == null || resultCode != 1)
     {
         txtCardNo.Text = string.Empty;
         MessageBox.Show("您输入的会员卡号或者密码错误!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     VIPCardAddMoney cardAddMoney = new VIPCardAddMoney
     {
         CardNo = cardNo, 
         CardPassword = _cardPassword, 
         StoreMoney = storeAmount, 
         EmployeeNo = ConstantValuePool.CurrentEmployee.EmployeeNo, 
         DeviceNo = ConstantValuePool.BizSettingConfig.DeviceNo, 
         PayoffID = _curPayoffWay.PayoffID, 
         PayoffName = _curPayoffWay.PayoffName
     };
     string tradePayNo;
     int result = VIPCardTradeService.GetInstance().AddVIPCardStoredValue(cardAddMoney, out tradePayNo);
     if (result == 1)
     {
         VIPCard card2;
         int resultCode2 = VIPCardService.GetInstance().SearchVIPCard(cardNo, _cardPassword, out card2);
         if (card2 != null && resultCode2 == 1)
         {
             PrintMemberCard printCard = new PrintMemberCard
             {
                 MemberVoucher = "会员充值凭单",
                 CardNo = cardNo,
                 ShopName = ConstantValuePool.CurrentShop.ShopName,
                 TradeType = "充值",
                 TranSequence = tradePayNo,
                 TradeTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                 PreTradeAmount = card.Balance.ToString("f2"),
                 PostTradeAmount = card2.Balance.ToString("f2"),
                 Payment = _curPayoffWay.PayoffName,
                 StoreValue = storeAmount.ToString("f2"),
                 GivenAmount = (card2.Balance - card.Balance - storeAmount).ToString("f2"),
                 PresentExp = (card2.Integral - card.Integral).ToString(),
                 AvailablePoints = card2.Integral.ToString(),
                 Operator = ConstantValuePool.CurrentEmployee.EmployeeNo,
                 Remark = string.Empty
             };
             int copies = ConstantValuePool.BizSettingConfig.printConfig.OrderCopies;
             string paperWidth = ConstantValuePool.BizSettingConfig.printConfig.PaperWidth;
             if (ConstantValuePool.BizSettingConfig.printConfig.PrinterPort == PortType.DRIVER)
             {
                 string printerName = ConstantValuePool.BizSettingConfig.printConfig.Name;
                 string paperName = ConstantValuePool.BizSettingConfig.printConfig.PaperName;
                 DriverCardPrint printer = DriverCardPrint.GetInstance(printerName, paperName, paperWidth);
                 for (int i = 0; i < copies; i++)
                 {
                     printer.DoPrintCardStore(printCard);
                 }
             }
             MessageBox.Show("会员充值成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
     }
     else if (result == 2)
     {
         MessageBox.Show("卡号不存在,请确认输入的卡号是否正确!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (result == 3)
     {
         MessageBox.Show("该卡未开通,请先开卡!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (result == 4)
     {
         MessageBox.Show("该卡已挂失,不能充值!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (result == 5)
     {
         MessageBox.Show("该卡已锁卡,不能充值!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (result == 6)
     {
         MessageBox.Show("该卡已作废,不能充值!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (result == 7)
     {
         MessageBox.Show("该卡所属会员组没有储值功能!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (result == 99)
     {
         txtCardNo.Text = string.Empty;
         MessageBox.Show("会员卡号或者密码错误!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         MessageBox.Show("服务器出现错误,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }