/// <summary> /// 开始找零 /// </summary> /// <param name="charge">找零金额</param> public static void StartCharge(decimal charge) { chargeItems.Clear(); int m1, m5, m50, m100; Charge.GetCount(charge, out m1, out m5, out m50, out m100); s_m1 = m1; s_m5 = m5; s_m50 = m50; s_m100 = m100; if (m100 > 0 || m50 > 0) { if (IsOpenCassetteAndRead == false) { //纸币第一次找零,必须打开钱箱 constrant?.OpenCassette(); constrant?.ReadId(); IsOpenCassetteAndRead = true; } } var remaing50 = Charge100(m100); m50 += remaing50; s_m50 = m50; var remaing5 = Charge50(m50); m5 += remaing5; s_m5 = m5; var remaing1 = Charge5(m5); m1 += remaing1; s_m1 = m1; var unChargeMoney = Charge1(m1); if (OnChargeOver != null) { //触发找零结束事件 Dictionary <ChargeMoneyType, int> chargeGroup = new Dictionary <MoneyCore.ChargeMoneyType, int>(); var count100 = chargeItems.Count(s => s == ChargeMoneyType.M100); chargeGroup.Add(ChargeMoneyType.M100, count100); var count50 = chargeItems.Count(s => s == ChargeMoneyType.M50); chargeGroup.Add(ChargeMoneyType.M50, count50); var count5 = chargeItems.Count(s => s == ChargeMoneyType.M5); chargeGroup.Add(ChargeMoneyType.M5, count5); var count1 = chargeItems.Count(s => s == ChargeMoneyType.M1); chargeGroup.Add(ChargeMoneyType.M1, count1); OnChargeOver(null, chargeGroup, unChargeMoney); } }
/// <summary> /// 开始找零 /// </summary> /// <param name="charge">找零金额</param> public static void StartCharge(decimal charge) { chargeItems.Clear(); int m1, m5, m50, m100; Charge.GetCount(charge, out m1, out m5, out m50, out m100); s_m1 = m1; s_m5 = m5; s_m50 = m50; s_m100 = m100; if (m100 > 0 || m50 > 0) { if (IsOpenCassetteAndRead == false) { //纸币第一次找零,必须打开钱箱 constrant?.OpenCassette(); constrant?.ReadId(); IsOpenCassetteAndRead = true; } } Charge100(m100); if (s_m100 > 0) { FireChargeOver(s_m100 * 100 + s_m50 * 50 + s_m5 * 5 + s_m1); return; } else if (s_m100 == 0 && s_m50 == 0 && s_m5 == 0 && s_m1 == 0) { FireChargeOver(0); return; } Charge50(m50); if (s_m50 > 0) { FireChargeOver(s_m100 * 100 + s_m50 * 50 + s_m5 * 5 + s_m1); return; } else if (s_m50 == 0 && s_m5 == 0 && s_m1 == 0) { FireChargeOver(0); return; } Charge5(m5); if (s_m5 > 0) { FireChargeOver(s_m100 * 100 + s_m50 * 50 + s_m5 * 5 + s_m1); return; } else if (s_m5 == 0 && s_m1 == 0) { FireChargeOver(0); return; } Charge1(m1); if (s_m1 > 0) { FireChargeOver(s_m100 * 100 + s_m50 * 50 + s_m5 * 5 + s_m1); return; } else if (s_m1 == 0) { FireChargeOver(0); } }