Пример #1
0
        public static byte[] AddVIPCardStoredValue(byte[] itemBuffer)
        {
            byte[]          objRet       = null;
            string          strReceive   = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, itemBuffer.Length - ParamFieldLength.PACKAGE_HEAD).Trim('\0');
            VIPCardAddMoney cardAddMoney = JsonConvert.DeserializeObject <VIPCardAddMoney>(strReceive);

            string tradePayNo = string.Empty;
            int    result;
            //验证卡身份
            VIPCard card;
            int     resultCode = VIPCardService.GetInstance().GetVIPCard(cardAddMoney.CardNo, cardAddMoney.CardPassword, out card);

            if (resultCode == 1 && card != null)
            {
                result = VIPCardTradeService.GetInstance().AddVIPCardStoredValue(cardAddMoney, out tradePayNo);
            }
            else
            {
                result = 99;    //会员卡号或者密码错误
            }
            byte[] buffer     = Encoding.UTF8.GetBytes(tradePayNo);
            int    transCount = ParamFieldLength.PACKAGE_HEAD + BasicTypeLength.INT32 + ParamFieldLength.TRADEPAYNO;

            objRet = new byte[transCount];
            Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
            Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            Array.Copy(BitConverter.GetBytes(result), 0, objRet, ParamFieldLength.PACKAGE_HEAD, BasicTypeLength.INT32);
            Array.Copy(buffer, 0, objRet, ParamFieldLength.PACKAGE_HEAD + BasicTypeLength.INT32, buffer.Length);

            return(objRet);
        }
Пример #2
0
        public Int32 AddVIPCardStoredValue(VIPCardAddMoney cardAddMoney, out string tradePayNo)
        {
            string json = JsonConvert.SerializeObject(cardAddMoney);

            byte[] jsonByte = Encoding.UTF8.GetBytes(json);

            int cByte = ParamFieldLength.PACKAGE_HEAD + jsonByte.Length;

            byte[] sendByte   = new byte[cByte];
            int    byteOffset = 0;

            Array.Copy(BitConverter.GetBytes((int)Command.ID_ADD_CARDSTOREDVALUE), sendByte, BasicTypeLength.INT32);
            byteOffset = BasicTypeLength.INT32;
            Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32);
            byteOffset += BasicTypeLength.INT32;
            Array.Copy(jsonByte, 0, sendByte, byteOffset, jsonByte.Length);
            byteOffset += jsonByte.Length;

            int result = 0;

            tradePayNo = string.Empty;
            using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port))
            {
                Byte[] receiveData = null;
                Int32  operCode    = socket.SendReceive(sendByte, out receiveData);
                if (operCode == (int)RET_VALUE.SUCCEEDED)
                {
                    result     = BitConverter.ToInt32(receiveData, ParamFieldLength.PACKAGE_HEAD);
                    tradePayNo = Encoding.UTF8.GetString(receiveData, ParamFieldLength.PACKAGE_HEAD + BasicTypeLength.INT32, receiveData.Length - ParamFieldLength.PACKAGE_HEAD - BasicTypeLength.INT32).Trim('\0');
                }
                socket.Close();
            }
            return(result);
        }
Пример #3
0
        public Int32 AddVIPCardStoredValue(VIPCardAddMoney cardMoney, out string tradePayNo)
        {
            int result = 0;

            tradePayNo = string.Empty;
            try
            {
                _daoManager.OpenConnection();
                //日结号
                string             dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo();
                VIPCardStoredVaule cardStoredVaule  = _vipCardTradeDao.GetVIPCardStoredVaule(cardMoney.CardNo, cardMoney.StoreMoney);
                decimal            giftAmount       = 0M;
                int giftIntegral = 0;
                if (cardStoredVaule != null)
                {
                    decimal multiple = 1M;
                    if (cardStoredVaule.IsMultiple)
                    {
                        multiple = cardMoney.StoreMoney / cardStoredVaule.StoredVauleAmount;
                    }
                    if (cardStoredVaule.FixedAmount > 0)
                    {
                        giftAmount = cardStoredVaule.FixedAmount * multiple;
                    }
                    else
                    {
                        giftAmount = cardMoney.StoreMoney * cardStoredVaule.PresentAmountRate * multiple;
                    }
                    if (cardStoredVaule.FixedIntegral > 0)
                    {
                        giftIntegral = Convert.ToInt32(cardStoredVaule.FixedIntegral * multiple);
                    }
                    else
                    {
                        giftIntegral = Convert.ToInt32(cardMoney.StoreMoney * cardStoredVaule.PresentIntegralRate * multiple);
                    }
                }
                result = _vipCardTradeDao.AddVIPCardStoredValue(cardMoney.CardNo, cardMoney.StoreMoney, giftAmount, giftIntegral, cardMoney.EmployeeNo, cardMoney.DeviceNo, dailyStatementNo, cardMoney.PayoffID, cardMoney.PayoffName, out tradePayNo);
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[AddVIPCardStoredValue]参数:cardMoney_{0}", JsonConvert.SerializeObject(cardMoney)), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(result);
        }
Пример #4
0
        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);
            }
        }