def handle(bot, update): logger.info("chatId: %s,first_name: %s,text: %s", update.message.chat_id, update.message.from_user.first_name, update.message.text) from_user = update.message.from_user cmd, text = parse_cmd(update.message.text) logger.info("%s %s", cmd, text) # 入参校验 if text == None or len(text) == 0 or text.isdigit() == False: update.message.reply_text(follow_notice_msg) return driver = driver_dao.select_by_id(text) if (len(driver) == 0): update.message.reply_text(follow_null_notice_msg) return member = member_service.select_by_tele_id(from_user) if text != member[0]['driver_id']: member_dao.update_driver(from_user.id, text) driver_info = member_dao.select_by_teleId(driver[0]['tele_id']) bot.send_message(chat_id=from_user.id, text=follow_send_msg.format(from_user.first_name, member[0]['id'], driver_info[0]['nickName']))
def current(from_user, status, current_page, msg_hash): member = member_service.select_by_tele_id(from_user) send_msg = order_service.select_by_status(status, current_page, member[0]['driver_id']) if int(msg_hash) != hash(send_msg): return page(from_user, status, current_page, send_msg, member) return '', []
def handle(bot, update): logger.info("chatId: %s,first_name: %s,text: %s", update.message.chat_id, update.message.from_user.first_name, update.message.text) from_user = update.message.from_user # 用户校验 member = member_service.select_by_tele_id(from_user) driver = driver_dao.select_by_id(member[0]['driver_id']) if driver == None or len(driver) == 0 or driver[0]['open_status'] == '1': update.message.reply_text(driver_close_msg.format(driver[0]['id'])) return cmd, text = parse_cmd(update.message.text) logger.info("%s %s", cmd, text) order_info = update.message.text.replace("/order ", "").split("#") # 入参校验 if text == None or len(text) == 0 or text.find('#') == -1 or (len(order_info) != 2): update.message.reply_text(order_notice_msg) return item, price = order_info item = item.strip() price = price.strip().replace("p", "").replace("P", "").strip() if price.isdigit() == False: update.message.reply_text(order_notice_msg) return balance = balance_service.select_amount_by_member(member[0]) if balance["amount"] < 0: bot.send_message(chat_id=from_user.id, text=order_fail_notice_msg) if balance["amount"] < int(price): bot.send_message(chat_id=from_user.id, text=order_balance_notice_msg) send_text = balance_service.select_all_by_tele_id(member[0]) bot.send_message(chat_id=from_user.id, text=send_text) driver = member_service.select_driver(member[0]) bot.send_message(chat_id=driver[0]['tele_id'], text=send_text) # return # 单号生成 order_id = str(int(time.time()))[4:] + from_user.first_name[:1] logging.info("order id: %s", order_id) order_info_dao.insert(order_id=order_id, tele_id=from_user.id, first_name=member[0]['nickName'], price=price, item=item, driver_id=member[0]['driver_id'] ) bot.send_message(chat_id=from_user.id, text=order_detail_msg.format(from_user.first_name, item, price, order_id, member[0]['driver_id']) )
def select_by_from_user(from_user): logger.info("select_by_from_user %s", from_user) member = member_service.select_by_tele_id(from_user) driver = driver_dao.select_by_id(member[0]['driver_id']) return store_dao.select_by_id(driver[0]['store_id'])
def handle(bot, update): logger.info("chatId: %s,first_name: %s,text: %s", update.message.chat_id, update.message.from_user.first_name, update.message.text) from_user = update.message.from_user # 用户校验 member = member_service.select_by_tele_id(from_user) # bot.send_message(chat_id=update.message.from_user.id, text=start_send_text) update.message.reply_text(start_send_text)
def page(from_user, status, current_page, send_msg=None, member=None): if member == None: member = member_service.select_by_tele_id(from_user) count = order_service.select_count_status(status, member[0]['driver_id']) if send_msg == None: send_msg = order_service.select_by_status(status, current_page, member[0]['driver_id']) keyboard_list = [] keyboard_status = gen_status_keyboard(status, send_msg) keyboard_list.append(keyboard_status) if count != 0 and int(count) > page_number: keyboard_page = create_page_button_list(send_msg, count, prefix, current_page, status) keyboard_list.append(keyboard_page) keyboard_list.append(close_button) return send_msg, keyboard_list
def handle(bot, update): logger.info("chatId: %s,first_name: %s,text: %s", update.message.chat_id, update.message.from_user.first_name, update.message.text) from_user = update.message.from_user # 用户校验 member = member_service.select_by_tele_id(from_user) if member[0]["driver_id"] == "-1": update.message.reply_text("雨季路滑请上车,方可获得发言权") bot.delete_message(chat_id=update.message.chat_id, message_id=update.message.message_id) return member[0]["driver_id"] = "2" balance = balance_service.select_amount_by_member(member[0]) if balance["amount"] < 0: # update.message.reply_text("请到司机处充值,方可获得发言权") bot.send_message(chat_id=from_user.id, text="请到司机处充值,方可获得发言权") bot.delete_message(chat_id=update.message.chat_id, message_id=update.message.message_id) return
def handle(bot, update): logger.info("chatId: %s,first_name: %s,text: %s", update.message.chat_id, update.message.from_user.first_name, update.message.text) from_user = update.message.from_user member = member_service.select_by_tele_id(from_user) if member[0]["is_driver"] != 1: update.message.reply_text(chat_id=from_user.id, text=driver_role_notice_text) return balance_list = balance_service.select_by_fee(from_user.id) for balance_info in balance_list: bot.send_message(chat_id=balance_info['tele_id'], text=balance_send_text.format( balance_info['nick_name'], balance_info['amount'], balance_info['id'], balance_info['driver_id'])) bot.send_message(chat_id=from_user.id, text=balance_send_text.format( balance_info['nick_name'], balance_info['amount'], balance_info['id'], balance_info['driver_id'])) bot.send_message(chat_id=from_user.id, text='催债结束')