Ejemplo n.º 1
0
 def call_weixin(self, order):
     if order.confirm_type == OrderModel.CONFIRM_TYPE_AUTO:
         raise gen.Return()
     map_hotels = UserHotelMappingModel.get_hotel_by_id(self.db, merchant_id=order.merchant_id,
                                                       hotel_id=order.hotel_id)
     order_dict = order.todict()
     if map_hotels:
         user_ids = [map_hotel.user_id for map_hotel in map_hotels]
         users = UserModel.get_users_by_id(self.db, user_ids)
         usernames = [user.username for user in users]
         order_dict['usernames'] = ",".join(usernames)
     url = API['WEIXIN'] + "/webchart/ebkOrderPush"
     body = urllib.urlencode(order_dict)
     try:
         yield AsyncHTTPClient().fetch(url, method='POST', body=body)
     except Exception, e:
         Log.exception(e)