""" @author: luojunhui """ import json 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亿人喜欢的视频平台" } XYMHFQDD_27 = { "avatar": "https://rescdn.yishihui.com/0temp/xymhfqdd.png", "id": "wx7187c217efef24a7", "name": "幸运美好福气多多" } # 27小程序候选账号 id EXPERIMENT_27_GH_ID_SET = {'gh_970460d9ccec', 'gh_bfea052b5baa', 'gh_5d18ac6e3118', 'gh_660afe87b6fd', 'gh_7c66e0dbd2cf', 'gh_57c9e8babea7', 'gh_749271f1ccd5', 'gh_2e615fa75ffb', 'gh_486568379bf8', 'gh_c9b664360ce6', 'gh_98ec0ffe69b3', 'gh_03d45c260115', 'gh_6d3aa9d13402', 'gh_1686250f15b6'} class Minigram(object): """ 小程序卡片 """ def __init__(self, params, config): self.gh_id = None self.params = params self.business_type = None self.mini_code = None self.trace_id = None self.config = config 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.gh_id = self.params.get('ghId', None) 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: """ pq_gh_id_list = json.loads(self.config.get_config_value('ghIdInPqVideo')) if self.gh_id in EXPERIMENT_27_GH_ID_SET: minigram = XYMHFQDD_27 elif self.gh_id in set(pq_gh_id_list): 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: """ return self.check_params() if self.check_params() else self.choose_minigram()