123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- """
- @author: luojunhui
- """
- from applications.functions.forward import forward_requests
- PQSP4 = {
- "avatar": "https://rescdn.yishihui.com/0temp/pqsp.png",
- "id": "wxbdd2a2e93d9a6e25",
- "name": "票圈视频"
- }
- VLOG0 = {
- "avatar": "https://rescdn.yishihui.com/0temp/logo.png",
- "id": "wx89e7eb06478361d7",
- "name": "票圈 l 3亿人喜欢的视频平台"
- }
- PQSP_GHID = {
- "gh_2ad5072e7a76",
- "gh_57c9e8babea7",
- "gh_a61d7ae2e594",
- "gh_2fe4c2f7d571",
- "gh_d8c215687f02",
- "gh_749271f1ccd5",
- "gh_617684416aec",
- "gh_a221d1a952aa",
- "gh_ec42d1027ba5",
- "gh_e3a8e14013cd",
- "gh_9ee8fc75c07f",
- "gh_0e4fd9e88386",
- "gh_2e8ae0384787",
- "gh_7c66e0dbd2cf",
- "gh_755225d8ede5",
- "gh_92da3c574f82",
- "gh_31e523f45168",
- "gh_df59c5e42954",
- "gh_6d3aa9d13402",
- "gh_810a439f320a",
- "gh_2e0c4609839f",
- "gh_f1122b34f1f3",
- "gh_da44c409ec0f",
- "gh_2e615fa75ffb",
- "gh_d32fe439b098",
- "gh_d7fa1998b4e1",
- "gh_abc6794e6996",
- "gh_c43c01198e6a",
- "gh_a447c30961b7",
- "gh_dc2da0611278",
- "gh_156c66ac3e37",
- "gh_ddf6ec0104d0",
- "gh_39218d3a3ec1",
- "gh_98ec0ffe69b3",
- "gh_243829b5ff02",
- "gh_03d32e83122f",
- "gh_a1c2771f8020",
- "gh_4f6bfd731ac8",
- "gh_9360765baf6a",
- "gh_1686250f15b6",
- "gh_6e977e8cd40d",
- "gh_dfa7599c181f"
- }
- class Minigram(object):
- """
- 小程序卡片
- """
- NEW_STRATEGY = "strategy_v2"
- def __init__(self, params):
- self.gh_id = None
- self.strategy = None
- self.params = params
- self.business_type = None
- self.mini_code = None
- self.trace_id = None
- def check_params(self):
- """
- 校验参数
- :return:
- """
- try:
- self.business_type = self.params['businessType']
- self.mini_code = self.params['miniCode']
- self.trace_id = self.params['traceId']
- self.strategy = self.params.get('strategy')
- self.gh_id = self.params.get('ghId', None)
- if not self.strategy:
- self.strategy = "strategy_v1"
- return None
- except Exception as e:
- response = {
- "status": "fail",
- "code": 1,
- "message": str(e),
- "info": "params check error"
- }
- return response
- def choose_minigram(self):
- """
- 分配小程序卡片
- :return:
- """
- if self.gh_id in PQSP_GHID:
- minigram = PQSP4
- else:
- minigram = VLOG0
- response = {
- "programAvatar": minigram['avatar'],
- "programId": minigram['id'],
- "programName": minigram['name'],
- "trace_id": self.trace_id
- }
- return response
- async def deal(self):
- """
- :return:
- """
- params_error = self.check_params()
- if params_error:
- return params_error
- else:
- if self.strategy == self.NEW_STRATEGY:
- response = await forward_requests(
- params=self.params,
- api="choose_minigram"
- )
- return response
- else:
- return self.choose_minigram()
|