update
This commit is contained in:
parent
4ab2a5462f
commit
783e61b12a
36
b/product/homepage_product_category.dspy
Normal file
36
b/product/homepage_product_category.dspy
Normal file
@ -0,0 +1,36 @@
|
||||
async def homepage_product_category(ns={}):
|
||||
if not ns.get('publish_type'):
|
||||
return {
|
||||
'status': False,
|
||||
'msg': '请传递产品类型'
|
||||
}
|
||||
publish_type = ns.get('publish_type')
|
||||
domain_name = ns.get('url_link').split("//")[1].split("/")[0]
|
||||
|
||||
if 'localhost' in domain_name:
|
||||
domain_name = 'dev.opencomputing.cn'
|
||||
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('kboss') as sor:
|
||||
# 读取user_publish_product产品
|
||||
user_publish_product_sql = """SELECT DISTINCT(product_category) FROM user_publish_product WHERE domain_name = '%s' AND first_page = '1' AND audit_status = 'approved' AND listing_status = 'listing' AND del_flg = '0' AND publish_type = '%s' ORDER BY create_at DESC;""" % (domain_name, publish_type)
|
||||
user_publish_product_result = await sor.sqlExe(user_publish_product_sql, {})
|
||||
if not user_publish_product_result:
|
||||
return {
|
||||
'status': False,
|
||||
'msg': '没有找到匹配的产品'
|
||||
}
|
||||
user_publish_product_ids = [item['product_category'].split(",")[0] for item in user_publish_product_result]
|
||||
|
||||
# 读取user_publish_product_category产品类别
|
||||
user_publish_product_category_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND del_flg = '0' ORDER BY priority ASC;""" % domain_name
|
||||
user_publish_product_category_result = await sor.sqlExe(user_publish_product_category_sql, {})
|
||||
result = [item for item in user_publish_product_category_result if str(item['id']) in user_publish_product_ids]
|
||||
return {
|
||||
'status': True,
|
||||
'msg': 'success',
|
||||
'data': result
|
||||
}
|
||||
|
||||
ret = await homepage_product_category(params_kw)
|
||||
return ret
|
||||
@ -91,6 +91,7 @@ async def publish_product_add(ns={}):
|
||||
if user_role != '客户':
|
||||
ns['status'] = '1'
|
||||
ns_dic['audit_status'] = 'approved'
|
||||
ns_dic['listing_status'] = 'listing'
|
||||
ns_dic['first_page'] = '1'
|
||||
try:
|
||||
await sor.C('user_publish_product', ns_dic)
|
||||
|
||||
@ -36,6 +36,8 @@ async def publish_product_search(ns={}):
|
||||
"""
|
||||
offset = ns.get('offset')
|
||||
manager_self = ns.get('manager_self')
|
||||
to_excel = ns.get('to_excel')
|
||||
|
||||
|
||||
if ns.get('userid'):
|
||||
userid = ns.get('userid')
|
||||
@ -141,6 +143,23 @@ async def publish_product_search(ns={}):
|
||||
res['img'] = 'https://' + domain_name + '/idfile?path=' + res['img']
|
||||
else:
|
||||
res['img'] = None
|
||||
|
||||
# 读取产品类别表 轮询匹配result中的所有类别
|
||||
product_category_list = await sor.R('user_publish_product_category', {'del_flg': '0'})
|
||||
for res in result:
|
||||
for product_category in product_category_list:
|
||||
if product_category['id'] == res['product_category'].split(",")[0]:
|
||||
res['category_name'] = product_category['product_category']
|
||||
break
|
||||
|
||||
if to_excel == '1':
|
||||
res = await publish_product_to_excel({'result_from_search': result})
|
||||
return {
|
||||
'status': True,
|
||||
'msg': 'search to excel success',
|
||||
'data': res['data']
|
||||
}
|
||||
else:
|
||||
return {
|
||||
'status': True,
|
||||
'msg': 'Requirements retrieved successfully',
|
||||
|
||||
@ -44,8 +44,12 @@ async def publish_product_search_detail(ns={}):
|
||||
|
||||
# 如果用户角色是运营并且from='b' product_list中的phone_number和email做加星号处理
|
||||
product_list = await sor.R('user_publish_product', {'id': ns.get('id'), 'del_flg': '0'})
|
||||
product_category = await sor.R('user_publish_product_category', {'id': product_list[0]['product_category'].split(',')[0]})
|
||||
product_list[0]['product_category'] = product_category[0]['product_category']
|
||||
if user_role == '运营' and ns.get('from') == 'b':
|
||||
pass
|
||||
elif orgid == product_list[0]['orgid']:
|
||||
pass
|
||||
else:
|
||||
for product in product_list:
|
||||
if product.get('phone_number'):
|
||||
|
||||
@ -20,8 +20,12 @@ async def publish_product_search_first_page(ns={}):
|
||||
async with db.sqlorContext('kboss') as sor:
|
||||
try:
|
||||
ns['del_flg'] = '0'
|
||||
if to_page == 'first_page':
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND first_page = '1' AND audit_status = 'approved' AND del_flg = '0' AND publish_type = '%s' ORDER BY create_at DESC;""" % (domain_name, publish_type)
|
||||
# 如果是首页并且有产品分类
|
||||
if to_page == 'first_page' and product_category:
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND first_page = '1' AND audit_status = 'approved' AND listing_status = 'listing' AND del_flg = '0' AND publish_type = '%s' AND product_category LIKE '%%%%%s%%%%' ORDER BY create_at DESC;""" % (domain_name, publish_type, product_category)
|
||||
find_sql = """SELECT upp.* FROM user_publish_product AS upp INNER JOIN user_publish_product_category AS uppc ON upp.product_category LIKE uppc.id WHERE upp.domain_name = '%s' AND upp.first_page = '1' AND upp.audit_status = 'approved' AND listing_status = 'listing' AND upp.product_category LIKE '%%%%%s%%%%' AND upp.del_flg = '0' AND upp.publish_type = '%s' ORDER BY uppc.priority ASC, upp.create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, product_category, publish_type, page_size, current_page)
|
||||
elif to_page == 'first_page':
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND first_page = '1' AND audit_status = 'approved' AND listing_status = 'listing' AND del_flg = '0' AND publish_type = '%s' ORDER BY create_at DESC;""" % (domain_name, publish_type)
|
||||
find_sql = """SELECT upp.* FROM user_publish_product AS upp INNER JOIN user_publish_product_category AS uppc ON upp.product_category LIKE uppc.id WHERE upp.domain_name = '%s' AND upp.first_page = '1' AND upp.audit_status = 'approved' AND upp.del_flg = '0' AND upp.publish_type = '%s' ORDER BY uppc.priority ASC, upp.create_at DESC LIMIT %s OFFSET %s;""" % (domain_name, publish_type, page_size, current_page)
|
||||
elif to_page == 'square' and product_category:
|
||||
count_sql = """SELECT COUNT(*) AS total_count FROM user_publish_product WHERE domain_name = '%s' AND product_category LIKE """ % domain_name + """'%%""" + product_category + """%%'""" + """ AND audit_status = 'approved' AND del_flg = '0' AND publish_type = '%s' ORDER BY create_at DESC;""" % publish_type
|
||||
|
||||
@ -68,10 +68,11 @@ async def publish_product_update(ns={}):
|
||||
# 非客户角色编辑客户的产品
|
||||
if user_role != '客户' and ns.get('orgid') != orgid:
|
||||
# 非客户角色审核客户的产品
|
||||
# 如果是待审状态 更新审核状态为通过 上架状态为上架
|
||||
# 如果是待审状态 更新审核状态为通过 上架状态为上架 清空驳回原因
|
||||
if ns.get('audit_status') == 'approved':
|
||||
ns_dic['audit_status'] = 'approved'
|
||||
ns_dic['listing_status'] = 'listing'
|
||||
ns_dic['reject_reason'] = None
|
||||
# 如果是上架商品 更新publish_time为当前时间
|
||||
if ns.get('listing_status') == 'listing':
|
||||
ns_dic['publish_time'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user