71 lines
3.1 KiB
Plaintext
71 lines
3.1 KiB
Plaintext
async def providerDelete(ns={}):
|
|
"""
|
|
:param ns:
|
|
:return:
|
|
"""
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
if not ns.get('id'):
|
|
return {
|
|
"status": False,
|
|
"msg": "provider id is empty, please check"
|
|
}
|
|
try:
|
|
aa = ['organization/id', 'provider/id', 'product/providerid', 'rp_discount/productid',
|
|
'rp_rebate_ctl/productid', 'rp_rebate/rebateid','floorprice/offer_orgid']
|
|
|
|
provider_id = ns.get('id')
|
|
ns['del_flg'] = '1'
|
|
# 删除机构表
|
|
await sor.U('organization',ns)
|
|
|
|
# 删除供应商表
|
|
provider_sql = """update provider set del_flg = '1' where orgid = ${orgid}$"""
|
|
await sor.sqlExe(provider_sql, {'orgid': provider_id})
|
|
|
|
# 删除product表
|
|
product_sql = """update product set state = '2', expire_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY), del_flg = '1' where providerid = ${providerid}$"""
|
|
await sor.sqlExe(product_sql, {'providerid': provider_id})
|
|
|
|
# 删除协议表
|
|
xieyi_sql = """update saleprotocol set del_flg = '1' where offer_orgid = '%s';""" % provider_id
|
|
await sor.sqlExe(xieyi_sql, {})
|
|
|
|
# 删除协议子表
|
|
protocolid_sql_search = """select * from saleprotocol where offer_orgid = '%s';""" % provider_id
|
|
protocolid_sql_search_li = await sor.sqlExe(protocolid_sql_search, {})
|
|
for protocolid_res in protocolid_sql_search_li:
|
|
protocolid = protocolid_res['id']
|
|
zibiao_sql = """update product_salemode set del_flg = '1' where protocolid = '%s';""" % protocolid
|
|
await sor.sqlExe(zibiao_sql, {})
|
|
# 删除回佣主表
|
|
huiyong_sql = """update rebate_cycle set del_flg = '1' where protocolid = '%s';""" % protocolid
|
|
await sor.sqlExe(huiyong_sql, {})
|
|
# 删除回佣子表
|
|
huiyong_zi_search_sql = """select * from rebate_cycle where protocolid = '%s';""" % protocolid
|
|
huiyong_zi_res_li = await sor.sqlExe(huiyong_zi_search_sql, {})
|
|
for huiyong_zi_res in huiyong_zi_res_li:
|
|
cycleid = huiyong_zi_res['id']
|
|
huiyong_zi_up_sql = """update rp_rebate set del_flg = '1' WHERE rebatecycleid = '%s';""" % cycleid
|
|
await sor.sqlExe(huiyong_zi_up_sql, {})
|
|
|
|
# 删除促销商品表
|
|
products_li = await sor.R('product', {'providerid': provider_id})
|
|
for product_info in products_li:
|
|
product_ids = product_info['id']
|
|
promote_sql = """UPDATE promote_discount SET del_flg = '1' WHERE productid = '%s';""" % product_ids
|
|
await sor.sqlExe(promote_sql, {})
|
|
return {
|
|
"status": True,
|
|
"msg": "provider delete success",
|
|
}
|
|
except Exception as e:
|
|
raise e
|
|
return {
|
|
"status": False,
|
|
"msg": "provider delete failed",
|
|
}
|
|
|
|
|
|
ret = await providerDelete(params_kw)
|
|
return ret |