Esempio n. 1
0
def get_product_dict(product, keyword_list, merchant_id, tag_dict):
    """拼接产品参数"""
    start_time = DateUtil.get_sys_date()
    category_mode = MongodbUtil.find_one('shopping', 'category')
    category_list, category, name, description = category_mode.get('category_dict'), product.get(tag_dict['category']), product.get(tag_dict['name']), product.get(tag_dict['description'])
    # 商品匹配定类
    category_result = fit_category(category_list, category, name, description)
    # 填充类别关键词集合
    fill_category_dict(category_list, category_result, category, name, description)
    product_dict = {
        'productId': product.get(tag_dict['id']),
        'category': category_result,
        'keywordList': keyword_list,
        'merchantId': merchant_id,
        'title': str(product.get(tag_dict['name'])).replace('&', ' '),
        'startTime': start_time,
        'aliveTime': settings.alive_time,
        'description': str(product.get(tag_dict['description'])).replace('&', ''),
        'currency': product.get(tag_dict['currency']),
        'price': float(product.get(tag_dict['price'])),
        'url': product.get(tag_dict['url']),
        'mpn': product.get(tag_dict.get('mpn', ''), ''),
        'color': product.get(tag_dict.get('color', ''), ''),
        'size': product.get(tag_dict.get('size', ''), ''),
        'merchantCategory': product.get(tag_dict.get('merchantCategory', ''), ''),
        'availability': product.get(tag_dict.get('availability', ''), ''),
        'shippingWeight': product.get(tag_dict.get('shippingWeight', ''), ''),
        'gender': product.get(tag_dict.get('gender', ''), ''),
        'ageGroup': product.get(tag_dict.get('ageGroup', ''), ''),
    }
    return product_dict
Esempio n. 2
0
def clear_product():
    """清理过期产品到备份集合中"""
    try:
        product_list = MongodbUtil.find('shopping', 'product')
        overdue_product_list = list()
        today = DateUtil.get_sys_date()
        for product in product_list.__iter__():
            start_date = product.get('startTime')
            alive_time = product.get('aliveTime')
            end_date = DateUtil.get_end_date(start_date, alive_time)
            if today > end_date:
                #添加到备份产品集合
                overdue_product_list.append(product)
                #执行删除操作
                delete_product(product)
        save_overdue_product(overdue_product_list)
    except Exception as e:
        logger.error(e.message)
Esempio n. 3
0
#! -*- coding:utf-8 -*-

"""
@author:Conner
@version:1.0
@date:13-12-5
@description:日期测试
"""
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

from affiliate.lib.util.date_util import DateUtil


if __name__ == '__main__':
    print(DateUtil.get_sys_date())
Esempio n. 4
0
                (overdue_cpc.get('webmaster'), overdue_cpc.get('merchant')))


def clear_product():
    """清理过期产品到备份集合中"""
    try:
        product_list = MongodbUtil.find('shopping', 'product')
        overdue_product_list = list()
        today = DateUtil.get_sys_date()
        for product in product_list.__iter__():
            start_date = product.get('startTime')
            alive_time = product.get('aliveTime')
            end_date = DateUtil.get_end_date(start_date, alive_time)
            if today > end_date:
                #添加到备份产品集合
                overdue_product_list.append(product)
                #执行删除操作
                delete_product(product)
        save_overdue_product(overdue_product_list)
    except Exception as e:
        logger.error(e.message)


if __name__ == '__main__':
    today = DateUtil.get_sys_date()
    start_date = '2014-02-18'
    alive_time = 30
    end_date = DateUtil.get_end_date(start_date, alive_time)
    print end_date
    print today > end_date