Exemplo n.º 1
0
 def get_ads_id(cls, category_index_id):
     sql = "SELECT id FROM cms_category_index_ads where category_index_id={0}".format(
         category_index_id)
     ids = BaseCursor.get_all(sql)
     result = set()
     for i in ids:
         result.add(i[0])
     return result
Exemplo n.º 2
0
 def get_goods_ids(cls, quick_id):
     sql = "SELECT id FROM cms_quick_order_goods where quick_order_id={0}".format(
         quick_id)
     ids = BaseCursor.get_all(sql)
     result = set()
     for i in ids:
         result.add(i[0])
     return result
Exemplo n.º 3
0
def _slice_category_select(key, page=1, per_page=10):
    if key and len(key) > 0:
        categories = r"select `id`,`name` from `cms_navi_category` where `parent_id` =0 and `fatherId`=0 and `type`<>0 and id not in (select category_id from cms_category_index) and (`id` like '%{0}%' or `name` like '%{0}%')".format(
            key)
    else:
        categories = r"select `id`,`name` from `cms_navi_category` where `parent_id` =0 and `fatherId`=0 and `type`<>0 and id not in (select category_id from cms_category_index)"
    total_page, result = BaseCursor.get_pageinate(page, per_page, categories)
    return total_page, result
Exemplo n.º 4
0
 def get_category(cls, quick_order_id):
     sql = "select c.name,c.id from cms_quick_order_category qoc inner join cms_navi_category c on c.id = qoc.category_id where qoc.quick_order_id={0}".format(
         quick_order_id)
     result = BaseCursor.get_all(sql)
     if len(result) == 1:
         return result[0]
     else:
         return None
Exemplo n.º 5
0
def _slice_goods_desc_select(key, category_id, page=1, per_page=15):
    if key and len(key) > 0:
        goods = r"select `goods_id`,CONCAT(name,'-',cp_name) from `view_cms_goods_formal` where `parent_id`=-1 and `new_category`={1} and  (`id` like '%{0}%' or `name` like '%{0}%' or `desc` like '%{0}%' )".format(
            key, category_id)
    else:
        goods = r"select `goods_id`,CONCAT(name,'-',cp_name) from `view_cms_goods_formal` where `parent_id`=-1 and `new_category`={0}".format(
            category_id)
    total_page, result = BaseCursor.get_pageinate(page, per_page, goods)
    return total_page, result
Exemplo n.º 6
0
def _slice_quick_order_select(key, category_id, page=1, per_page=20):
    if key and len(key) > 0:
        goods = r"select qo.id,qo.cms_quick_desc,qo.cms_quick_name from cms_quick_order_category qoc inner join  cms_quick_order qo on qoc.quick_order_id = qo.id where qoc.category_id={1} and (qo.id like '%{0}%' or qo.cms_quick_name like '%{0}%')".format(
            key, category_id)
    else:
        goods = r"select qo.id,qo.cms_quick_desc,qo.cms_quick_name from cms_quick_order_category qoc inner join  cms_quick_order qo on qoc.quick_order_id = qo.id where qoc.category_id={0}".format(
            category_id)
    total_page, result = BaseCursor.get_pageinate(page, per_page, goods)
    return total_page, result
Exemplo n.º 7
0
    def get_recommended(cls, category_index_id):
        sql = "select cg.goods_id,g.name,cg.start_date,cg.end_date from cms_category_index_recommended_goods cg inner join view_cms_goods_formal g on g.goods_id = cg.goods_id and g.parent_id=-1 where cg.category_index_id={0} ORDER BY cg.sort DESC".format(
            category_index_id)
        result = BaseCursor.get_all(sql=sql)

        def _format(item):
            item[-1] = timestamp2str(item[-1])
            item[-2] = timestamp2str(item[-2])
            return item

        result = list(map(_format, result))
        return result
Exemplo n.º 8
0
    def get_ads(cls, category_index_id):
        sql = "SELECT ad.id AS adbean_id, ad.name AS adbean_name, ad.img_url AS image, ad.start, ad.end, ad.action_id, ifnull(ac.memo,'') AS action_name, ad.city FROM cms_adbeans ad LEFT JOIN cms_actions ac ON ac.id = ad.action_id INNER JOIN cms_category_index_ads cad ON cad.adbean_id = ad.id WHERE cad.category_index_id = {0} ORDER BY cad.sort DESC ".format(
            category_index_id)
        result = BaseCursor.get_all(sql=sql)

        def _format(item):
            item[3] = timestamp2str(item[3])
            item[4] = timestamp2str(item[4])
            if item[6]:
                item[6] = "%d(%s)" % (item[5], item[6])
            else:
                item[6] = "%d" % (item[5])
            return item

        result = list(map(_format, result))
        return result
Exemplo n.º 9
0
 def search_quick_order(cls, page, per_page, key=None):
     sql = "select qo.id,c.name,qo.cms_quick_name,qo.cms_quick_desc from cms_quick_order qo inner join cms_quick_order_category qoc on qoc.quick_order_id = qo.id inner join cms_navi_category c on c.id=qoc.category_id order by qo.id desc"
     total_page, result = BaseCursor.get_pageinate(page, per_page, sql)
     return total_page, result
Exemplo n.º 10
0
 def get_goods(cls, quick_order_id):
     sql = "select qg.goods_id,qg.operation_desc,g.cp_name,g.city,g.name from cms_quick_order_goods qg inner join view_cms_goods_formal g on g.goods_id = qg.goods_id and g.parent_id=-1 where qg.quick_order_id={0} order by qg.sort desc".format(
         quick_order_id)
     result = BaseCursor.get_all(sql)
     return result
Exemplo n.º 11
0
 def get_goods_simple(cls, quick_id):
     sql = "select g.cp_name,g.name from cms_quick_order_goods qog inner join view_cms_goods_formal g on g.goods_id = qog.goods_id and g.parent_id=-1 where qog.quick_order_id={0}".format(
         quick_id)
     result = BaseCursor.get_all(sql=sql)
     return list(map(cls.quick_order_simple_format, result))
Exemplo n.º 12
0
 def search_category_index(cls, page, per_page, key=None):
     sql = "select ci.id,nc.name,ci.city from cms_category_index ci inner join cms_navi_category nc on nc.id = ci.category_id order by ci.id DESC "
     total_page, result = BaseCursor.get_pageinate(page, per_page, sql)
     return total_page, result
Exemplo n.º 13
0
 def get_quick_orders(cls, category_index_id):
     sql = "select ciqo.quick_order_id,qo.cms_quick_desc,qo.cms_quick_name from cms_category_index_quick_order ciqo inner join cms_quick_order qo on qo.id = ciqo.quick_order_id where ciqo.category_index_id={0} ORDER BY ciqo.sort DESC".format(
         category_index_id)
     result = BaseCursor.get_all(sql=sql)
     return result