Ejemplo n.º 1
0
        /// <summary>
        /// 关纸硬币器
        /// </summary>
        public OperateResult CloseCoinPaper()
        {
            OperateResult operateResult;

            try
            {
                operateResult = MachineFactory.Machine.CloseCoinPaper();
            }
            catch (Exception ex)
            {
                operateResult = new OperateResult();
                operateResult.Success = false;
                operateResult.ErrorMsg = ex.Message;
                FileLogger.LogError("关纸硬币器失败" + ex.Message);
            }

            return operateResult;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 出货
        /// </summary>
        /// <param name="com">串口号</param>
        /// <param name="box">货柜</param>
        /// <param name="floor">货道层</param>
        /// <param name="num">货道列</param>
        /// <param name="cash">是否现金支付</param>
        /// <param name="cost">金额(单位:分)</param>
        /// <param name="check">是否掉货检测</param>
        public OperateResult Shipment(string com, int box, int floor, int num, bool cash, int cost, bool check)
        {
            OperateResult operateResult;

            try
            {
                IMachine machine = MachineFactory.GetMachine(com);
                operateResult = machine.Shipment(box, floor, num, cash, cost, check);
            }
            catch (Exception ex)
            {
                operateResult = new OperateResult();
                operateResult.Success = false;
                operateResult.ErrorMsg = ex.Message;
                FileLogger.LogError("出货失败" + ex.Message);
            }

            return operateResult;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 出货
        /// </summary>
        /// <param name="box">货柜</param>
        /// <param name="floor">货道层</param>
        /// <param name="num">货道列</param>
        /// <param name="cash">是否现金支付</param>
        /// <param name="cost">金额(单位:分)</param>
        /// <param name="check">是否掉货检测</param>
        public OperateResult Shipment(int box, int floor, int num, bool cash, int cost, bool check)
        {
            OperateResult result = new OperateResult();

            byte hd_id = 0x00;

            #region 计算货道
            hd_id = (byte)((floor - 1) * JPBoxConfigUtil.GetColcount(m_com) + num);
            #endregion

            byte type = cash ? (byte)0x00 : (byte)0x01;

            VendoutRpt vendoutRpt = base.VENDOUT_IND((byte)box, 2, hd_id, type, cost);
            if (vendoutRpt.status == 0)
            {
                if (cash)
                {
                    //出货完成扣款
                    CostRpt costRpt = base.COST_IND(0, cost, (byte)0x00);
                    if (costRpt.value == cost)
                    {
                        result.Success = true;
                    }
                    else
                    {
                        result.Success = false;
                        result.ErrorMsg = "扣款失败";
                        FileLogger.LogError(string.Format("扣款失败,出货柜号:{0},层:{1},列:{2}", box, floor, num));
                    }
                }
                else
                {
                    result.Success = true;
                }
            }
            else
            {
                result.Success = false;
                result.ErrorMsg = "出货失败";
                FileLogger.LogError(string.Format("出货失败,柜号:{0},层:{1},列:{2}", box, floor, num));
            }

            return result;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 退币
        /// </summary>
        /// <param name="amount">退币金额(单位:分)</param>
        public OperateResult RefundMoney(int amount)
        {
            OperateResult operateResult;

            try
            {
                operateResult = MachineFactory.Machine.RefundMoney(amount);
            }
            catch (Exception ex)
            {
                operateResult = new OperateResult();
                operateResult.Success = false;
                operateResult.ErrorMsg = ex.Message;
                FileLogger.LogError("退币(金额:" + amount + "分)失败" + ex.Message);
            }

            return operateResult;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 开纸硬币器
        /// </summary>
        public OperateResult OpenCoinPaper()
        {
            OperateResult result = new OperateResult();

            try
            {
                bool bl = base.CtrlCoinPaper(true);
                result.Success = bl;
            }
            catch (Exception ex)
            {
                FileLogger.LogError("开纸硬币器失败:" + ex.Message);
                result.Success = false;
                result.ErrorMsg = ex.Message;
            }

            return result;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 退币
        /// </summary>
        /// <param name="amount">退币金额(单位:分)</param>
        public OperateResult RefundMoney(int amount)
        {
            OperateResult result = new OperateResult();

            int yb = amount % 500;
            int zb = amount - yb;
            PayoutRpt ybRpt = base.PAYOUT_IND(PayoutType.硬币出币, yb, (byte)0x00);
            PayoutRpt zbRpt = base.PAYOUT_IND(PayoutType.纸币出币, zb, (byte)0x00);
            //由于PAYOUT_IND 不会减少用户余额,退币后扣款
            CostRpt costRpt = base.COST_IND(0, amount, (byte)0x00);
            if (costRpt.value == amount)
            {
                result.Success = true;
            }
            else
            {
                result.Success = false;
                result.ErrorMsg = "扣款失败";
                FileLogger.LogError(string.Format("扣款失败,金额:{0}分", amount));
            }

            if (amount > 0 && ybRpt.value == 0 && zbRpt.value == 0)
            {
                result.Success = false;
                result.ErrorMsg = "退币失败";
                FileLogger.LogError(string.Format("退币失败,应退金额:{0}分,实退金额:{1}分", amount, ybRpt.value + zbRpt.value));
            }

            if (ybRpt.value + zbRpt.value < amount)
            {
                result.Success = false;
                result.ErrorMsg = "退币失败";
                FileLogger.LogError(string.Format("退币失败,应退金额:{0}分,实退金额:{1}分", amount, ybRpt.value + zbRpt.value));
            }

            return result;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 联机
        /// </summary>
        public OperateResult Connect()
        {
            OperateResult result = new OperateResult();

            try
            {
                base.Init(this.m_com);
                result.Success = true;
            }
            catch (Exception ex)
            {
                FileLogger.LogError("联机失败:" + ex.Message);
                result.Success = false;
                result.ErrorMsg = ex.Message;
            }

            return result;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 关纸硬币器
        /// </summary>
        public OperateResult CloseCoinPaper()
        {
            OperateResult result = new OperateResult();

            try
            {
                string msgCoin = string.Empty;
                string msgPaper = string.Empty;
                bool blCoin = base.CoinDisable(out msgCoin);
                bool blPaper = base.PaperMoneyDisable(out msgPaper);

                result.Success = blCoin && blPaper;
                if (!blCoin)
                {
                    result.ErrorMsg += msgCoin;
                }
                if (!blPaper)
                {
                    result.ErrorMsg += msgPaper;
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.ErrorMsg = ex.Message;
            }

            return result;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 出货
 /// </summary>
 /// <param name="box">货柜</param>
 /// <param name="floor">货道层</param>
 /// <param name="num">货道列</param>
 /// <param name="cash">是否现金支付</param>
 /// <param name="cost">金额(单位:分)</param>
 /// <param name="check">是否掉货检测</param>
 public OperateResult Shipment(int box, int floor, int num, bool cash, int cost, bool check)
 {
     OperateResult result = new OperateResult();
     string msg = string.Empty;
     bool bl = base.Shipment(box, floor, num, cash, cost, check, out msg);
     if (bl)
     {
         bool isSuccess = false;
         int remainder = 0;
         string msgTemp = string.Empty;
         while (!base.QueryShipment(out isSuccess, out remainder, false, out msgTemp))
         {
             Thread.Sleep(50);
         }
         if (isSuccess)
         {
             result.Success = true;
         }
         else
         {
             result.Success = false;
             result.ErrorMsg = msgTemp;
         }
     }
     else
     {
         result.Success = false;
         result.ErrorMsg = msg;
     }
     return result;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 退币
        /// </summary>
        /// <param name="amount">退币金额(单位:分)</param>
        public OperateResult RefundMoney(int amount)
        {
            OperateResult result = new OperateResult();

            string msg = string.Empty;
            bool bl = base.RefundMoney(amount, out msg);
            if (bl)
            {
                int remainder = 0;
                bool isSuccess = false;
                while (!base.QueryRefundMoney(out isSuccess, out remainder, out msg))
                {
                    Thread.Sleep(50);
                }
                if (isSuccess)
                {
                    result.Success = true;
                }
                else
                {
                    result.Success = false;
                    result.ErrorMsg = msg;
                }
            }
            else
            {
                result.Success = false;
                result.ErrorMsg = msg;
            }

            return result;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 联机
        /// </summary>
        public OperateResult Connect()
        {
            OperateResult result = new OperateResult();

            try
            {
                string msg = string.Empty;
                bool bl = base.Connect(out msg);
                result.Success = bl;
                result.ErrorMsg = msg;
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.ErrorMsg = ex.Message;
            }

            return result;
        }