累死了,删除了所有跨平台逻辑,进行了表迁移
This commit is contained in:
@@ -29,10 +29,9 @@ from utils.weixin_broadcast import WeixinBroadcastSender
|
||||
from utils.invitationcode_utils import CreateInvitationCode, VerifyInvitationCode
|
||||
|
||||
from backend.utils import update_shangjia_daily
|
||||
from orders.utils import sync_order_to_partners
|
||||
|
||||
from .models import (
|
||||
Gonggao, Lunbo, ClubConfig, Tupianpeizhi, Qunpeizhi,
|
||||
Gonggao, Lunbo, Tupianpeizhi, Qunpeizhi,
|
||||
ShangjiaMoban, ShangjiaLianjie, PopupPage, PopupConfig, WithdrawConfig
|
||||
)
|
||||
|
||||
@@ -63,49 +62,19 @@ class GetDynamicConfigView(APIView):
|
||||
|
||||
def post(self, request):
|
||||
try:
|
||||
# 查询我方俱乐部配置(is_self=1),取第一条(通常只有一条)
|
||||
club_config = ClubConfig.objects.filter(is_self=1).only(
|
||||
'storage_bucket_domain',
|
||||
'storage_bucket_name',
|
||||
'chat_api_key',
|
||||
'customer_service_api_url',
|
||||
'customer_service_corp_id'
|
||||
).first()
|
||||
|
||||
# 默认值(防止空数据导致前端报错)
|
||||
cos_bucket = ''
|
||||
cos_region = 'ap-shanghai'
|
||||
cos_oss_url = ''
|
||||
# 从 settings 获取配置
|
||||
cos_oss_url = getattr(settings, 'COS_DOMAIN', '')
|
||||
if cos_oss_url and not cos_oss_url.endswith('/'):
|
||||
cos_oss_url += '/'
|
||||
cos_bucket = getattr(settings, 'COS_BUCKET', '')
|
||||
cos_region = getattr(settings, 'COS_REGION', 'ap-shanghai')
|
||||
goeasy_host = 'hangzhou.goeasy.io'
|
||||
goeasy_appkey = ''
|
||||
kefu_link = ''
|
||||
kefu_enterprise_id = ''
|
||||
goeasy_appkey = getattr(settings, 'GOEASY_APPKEY', '')
|
||||
kefu_link = getattr(settings, 'KEFU_LINK', '')
|
||||
kefu_enterprise_id = getattr(settings, 'KEFU_ENTERPRISE_ID', '')
|
||||
morentouxiang = 'beijing/morentouxiang.jpg'
|
||||
dashouguize = 'a_long/dashouguize.jpg'
|
||||
|
||||
if club_config:
|
||||
# 存储桶配置
|
||||
bucket = club_config.storage_bucket_name or ''
|
||||
region = 'ap-shanghai' # 若需要动态,可单独存储
|
||||
cos_oss_url = club_config.storage_bucket_domain or ''
|
||||
if cos_oss_url and not cos_oss_url.endswith('/'):
|
||||
cos_oss_url += '/'
|
||||
cos_bucket = bucket
|
||||
cos_region = region
|
||||
|
||||
# GoEasy 配置
|
||||
if club_config.chat_api_key:
|
||||
goeasy_appkey = club_config.chat_api_key
|
||||
# host 如果需要可动态,这里固定或从其他字段获取
|
||||
|
||||
# 客服配置
|
||||
if club_config.customer_service_api_url:
|
||||
kefu_link = club_config.customer_service_api_url
|
||||
if club_config.customer_service_corp_id:
|
||||
kefu_enterprise_id = club_config.customer_service_corp_id
|
||||
|
||||
# 其他配置可在此扩展
|
||||
|
||||
# 构造返回数据
|
||||
data = {
|
||||
"code": 0,
|
||||
@@ -2229,26 +2198,10 @@ class KehuGetDingdanLianjieView(APIView):
|
||||
# ========== 新增:确定俱乐部配置 ==========
|
||||
# 默认头像(相对路径)
|
||||
default_avatar = 'a_long/morentouxiang.jpg'
|
||||
# 初始化配置字段默认值
|
||||
kefu_link = ''
|
||||
oss_url = ''
|
||||
goeasy_appkey = ''
|
||||
|
||||
# 判断是否为跨平台订单(保留,但不影响配置选择)
|
||||
is_cross = dingdan_obj.is_cross if hasattr(dingdan_obj, 'is_cross') else 0
|
||||
|
||||
# 始终使用我方俱乐部配置
|
||||
try:
|
||||
club_config = ClubConfig.objects.filter(is_self=1).first()
|
||||
if club_config:
|
||||
logger.info(f"使用我方俱乐部配置,club_id={club_config.club_id}")
|
||||
kefu_link = club_config.customer_service_api_url or ''
|
||||
oss_url = club_config.storage_bucket_domain or ''
|
||||
goeasy_appkey = club_config.chat_api_key or ''
|
||||
else:
|
||||
logger.warning("未找到我方俱乐部配置(is_self=1)")
|
||||
except Exception as e:
|
||||
logger.error(f"查询我方俱乐部配置异常: {str(e)}", exc_info=True)
|
||||
# 从 settings 获取配置
|
||||
kefu_link = getattr(settings, 'KEFU_LINK', '')
|
||||
oss_url = getattr(settings, 'COS_DOMAIN', '')
|
||||
goeasy_appkey = getattr(settings, 'GOEASY_APPKEY', '')
|
||||
|
||||
# ========== 构建订单信息 ==========
|
||||
dingdan_info = {
|
||||
@@ -2256,7 +2209,6 @@ class KehuGetDingdanLianjieView(APIView):
|
||||
'jiage': str(dingdan_obj.jine) if dingdan_obj.jine is not None else '0.00', # 金额字段名是 jine
|
||||
'shangjia_mingcheng': shangjia_nicheng,
|
||||
'zhuangtai': dingdan_obj.zhuangtai,
|
||||
'is_cross': is_cross,
|
||||
# 新增配置字段
|
||||
'kefu_link': kefu_link,
|
||||
'oss_url': oss_url,
|
||||
@@ -2313,7 +2265,6 @@ class KehuGetDingdanLianjieView(APIView):
|
||||
'dashou_biaoshi': '',
|
||||
'shangjia_biaoshi': '',
|
||||
'you_dashou': False,
|
||||
'is_cross': 0,
|
||||
'kefu_link': '',
|
||||
'oss_url': '',
|
||||
'default_avatar': 'a_long/morentouxiang.jpg',
|
||||
@@ -2330,7 +2281,6 @@ class KehuGetDingdanLianjieView(APIView):
|
||||
'dashou_biaoshi': '',
|
||||
'shangjia_biaoshi': '',
|
||||
'you_dashou': False,
|
||||
'is_cross': 0,
|
||||
'kefu_link': '',
|
||||
'oss_url': '',
|
||||
'default_avatar': 'a_long/morentouxiang.jpg',
|
||||
@@ -2348,7 +2298,6 @@ class KehuGetDingdanLianjieView(APIView):
|
||||
'dashou_biaoshi': '',
|
||||
'shangjia_biaoshi': '',
|
||||
'you_dashou': False,
|
||||
'is_cross': 0,
|
||||
'kefu_link': '',
|
||||
'oss_url': '',
|
||||
'default_avatar': 'a_long/morentouxiang.jpg',
|
||||
@@ -2627,13 +2576,6 @@ class KehuTianxieDingdanView(APIView):
|
||||
shangjia_mingcheng = f"商家{lianjie_obj.yonghu_id}"
|
||||
logger.warning(f"获取商家昵称失败,使用默认 - 用户ID: {lianjie_obj.yonghu_id}")
|
||||
|
||||
# ========== 新增:判断是否需要跨平台同步 ==========
|
||||
# 获取商家ID(从链接记录)
|
||||
shangjia_user_id = lianjie_obj.yonghu_id
|
||||
# 跨平台条件:商家ID在白名单、订单为普通状态(zhuangtai=1)、要求类型为1、会员ID等于配置值
|
||||
sync_order_to_partners(dingdan_obj.dingdan_id)
|
||||
# ========== 新增结束 ==========
|
||||
|
||||
# 14. 返回成功响应
|
||||
response_data = {
|
||||
#'dingdan_id': dingdan_obj.dingdan_id,
|
||||
|
||||
Reference in New Issue
Block a user