do_consume.c
上传用户:shyuanyi
上传日期:2008-05-24
资源大小:69k
文件大小:3k
- #include "My_head.h"
- #include "carddef.h"
- //#include "rfic.h"
- //#include "sendcard.h"
- #include "DS_addr.h"
- #include "DataFlash.H"
- #include "RfModuleFunc.H"
- //#define _DEBUG
- #ifdef _DEBUG
- #include "Debug.h"
- #endif
- extern sttCardholderInfo xdata stCardholderInfo; //持卡人信息
- extern sttBusinessInfo xdata stBusinessInfo; //交易信息
- extern sttOtherTableInfo xdata stOtherTableInfo;
- extern unsigned char xdata gcDateTime[7]; //全局时钟
- extern char FillMoneyOrTime();
- //保存订餐记录
- unsigned char SaveFillRecord()
- {
- Con_Record xdata stFillRecord;
- //准备数据
- if(stBusinessInfo.stFillInfo.cMode==FILL_MONEY)
- {
- stFillRecord.balance=stBusinessInfo.lMoney; //卡上余额(本次操作后)
- stFillRecord.con_Money=stBusinessInfo.stFillInfo.lMoney; //本次操作(消费、充值等)金额;(不要负数)
- stFillRecord.mark = 2; //充值
- }else{
- stFillRecord.balance=stBusinessInfo.iTimes; //卡上余额(本次操作后)
- stFillRecord.con_Money=stBusinessInfo.stFillInfo.iTimes; //本次操作(消费、充值等)金额;(不要负数)
- stFillRecord.mark = 12; //充次
- }
- memcpy(stFillRecord.card_code,stCardholderInfo.cSerialNo,3);//卡编号(卡流水号)
- memcpy(stFillRecord.con_time,gcDateTime,6);//本次操作(消费、充值、挂失等)时间;
- memcpy((unsigned char*)&stFillRecord.card_count,stBusinessInfo.cIndex,2); //本卡操作(消费、充值、被挂失)累计流水号("卡"平帐用);
- stFillRecord.equip_count=stOtherTableInfo.iRecordIndex++;//本机操作(消费、充值、被挂失)累计流水号("机"平帐用);
- memset(stFillRecord.reserver,0,2);//保留以后用;
- #ifdef _DEBUG
- DebugString("stFillRecord Data:rn");
- DebugData(24,24,(unsigned char *)&stFillRecord);
- #endif
- //保存订餐记录
- return Save_ConData_to_Memory(&stFillRecord);
- }
- BYTE Do_CheckCard_Event_9(BYTE Dat)
- {
- BYTE i;
- if((!equip_addr.ntype) || ((!seedcard_info.unit_code[0])&&(!seedcard_info.unit_code[1])&&(!seedcard_info.unit_code[2])))
- {
- i=NO_INI_EQUIP;
- }
- else
- if((i=FillMoneyOrTime())==0)
- { //成功
- Dis_Consume_Led(TRUE);
- #ifdef _DEBUG
- DebugString("正常充值rn");
- #endif
- i=SaveFillRecord();
- thekey.key_val = stBusinessInfo.lMoney;
- KeyVal_Tobuf();
- Dis_KeyBuf();
- //Dis_Balance_Led(TRUE);
- My_Do_Buzzer(250,1);
- }
- #ifdef _DEBUG
- DebugString("Order Dinner Result:");
- DebugData(1,1,&i);
- #endif
- if(i > 1)
- {
- Dis_Err_Led(TRUE); //FOR 技嘉
- if(i==60) //要求重刷卡
- do_buzzer(3);
- else
- do_buzzer(BUZZER_ERROR);
- Dis_Err(i);
- }
- //SendStr("c:",2);SendStr(&i,1);
- Stop_Timer(DISPLAY_DELAYEVENT_Tevent);//msut!!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- Do_DisLed_Flash(0x00,0x00,145);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);//(1)
- SetCurState(IDEL_STATUS);//ActiveState(INIT_STATUS);
- Dat=Dat;
- return(i);
- }
- BYTE Do_DisCardVal_Event_7(BYTE Dat)
- {
- return(Dat);
- }
- BYTE Do_TestCardWrite_Event_6(BYTE Dat)
- {
- return(Dat);
- }
- BYTE Do_CardConsume_Event_8(BYTE Dat)
- {
- return(Dat);
- }