def data_handle(self): try: Param = web.input().get('Param') if Param == None: return FuncResult(fail='Have no Param!') logging = Log().logging('ChangeRoom', Param) jsonParam = json.loads(Param) print "---------------------------------------------------------------------------" print " get PMS params :" print jsonParam print "---------------------------------------------------------------------------" HotleCode = jsonParam['HotelCode'] HotelName = jsonParam['HotelName'] OldRoomNo = jsonParam['OldRoomNo'] OldRoomTypeCode = jsonParam['OldRoomTypeCode'] OldRoomTypeName = jsonParam['OldRoomTypeName'] NewRoomNo = jsonParam['NewRoomNo'] NewRoomTypeCode = jsonParam['NewRoomTypeCode'] NewRoomTypeName = jsonParam['NewRoomTypeName'] FolioCode = jsonParam['FolioCode'] OperateTime = jsonParam['OperateTime'] Remark = jsonParam['Remark'] except Exception, ce: # 异常处理 print '---------------------------------------------------------------' print 'Error !!' print '参数有误' print '---------------------------------------------------------------' errorLog().errorLogging('ChangeRoomAPI', '参数有误') return FuncResult(fail='参数有误!')
def add_hotel(self, HotelCode, RoomNo, HotelName, FolioCode, OperateTime): try: ResOjCheckIn = CheckIn().query2(CheckIn).filter(CheckIn.FolioCode == FolioCode). \ order_by(desc(CheckIn.CheckInID)).all() if ResOjCheckIn: objCheckIn = CheckIn() resHotel = Hotel().query.filter( Hotel.HotelCode == HotelCode).first() if resHotel: objCheckIn.HotelID = resHotel.HotelID else: print '--------------------------------------------------------------------' print 'Error !!' print 'Can not find this hotel info!' errorLog().errorLogging('RecoverCheckIn', 'Can not find this hotel info!') print '--------------------------------------------------------------------' return FuncResult(success=False, msg='Can not find this hotel info!') objCheckIn.RoomNo = RoomNo objCheckIn.RoomTypeCode = ResOjCheckIn[0].RoomTypeCode objCheckIn.RoomTypeName = ResOjCheckIn[0].RoomTypeName objCheckIn.LastModifyTime = datetime.datetime.now() objCheckIn.HotelLastModifyTime = to_datetime(OperateTime) objCheckIn.ArrivalTime = ResOjCheckIn[0].ArrivalTime objCheckIn.DepartTime = ResOjCheckIn[0].DepartTime objCheckIn.CheckInTime = ResOjCheckIn[0].CheckInTime objCheckIn.CheckOutTime = ResOjCheckIn[0].CheckOutTime objCheckIn.FolioCode = FolioCode objCheckIn.FolioState = ResOjCheckIn[0].FolioState objCheckIn.CheckInType = 5 objCheckIn.save(flush=True) lsRelaCheckIn = RelationCheckIn().query.filter( RelationCheckIn.CheckInID == ResOjCheckIn[0].CheckInID).all() for objRelaCheckIn in lsRelaCheckIn: NewObjRelaCheckIn = RelationCheckIn() NewObjRelaCheckIn.CheckInID = objCheckIn.CheckInID NewObjRelaCheckIn.HotelGuestID = objRelaCheckIn.HotelGuestID NewObjRelaCheckIn.GuestDocID = objRelaCheckIn.GuestDocID NewObjRelaCheckIn.CheckInType = 5 NewObjRelaCheckIn.CheckInTime = objRelaCheckIn.CheckInTime NewObjRelaCheckIn.CheckOutTime = objRelaCheckIn.CheckOutTime NewObjRelaCheckIn.GuestState = objRelaCheckIn.GuestState NewObjRelaCheckIn.LastModifyTime = datetime.datetime.now() NewObjRelaCheckIn.HotelLastModifyTime = to_datetime( OperateTime) NewObjRelaCheckIn.save() return FuncResult(success=True, msg='Do Success!') else: print '---------------------------------------------------------------' print 'Error !!' print 'Can not find this FolioCode!' print '---------------------------------------------------------------' errorLog().errorLogging('RecoverCheckIn', 'Can not find this FolioCode!') return FuncResult(success=False, msg='Have No This FolioCode!') except Exception, ce: return FuncResult(fail=ce)
def data_handle(self): try: Param = web.input().get('Param') if Param == None: return FuncResult(fail='Have no Param!') logging = Log().logging('ReduceGuests', Param) jsonParam = json.loads(Param) print "---------------------------------------------------------------------------" print " get PMS params :" print jsonParam print "---------------------------------------------------------------------------" lsReduce = jsonParam['Reduce'] for objReduce in lsReduce: GuestCode = objReduce['CheckOut']['GuestCode'] HotelCode = objReduce['CheckOut']['HotelCode'] CheckOutTime = objReduce['CheckOut']['CheckOutTime'] FolioCode = objReduce['CheckOut']['FolioCode'] OperateTime = objReduce['CheckOut']['OperateTime'] Res = self.add_hotel(GuestCode, HotelCode, CheckOutTime, FolioCode, OperateTime) if Res == 1: print '---------------------------------------------------------------' print 'Error !!' print 'Can not find this folio!' print '---------------------------------------------------------------' errorLog().errorLogging('ReduceGuests', 'Can not find this folio!') return FuncResult(success=False, msg='Can not find this folio') elif Res == 2: print '---------------------------------------------------------------' print 'Error !!' print 'Can not find this hotel info!' print '---------------------------------------------------------------' errorLog().errorLogging('ReduceGuests', 'Can not find this hotel info!') return FuncResult(success=False, msg='Can not find this hotel info') elif Res == 3: print '---------------------------------------------------------------' print 'Error !!' print 'Can not find this hotel guest!' print '---------------------------------------------------------------' errorLog().errorLogging('ReduceGuests', 'Can not find this guest!') return FuncResult(success=False, msg='Can not find this guest') elif Res == 4: errorLog().errorLogging( 'ReduceGuests', 'Logic error , can not find this checkIn folio!') return FuncResult( success=False, msg='Logic error , can not find this checkIn folio!') else: return FuncResult(success=True, msg='Do Success!') # return FuncResult(success=True, msg='Do Success!') except Exception, ce: # 异常处理 return FuncResult(fail='参数有误!')
def data_handle(self): try: Param = web.input().get('Param') if Param == None: return FuncResult(fail='Have no Param!') logging = Log().logging('UploadHeadPhoto', Param) jsonParam = json.loads(Param) print "---------------------------------------------------------------------------" print " get PMS params :" print jsonParam print "---------------------------------------------------------------------------" Params = jsonParam # DocPhotoUrl if Params['CerType'] == '1': # basePath = Params['basePath'].encode(encoding='UTF-8') CerNo = Params['CerNo'] imageName = Params['ImageName'] objGuestDoc = GuestDoc().query.filter( GuestDoc.DocNo == CerNo).first() newFilePath = mkdir(1) + '/' + str(uuid.uuid1()) + imageName newBasePath = base64.b64encode(newFilePath) # if have this GuestDoc before: if objGuestDoc: CerBaseURL = objGuestDoc.DocPhotoURL if CerBaseURL != None: filePath = base64.b64decode(CerBaseURL) os.remove(filePath) # delete before photo objGuestDoc.DocPhotoURL = newBasePath objGuestDoc.save() fout = open(newFilePath, 'w') Img = Params['Img'].replace(' ', '+') print '---------------------------------------------------------------------' print 'decode begin' try: image = base64.b64decode(Img) fout.write(image) except Exception, ce: print '-------------------------------------------------------------------' errorLog().errorLogging('UploadHeadPhoto', 'base64 decode fail') print 'decode fail' print '-------------------------------------------------------------------' print 'decode end ' print '--------------------------------------------------------------------' resDict = {'DocPhotoURL': newBasePath, 'code': 200} # HotelGuestPhotoUrl else:
def add_hotel(self, CheckInInfo, GuestInfoSet): try: # save CheckIn objCheckIn = CheckIn() # oldCheckIn = CheckIn().query.filter(CheckIn.FolioCode == CheckInInfo['FolioCode']).\ # order_by(desc(CheckIn.CheckInID)).all() if isHasParams('HotelCode', CheckInInfo): resHotel = Hotel().query.filter( Hotel.HotelCode == CheckInInfo['HotelCode']).first() if resHotel: objCheckIn.HotelID = resHotel.HotelID else: print '--------------------------------------------------------------------' print 'Error !!' print 'Can not find this hotel info!' errorLog().errorLogging('AddGuestCheckInAPI', 'Can not find this hotel info!') print '--------------------------------------------------------------------' return FuncResult(success=False, msg='Can not find this hotel info!') else: print '--------------------------------------------------------------------' print 'Error !!' print 'Can not find this hotel info!' print '--------------------------------------------------------------------' errorLog().errorLogging('AddGuestCheckInAPI', 'Can not find this hotel info!') return FuncResult(success=False, msg='Can not find this hotel info!') if isHasParams('RoomNo', CheckInInfo): objCheckIn.RoomNo = CheckInInfo['RoomNo'] if isHasParams('RoomTypeCode', CheckInInfo): objCheckIn.RoomTypeCode = CheckInInfo['RoomTypeCode'] if isHasParams('RoomTypeName', CheckInInfo): objCheckIn.RoomTypeName = CheckInInfo['RoomTypeName'] if isHasParams('ArrivalTime', CheckInInfo): objCheckIn.ArrivalTime = to_datetime( CheckInInfo['ArrivalTime']) objCheckIn.CheckInTime = to_datetime( CheckInInfo['ArrivalTime']) if isHasParams('DepartTime', CheckInInfo): objCheckIn.DepartTime = to_datetime(CheckInInfo['DepartTime']) objCheckIn.CheckOutTime = to_datetime( CheckInInfo['DepartTime']) if isHasParams('FolioCode', CheckInInfo): objCheckIn.FolioCode = CheckInInfo['FolioCode'] objCheckIn.LastModifyTime = datetime.datetime.now() objCheckIn.CheckInType = 6 objCheckIn.save(flush=True) CheckInID = objCheckIn.CheckInID # save GuesetInfo for GuestInfo in GuestInfoSet: objGuestInfo = GuestCheckIn() objDocInfo = GuestDoc() dictGuestInfo = GuestInfo['GuestInfo'] dictDocInfo = GuestInfo['DocInfo'] # have this GuesetInfo before ? resGuestInfo = GuestCheckIn().query.filter( GuestCheckIn.HotelDocNo == dictGuestInfo['HotelDocNo']).first() if not resGuestInfo: if isHasParams('HotelDocType', dictGuestInfo): objGuestInfo.HotelDocType = dictGuestInfo[ 'HotelDocType'] if isHasParams('HotelDocNo', dictGuestInfo): objGuestInfo.HotelDocNo = dictGuestInfo['HotelDocNo'] if isHasParams('HotelDocName', dictGuestInfo): objGuestInfo.HotelDocName = dictGuestInfo[ 'HotelDocName'] if isHasParams('HotelBornDate', dictGuestInfo): objGuestInfo.HotelBornDate = dictGuestInfo[ 'HotelBornDate'] if isHasParams('HotelSex', dictGuestInfo): objGuestInfo.HotelSex = dictGuestInfo['HotelSex'] if isHasParams('NationaCode', dictGuestInfo): objGuestInfo.HotelNation = dictGuestInfo['NationaCode'] if isHasParams('HotelAddress', dictGuestInfo): objGuestInfo.HotelAddress = dictGuestInfo[ 'HotelAddress'] if isHasParams('HotelRemark', dictGuestInfo): objGuestInfo.HotelRemark = dictGuestInfo['HotelRemark'] if isHasParams('HotelLastModifyTime', dictGuestInfo): objGuestInfo.HotelLastModifyTime = to_datetime( dictGuestInfo['HotelLastModifyTime']) if isHasParams('HotelTel', dictGuestInfo): objGuestInfo.HotelTel = dictGuestInfo['HotelTel'] if isHasParams('MatchResult', dictDocInfo): objGuestInfo.MatchResult = dictDocInfo['MatchResult'] if isHasParams('MatchResultPercent', dictDocInfo): objGuestInfo.MatchResultPercent = dictDocInfo[ 'MatchResultPercent'] objGuestInfo.save(flush=True) HotelGuestID = objGuestInfo.HotelGuestID else: HotelGuestID = resGuestInfo.HotelGuestID # have this GuestDocID before ? resGuestDocInfo = GuestDoc().query.filter( GuestDoc.DocNo == dictDocInfo['DocNo']).first() if not resGuestDocInfo: if isHasParams('GuestType', dictDocInfo): objDocInfo.GuestType = dictDocInfo['GuestType'] if isHasParams('GuestType', dictDocInfo): objDocInfo.GuestType = dictDocInfo['GuestType'] if isHasParams('DocType', dictDocInfo): objDocInfo.DocType = dictDocInfo['DocType'] if isHasParams('DocNo', dictDocInfo): objDocInfo.DocNo = dictDocInfo['DocNo'] if isHasParams('DocName', dictDocInfo): objDocInfo.DocName = dictDocInfo['DocName'] if isHasParams('GuestName', dictDocInfo): objDocInfo.GuestName = dictDocInfo['GuestName'] if isHasParams('BornDate', dictDocInfo): objDocInfo.BornDate = dictDocInfo['BornDate'] if isHasParams('Sex', dictDocInfo): objDocInfo.Sex = dictDocInfo['Sex'] if isHasParams('NativePlace', dictDocInfo): objDocInfo.NativePlace = dictDocInfo['NativePlace'] if isHasParams('Nation', dictDocInfo): objDocInfo.Nation = dictDocInfo['Nation'] if isHasParams('AuthStatus', dictDocInfo): objDocInfo.AuthStatus = dictDocInfo['AuthStatus'] if isHasParams('ResAddress', dictDocInfo): objDocInfo.ResAddress = dictDocInfo['ResAddress'] if isHasParams('State', dictDocInfo): objDocInfo.State = dictDocInfo['State'] if isHasParams('CertiOffice', dictDocInfo): objDocInfo.CertiOffice = dictDocInfo['CertiOffice'] if isHasParams('CertiEffStartTime', dictDocInfo): objDocInfo.CertiEffStartTime = to_datetime( dictDocInfo['CertiEffStartTime']) if isHasParams('CertiEffEndTime', dictDocInfo): objDocInfo.CertiEffEndTime = to_datetime( dictDocInfo['CertiEffEndTime']) if isHasParams('DocPhotoURL', dictDocInfo): objDocInfo.DocPhotoURL = dictDocInfo['DocPhotoURL'] if isHasParams('Remark', dictDocInfo): objDocInfo.Remark = dictDocInfo['Remark'] objDocInfo.CreateTime = datetime.datetime.now() objDocInfo.save(flush=True) GuestDocID = objDocInfo.GuestDocID else: GuestDocID = resGuestDocInfo.GuestDocID if isHasParams('IsForeigner', dictGuestInfo): # if is foreigner if dictGuestInfo['IsForeigner']: objForeigner = Foreigner() # have this foreigner before ? resForeigner = Foreigner().query.filter( Foreigner.PassNo == dictGuestInfo['PassNo']).first() if not resForeigner: if isHasParams('GuestDocID', dictGuestInfo): objForeigner.GuestDocID = GuestDocID if isHasParams('PassNo', dictGuestInfo): objForeigner.PassNo = dictGuestInfo['PassNo'] if isHasParams('VisaDeadline', dictGuestInfo): objForeigner.VisaDeadline = dictGuestInfo[ 'VisaDeadline'] if isHasParams('DepartureTime', dictGuestInfo): objForeigner.DepartureTime = dictGuestInfo[ 'DepartureTime'] if isHasParams('EntryTime', dictGuestInfo): objForeigner.EntryTime = dictGuestInfo[ 'EntryTime'] if isHasParams('EntryPlace', dictGuestInfo): objForeigner.EntryPlace = dictGuestInfo[ 'EntryPlace'] if isHasParams('DeparturePlace', dictGuestInfo): objForeigner.DeparturePlace = dictGuestInfo[ 'DeparturePlace'] if isHasParams('VisaType', dictGuestInfo): objForeigner.VisaType = dictGuestInfo[ 'VisaType'] objForeigner.CreateTime = datetime.datetime.now() objForeigner.save(flush=True) # save in h_relation_checkin table self.addRealtionCheckIn(CheckInID, HotelGuestID, GuestDocID, CheckInInfo) print 22 return FuncResult(success=True, msg='操作成功!') except Exception, ce: return FuncResult(fail=ce)