예제 #1
0
def get_china_department_vaccine_info():
    departmentVaccineInfos = get_all_department_vaccine_infos('')
    save_json(
        departmentVaccineInfos,
        osp.join(cfg.save_departments_info_root,
                 cfg.VACCINDE_INFO[cfg.customId], '全国社区疫苗信息.json'))
    print('[info]: 全国范围内一共查找保存{}社区疫苗信息'.format(len(departmentVaccineInfos)))
    return departmentVaccineInfos
예제 #2
0
def query_is_arrive_vaccine_in_china():
    """
    查找全国范围内的到苗社区
    :return: 有疫苗已经到的社区的信息列表 [ item1, item2, ... ]
        item : { 社区名字: **, 社区电话: **, 社区地址: **, 该疫苗描述: **, 是否可秒杀: ** }
    """
    departmentVaccineInfos = get_china_department_vaccine_info()
    results = is_arrive_vaccine(departmentVaccineInfos)
    if len(results) != 0:
        save_json(
            results,
            osp.join(cfg.save_departments_info_root,
                     cfg.VACCINDE_INFO[cfg.customId], "全国社区疫苗已经到苗.json"))
    # print(results)
    print('[info]: 全国范围内查找保存{}社区疫苗信息中有{}社区医院已经到苗\n\n'.format(
        len(departmentVaccineInfos), len(results)))
    return results
예제 #3
0
def get_department_vaccine_info_by_province(province):
    """
    根据省的名字获取该省的所有的社区疫苗信息
    :param province:
    :return: [ departmentVaccine1, departmentVaccine2, ..., departmentVaccine ... ]
    departmentVaccine: {
            id: 10164                           # depaVaccId,部门疫苗编号id
            departmentCode: 4101840002          # 部门编号
            vaccineCode: 8803                   # 疫苗编号
            departmentName: 新郑市龙湖镇卫生院(新郑市第三人民医院)            # 部门名字
            describtion:                # 描述
            instructionsUrls: []                # 说明网址
            isArriveVaccine: 0                  # 是否到达疫苗
            name: 九价HPV疫苗(仅接受第一针在我门诊接种的,并该接种第二针、第三针的受种者)...
            prompt:                             # 提示,弹窗提示消息
            subscribed: 13                      # 已订阅
            total: -1                           # 总数
            stopSubscribe: 1                    # 停止订阅
            sourceType: 1                       # 源类型
            urls: [ *.jpg ... *.jpg]            # 图片链接
            items: [
                {
                    id: 10164                   # depaVaccId,部门疫苗编号id
                    vaccineCode: 8803           # 疫苗编号
                    factoryName: 默沙东集团       # 工厂名称
                    specifications: 0.5mL/支     # 规格
                    name:                       # 疫苗名字描述
                    price: 132000               # 价格
                    sourceType: 1               # 源类型
                    isNoticedUserAllowed: 0     # 是否通知用户允许
                }
            ]
            departmentVaccineId: 10164          # 部门疫苗id
            isNoticedUserAllowed: 0             #
        }
    """
    province_code = get_province_code(province=province)
    departmentVaccineInfos = get_all_department_vaccine_infos(province_code)
    save_json(
        departmentVaccineInfos,
        osp.join(cfg.save_departments_info_root,
                 cfg.VACCINDE_INFO[cfg.customId], province + '_社区疫苗信息.json'))
    print('[info]: 从"{}"一共查找保存{}社区疫苗信息'.format(province,
                                               len(departmentVaccineInfos)))
    return departmentVaccineInfos
예제 #4
0
def query_is_arrive_vaccine_by_province(province):
    """
    查询某省内所有有苗的信息
    :param province: 省的名称:河南省
    :return: 有疫苗已经到的社区的信息列表 [ item1, item2, ... ]
        item : { 社区名字: **, 社区电话: **, 社区地址: **, 该疫苗描述: **, 是否可秒杀: ** }
    """
    departmentVaccineInfos = get_department_vaccine_info_by_province(
        province=province)
    results = is_arrive_vaccine(departmentVaccineInfos)
    if len(results) != 0:
        save_json(
            results,
            osp.join(cfg.save_departments_info_root,
                     cfg.VACCINDE_INFO[cfg.customId],
                     province + "_社区疫苗已经到苗.json"))
    # print(results)
    print('[info]: 从"{}"查找保存的{}社区疫苗信息中一共有{}社区医院已经到苗\n\n'.format(
        province, len(departmentVaccineInfos), len(results)))
    return results
