#-*-coding:utf-8-*- _author_ = 'Emily' #@Time:2020/8/7 11:09 import unittest import requests import HTMLTestRunner class syncDataApi(unittest.TestCase): def setUp(self): self.post_url = "http://192.168.55.98/?m=payorder&a=syncOrderData" # def test_sync_xiaotuiche(self): # """小推车订单同步""" # payload = { # 'data': '{"thirdPayOrder":{"authCode":"","bankCardNum":"","bankCardType":"","orderNum":"84916032324203","orderType":"ZF010002","sysReference":"15321117756","terminalId":"51","thirdOrderNum":"1578722221117756","trace":""},"posBill":{"attendant":"1010","billAmount":120,"billCode":"30416032324203","cargoRackId":"73","cashDeviceCode":"33","channelCode":"APP","discountAmount":18,"giveMeGoodsNumber":"8000000785","giveMoney":0,"realAmount":102,"reportDate":"2020-08-07"},"posBillDetail":[{"attendant":"","billCode":"30416032324203","cashDeviceCode":"51","categoryCode":"0101","categoryId":19,"categoryName":"小挂件","comboDetails":[],"dcxh":1,"discountAmount":18,"extraMoney":0,"giveAmount":0,"giveReason":"","goodsAmount":120,"goodsAttribute":"单品","goodsCode":"01010004","goodsId":61152,"goodsName":"艾泽拉斯纪念章","goodsTypeCode":"ERP_ITEMINFO_SALES_SP","id":27994,"payInfo":[{"orderType":"2","payValue":102}],"price":40,"quantity":3,"realAmount":102,"reportDate":"2020-08-07","unitName":"份"}],"discountDetails":[{"discountAmount":18,"discountName":"满100打85折","discountType":"0","discountTypeId":512,"id":27995}],"orderTime":"2020-08-28 03:18:27"}'} # # data1 = data.encode("utf-8").decode("latin1") # req = requests.post(self.post_url, data=payload) # result = req.json() # print("打印处理结果test_quHuoTicket:", result) # self.assertEqual(result['status'], 1, msg='处理结果异常') # def test_zeroJuan(self): # """0元卖品劵""" # payload = { # 'data': '{"posBill":{"attendant":"1002","billAmount":6,"billCode":"84925000002666","cargoRackId":"82",' # '"cashDeviceCode":"ONLINE","channelCode":"1_2","discountAmount":6,"giveMoney":0,"realAmount":0,' # '"reportDate":"2020-12-17"},"orderTime":"2020-12-17 11:44:14",' # '"discountDetails":[{"discountAmount":-6,"discountName":"代金券减免优惠","discountType":"0",' # '"discountTypeId":-114,"id":30732}],"onlineDiscountDetails":[{"discountAmount":6,' # '"discountRate":0,"discountType":"MPDJQ","expireDate":"2022-12-31","kdzdbh":"84925000002666",' # '"subOrderCode":"8790243","voucherFaceValue":12,"voucherNo":"8275494189316368679",' # '"voucherType":"价值为12元-代金券允许-卖品代金券","voucherValue":0}],' # '"thirdPayOrder":[{"orderType":"CASH","payName":"现金支付","payValue":0,' # '"preferentialAmount":0,"realityAmount":0,"thirdName":"现金"}],' # '"posBillDetail":[{"billCode":"84925000002666","cashDeviceCode":"ONLINE","categoryCode":"10006",' # '"categoryId":472,"dcxh":1,"discountAmount":6,"extraMoney":0,"giveAmount":0,' # '"goodsAmount":6,"goodsAttribute":"单品","goodsCode":"100060004","goodsId":1019193,' # '"goodsName":"蛋挞","goodsTypeCode":"ERP_ITEMINFO_SALES_SP","id":"8790243",' # '"onlineDiscountDetails":[{"discountAmount":6,"discountRate":0,"discountType":"MPDJQ",' # '"expireDate":"2022-12-31","kdzdbh":"84925000002846","subOrderCode":"8790243",' # '"voucherFaceValue":12,"voucherNo":"8275494189316368679","voucherType":"价值为12元-代金券允许-卖品代金券",' # '"voucherValue":0}],"payInfo":[{"orderType":"CASH","payName":"现金支付","payValue":0,"preferentialAmount":0,' # '"realityAmount":0,"thirdName":"现金"}],"price":6,"quantity":1,"realAmount":0,' # '"reportDate":"2020-12-17","unitName":"个"}]}'} # req = requests.post(self.post_url,data=payload) # result = req.json() # print(result) def test_sync_online(self): # """小程序订单""" #折扣劵 # payload = { # 'data': '{"posBill":{"attendant":"1002","billAmount":16,"billCode":"84926000440011","cargoRackId":"82","cashDeviceCode":"ONLINE","channelCode":"1_1","discountAmount":3.96,"giveMoney":0,"realAmount":12.04,"reportDate":"2020-12-17"},"orderTime":"2020-12-25 16:59:38","discountDetails":[{"discountAmount":-3.96,"discountName":"卖品折扣券打折","discountType":"0","discountTypeId":-112,"id":475310}],"onlineDiscountDetails":[{"discountAmount":3.96,"discountRate":34,"discountType":"MPZKQ","expireDate":"2022-12-31","kdzdbh":"84926000440000","subOrderCode":"8791713","voucherFaceValue":0,"voucherNo":"2612312213534895782","voucherType":"MX测试-卖品折扣券","voucherValue":0}],"thirdPayOrder":[{"orderType":"YSF","payName":"银联云闪付","payValue":2.04,"preferentialAmount":0,"realityAmount":0,"thirdCode":"642012170918097533333","thirdOrder":"2102020121709180945216418889"},{"orderType":"DZM","payName":"电子码","payValue":10,"voucherInfo":[{"expiredate":"2022-12-31","isFirstPay":0,"orderType":"DZM","panYing":0,"payValue":10,"rwid":8791715,"thirdName":"电子码","voucherName":"MX测试-包含1兑1-2兑1-卖品兑换券","voucherNumber":"9281690571657964851","voucherType":"C","voucherValue":10}]}],"posBillDetail":[{"billCode":"84926000440011","cashDeviceCode":"ONLINE","categoryCode":"10006","categoryId":472,"dcxh":1,"discountAmount":3.96,"extraMoney":0,"giveAmount":0,"goodsAmount":6,"goodsAttribute":"单品","goodsCode":"100060004","goodsId":1019193,"goodsName":"蛋挞","goodsTypeCode":"ERP_ITEMINFO_SALES_SP","id":"8791713","onlineDiscountDetails":[{"discountAmount":3.96,"discountRate":34,"discountType":"MPZKQ","expireDate":"2022-12-31","kdzdbh":"84926000440011","subOrderCode":"8791713","voucherFaceValue":0,"voucherNo":"2612312213534895782","voucherType":"MX测试-卖品折扣券","voucherValue":0}],"payInfo":[{"orderType":"YSF","payName":"银联云闪付","payValue":2.04,"preferentialAmount":0,"realityAmount":0,"thirdCode":"642012170918097533333","thirdOrder":"2102020121709180945216418889"}],"price":6,"quantity":1,"realAmount":2.04,"reportDate":"2020-12-17","unitName":"个"},{"billCode":"84926000440011","cashDeviceCode":"ONLINE","categoryCode":"10001","categoryId":531,"dcxh":2,"discountAmount":0,"extraMoney":0,"giveAmount":0,"goodsAmount":10,"goodsAttribute":"单品","goodsCode":"100010011","goodsId":1125087,"goodsName":"蔡依林签名","goodsTypeCode":"ERP_ITEMINFO_SALES_SP","id":"8791789","onlineDiscountDetails":[],"payInfo":[{"orderType":"DZM","payName":"电子码","payValue":10,"voucherInfo":[{"expiredate":"2022-12-31","isFirstPay":0,"orderType":"DZM","panYing":0,"payValue":10,"rwid":8791715,"thirdName":"电子码","voucherName":"MX测试-包含1兑1-2兑1-卖品兑换券","voucherNumber":"9281690571657964851","voucherType":"C","voucherValue":10}]}],"price":10,"quantity":1,"realAmount":10,"reportDate":"2020-12-25","unitName":"大A"}]}'} #储值卡单独支付 payload1 = {'data':'{"posBill":{"attendant":"1002","billAmount":16,"billCode":"84926000446290","cargoRackId":"82","cashDeviceCode":"ONLINE","channelCode":"XIAOCHENGXUGP","discountAmount":0,"giveMoney":0,"realAmount":16,"reportDate":"2021-01-11"},"orderTime":"2021-01-11 14:00:25","discountDetails":[],"onlineDiscountDetails":[],"thirdPayOrder":[],"posBillDetail":[{"billCode":"84926000446290","cashDeviceCode":"ONLINE","categoryCode":"10006","categoryId":472,"dcxh":1,"discountAmount":0,"extraMoney":0,"giveAmount":0,"goodsAmount":16,"goodsAttribute":"单品","goodsCode":"100020004","goodsId":1022190,"goodsName":"洋葱圈","goodsTypeCode":"ERP_ITEMINFO_SALES_SP","id":"8795190","onlineDiscountDetails":[],"payInfo":[{"orderType":"MEMBERCARD","payName":"储值卡","payValue":16,"preferentialAmount":0,"realityAmount":0,"thirdCode":"84926000446290","thirdName":"储值卡支付","thirdOrderNum":"6718304331419990"}],"price":16,"quantity":1,"realAmount":16,"reportDate":"2021-01-07","unitName":"例"}]}'} # data1 = data.encode("utf-8").decode("latin1") req = requests.post(self.post_url, data=payload1) result = req.json() print("打印处理结果test_quHuoTicket:", result) self.assertEqual(result['status'], 1, msg='处理结果异常') # def test_sync_(self): # # """小推车""" # # payload = { # 'data': '{"thirdPayOrder":{"authCode":"","bankCardNum":"","bankCardType":"","orderNum":"849150000267391598591387785","orderType":"ZF010002","sysReference":"149513463501","terminalId":"50","thirdOrderNum":"149513463509","trace":""},"posBill":{"attendant":"1112","billAmount":5,"billCode":"84915000026767","cargoRackId":"62","cashDeviceCode":"kuaiqian","channelCode":"APP","discountAmount":0,"giveMeGoodsNumber":"4000000545","giveMoney":0,"realAmount":5,"reportDate":"2020-12-17"},"posBillDetail":[{"attendant":"","billCode":"84915000026767","cashDeviceCode":"50","categoryCode":"0301","categoryId":251,"categoryName":"膨化食品","comboDetails":[],"dcxh":1,"discountAmount":0,"extraMoney":0,"giveAmount":0,"giveReason":"","goodsAmount":5,"goodsAttribute":"单品","goodsCode":"03010067","goodsId":7018,"goodsName":"良品铺子小米锅巴五香味90g","goodsTypeCode":"ERP_ITEMINFO_SALES_SP","id":97906,"payInfo":[{"orderType":"ZF010002","payValue":5}],"price":5,"quantity":1,"realAmount":5,"reportDate":"2020-12-17","unitName":"袋"}],"discountDetails":[],"orderTime":"2020-12-17 15:51:34"}'} # # req = requests.post(self.post_url, data=payload) # result = req.json() # print("打印处理结果test_quHuoTicket:", result) # self.assertEqual(result['status'], 1, msg='处理结果异常') # def test_sync_wechatxu(self): # # # # data1 = data.encode("utf-8").decode("latin1") # req = requests.post(self.post_url, data=payload) # result = req.json() # print("打印处理结果test_quHuoTicket:", result) # self.assertEqual(result['status'], 1, msg='处理结果异常') def tearDown(self): pass if __name__ == '__main__': unittest.main()