|
@@ -184,42 +184,32 @@ class AgentCustomerView(View):
|
|
|
"""
|
|
|
添加代理云服务套餐
|
|
|
@param request_dict: 请求参数
|
|
|
+ @request_dict package_id: 代理服务id
|
|
|
@request_dict service_name: 代理服务名称
|
|
|
@request_dict package_type: 套餐类型 1:云存,2:4G
|
|
|
@response_dict profit_type: 利润分配类型 1:固定值,2:百分比
|
|
|
@response_dict cost: 成本
|
|
|
@response_dict profit: 利润值
|
|
|
- @param userID: userID
|
|
|
@param response: 响应对象
|
|
|
@return:
|
|
|
"""
|
|
|
- service_name = request_dict.get('service_name')
|
|
|
+ package_id = request_dict.get('package_id', None)
|
|
|
+ service_name = request_dict.get('service_name', None)
|
|
|
package_type = int(request_dict.get('package_type', 0)) # 默认为0,确保类型安全
|
|
|
profit_type = int(request_dict.get('profit_type', 1)) # 默认值为1
|
|
|
profit = request_dict.get('profit', 0)
|
|
|
+ cost = request_dict.get('cost', 0)
|
|
|
|
|
|
try:
|
|
|
- # 1:云存, 2:4G
|
|
|
- print(package_type)
|
|
|
- if package_type == 1:
|
|
|
- # 从Store_Meal查询
|
|
|
- package = Store_Meal.objects.filter(bucket__bucket=service_name, is_show=1).first()
|
|
|
- elif package_type == 2:
|
|
|
- # 从UnicomCombo查询
|
|
|
- package = UnicomCombo.objects.filter(combo_name=service_name, is_show=1, is_del=False).first()
|
|
|
- else:
|
|
|
- return response.json(444)
|
|
|
- if not package:
|
|
|
- return response.json(173)
|
|
|
# 创建AgentCloudServicePackage实例并保存
|
|
|
agent_service_package = AgentCloudServicePackage(
|
|
|
service_name=service_name,
|
|
|
- package_id=package.id if package else None,
|
|
|
+ package_id=package_id,
|
|
|
type=package_type,
|
|
|
profit_type=profit_type,
|
|
|
- cost=package.price,
|
|
|
profit=profit,
|
|
|
status=1,
|
|
|
+ cost=cost,
|
|
|
created_time=int(time.time()),
|
|
|
updated_time=int(time.time())
|
|
|
)
|