Пример #1
0
def fill_category_dict(category_list, category_result, category, name, description):
    """补充类别关键词"""
    c_k = category_list[category_result].get('category_keyword')
    d_k = category_list[category_result].get('desc_keyword')
    n_k = category_list[category_result].get('name_keyword')
    c_k_list = StringUtil.cut_word(category) if category else list()
    d_k_list = StringUtil.cut_word(description) if description else list()
    n_k_list = StringUtil.cut_word(name) if name else list()
    for keyword in c_k_list:
        if not c_k.__contains__(keyword):
            c_k.append(keyword)
        if d_k.__contains__(keyword):
            d_k.remove(keyword)
        if n_k.__contains__(keyword):
            n_k.remove(keyword)
    for keyword in d_k_list:
        if not d_k.__contains__(keyword) and not c_k.__contains__(keyword):
            d_k.append(keyword)
        if n_k.__contains__(keyword):
            n_k.remove(keyword)
    for keyword in n_k_list:
        if not n_k.__contains__(keyword) and not d_k.__contains__(keyword) and not c_k.__contains__(keyword):
            n_k.append(keyword)
    category_list[category_result]['category_keyword'] = c_k
    category_list[category_result]['desc_keyword'] = d_k
    category_list[category_result]['name_keyword'] = n_k
    MongodbUtil.update('shopping', 'category', {'_id': category_list.get('_id')}, category_list)
Пример #2
0
 def _cpsuc_effect(self, order_list):
     for order in order_list:
         # 获取校验参数
         if type(order) is dict and order.has_key(
                 'merchant') and order.has_key('orderId') and order.has_key(
                     'productList') and order.has_key('merchant'):
             exist_order = MongodbUtil.find_one('api',
                                                'cps',
                                                spec_or_id={
                                                    'orderId':
                                                    order.get('orderId'),
                                                    'merchant':
                                                    order.get('merchant')
                                                })
             if exist_order:
                 exist_order['status'] = 'successful'
                 exist_order['successfulTime'] = DateUtil.get_sys_time()
                 MongodbUtil.update(
                     'api',
                     'cps',
                     spec_or_id={'_id': exist_order.get('_id')},
                     document=exist_order)
                 continue
         else:
             continue
         order = self._fit_params(order)
         # 插入cps
         cps_id = MongodbUtil.insert('api', 'cps', order)
         if cps_id:
             self._event('cps_insert:%s' % cps_id)
Пример #3
0
 def _cps_effect(self, merchant, order_list):
     """广告主订单成功,在联盟插入cps数据,确认cps生效"""
     cookie_value = ''
     for order in order_list:
         # 获取校验参数
         if type(order) is dict and order.has_key(
                 'merchant') and order.has_key('orderId') and order.has_key(
                     'productList') and order.has_key('merchant') and (
                         merchant == order.get('merchant')):
             exist_order = MongodbUtil.find_one('api',
                                                'cps',
                                                spec_or_id={
                                                    'orderId':
                                                    order.get('orderId'),
                                                    'merchant':
                                                    order.get('merchant')
                                                })
             if exist_order:
                 exist_order['status'] = 'successful'
                 exist_order['successfulTime'] = DateUtil.get_sys_time()
                 MongodbUtil.update(
                     'api',
                     'cps',
                     spec_or_id={'_id': exist_order.get('_id')},
                     document=exist_order)
                 continue
         else:
             continue
         order = self._fit_params(order)
         # 插入cps
         cps_id = MongodbUtil.insert('api', 'cps', order)
         if cps_id:
             self._event('cps_insert:%s' % cps_id)
             cookie_value += '_%s' % cps_id.__str__()
     if cookie_value:
         self.set_cookie('c_i_l',
                         cookie_value,
                         expires_days=settings.cookie_alive_time)
Пример #4
0
 def _update_cps_status(self):
     """更新订单状态为成功"""
     self._event('update_status')
     cps_id_str = self.get_cookie('c_i_l')
     cps_id_list = cps_id_str.split('_') if cps_id_str else list()
     for cps_id in cps_id_list:
         if cps_id:
             cps_document = MongodbUtil.find_one(
                 'api', 'cps', spec_or_id={'_id': ObjectId(cps_id)})
             if cps_document:
                 cps_document['status'] = 'successful'
                 cps_document['successfulTime'] = DateUtil.get_sys_time()
                 MongodbUtil.update(
                     'api',
                     'cps',
                     spec_or_id={'_id': cps_document.get('_id')},
                     document=cps_document)
     self.set_cookie('c_i_l', '', expires_days=settings.cookie_alive_time)
     result_info = {
         'status': '200',
         'message': 'successful',
     }
     self.write(json_encode(result_info))
Пример #5
0
 def cpc_un_effect(self, cpc_id):
     """浏览器异常关闭有效点击数减一"""
     self._event('cpc_un_effect')
     cpc_document = MongodbUtil.find_one('api',
                                         'cpc',
                                         spec_or_id={'_id': cpc_id})
     if cpc_document:
         cpc_document['takeEffect'] = 0
         result_id = MongodbUtil.update('api',
                                        'cpc',
                                        spec_or_id={'_id': cpc_id},
                                        document=cpc_document)
         if not result_id:
             self.cpc_un_effect(cpc_id)
         logger.info('Update cpc successful for : %s' % cpc_id)