Exemple #1
0
def sxb_product(sqlstore, redis, app):
    vendor = Vendor.get_by_name(Provider.sxb)
    if vendor is None:
        vendor = Vendor.add(Provider.sxb.value, 'sxb')
    product = Product.get_by_remote_id(vendor.id_,
                                       ProductConsts.SXB_VENDOR_PRODUCT_ID[0])
    if product is None:

        def add_product(product_info):
            start_sell_date, end_sell_date = check_available_for_product(
                product_info)
            Product.add_or_update(
                vendor.id_, product_info.product_id, product_info.name,
                product_info.quota, product_info.total_quota,
                product_info.today_quota, product_info.total_amount,
                product_info.total_buy_amount, product_info.min_redeem_amount,
                product_info.max_redeem_amount, product_info.day_redeem_amount,
                product_info.add_year_rate, product_info.remark,
                Product.Type.unlimited, product_info.min_amount,
                product_info.max_amount, product_info.return_rate_type,
                product_info.return_rate, product_info.effect_day_type,
                product_info.effect_day, product_info.effect_day_unit,
                product_info.is_redeem, start_sell_date, end_sell_date)

        for i in range(len(ProductConsts.SXB_PRODUCT_INFO)):
            product_info = ProductConsts.SXB_PRODUCT_INFO[
                ProductConsts.SXB_VENDOR_PRODUCT_ID[i]]
            add_product(Obj(product_info))
        sxb_products = Product.get_products_by_vendor_id(vendor.id_)
        for p in sxb_products:
            if p.is_taken_down:
                p.go_on_sale()
            if p.remote_id == ProductConsts.SXB_VENDOR_PRODUCT_ID[0]:
                product = p
    return product
Exemple #2
0
def xm_product(sqlstore, redis):
    vendor = Vendor.get_by_name(Provider.xm)
    if vendor is None:
        vendor = Vendor.add(Provider.xm.value, 'xm')
    product = XMProduct.get(ProductConsts.XINMI_PRODUCT_ID)
    if product is None:

        def add_product(product):
            start_sell_date, end_sell_date = check_available_for_product(
                product)
            Product.add_or_update(vendor.id_, product.product_id, product.name,
                                  float(product.quota),
                                  float(product.total_amount),
                                  float(product.total_amount),
                                  float(product.total_amount), 0, 0, 0, 0, 0,
                                  product.remark, Product.Type.classic,
                                  product.min_amount, product.max_amount, 1,
                                  product.return_rate, 1, 1, 1,
                                  Product.RedeemType.auto.value,
                                  start_sell_date, end_sell_date,
                                  product.expire_period,
                                  product.expire_period_unit)

        add_product(Obj(ProductConsts.XINMI_PRODUCT_INFO))
        xm_products = Product.get_products_by_vendor_id(vendor.id_)
        for p in xm_products:
            if p.is_taken_down:
                p.go_on_sale()
        product = XMProduct.add(ProductConsts.XINMI_PRODUCT_INFO)
    return product
Exemple #3
0
# coding: utf-8

from libs.utils.log import bcolors
from core.models.hoarder.vendor import Vendor, Provider

if __name__ == '__main__':
    bcolors.run('Add product_vendor.')
    Vendor.add(Provider.sxb.value, 'sxb')
    Vendor.add(Provider.xm.value, 'xm')
    Vendor.add(Provider.zw.value, 'zw')
    Vendor.add(Provider.ms.value, 'ms')
    bcolors.success('Init product vendor done.')
Exemple #4
0
 def init_vendor(self):
     return Vendor.add(Provider.sxb.value, 'test')