예제 #5
0
파일: order.py 프로젝트: uaatake/HPVOrder
def order_immediately(departmentCode,
                      departmentVaccineId,
                      linkmanId=8350927,
                      username=None):
    """
    某一个医院界面内点击立即预约按钮
        请求参数组成:depaCode=4201020003&vaccineCode=8803&id=3680
    :param username: 开始预约的用户名字,当该字段不为空时,它将覆盖传入的 linkmanId 参数
    :param departmentCode: 部门编码,组成:区号+区内部号
    :param departmentVaccineId: 部门疫苗id,也就是选择请求某一个医院的唯一标识。注意:虽然可能是同一个社区名字,但是预约的价数不一样,则对应的 departmentVaccineId 也不一样
    :param linkmanId: 用户编号
    :return: 返回请求的返回结果:
                预约成功,返回:get_my_order_info_by_subscribeId 函数返回的结果,即预约成功的详细信息
                预约失败,返回 None
    """

    #####################################################################
    # 如果用户名不为空,根据传入的用户名来获取 linkmanId
    if username is not None:
        linkmanId = get_linkmanId_by_name(username)
        if linkmanId is None:
            print('[error]: 输入的用户名 {} 没有在系统中注册'.format(username))
            return 0
    #####################################################################

    #####################################################################
    # 根据社区疫苗编号获取该社区的信息,从而获取到该社区是预约哪一价的疫苗,机获取疫苗编号 vaccineCode
    response = get_department_vaccine_info(depaVaccId=departmentVaccineId)
    if response is None:
        return
    if not response['ok']:
        print('[error]: 没有找到该社区的信息... , {}'.format(response['msg']))
        return
    departmentName = response['data']['departmentName']
    vaccineCode = response['data']['vaccineCode']
    #####################################################################

    #####################################################################
    # 第一步,判断是否可预约
    # https://wx.scmttec.com/order/subscribe/isCanSubscribe.do?depaCode=4101840002&vaccineCode=8802&id=10162
    response = judge_order(departmentCode=departmentCode,
                           departmentVaccineId=departmentVaccineId,
                           vaccineCode=vaccineCode,
                           linkmanId=linkmanId)
    if response is None:
        return
    if not response['ok']:
        # print(response)
        print('[error]: 没有可预约的疫苗... , {}'.format(
            response.get('msg', 'error_info')))
        return
    if response['data'] == 0:
        print('[error]: 该社区暂时没有可预约信息...')
        return
    #####################################################################

    #####################################################################
    # 第二步,获取疫苗信息
    # https://wx.scmttec.com/base/department/vaccine.do?vaccineCode=8802&depaCode=4101840002&departmentVaccineId=10162&isShowDescribtion=false
    response = get_vaccine_info(depaCode=departmentCode,
                                depaVaccId=departmentVaccineId,
                                vaccineCode=vaccineCode)

    response = get_server_time()
    #####################################################################

    #####################################################################
    # 第三步,判断是否需要注册
    # https://wx.scmttec.com/passport/register/isNeedRegister.do?vaccineCode=8802&depaCode=4101840002&linkmanId=8350927&departmentVaccineId=10162
    # response = judge_isNeedRegister(departmentCode=departmentCode, departmentVaccineId=departmentVaccineId,
    #                                 vaccineCode=vaccineCode, linkmanId=linkmanId)
    # if response is None:
    #     return
    # if not response['ok'] or response['data'] == 0:
    #     print('[error]: 需要注册...')
    #     print(response)
    #     return
    #####################################################################

    #####################################################################
    # 第四步,选择针数
    # https://wx.scmttec.com/order/subscribe/workDays.do?depaCode=4101840002&linkmanId=8350927&vaccCode=8802&vaccIndex=1&departmentVaccineId=10162
    response = workdays(departmentCode=departmentCode,
                        departmentVaccineId=departmentVaccineId,
                        vaccineCode=vaccineCode,
                        vaccIndex=cfg.vaccIndex,
                        linkmanId=linkmanId)
    if response is None:
        return
    if not response['ok']:
        print('[error]: 针数 {} 没有可预约日期, {}'.format(cfg.vaccIndex,
                                                  response['msg']))
        return
    #####################################################################

    #####################################################################
    # 第五步,同时获取每一天的可预约的人数
    dataList = [d.replace('-', '') for d in response['data']['dateList']]
    days = ','.join(dataList)
    response = findSubscribeAmountByDays(
        departmentCode=departmentCode,
        departmentVaccineId=departmentVaccineId,
        vaccineCode=vaccineCode,
        vaccIndex=cfg.vaccIndex,
        days=days)
    if response is None:
        return
    if not response['ok']:
        print('[error]: 针数: {}, 日期: {}不可预约, {}'.format(cfg.vaccIndex, days,
                                                       response['msg']))
        return

    subscribeDates = response['data']
    if len(subscribeDates) == 0:
        print('[error]: 可订阅天数为0...')
        return

    # 遍历所有的时间段,直到预约成功
    flag, response = loop_order_until_success(
        departmentCode=departmentCode,
        departmentVaccineId=departmentVaccineId,
        vaccineCode=vaccineCode,
        vaccIndex=cfg.vaccIndex,
        subscribeDates=response['data'],
        linkmanId=linkmanId)
    if response is None:
        return

    if flag:
        subscribeId = response['subscribeId']
        response = get_my_order_info_by_subscribeId(subscribeId=subscribeId)
        save_json(
            response,
            osp.join(cfg.save_departments_info_root,
                     cfg.VACCINDE_INFO[cfg.customId], 'order_success.json'))
        print_my_order_success_info(data=response)
    else:
        print('[error]: 所有全部预约失败!')

    return response