addproject
This commit is contained in:
1
zhyy/qa_helper/common/__init__.py
Normal file
1
zhyy/qa_helper/common/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
print("222222222222")
|
||||
BIN
zhyy/qa_helper/common/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
zhyy/qa_helper/common/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
BIN
zhyy/qa_helper/common/__pycache__/order.cpython-38.pyc
Normal file
BIN
zhyy/qa_helper/common/__pycache__/order.cpython-38.pyc
Normal file
Binary file not shown.
BIN
zhyy/qa_helper/common/__pycache__/user.cpython-38.pyc
Normal file
BIN
zhyy/qa_helper/common/__pycache__/user.cpython-38.pyc
Normal file
Binary file not shown.
337
zhyy/qa_helper/common/course_package.py
Normal file
337
zhyy/qa_helper/common/course_package.py
Normal file
@@ -0,0 +1,337 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
Author: 陈江
|
||||
Email: chenjiang@sparkedu.com
|
||||
Create Date: 2022/09/23 2:06 下午
|
||||
"""
|
||||
from base_framework.public_tools.sqlhelper import MySqLHelper
|
||||
|
||||
import json
|
||||
|
||||
obj_mysql_helper = MySqLHelper()
|
||||
|
||||
|
||||
class CoursePackage:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def __get_data_name(data_list):
|
||||
temp_data_list = []
|
||||
if data_list:
|
||||
for data in data_list:
|
||||
temp_data_list.append(
|
||||
{"course_package_id": data.get('value'), "cc显示_course_package_name": data.get('name'),
|
||||
"course_package_name": data.get('text')})
|
||||
return temp_data_list
|
||||
return None
|
||||
|
||||
def get_course_package_by_cc_crm(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 获取套餐信息,根据cc/crm购买可选套餐 |
|
||||
| 输入参数: |
|
||||
| 作者信息: | 陈江 | 修改时间 | 2022-9-28 |
|
||||
"""
|
||||
sql_crm_vispark_subscribe_chinese = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type = 2
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',2,'
|
||||
AND course_type IN ( ',5,', ',1,' )
|
||||
AND sale_type = 2
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,7,%'
|
||||
ORDER BY
|
||||
id DESC LIMIT 3;"""
|
||||
crm_vispark_subscribe_chinese_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_subscribe_chinese))
|
||||
|
||||
sql_crm_vispark_subscribe_sg = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type = 1
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',1,'
|
||||
AND course_type IN ( ',5,' )
|
||||
AND sale_type = 2
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,10,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_subscribe_sg_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_subscribe_sg))
|
||||
|
||||
sql_crm_vispark_subscribe_oc = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type in( 1,10 )
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',1,'
|
||||
AND course_type IN ( ',5,' )
|
||||
AND sale_type = 2
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,13,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_subscribe_oc_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_subscribe_oc))
|
||||
|
||||
sql_crm_vispark_buy_chinese = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type = 2
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',2,'
|
||||
AND course_type IN ( ',5,', ',1,', ',1,5,', ',5,1,')
|
||||
AND sale_type = 1
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,7,%'
|
||||
ORDER BY
|
||||
IF (abbreviation="",NAME,abbreviation) asc limit 3;"""
|
||||
crm_vispark_buy_chinese_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_buy_chinese))
|
||||
|
||||
sql_crm_vispark_buy_us = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type = 10
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',1,'
|
||||
AND course_type IN ( ',5,', ',1,', ',1,5,', ',5,1,')
|
||||
AND sale_type = 1
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,11,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_buy_us_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_buy_us))
|
||||
|
||||
sql_crm_vispark_buy_canada = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type = 10
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',1,'
|
||||
AND course_type IN ( ',5,', ',1,', ',1,5,', ',5,1,')
|
||||
AND sale_type = 1
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,1012,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_buy_canada_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_buy_canada))
|
||||
|
||||
sql_crm_vispark_buy_sg = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type = 1
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',1,'
|
||||
AND course_type IN ( ',5,', ',1,', ',1,5,', ',5,1,')
|
||||
AND sale_type = 1
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,10,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_buy_sg_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_buy_sg))
|
||||
|
||||
sql_crm_vispark_buy_oc = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
type = 1
|
||||
AND business_line = 1
|
||||
AND business_line_type in( 1,10 )
|
||||
AND teaching_method = 0
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject = ',1,'
|
||||
AND course_type IN ( ',5,', ',1,', ',1,5,', ',5,1,')
|
||||
AND sale_type = 1
|
||||
AND course_teaching_method = 1
|
||||
AND STATUS = 1
|
||||
AND view_authority_scope LIKE '%,13,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_buy_oc_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_buy_oc))
|
||||
|
||||
sql_crm_vispark_buy_huohua = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
teaching_method = 0
|
||||
AND business_line_type in( 0,4,9 )
|
||||
-- AND business_line = 0 (以及业务线)
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject like '%,2,%'
|
||||
-- AND course_type IN ( ',1,',',5,' ) (课程类型)
|
||||
AND sale_type = 1
|
||||
AND course_teaching_method = 1
|
||||
-- AND STATUS = 1 (状态)
|
||||
AND view_authority_scope LIKE '%,7,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_buy_huohua_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_buy_huohua))
|
||||
|
||||
sql_crm_vispark_subscribe_huohua = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
teaching_method = 0
|
||||
AND business_line_type in( 0,4,9 )
|
||||
AND business_line = 1
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject like '%,2,%'
|
||||
-- AND course_type IN ( ',1,',',5,' ) (课程类型)
|
||||
AND sale_type = 2
|
||||
AND course_teaching_method = 1
|
||||
-- AND STATUS = 1 (状态)
|
||||
AND view_authority_scope LIKE '%,7,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
crm_vispark_subscribe_huohua_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_crm_vispark_subscribe_huohua))
|
||||
|
||||
sql_cc_vispark_subscribe_huohua = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
teaching_method = 0
|
||||
AND business_line_type in( 0,3,9 )
|
||||
AND business_line = 1
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject like '%,1,%'
|
||||
-- AND course_type IN ( ',1,',',5,' ) (课程类型)
|
||||
AND sale_type = 2
|
||||
AND course_teaching_method = 1
|
||||
-- AND STATUS = 1 (状态)
|
||||
AND view_authority_scope LIKE '%,2,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
cc_vispark_subscribe_huohua_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_cc_vispark_subscribe_huohua))
|
||||
|
||||
sql_cc_vispark_buy_huohua = """SELECT
|
||||
IF (abbreviation="",NAME,abbreviation) AS 'text',name,
|
||||
id AS 'value',
|
||||
type,business_line,business_line_type,teaching_method,sale_status,saleable_status,course_subject,course_type,sale_type,course_teaching_method,STATUS,view_authority_scope
|
||||
FROM
|
||||
peppa.course_package
|
||||
WHERE
|
||||
teaching_method = 0
|
||||
AND business_line_type in( 0,3,9 )
|
||||
AND business_line = 1
|
||||
AND sale_status = 1
|
||||
AND saleable_status = 1
|
||||
AND course_subject like '%,1,%'
|
||||
-- AND course_type IN ( ',1,',',5,' ) (课程类型)
|
||||
AND sale_type = 1
|
||||
AND course_teaching_method = 1
|
||||
-- AND STATUS = 1 (状态)
|
||||
AND view_authority_scope LIKE '%,2,%'
|
||||
ORDER BY
|
||||
id DESC limit 3;"""
|
||||
cc_vispark_buy_huohua_list = self.__get_data_name(
|
||||
obj_mysql_helper.select_all(sql_cc_vispark_buy_huohua))
|
||||
data = {"crm中订阅vispark业务的对外汉语-套餐": crm_vispark_subscribe_chinese_list,
|
||||
"crm中订阅vispark业务的sg-套餐": crm_vispark_subscribe_sg_list,
|
||||
"crm中订阅vispark业务的海华-套餐": crm_vispark_subscribe_oc_list,
|
||||
"crm中直购vispark业务的对外汉语-套餐": crm_vispark_buy_chinese_list,
|
||||
"crm中直购vispark业务的us-套餐": crm_vispark_buy_us_list,
|
||||
"crm中直购vispark业务的加拿大-套餐": crm_vispark_buy_canada_list,
|
||||
"crm中直购vispark业务的sg-套餐": crm_vispark_buy_sg_list,
|
||||
"crm中直购vispark业务的海华-套餐": crm_vispark_buy_oc_list,
|
||||
"crm中直购vispark业务的火花-套餐": crm_vispark_buy_huohua_list,
|
||||
"crm中订阅vispark业务的火花-套餐": crm_vispark_subscribe_huohua_list,
|
||||
"cc中订阅vispark业务的火花-套餐": cc_vispark_subscribe_huohua_list,
|
||||
"cc中直购vispark业务的火花-套餐": cc_vispark_buy_huohua_list}
|
||||
|
||||
return data
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cc = CoursePackage()
|
||||
bb = cc.get_course_package_by_cc_crm('')
|
||||
print(bb)
|
||||
109
zhyy/qa_helper/common/order.py
Normal file
109
zhyy/qa_helper/common/order.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
Author: 陈江
|
||||
Email: chenjiang@sparkedu.com
|
||||
Create Date: 2022/09/23 2:06 下午
|
||||
"""
|
||||
from base_framework.public_business.common.UBRD.kw.coursePackage_keyword import CoursePackageKW
|
||||
from base_framework.public_tools import utils
|
||||
from base_framework.public_tools.sqlhelper import MySqLHelper
|
||||
from base_framework.public_tools.mg_keyword import ManageKeyWord
|
||||
from base_framework.public_business import manage_public_business
|
||||
|
||||
import json
|
||||
|
||||
|
||||
obj_course_package_kw = CoursePackageKW()
|
||||
obj_get_way = utils.Tools()
|
||||
obj_mysql_helper = MySqLHelper()
|
||||
obj_manage_kw = ManageKeyWord()
|
||||
obj_manage_business = manage_public_business.ManagePublicBusiness()
|
||||
|
||||
class Order:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def order_done_pay(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 订单完成支付 |
|
||||
| 输入参数: |
|
||||
|orderId/orderCode/prepayCode| 订单id/code/prepayCode | 必填其一
|
||||
| podenv | str | 独立环境编号| 非必填
|
||||
| 作者信息: | 陈江 | 修改时间 | 2022-9-28 |
|
||||
"""
|
||||
if not post_data_input.get('orderId') and not post_data_input.get('orderCode') and not post_data_input.get(
|
||||
'prepayCode'):
|
||||
raise "orderId/orderCode/prepayCode必传1个"
|
||||
|
||||
ordr_info = obj_course_package_kw.get_order_info(post_data_input)
|
||||
order_id = ordr_info.get('orderId')
|
||||
mq_body_dict = obj_course_package_kw.kw_ubrd_public_get_service_id_by_order_id({"orderId": order_id})
|
||||
message_body = {"orderId": order_id, "serviceId": int(mq_body_dict.get('serviceId'))}
|
||||
if post_data_input.get('podenv'):
|
||||
obj_get_way.mq_send(mq_body_dict.get('topic'), json.dumps(message_body), pro=post_data_input.get('podenv'))
|
||||
else:
|
||||
obj_get_way.mq_send(mq_body_dict.get('topic'), json.dumps(message_body))
|
||||
order_100_sql = f"SELECT id FROM `order_center`.`order_course_package` WHERE id='{order_id}' AND status=100"
|
||||
obj_mysql_helper.check_result_exist(order_100_sql, retry_count=20)
|
||||
subscribe_id_sql = f"SELECT subscribe_id FROM `order_center`.`subscribe_order_log` WHERE order_id={order_id}"
|
||||
obj_mysql_helper.check_result_exist(subscribe_id_sql, retry_count=20)
|
||||
subscribe_id = obj_mysql_helper.select_one(subscribe_id_sql).get('subscribe_id')
|
||||
|
||||
return {"order_id": order_id, "subscribe_id": subscribe_id}
|
||||
|
||||
def add_review_subscribe_order(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 生成续订阅订单 |
|
||||
| 输入参数: |
|
||||
|subscribeIds| 订阅id | 传了用该订阅id生成续订阅订单,必传 比如[3355]
|
||||
| 作者信息: | 张楠 | 修改时间 | 2022-11-10 |
|
||||
"""
|
||||
try:
|
||||
post_data_input = eval(post_data_input)
|
||||
except:
|
||||
post_data_input = post_data_input
|
||||
|
||||
if not post_data_input.get('subscribeIds'):
|
||||
raise RuntimeWarning("订阅id必传")
|
||||
# 构造生成续订阅订单请求参数
|
||||
response_data = obj_manage_kw.kw_execute_xxl_job(8306, para=json.dumps(post_data_input))
|
||||
return response_data
|
||||
|
||||
def create_order(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 创建直购订单 |
|
||||
| 请求参数名 | 说明 | 类型 | 是否必填 | 如无要求时的值 |
|
||||
| userId | 用户id | string | 0 | |
|
||||
| phone | 用户手机号 | string | 0 | |
|
||||
| coursePackageId | 套餐id | integer | 0 | |
|
||||
| businessLine | 业务线一级类型,0:火花中国、1:vispark | integer | 0 | |
|
||||
| businessLineType | 业务线二级类型,1:新加坡数学、2:对外汉语、3:直播逻辑思维、4:直播中文素养、5:直播双语素养、6:AI、7:围棋、8:国际象棋、9:其他、10:北美数学、11:越南数学、12:春风思维、13:口才课 | integer | 0 | |
|
||||
| category | 业务线三级类型,K-SMAP:新加坡AP、P-CM:新加坡CP、A:北美AP、C-北美CP、V-越南AP、N-越南CP、ZHK-对外汉语综合课 | string | 0 | |
|
||||
| teachingMethod | 授课方式, 0:直播、1:AI | integer | 0 | 0 |
|
||||
| type | 套餐类型,1:正式课、2:体验课 | integer | 0 | 1 |
|
||||
| courseSubjectList | 课程学科集合,1:数学、2:语文、3:科学、4:英语、5:编程、7:围棋、8:国际象棋、9:春风思维、10:口才课 | list | 0 | |
|
||||
| courseId | 课程id | integer | 0 | |
|
||||
| channel | 渠道,1:电商、0:非电商 | integer | 0 | 0 |
|
||||
| channelValue | 渠道chi | string | 0 | 0 |
|
||||
| classHourType | 课时类型,0:小班课、3:1v1 | integer | 0 | |
|
||||
| offline | 线下,1:线下、0:线上 | integer | 0 | 1 |
|
||||
| businessType | 业务类型,0:常规、1:补差、2:可补差 | integer | 0 | 0 |
|
||||
| currency | 币种,0:人民币、1:美元 | integer | 0 | |
|
||||
| saleType | 售卖方式,1:直购、2:订阅 | integer | 0 | 1 |
|
||||
| teachingScope | 授课范围,1:所有课程、2:自定义课程 | integer | 0 | 1 |
|
||||
| payPrice | 实付金额 | integer | 0 | |
|
||||
| createdType | 订单类型,0:默认未选择、 10:团购订单、11:加价购-团购订单、12:加价购-普通订单、20:CC提单、30:CC提单、40:自助下单、50:微店购买| integer | 0| 0 |
|
||||
Returns:
|
||||
{orderId, orderCode}
|
||||
| 作者信息: | lrq | 修改时间 | 2025-03-18 |
|
||||
"""
|
||||
try:
|
||||
post_data_input = eval(post_data_input)
|
||||
except:
|
||||
post_data_input = post_data_input
|
||||
return obj_manage_business.kw_public_manage_create_order(**post_data_input)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
a = Order()
|
||||
a.create_order({"userId":"2557864","channel":"35d75242534611e8b5325cb9018964ec","coursePackageId":"2503934602"})
|
||||
208
zhyy/qa_helper/common/user.py
Normal file
208
zhyy/qa_helper/common/user.py
Normal file
@@ -0,0 +1,208 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
Author: 陈江
|
||||
Email: chenjiang@sparkedu.com
|
||||
Create Date: 2022/09/23 2:06 下午
|
||||
"""
|
||||
from base_framework.public_business.common.UBRD.UBRD_public_business import BaseLogic
|
||||
from base_framework.public_business.common.UBRD.kw.coursePackage_keyword import CoursePackageKW
|
||||
from base_framework.public_tools import utils
|
||||
from base_framework.public_tools.sqlhelper import MySqLHelper
|
||||
from base_framework.public_tools.log import get_logger
|
||||
from base_framework.public_business.common.UBRD.kw.user_keyword import UserKW
|
||||
from base_framework.public_tools.mg_keyword import ManageKeyWord
|
||||
from library.CommonFun.handle_tools import Handle_tools
|
||||
import requests
|
||||
|
||||
obj_base_logic = BaseLogic()
|
||||
obj_course_package_kw = CoursePackageKW()
|
||||
obj_get_way = utils.Tools()
|
||||
obj_mysql_helper = MySqLHelper()
|
||||
log = get_logger()
|
||||
obj_user_kw = UserKW()
|
||||
obj_manage_kw = ManageKeyWord()
|
||||
obj_handle_tools = Handle_tools()
|
||||
|
||||
|
||||
class User:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def add_user_recharge(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 新增用户,充值课时 |
|
||||
| 输入参数: |
|
||||
|phone/userId| 用户手机号/用户id | 非必填,不传会默认随机注册一个账号;传的手机号不存在会自动进行注册;
|
||||
|coursePackageCode/courseId/coursePackageId/coursePackageName| 传一个即可 | 传了就给用充值课时,不传就不充
|
||||
|classHour | | 充值课时 | 不传,需要充值时默认充值100
|
||||
|new_user_count | | 生成新账号数量,存在这个参数时只会生成相应数量的账号 |
|
||||
| 作者信息: | 陈江 | 修改时间 | 2022-9-23 |
|
||||
"""
|
||||
user_list = []
|
||||
try:
|
||||
post_data_input = eval(post_data_input)
|
||||
except:
|
||||
post_data_input = post_data_input
|
||||
|
||||
if post_data_input.get('new_user_count'):
|
||||
new_user_count = post_data_input.pop('new_user_count')
|
||||
for count in range(0, int(new_user_count)):
|
||||
user_info = obj_base_logic.logic_public_add_user_recharge(post_data_input)
|
||||
user_list.append(user_info)
|
||||
return user_list
|
||||
return obj_base_logic.logic_public_add_user_recharge(post_data_input)
|
||||
|
||||
def add_new_user(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 新增用户 |
|
||||
| 输入参数: |
|
||||
|fu_phone/fu_user_Id| 邀请人手机号或者user_id | 非必填,不传新增用户无邀请人;
|
||||
|new_phone| 新增用户手机号 | 传了用该手机号注册,不传则随机一个手机号
|
||||
|new_user_count | | 生成新账号数量,存在这个参数时只会生成相应数量的账号 |
|
||||
| 作者信息: | 陈江 | 修改时间 | 2022-11-01 |
|
||||
"""
|
||||
user_list = []
|
||||
try:
|
||||
post_data_input = eval(post_data_input)
|
||||
except:
|
||||
post_data_input = post_data_input
|
||||
|
||||
# 构造增加用户请求参数
|
||||
add_user_params = {}
|
||||
# 判断是否需要进行邀请
|
||||
if post_data_input.get('fu_phone'):
|
||||
user_info = obj_user_kw.kw_ubrd_public_get_user_info_by_phone(phone=post_data_input.get('fu_phone'))
|
||||
add_user_params['fromUserId'] = user_info.get('user_id')
|
||||
elif post_data_input.get('fu_user_Id'):
|
||||
add_user_params['fromUserId'] = post_data_input.get('fu_user_Id')
|
||||
else:
|
||||
pass
|
||||
|
||||
if post_data_input.get('new_phone'):
|
||||
user_info = obj_user_kw.kw_ubrd_public_get_user_info_by_phone(phone=post_data_input.get('new_phone'))
|
||||
if user_info:
|
||||
raise RuntimeWarning(f"该手机号{post_data_input.get('new_phone')}已经存在")
|
||||
add_user_params['phone'] = post_data_input.get('new_phone')
|
||||
obj_user_kw.kw_ubrd_public_add_user_profile(post_data_input=add_user_params)
|
||||
user_info = obj_user_kw.kw_ubrd_public_get_user_info_by_phone(phone=post_data_input.get('new_phone'))
|
||||
return user_info
|
||||
else:
|
||||
if post_data_input.get('new_user_count'):
|
||||
new_user_count = post_data_input.pop('new_user_count')
|
||||
for count in range(0, int(new_user_count)):
|
||||
phone = obj_user_kw.kw_ubrd_public_get_unregistered_phone()
|
||||
add_user_params['phone'] = phone
|
||||
obj_user_kw.kw_ubrd_public_add_user_profile(post_data_input=add_user_params)
|
||||
user_info = obj_user_kw.kw_ubrd_public_get_user_info_by_phone(phone=phone)
|
||||
user_list.append(user_info)
|
||||
return user_list
|
||||
else:
|
||||
phone = obj_user_kw.kw_ubrd_public_get_unregistered_phone()
|
||||
add_user_params['phone'] = phone
|
||||
obj_user_kw.kw_ubrd_public_add_user_profile(post_data_input=add_user_params)
|
||||
user_info = obj_user_kw.kw_ubrd_public_get_user_info_by_phone(phone=phone)
|
||||
return user_info
|
||||
|
||||
def add_new_haihua_user(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 生成海华标签新用户 |
|
||||
| 输入参数: |
|
||||
|fu_phone/fu_user_Id| 邀请人手机号或者user_id | 非必填,不传新增用户无邀请人;
|
||||
|new_phone| 新增用户手机号 | 传了用该手机号注册,不传则随机一个手机号
|
||||
|new_user_count | | 生成新账号数量,存在这个参数时只会生成相应数量的账号 |
|
||||
| 作者信息: | 陈江 | 修改时间 | 2022-11-01 |
|
||||
"""
|
||||
user_info_list = self.add_new_user(post_data_input)
|
||||
if user_info_list:
|
||||
for user_info in user_info_list:
|
||||
# 设置权益信息
|
||||
obj_mysql_helper.insert_one(
|
||||
f"""INSERT INTO `operation`.`haibao_task_equity`(`user_id`, `order_id`, `order_business_side`, `course_package_id`, `course_package_name`, `equity_num`, `used_num`, `remain_num`, `lock_num`, `start_time`, `end_time`, `effect_period`, `generated_first_task`, `frozen_status`, `refund_status`, `equity_status`, `policy`, `subject_type`, `related_order_id`, `creator_id`, `creator_name`, `created_time`, `modifier_id`, `modifier_name`, `modified_time`) VALUES ({user_info.get('user_id')}, 8881050, 0, 23002, '逻辑思维直播系统课48课包', 20, 0, 20, 0, '2023-02-09 14:44:36', '2023-02-09 14:44:36', 360, 0, 0, 0, 0, 2, 0, 0, 0, '', '2023-02-01 00:00:01', 0, '', '2023-02-09 14:44:36');""")
|
||||
# 设置海华标签
|
||||
obj_mysql_helper.insert_one(
|
||||
f"""INSERT INTO `utag_mass`.`user_tag`(`user_id`, `tag_id`, `tag_name`, `creator_id`, `creator_name`, `created_time`, `status`, `is_del`, `source_type`, `expiration_time`, `modifier_id`, `modifier_name`, `modified_time`) VALUES ({user_info.get('user_id')}, 51, '海外及港澳台用户', 587312, '陈江', '2023-02-09 16:08:24', 1, 0, 0, NULL, 587312, '陈江', '2023-02-09 16:08:24');""")
|
||||
return user_info_list
|
||||
|
||||
def get_unregistered_user(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 获取未注册手机号 |
|
||||
| 输入参数: |
|
||||
|user_count | | 返回未注册手机号数量 |
|
||||
| 作者信息: | 刘涛婷 | 修改时间 | 2022-11-10 |
|
||||
"""
|
||||
user_list = []
|
||||
try:
|
||||
post_data_input = eval(post_data_input)
|
||||
except:
|
||||
post_data_input = post_data_input
|
||||
|
||||
if post_data_input.get('user_count'):
|
||||
user_count = post_data_input.pop('user_count')
|
||||
for count in range(0, int(user_count)):
|
||||
user_phone = obj_user_kw.kw_ubrd_public_get_unregistered_phone()
|
||||
user_list.append(user_phone)
|
||||
return user_list
|
||||
return obj_user_kw.kw_ubrd_public_get_unregistered_phone()
|
||||
|
||||
def get_sms_code_by_phone(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 发送验证码 |
|
||||
| 输入参数:
|
||||
| phone | 手机号| 必填
|
||||
| countryCode | 国家码 | 默认 86
|
||||
| authType | 验证码类型 | 默认2
|
||||
| verifyAppId | 验证appId | 默认2
|
||||
| 作者信息: | 陈江 | 2022/10/21 |
|
||||
"""
|
||||
# 发送验证码
|
||||
obj_base_logic.logic_public_send_auth_code(post_data_input)
|
||||
# 获取验证码内容
|
||||
# 根据phone获取phone_code
|
||||
phone_server_ip = obj_get_way.get_container_ip_from_eureka('PHONE-SERVER', need_jira_id='qa',
|
||||
eureka_url='http://eureka.qa.huohua.cn')
|
||||
if post_data_input.get('countryCode'):
|
||||
phone = f"{post_data_input.get('countryCode')}-{post_data_input.get('phone')}"
|
||||
else:
|
||||
phone = post_data_input.get('phone')
|
||||
|
||||
if phone_server_ip.get('container_ip'):
|
||||
url = 'http://{}:8080/encrypt/regdata?biztype=phone&uid=123456&sourceData={}'.format(
|
||||
phone_server_ip.get('container_ip'), phone)
|
||||
response = requests.post(url=url) # 三个参数
|
||||
response_json = response.json()
|
||||
else:
|
||||
raise "获取phone server ip失败"
|
||||
|
||||
if response_json.get('data'):
|
||||
msg = obj_mysql_helper.select_all(
|
||||
'SELECT msg FROM `push_service`.`sms` WHERE `phone_code` = \'{}\' ORDER BY id DESC LIMIT 1 '.format(
|
||||
response_json.get('data')))
|
||||
if msg:
|
||||
web_hook = "https://open.feishu.cn/open-apis/bot/v2/hook/c9baf09d-55f1-46a6-8d67-9d4ff30b1be2"
|
||||
message_data = {"msg_type": "post", "content": {
|
||||
"post": {"zh_cn": {"title": "message",
|
||||
"content": [[{"tag": "text", "text": msg[0].get('msg')}]]}}}}
|
||||
obj_handle_tools.send_message_by_feishu(web_hook, message_data)
|
||||
else:
|
||||
raise f"{phone}获取验证码失败"
|
||||
return msg[0].get('msg')
|
||||
|
||||
else:
|
||||
return response_json
|
||||
|
||||
def register_user(self, post_data_input):
|
||||
"""
|
||||
| 功能说明: | 通过注册接口进行注册用户并设置密码A123456(支持邀请码,渠道) |
|
||||
| 输入参数: |
|
||||
| | | channelId | string | 渠道id |
|
||||
| | | invitePhone | string | 手机号 | "12030690001/86-13400114600"
|
||||
| | | registerPhone | string | 手机号 | "12030690001/86-13400114600"
|
||||
| 作者信息: | 陈江 | 修改时间 | 2022-11-10 |
|
||||
"""
|
||||
return obj_base_logic.logic_public_register_user(post_data_input)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ff = {'phone': '13400234500','coursePackageId':29497}
|
||||
# User().add_user_recharge(ff)
|
||||
User().add_new_user(post_data_input={"new_user_count":"2"})
|
||||
Reference in New Issue
Block a user