test_createAndTrade.py 3.02 KB
import unittest
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from commons.MySession import hg,my
from commons import ConfigDB as db
from commons.api.hg.transaction.createAndTrade import createAndTrade
from commons.basic.registerRecord_save import registerRecord_save
creat = createAndTrade()
r = registerRecord_save()

"""
创建大客户订单
"""

class test_createAndTrade(unittest.TestCase):
    "创建大客户订单"
    @classmethod
    def setUpClass(cls):
        # 新增一个进门批号单
        # 新增一个进门批号单
        #         cls.aaa = db.mysql_selectOne('''
        #         SELECT
        # 	aua.account_id,auc.card_no,aua.customer_id,aua.customer_code,aua.customer_name,aua.customer_certificate_number
        # FROM
        # 	( `dili_account`.`account_user_account` AS aua LEFT JOIN `dili_account`.`account_user_card` AS auc ON aua.account_id = auc.account_id )
        # 	LEFT JOIN `dili-customer`.`special_permissions` AS sp ON aua.customer_id = sp.customer_id
        # 	ORDER BY aua.account_id  DESC LIMIT 1
        #         ''')
        cls.aaa = db.mysql_selectOne('''
                        SELECT
	aua.account_id AS "账号id",
	auc.card_no AS "园区卡号",
	aua.customer_id AS "客户id",
	aua.customer_code AS "客户code",
	aua.customer_name AS "客户姓名",
	aua.customer_certificate_number AS "客户身份证号码",
	aua.hold_contacts_phone AS "持卡人电话"
FROM
	( `dili_account`.`account_user_account` AS aua LEFT JOIN `dili_account`.`account_user_card` AS auc ON aua.account_id = auc.account_id )
	LEFT JOIN `dili-customer`.`special_permissions` AS sp ON aua.customer_id = sp.customer_id 
WHERE
	sp.customer_id = 141962 AND sp.market_id =15
ORDER BY
	aua.account_id DESC 
	LIMIT 1
	''')
        body2 = r.body.copy()
        body2["accountId"] = str(cls.aaa[0])
        body2["cardNo"] = str(cls.aaa[1])
        body2["customerId"] = str(cls.aaa[2])
        body2["customerCode"] = str(cls.aaa[3])
        body2["customerName"] = str(cls.aaa[4])
        body2["identityCardNo"] = str(cls.aaa[5])
        body2["mobilephoneNumber"] = str(cls.aaa[6])
        body2["categoryId"] = 44
        body2["categoryCode"] = 754107
        body2["categoryName"] = "葡萄"
        re = hg.post(url = r.url, headers = r.header, json = body2,proxies = hg.proxies)
        "获取批号"
        print("获取批号结果:",re.json())
        cls.batch = re.json()["data"]["batchCode"]
        return cls.batch

    @unittest.case_mark(my.mark())
    def test_createAndTrade_01(self):
        "大客户创建订单"
        body = creat.body.copy()
        body["orderItemList"][0]["batchCode"] = self.batch
        print("创建订单body",body)
        re1 = hg.post(url = creat.url, headers = creat.header, json = body,proxies = hg.proxies)
        print(re1.json())
        self.assertEqual(re1.status_code, 200)
        self.assertTrue("'操作成功'" in str(re1.json()).replace(" ", ""))
    @classmethod
    def tearDownClass(cls):
        pass


if __name__ == '__main__':
    unittest.main()