예제 #1
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);
        }
예제 #2
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);
        }