def collect_online_info(self):
        """获取用户数据中心信息"""

        #获取所有用户
        all_shop = ShopDBService.get_all_shop_list()
        self.nick_shop = {}
        for shop in all_shop:
            self.nick_shop[shop['nick']] = shop

        #获取所有退款
        all_refund = RefundDBService.get_all_refunds_list()
        refund_list = [refund['order_id'] for refund in all_refund]

        #获取所有订单
        all_order = OrderDBService.get_all_orders_list()
        self.user_order = {}

        order_flag = False
        order_time = datetime.datetime.combine(
            datetime.date.today() - datetime.timedelta(days=1),
            datetime.time())

        for order in all_order:
            if not order_flag and order['occur_time'] >= order_time:
                order_flag = True
            if not order['article_code'] in self.article_code_list:
                continue
            if order['order_id'] in refund_list:
                continue
            key = order['nick'] + order['article_code']
            old_order = self.user_order.get(
                key,
                {'order_cycle_start': datetime.datetime(2011, 1, 1, 0, 0)})
            if order['order_cycle_start'] > old_order['order_cycle_start']:
                self.user_order[key] = order
        if not order_flag:
            send_sms('13738141586', str(order_time) + '的订单没有抓取成功')

        #获取所有服务支持
        all_support = SupportDBService.get_all_supports_list()
        self.user_supports = {}

        for support in all_support:
            if not support['article_code'] in self.article_code_list:
                continue
            key = support['nick'] + support['article_code']
            if not self.user_supports.has_key(key):
                self.user_supports[key] = []
            self.user_supports[key].append(support)

        #nick_worker存放 需要修改的客户客服关系 后期 取消
        self.nick_worker = {}

        for line in file(CURRENT_DIR + 'data/worker_nick.csv'):
            line_data = line.split(',')
            worker_id = int(line_data[0])
            nick = (line_data[1].split('\n'))[0].decode('utf-8')
            self.nick_worker[nick] = worker_id
Example #2
0
    def collect_online_info(self):
        """获取用户数据中心信息"""
        
        #获取所有用户
        all_shop = ShopDBService.get_all_shop_list()
        self.nick_shop = {}        
        for shop in all_shop:
            self.nick_shop[shop['nick']] = shop
        
        #获取所有退款
        all_refund = RefundDBService.get_all_refunds_list()
        refund_list = [refund['order_id'] for refund in all_refund]
        
        #获取所有订单
        all_order = OrderDBService.get_all_orders_list()
        self.user_order = {}
        
        order_flag = False 
        order_time = datetime.datetime.combine(datetime.date.today()-datetime.timedelta(days=1), datetime.time())
        
        for order in all_order:
            if not order_flag and order['occur_time'] >= order_time:
                order_flag = True
            if not order['article_code'] in self.article_code_list:
                continue
            if order['order_id'] in refund_list:
                continue
            key = order['nick'] + order['article_code']
            old_order = self.user_order.get(key, {'order_cycle_start':datetime.datetime(2011, 1, 1, 0, 0)})
            if order['order_cycle_start'] > old_order['order_cycle_start']:
                self.user_order[key] = order
        if not order_flag:
            send_sms('13738141586',str(order_time)+'的订单没有抓取成功')

        #获取所有服务支持
        all_support = SupportDBService.get_all_supports_list()
        self.user_supports = {}
        
        for support in all_support:
            if not support['article_code'] in self.article_code_list:
                continue
            key = support['nick'] + support['article_code']
            if not self.user_supports.has_key(key):
                self.user_supports[key] = []
            self.user_supports[key].append(support)

        #nick_worker存放 需要修改的客户客服关系 后期 取消
        self.nick_worker = {}
        
        for line in file(CURRENT_DIR+'data/worker_nick.csv'):
            line_data = line.split(',')
            worker_id = int(line_data[0])
            nick = (line_data[1].split('\n'))[0].decode('utf-8')
            self.nick_worker[nick] = worker_id
 def collect_online_info(self):
     """获取用户数据中心信息"""
     
     logger.info('start collect_online_info')
     
     #获取所有用户
     all_shop = ShopDBService.get_all_shop_list()
     self.nick_shop = {}        
     for shop in all_shop:
         self.nick_shop[shop['nick']] = shop
     
     logger.info('finish collect shop info')
     
     #获取所有订单
     all_order = OrderDBService.get_all_orders_list()
     logger.info('finish collect order info')
     
     self.user_orders = {}
     for order in all_order:
         key = (order['nick'], order['article_code'])
         if not self.user_orders.has_key(key):    
             self.user_orders[key] = []
         self.user_orders[key].append(order)
     
     logger.info('finish arrange order info')
     
     #获取所有退款
     all_refund = RefundDBService.get_all_refunds_list()
     refund_list = [refund['order_id'] for refund in all_refund]
     
     logger.info('finish collect refund info')
     
     for key in self.user_orders.keys():
         real_orders = []
         orders = self.user_orders[key]
         orders.sort(key=lambda order:order['order_cycle_start'])
         for i in range(len(orders)):
             order = orders[i]
             if int(order['total_pay_fee']) > 500:
                 if i < len(orders) - 1:
                     next_order = orders[i+1]
                     if int(next_order['total_pay_fee']) <= 500 and next_order['biz_type'] == 2:
                         order['order_cycle_end'] = next_order['order_cycle_end']
                 real_orders.append(order)
         self.user_orders[key] = real_orders
     logger.info('finish collect_online_info')