Exemplo n.º 1
0
    def match_intent_level_lookups(store_ids):
        from application.models.hwaccount import HwjdAccount
        stores = HwjdAccount.find_all_stores()
        if store_ids:
            stores = filter(lambda s: unicode(s.store_id) in store_ids, stores)
        for store_config in stores:
            from application.models.lookup import Lookup
            isr_lookup = Lookup.find_by_name_and_store(store_config.store_id,
                                                       'intent-level')

            hwjd_lookupvalues = HwjdLookup.find_by_type(u'市场-级别')
            for index, item in enumerate(hwjd_lookupvalues):
                from application.models.lookup import LookupValue
                isr_lookupvalue = LookupValue()
                isr_lookupvalue.code = item.name
                isr_lookupvalue.value = item.name
                isr_lookupvalue.lookup_id = isr_lookup.id
                isr_lookupvalue.parent_id = -1
                # order从10开始,按照10步进
                isr_lookupvalue.order = 10 + index * 10
                isr_lookupvalue.version = isr_lookup.version + 1
                isr_lookupvalue.vendor_code = item.code
                isr_lookupvalue.vendor_value = item.name
                db.session.add(isr_lookupvalue)

            isr_lookup.version += 1
Exemplo n.º 2
0
    def match_intent_car_lookups(store_ids):
        from application.models.hwaccount import HwjdAccount
        stores = HwjdAccount.find_all_stores()
        if store_ids:
            stores = filter(lambda s: unicode(s.store_id) in store_ids, stores)
        for store_config in stores:
            hwjd_lookupvalues = HwjdLookup.find_by_make_models(
                store_config.make, store_config.models_array())

            if hwjd_lookupvalues and len(hwjd_lookupvalues) > 0:
                from application.models.lookup import Lookup
                isr_lookup = Lookup.find_by_name_and_store(
                    store_config.store_id, 'intent-car')

                for index, item in enumerate(hwjd_lookupvalues):
                    # 六位的code证明这个值不是具体车型的值,不做mapping
                    if len(item.code) > 6 and item.name != item.extra:
                        from application.models.lookup import LookupValue
                        isr_lookupvalue = LookupValue()
                        # 没用用hwjd的code是因为在报表里, 有可能直接用code来做显示了
                        from application.utils import underscore_join_str
                        isr_lookupvalue.code = u'%s_%s' % (
                            item.model, underscore_join_str(item.extra))
                        isr_lookupvalue.value = item.extra
                        isr_lookupvalue.lookup_id = isr_lookup.id
                        isr_lookupvalue.parent_id = -1
                        # order从10开始,按照10步进
                        isr_lookupvalue.order = 10 + index * 10
                        isr_lookupvalue.section = item.model
                        isr_lookupvalue.version = isr_lookup.version + 1
                        isr_lookupvalue.vendor_code = item.code
                        isr_lookupvalue.vendor_value = item.extra
                        isr_lookupvalue.vendor_section = item.name
                        db.session.add(isr_lookupvalue)

                isr_lookup.version += 1