def yes(tele_id): driver = driver_dao.select_by_teleId(tele_id) if len(driver) == 0: driver_dao.insert(tele_id=tele_id) driver = driver_dao.select_by_teleId(tele_id) user = member_dao.select_by_teleId(tele_id) send_msg = driver_yes_msg.format(user[0]['nickName'], driver[0]['id']) return send_msg, []
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 # 司机校验 driver = driver_dao.select_by_teleId(from_user.id) if len(driver) == 0: update.message.reply_text(driver_role_notice_text) return cmd, text = parse_cmd(update.message.text) if text.find('#') == -1: update.message.reply_text() return id, price = text.split("#") member = member_service.select_by_id(id) logger.info("member:%s", member) if len(member) == 0: update.message.reply_text() return balance_service.update_amount(tele_id=member[0]["tele_id"], price=price, driver_tele_id=from_user.id) send_text = balance_service.select_by_tele_id(member[0], from_user.id) bot.send_message(chat_id=from_user.id, text=send_text) send_text = deposit_send_text.format(from_user.first_name, price) + send_text bot.send_message(chat_id=member[0]['tele_id'], text=send_text)
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 # 司机校验 driver = driver_dao.select_by_teleId(from_user.id) if len(driver) == 0: update.message.reply_text(driver_role_notice_text) return driver_dao.update_status_by_teleId("1", from_user.id) update.message.reply_text(driver_close_notice_text)
def insert_without_check(tele_id, driver_tele_id=None, driver_id=None): follow = member_dao.select_by_teleId(tele_id) if driver_tele_id != None: driver = driver_dao.select_by_teleId(driver_tele_id)[0] if driver_id != None: driver = driver_dao.select_by_id(driver_id)[0] balance_dao.insert(tele_id=tele_id, nick_name=follow[0]['nickName'], member_id=follow[0]['id'], driver_id=driver['id'], driver_tele_id=driver['tele_id']) balance = balance_dao.select_by_teleId(follow[0]['tele_id'], driver['tele_id']) logging.info(balance) return balance
def deposit(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 # 司机校验 driver = driver_dao.select_by_teleId(from_user.id) if len(driver) == 0: update.message.reply_text(driver_role_notice_text) return ConversationHandler.END # if from_user.id != 427009122: # bot.send_message(chat_id=from_user.id, # text=role_send_text) # return ConversationHandler.END bot.send_message(chat_id=from_user.id, text=deposit_notice_text) return DOING
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) # 司机校验 driver = driver_dao.select_by_teleId(from_user.id) if len(driver) == 0: update.message.reply_text(driver_role_notice_text) return member = member_dao.select_by_id(text) balance = balance_service.select_by_tele_id(member[0], from_user.id) order_list = order_info_dao.select_init_driver_id(driver[0]['id']) if len(order_list) == 0: update.message.reply_text(order_over_notice_msg) return send_msg_list = [] for order in order_list: logger.info("over order id:%s,nick_name:%s,price:%s,driver_id:%s", order["id"], order["nick_name"], order["price"], order["driver_id"]) balance = balance_service.update_amount(order["member_id"], -order["price"], from_user.id) status = "3" if balance["amount"] >= 0 else "2" order_info_dao.update_status(status=status, id=order["id"]) send_msg_list.append({ "id": balance["id"], "amount": balance["amount"], "order_id": order["id"], "tele_id": order["member_id"], "nick_name": order["nick_name"], "price": order["price"], "create_time": order["create_time"], "item": order["item"], "status": status }) send_msg = over_title_msg total_price = 0 for send_msg_info in send_msg_list: send_order_msg = over_info_msg.format(send_msg_info["nick_name"], send_msg_info["item"], send_msg_info["price"]) send_msg = send_msg + send_order_msg total_price = total_price + int(send_msg_info["price"]) try: bot.send_message(chat_id=send_msg_info["tele_id"], text=over_title_msg + send_order_msg + "\n余额:{0}".format(send_msg_info["amount"])) except: logger.warning(send_order_msg) number = int(text) if text != None and text.isdigit() else int( len(order_list) / 10) - 1 for x in range(number): random_order = random_send_msg(send_msg_list, from_user) bot.send_message(chat_id=update.message.chat_id, text="请 <{0}> 协助拿饭".format(random_order["nick_name"])) bot.send_message(chat_id=random_order["tele_id"], text="请 <{0}> 协助拿饭".format(random_order["nick_name"])) send_msg = send_msg + "\n合计:{0} \t份数:{1}".format(total_price, len(order_list)) bot.send_message(chat_id=update.message.chat_id, text=send_msg)