def setUpClass(self):
     redis = MyRedis()
     env_flag = redis.str_get("ysx_crm_env_flag")
     env_num = redis.str_get("ysx_crm_env_num")
     self.session = requests.Session()
     cookies = get_ysx_crm_cookie(env_flag,env_num)
     header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36","Accept": "application/json, text/javascript, */*; q=0.01","Accept-Encoding": "gzip, deflate, br","Accept-Language": "zh-CN,zh;q=0.9","Connection": "keep-alive","Upgrade-Insecure-Requests": "1"}
     self.msg = """\n        Expect:  {Expect}-*-\n        Really:  {Really}"""  # 校验HTTP返回代码
     self.session.headers = header
     self.session.cookies = cookies
Example #2
0
def test_file_order():
    """
    绩效专用
    接口生成补单
    """
    phone = request.args.get("phone")
    productId = request.args.get("pId")
    phId = request.args.get("phId")
    product_url = "https://admin.crm.yunshuxie.com/v1/admin/order/query/product_list?productId={productId}&productName=&sort=productId&order=asc&limit=100&offset=0".format(
        productId=productId)
    cookies = get_ysx_crm_cookie(env_flag="beta",
                                 env_num="1",
                                 account_username="******",
                                 account_passwd="ysx2019")["cookies"]
    resp = requests.get(url=product_url, cookies=cookies)
    productSelect = json.loads(resp.text, encoding="utf-8")
    if productSelect["rows"]:
        for productDict in productSelect["rows"]:
            if int(phId) == productDict["productCourseHoursId"] and int(
                    productId) == productDict["productId"]:
                searchProduct = productDict
                fill_order_params = {
                    "contactPhone":
                    phone,
                    "orderAmount":
                    searchProduct["productPrice"],
                    "productName":
                    searchProduct["productName"],
                    "productId":
                    searchProduct["productId"],
                    "productType":
                    searchProduct["productType"],
                    "courseHoursTitles":
                    searchProduct["courseHoursTitle"],
                    "productCourseHoursId":
                    searchProduct["productCourseHoursId"],
                    "grade":
                    searchProduct["grade"],
                    "originalAmount":
                    searchProduct["productPrice"],
                    "callbackTime":
                    "2019-10-01 00:00:00",
                    "payAccount":
                    "1",
                    "orderSource":
                    "微信",
                    "shareKeyFirst":
                    "-1",
                    "shareKeySecond":
                    "-1",
                    "shareKey":
                    "-1",
                    "fromOpenId":
                    "CCrm_653",
                    "chargeTeacher":
                    "赵红玲",
                    "chargeTeacher1":
                    "CCrm_653",
                    "outerTradeId":
                    "osxBJ6MQ69yOMyhCejqj55SdKzyI",
                    "file":
                    file(
                        "/home/guohj/Pictures/Operating_System_Apple_Mac_72px_1072593_easyicon.net.png",
                        "rb"),
                    "fillOrderDesc":
                    "测试"
                }

                fill_order_url = "https://admin.crm.yunshuxie.com/fill/order"
                resp = requests.post(url=fill_order_url,
                                     data=fill_order_params,
                                     cookies=cookies)
                print resp.text

    return make_response(jsonify(resp.text))