Пример #1
0
 def get_total_count_moderation_wares():
     """
     Получение общего количества товаров на модерацию
     :return:
     """
     search_req1 = WarehouseMethods.get_SearchRequestDto(stock_states=[2], moderation_states=[1])
     search_req2 = WarehouseMethods.get_SearchRequestDto(stock_states=[3], moderation_states=[3])
     result1 = services.warehouse_index.root.tframed.search(search_req1)
     result2 = services.warehouse_index.root.tframed.search(search_req2)
     total_count = result1.totalCount + result2.totalCount
     return total_count
Пример #2
0
 def set_ware_to_moderate(shop_id, link_db):
     """
     Создание нового товара
     :return:
     """
     ware = WarehouseMethods.get_random_ware(link_db.warehouse.get_wares_by_shop_id(shop_id))
     # создаём товар, статус товара BELIEVED (по умолчанию - Доверенный)
     ware_req = WarehouseMethods.duplicate_ware_req(ware['shop_id'], ware['managed_category_id'], ware["content"], ware['stock_state_id'])
     wh_ware_st1_0 = services.warehouse.root.tframed.createWare(ware_req)
     stock_state = WarehouseMethods.get_StockState('PUBLISHED')
     wh_ware_st1_0 = services.warehouse.root.tframed.makePublication(wh_ware_st1_0.wareId, stock_state)
     return wh_ware_st1_0
Пример #3
0
 def set_price_for_good_by_id(good_id, value=None):
     """
     Метод задает значение поля цена для товара в зависимости от выбранной стратегии
     :param good_id:
     :param price_strategy:
     :return:
     """
     # TODO: не работает
     ware_cassandra = databases.db0.warehouse.get_wares_by_ware_id(good_id)[0]
     WarehouseMethods.update_data_content(
         ware_cassandra, WarehouseMethods.deserialize_content(ware_cassandra["content"])
     )
     ware_obj = WarehouseMethods.req_update_ware(
         good_id, ware_cassandra["managed_category"], ware_cassandra["content"]
     )
     ware_obj.newWareContent.currencyFields["price"].amount.significand = value
     services.warehouse.root.tframed.updateWare(ware_obj)
     return value
Пример #4
0
 def created_req(limit_n=1, offset_n=0):
     """ Формируем запрос для условий выборки товара.
     :param limit_n: лимит
     :param offset_n: смещение
     :return: запрос
     """
     pag = AccountingMethods.get_PaginationDto(limit=limit_n, offset=offset_n)
     search_req = WarehouseMethods.get_SearchRequestDto(search_category=index.categoryId, pagination=pag,
                                                        stock_states=[1, 2, 3, 4, 5],
                                                        moderation_states=[1, 2, 3, 4])
     p = services.warehouse_index.root.tframed.search(search_req)
     return p
Пример #5
0
 def set_photo(ware_cassandra, good_id):
     """
     Метод добавляет фото к товару
     :param ware_cassandra:
     :param good_id:
     :return:
     """
     if len(ware_cassandra["content"]["pictures"]["value"]) < 5:
         ware_cassandra["content"]["pictures"]["value"].append(ware_cassandra["content"]["pictures"]["value"][0])
         ware_obj = WarehouseMethods.req_update_ware(
             good_id, ware_cassandra["managed_category_id"], ware_cassandra["content"]
         )
         services.warehouse.root.tframed.updateWare(ware_obj)