Arthur-Wu committed this file on 2024-11-15
This commit is contained in:
parent
c871e12b16
commit
298268c133
198
YiMao/businessFunc/ClientApiLib.py
Normal file
198
YiMao/businessFunc/ClientApiLib.py
Normal file
@ -0,0 +1,198 @@
|
||||
# !/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author:: Arthur Wu
|
||||
# @Date:: 2024/11/14-14:35
|
||||
# @Description::
|
||||
import requests,json, logging
|
||||
from commons.SignatureYM import SignatureYM2
|
||||
|
||||
|
||||
|
||||
class YMClientApi(object):
|
||||
def __init__(self):
|
||||
self.Domain = "https://api.test.yimaogo.com/cart"
|
||||
self.headerss = SignatureYM2(Mac="b8:2d:28:04:c7:5c")._headers()
|
||||
|
||||
def session_start(self):
|
||||
logging.info("========== [前置] session_start ==========")
|
||||
url = self.Domain+"/v1/session/start"
|
||||
payload = ""
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
|
||||
def session_end(self):
|
||||
logging.info("========== [后置] session_end ==========")
|
||||
url = self.Domain+"/v1/session/end?reason"
|
||||
payload = {}
|
||||
response = requests.request("PUT", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
|
||||
def login_app_v2(self, Payload):
|
||||
'''
|
||||
1-匿名登录
|
||||
{"action": 0, "isAnon": True}
|
||||
2-会员登录
|
||||
{"action":1,"code":"18052753212","isAnon":False}
|
||||
:param Payload:
|
||||
:return:
|
||||
'''
|
||||
logging.info("========== [登录] login_app_v2 ==========")
|
||||
payload = json.dumps(Payload)
|
||||
url = self.Domain+"/v2/login"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def get_login_type(self):
|
||||
logging.info("========== [获取登录方式] get_login_type ==========")
|
||||
payload = {}
|
||||
url = self.Domain+"/v2/login/type?action=1"
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
|
||||
def get_goods_info(self, InputCode):
|
||||
logging.info("========== [获取商品信息] get_goods_info ==========")
|
||||
payload = {}
|
||||
url = self.Domain+"/v2/shopping/{inputCode}".replace("{inputCode}", str(InputCode))
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def add_retire_purchase(self, GoodsInfoData, LoginData):
|
||||
logging.info("========== [加入购物车] add_retire_purchase ==========")
|
||||
payload = json.dumps({
|
||||
"addGoods":[{
|
||||
"inputCode": GoodsInfoData["data"]["inputCode"],
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": GoodsInfoData["data"]["qty"],
|
||||
"weight": int(GoodsInfoData["data"]["weight"]),
|
||||
}],
|
||||
"autoSelectCoupon": True,
|
||||
"coupons": [],
|
||||
"deleteGoods": [],
|
||||
"existGoods": [],
|
||||
"orderNo": LoginData["data"][0]["orderNo"]
|
||||
})
|
||||
url = self.Domain+"/v2/shopping/add/retire/purchase"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
|
||||
def get_coupon_list(self):
|
||||
logging.info("========== [获取优惠券列表] get_coupon_list ==========")
|
||||
payload = json.dumps({
|
||||
"code":"4",
|
||||
"value":""
|
||||
})
|
||||
url = self.Domain+"/v1/coupon/list"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def receive_coupon(self, CouponListData):
|
||||
logging.info("========== [领取优惠券] receive_coupon ==========")
|
||||
CouponList = []
|
||||
for i in CouponListData["data"]:
|
||||
CouponList.append(i["name"])
|
||||
payload = json.dumps({"activityIds": CouponList})
|
||||
url = self.Domain+"/v1/coupon/receive"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def query_coupon_list_user(self):
|
||||
logging.info("========== [查询优惠券列表] query_coupon_list_user ==========")
|
||||
payload = {}
|
||||
url = self.Domain+"/v1/coupon/list/user?state=2&page=0&pageSize=10"
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def get_cart_goods_info(self, GoodsInfoData):
|
||||
logging.info("========== [获取购物车商品信息] get_cart_goods_info ==========")
|
||||
payload = json.dumps({"goodsParamList":[{
|
||||
"inputCode": GoodsInfoData["data"]["inputCode"],
|
||||
"qty": GoodsInfoData["data"]["qty"],
|
||||
"weight": int(GoodsInfoData["data"]["weight"]),
|
||||
}]})
|
||||
url = self.Domain+"/v2/shopping/cart/goods/info"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def request_order_settlement(self, LoginData):
|
||||
logging.info("========== [请求订单结算] request_order_settlement ==========")
|
||||
payload = json.dumps({
|
||||
"orderNo": LoginData["data"][0]["orderNo"],
|
||||
"setCouponFlag": False,
|
||||
"setPayMethodFlag": False
|
||||
})
|
||||
url = self.Domain+"/v2/shopping/order/settle"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
''' 加购购物袋
|
||||
POST
|
||||
https://api.test.yimaogo.com/cart/v2/shopping/add/retire/purchase
|
||||
|
||||
payload = {"addGoods":[{"inputCode":"6942728414063","isNormalAddPurchase":true,"qty":1,"weight":0}],"autoSelectCoupon":true,"coupons":[],"deleteGoods":[],"existGoods":[],"orderNo":"1857003957307801600"}
|
||||
'''
|
||||
|
||||
|
||||
|
||||
''' 2- without sessionid '''
|
||||
def get_ads_list(self):
|
||||
logging.info("========== [获取广告列表] get_ads_list ==========")
|
||||
''' method 1 '''
|
||||
payload = {}
|
||||
url = self.Domain+"/v1/ads/list?areaCode&userId&barcode&adsAreaIds=1,2,3,4,5,6"
|
||||
logging.info(f"---url: {url}---")
|
||||
logging.info(f"---headers: {self.headerss}---")
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def query_ad_detail(self, ADsId:str):
|
||||
logging.info("========== [查询广告详情] query_ad_detail ==========")
|
||||
payload = {}
|
||||
url = self.Domain+"/v1/ads/{adsId}".replace("{adsId}", str(ADsId))
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ym = YMClientApi()
|
||||
''' 01- '''
|
||||
ym.session_start() # step1:session开始
|
||||
Payload01 = {"action": 0, "isAnon": True}
|
||||
LoginData = ym.login_app_v2(Payload01) # step2:匿名登录
|
||||
ym.get_login_type() # step3:获取登录方式
|
||||
Payload02 = {"action": 1, "code": "18052753212", "isAnon": False}
|
||||
ym.login_app_v2(Payload02) # step4:切换会员登录
|
||||
GoodsInfoData = ym.get_goods_info(InputCode=6924882486100) # step5:获取商品信息
|
||||
CouponListData = ym.get_coupon_list() # step6:获取优惠券列表
|
||||
ym.receive_coupon(CouponListData) # step7:领取优惠券
|
||||
ym.query_coupon_list_user() # step8:查询用户持有的优惠券列表
|
||||
ym.add_retire_purchase(GoodsInfoData, LoginData) # step9:加购商品
|
||||
ym.get_cart_goods_info(GoodsInfoData) # step10:获取购物车商品信息
|
||||
ym.request_order_settlement(LoginData) # step11:请求订单结算
|
||||
|
||||
ym.session_end()
|
||||
|
78
YiMao/businessFunc/ServiceApiLib.py
Normal file
78
YiMao/businessFunc/ServiceApiLib.py
Normal file
@ -0,0 +1,78 @@
|
||||
# !/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author:: Arthur Wu
|
||||
# @Date:: 2024/11/15-13:10
|
||||
# @Description::
|
||||
import requests,json, time, logging
|
||||
from configs.globalParams import *
|
||||
from commons.SignatureYM import SignatureYM
|
||||
|
||||
|
||||
class YMServiceApi(object):
|
||||
def __init__(self):
|
||||
self.Domain = "https://api.test.yimaogo.com/"
|
||||
self.headerss = SignatureYM().return_headers()
|
||||
|
||||
''' 1-广告模块 '''
|
||||
def publish_ad(self, ADDetail, MarketAndStoreDetail):
|
||||
logging.info("========== [发布广告] ==========")
|
||||
timeStamp = str(int(time.time()))
|
||||
PublicParams = {
|
||||
"status": 4, "name": "Auto"+timeStamp,
|
||||
"agencyId": 3, "agencyName": "洪家班", "advertiserId": 3,
|
||||
"advertiserName": "阿宝传媒", "adsUse": 1, "customerTag": 3,
|
||||
"putRangeCycle": "[7,6,5,1,2,3,4]",
|
||||
"addType": 1, "pricingType": 1, "standardPrice": "1", "minPrice": "1",
|
||||
"putStart": GlobalParams["todayDate"], "putEnd": GlobalParams["todayDate"],
|
||||
"putStartTime": "00:00:00", "putEndTime": "23:00:00"
|
||||
}
|
||||
payload = json.dumps(PublicParams | ADDetail | MarketAndStoreDetail)
|
||||
url = self.Domain + "admin/ads"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
yms = YMServiceApi()
|
||||
''' 武商 '''
|
||||
ADDetail = [
|
||||
{ # 登录页
|
||||
"adsAreaId": 1, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/534ae9d7-3f65-48da-bc2e-3d5e66fe56d8.jpg",
|
||||
"showOrder": 1, "showTime": 5,
|
||||
},
|
||||
{ # 登录后弹窗
|
||||
"adsAreaId": 2, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/93e34d0e-9f4c-499b-ad8b-5741e55528b5.jpg",
|
||||
},
|
||||
{ # 购物车主页
|
||||
"adsAreaId": 3, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/581ec30a-4d90-43f3-b0e9-b5c8fe0006b4.jpg",
|
||||
"showOrder": 1, "showTime": 5,
|
||||
},
|
||||
{ # 待机页
|
||||
"adsAreaId": 4, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/8c8f6de0-6eb7-4b66-98cd-2c85eb057ed5.png",
|
||||
"showOrder": 1, "showTime": 5,
|
||||
},
|
||||
{ # 扫码
|
||||
"adsAreaId": 5, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/9d5555e3-fec1-4e1a-94e7-b517f4e88aba.jpg",
|
||||
},
|
||||
{ # 支付后
|
||||
"adsAreaId": 6, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/e2e2e892-1a81-4b0f-9af2-cb46f04a5dc4.jpg",
|
||||
},
|
||||
{ # 小票
|
||||
"adsAreaId": 7, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/6d9c14ca-3fd1-4fe7-b04a-84cf18937e60.jpg",
|
||||
}
|
||||
]
|
||||
MarketAndStoreDetail = {"putMarketId": 50, "putStoreId": ["29"]}
|
||||
for ad in ADDetail:
|
||||
yms.publish_ad(ad, MarketAndStoreDetail)
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
|
149
YiMao/config/ClientApiInfo.py
Normal file
149
YiMao/config/ClientApiInfo.py
Normal file
@ -0,0 +1,149 @@
|
||||
# !/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author:: Arthur Wu
|
||||
# @Date:: 2024/11/12-11:28
|
||||
# @Description::
|
||||
''' 客户端API接口列表 '''
|
||||
|
||||
|
||||
api_env = {
|
||||
"test_env": "https://api.test.yimaogo.com/cart",
|
||||
"gray_env": "https://api.yimaogo.com/cart",
|
||||
}
|
||||
|
||||
ApplicatonApi_zh = {
|
||||
# 01-session
|
||||
"session数据上报": "/v1/session/report/case", # POST
|
||||
"session开始": "/v1/session/start", # POST
|
||||
"session数据批量上报": "/v2/session/report/case", # POST
|
||||
"session结束": "/v1/session/end", # PUT
|
||||
"更新session的业务字段": "/v1/session/update", # POST
|
||||
|
||||
# 02-登录
|
||||
"小程序码": "/v1/login/getMiniProgramUrl", # POST
|
||||
"登录V1": "/v1/login", # POST 仅杭联走V1
|
||||
"登录V2": "/v2/login", # POST 其他都走V2
|
||||
"支付宝刷脸初始化": "/v1/login/initialize", # POST
|
||||
"会员扫码联华": "/v1/login/unlockCart", # POST
|
||||
"会员选择": "/v2/login/{customerId}", # POST
|
||||
"获取购物车登录类型": "/v2/login/type", # GET
|
||||
|
||||
# 03-私人物品
|
||||
"私人物品新增保存": "/v1/personal/things/save", # POST
|
||||
|
||||
# 04-车辆
|
||||
"获取购物车信息": "/v1/cart/info", # GET
|
||||
"获取商超购物车POS配置": "/v1/cart/pos/config", # GET
|
||||
"获取门店列表": "/v1/cart/storeList", # GET
|
||||
"购物车注册": "/v1/cart/register", # POST
|
||||
|
||||
# 05-闸机
|
||||
"获取闸机信息": "/v1/gate/info", # GET
|
||||
"吐袋机吐袋数量上报": "/v1/gate/bag/num", # POST
|
||||
"检查是否可以开门": "/v1/gate/canOpen", # GET
|
||||
"查询订单详情": "/v1/gate/queryOrderInfoByMac", # GET
|
||||
"闸机开门": "/v1/gate/openDoor", # POST
|
||||
"获取订单列表": "/v1/gate/order", # POST
|
||||
"核验订单": "/v1/gate/checkOrder", # GET
|
||||
"小票打印": "/v1/gate/order/printReceipt", # GET
|
||||
"手动小票打印": "/v1/gate/order/manualPrintReceipt", # GET
|
||||
"结算单打印": "/v1/gate/order/getSettlementInfo", # GET
|
||||
"绑定订单接口": "/v1/gate/order/bind", # POST
|
||||
|
||||
# 06-广告
|
||||
"获取广告列表": "/v1/ads/list", # GET
|
||||
"查询广告详情": "/v1/ads/{adsId}", # GET
|
||||
|
||||
# 07-优惠券
|
||||
"获取优惠券的规则": "/v1/coupon/list/settings", # POST
|
||||
"获取车上优惠券": "/v1/coupon/list", # POST
|
||||
"领取优惠券": "/v1/coupon/receive", # POST
|
||||
"查询用户有的优惠券": "/v1/coupon/list/user", # GET
|
||||
"V2百联用券接口": "/v2/coupon/bl/use", # POST
|
||||
"V2百联取消用券接口": "/v2/coupon/bl/cancel/use", # POST
|
||||
"V2百联优惠券支付接口": "/v2/coupon/bl/pay", # POST
|
||||
"永辉优惠劵兑换": "/v1/coupon/getTouristCoupon", # GET
|
||||
|
||||
# 08-商品
|
||||
"获取商品信息(客户端输入inputCode)": "/v2/shopping/{inputCode}", # GET
|
||||
"获取商品信息": "/v1/shopping/{barcode}", # GET
|
||||
"无条码商品列表": "/v1/shpping/no/barcode/list", # GET
|
||||
"获取采集商品信息": "/v1/shopping/collect/6921168509256", # GET
|
||||
|
||||
# 09-购物
|
||||
"获取购物车商品信息": "/v1/shopping/cart/goods/info", # POST
|
||||
"加购/退购接口V2": "/v2/shopping/add/retire/purchase", # POST
|
||||
"获取无条形码商品列表": "/v1/shopping/no/barcode/list", # GET
|
||||
"清空购物车": "/v1/shopping/clear/cart", # POST
|
||||
"加购/退购接口": "/v1/shopping/add/retire/purchase", # POST
|
||||
"订单结算": "/v1/shopping/order/settle", # POST
|
||||
"订单支付": "/v1/shopping/order/pay", # POST
|
||||
"查询订单支付": "/v1/shopping/query/order/pay", # GET
|
||||
"订单取消": "/v1/shopping/order/cancel", # POST
|
||||
"聚合支付通知": "/v1/shopping/pay/notify", # POST
|
||||
"获取购物车商品信息V2": "/v2/shopping/cart/goods/info", # POST
|
||||
"订单结算V2": "/v2/shopping/order/settle", # POST
|
||||
"购物车商品识别": "/v2/shopping/predict", # POST
|
||||
|
||||
# 10-鉴权
|
||||
"MQTT": "/v1/auth/mqtt", # POST
|
||||
"核验码鉴权": "/v1/auth/verification", # POST
|
||||
|
||||
# 11-核验
|
||||
"核验商品上报": "/v1/check/goods", # POST
|
||||
"核验私人物品上报": "/v1/check/personal", # POST
|
||||
"通过核验商品": "/v1/check/goods/update", # POST
|
||||
"采集商品重量": "/v1/check/collectGoodsWeight", # POST
|
||||
|
||||
# 12-文件上传
|
||||
"文件上传": "/v1/upload/s3", # POST
|
||||
|
||||
# 13-日志上报
|
||||
"日志上报": "/v1/log", # POST
|
||||
"闸机上报": "/v1/log/gate", # POST
|
||||
|
||||
# 14-传感器信息采集
|
||||
"记录上传": "/v1/sensor/record", # POST
|
||||
|
||||
# 15-地图导航
|
||||
"获取门店区域列表": "/v1/navigation/area", # GET
|
||||
|
||||
# 16-抽奖活动
|
||||
"抽奖活动入口": "/v1/lottery/entrance", # POST
|
||||
"抽奖页面初始化": "/v1/lottery/init", # POST
|
||||
"抽奖": "/v1/lottery/draw", # POST
|
||||
"查询奖品列表": "/v1/lottery/prize/list", # POST
|
||||
|
||||
# 17-派样活动
|
||||
"老系统同步派样活动": "/v1/sample/sync/activity", # POST
|
||||
"老系统同步派样记录": "/v1/sample/sync", # POST
|
||||
"绑定派样": "/v1/sample/bind", # POST
|
||||
"核销派样": "/v1/sample/write/off", # POST
|
||||
"分页查询派样记录": "/v1/sample/list", # POST
|
||||
|
||||
# 18-微信小程序
|
||||
"获取赠品绑定小程序码": "/mp/getQrCode", # POST
|
||||
|
||||
# 19-埋点上报
|
||||
"埋点上报": "/v1/event/tracking/report", # POST
|
||||
|
||||
# 20-配套软件
|
||||
"获取门店配套软件": "/v1/supporting/software/list", # POST
|
||||
|
||||
# 21-MQTT查询
|
||||
"会员登录查询": "/v1/mqtt/login", # GET
|
||||
"商品核验状态查询": "/v1/mqtt/check/goods", # GET
|
||||
"私人物品核验状态查询": "/v1/mqtt/check/personal", # GET
|
||||
"出闸状态查询": "/v1/mqtt/gate/out", # GET
|
||||
"绑定账号结果查询": "/v1/mqtt/member/bind", # GET
|
||||
|
||||
# 22-本地特征库
|
||||
"本地特征库upgrade": "/v1/usearch/upgrade", # POST
|
||||
|
||||
# 23-登录接口
|
||||
"会员扫码回调": "/v2/login/unlockCart", # POST
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
42
YiMao/data/WuShangSceneData.py
Normal file
42
YiMao/data/WuShangSceneData.py
Normal file
@ -0,0 +1,42 @@
|
||||
# !/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author:: Arthur Wu
|
||||
# @Date:: 2024/11/15-14:46
|
||||
# @Description::
|
||||
''' 武商场景数据集 '''
|
||||
|
||||
''' 1-发布广告 '''
|
||||
ADDetail = [
|
||||
{ # 登录页
|
||||
"adsAreaId": 1, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/534ae9d7-3f65-48da-bc2e-3d5e66fe56d8.jpg",
|
||||
"showOrder": 1, "showTime": 5,
|
||||
},
|
||||
{ # 登录后弹窗
|
||||
"adsAreaId": 2, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/93e34d0e-9f4c-499b-ad8b-5741e55528b5.jpg",
|
||||
},
|
||||
{ # 购物车主页
|
||||
"adsAreaId": 3, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/581ec30a-4d90-43f3-b0e9-b5c8fe0006b4.jpg",
|
||||
"showOrder": 1, "showTime": 5,
|
||||
},
|
||||
{ # 待机页
|
||||
"adsAreaId": 4, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/8c8f6de0-6eb7-4b66-98cd-2c85eb057ed5.png",
|
||||
"showOrder": 1, "showTime": 5,
|
||||
},
|
||||
{ # 扫码
|
||||
"adsAreaId": 5, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/9d5555e3-fec1-4e1a-94e7-b517f4e88aba.jpg",
|
||||
},
|
||||
{ # 支付后
|
||||
"adsAreaId": 6, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/e2e2e892-1a81-4b0f-9af2-cb46f04a5dc4.jpg",
|
||||
},
|
||||
{ # 小票
|
||||
"adsAreaId": 7, "mediaType": 1,
|
||||
"mediaUrl": "ads/content/6d9c14ca-3fd1-4fe7-b04a-84cf18937e60.jpg",
|
||||
}
|
||||
]
|
||||
MarketAndStoreDetail = {"putMarketId": 50, "putStoreId": ["29"]}
|
34
YiMao/scripts/BusiScenarios/test_C001_CheckADs.py
Normal file
34
YiMao/scripts/BusiScenarios/test_C001_CheckADs.py
Normal file
@ -0,0 +1,34 @@
|
||||
# !/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author:: Arthur Wu
|
||||
# @Date:: 2024/11/15-14:43
|
||||
# @Description::
|
||||
import unittest,allure,time
|
||||
from configs.globalObj import LOGGER
|
||||
from YiMao.businessFunc.ClientApiLib import YMClientApi
|
||||
|
||||
|
||||
class Test_C001_CheckADs(unittest.TestCase):
|
||||
'''@Date:: 2024/11/15
|
||||
@Author:: Arthur Wu
|
||||
@Desc::
|
||||
[购物车客户端] 广告验证
|
||||
'''
|
||||
def setUp(self) -> None:
|
||||
self.timestamp = int(time.time())
|
||||
self.ymc = YMClientApi()
|
||||
|
||||
@allure.story('[购物车客户端] 广告验证')
|
||||
def test_C001_CheckADs(self):
|
||||
allure.dynamic.description("描述:购物车客户端-广告验证")
|
||||
AdListData = self.ymc.get_ads_list()
|
||||
if "error_msg" not in AdListData:
|
||||
adIdList = []
|
||||
for ad in AdListData['data']:
|
||||
adIdList.append(ad['id'])
|
||||
LOGGER.info(f"---adIdList: {adIdList}---\n")
|
||||
for adId in adIdList:
|
||||
self.ymc.query_ad_detail(str(adId))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
5
YiMao/scripts/YMClient/__init__.py
Normal file
5
YiMao/scripts/YMClient/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
# !/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author:: Arthur Wu
|
||||
# @Date:: 2024/11/15-14:25
|
||||
# @Description::
|
5
YiMao/scripts/YMService/__init__.py
Normal file
5
YiMao/scripts/YMService/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
# !/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author:: Arthur Wu
|
||||
# @Date:: 2024/11/15-16:28
|
||||
# @Description::
|
@ -3,7 +3,7 @@
|
||||
import unittest,allure,ddt,time,json,requests
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel
|
||||
from commons.AssertLib import _assert_result
|
||||
ExlFilePath = GlobalPath['YMDataPath'] + '/YMHT_ApiTestCase_0.0.1.xlsx'
|
@ -3,7 +3,7 @@
|
||||
import unittest,allure,ddt,time,json,requests
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel,Txt
|
||||
from commons.AssertLib import _assert_result
|
||||
ExlFilePath = GlobalPath['YMDataPath'] + '/YMHT_ApiTestCase_0.0.1.xlsx'
|
@ -4,7 +4,7 @@ import unittest,allure,ddt,time,json,requests,datetime
|
||||
from datetime import datetime,timedelta
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel,Txt
|
||||
from commons.PgSqlLib import PGSQL
|
||||
from commons.AssertLib import _assert_result
|
@ -3,7 +3,7 @@
|
||||
import unittest,allure,ddt,json,requests
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel,Txt
|
||||
from commons.AssertLib import _assert_result
|
||||
ExlFilePath = GlobalPath['YMDataPath'] + '/YMHT_ApiTestCase_0.0.1.xlsx'
|
@ -4,7 +4,7 @@ import unittest,allure,ddt,time,json,requests,datetime
|
||||
from datetime import datetime,timedelta
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel,Txt
|
||||
from commons.PgSqlLib import PGSQL
|
||||
from commons.AssertLib import _assert_result
|
@ -4,7 +4,7 @@ import unittest,allure,ddt,time,json,requests,datetime
|
||||
from datetime import datetime,timedelta
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel,Txt
|
||||
from commons.AssertLib import _assert_result
|
||||
ExlFilePath = GlobalPath['YMDataPath'] + '/YMHT_ApiTestCase_0.0.1.xlsx'
|
@ -4,7 +4,7 @@ import unittest,allure,ddt,time,json,requests,datetime
|
||||
from datetime import datetime,timedelta
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel,Txt
|
||||
from commons.AssertLib import _assert_result
|
||||
ExlFilePath = GlobalPath['YMDataPath'] + '/YMHT_ApiTestCase_0.0.1.xlsx'
|
@ -4,7 +4,7 @@ import unittest,allure,ddt,time,json,requests,datetime
|
||||
from datetime import datetime,timedelta
|
||||
from configs.globalObj import LOGGER
|
||||
from configs.globalParams import *
|
||||
from YiMao.config.ApiInfo_web import *
|
||||
from YiMao.config.ServiceApiInfo import *
|
||||
from commons.FileHandler import ReadExcel,Txt
|
||||
from commons.AssertLib import _assert_result
|
||||
# ExlFilePath = GlobalPath['YMDataPath'] + '/YMHT_ApiTestCase_0.0.1.xlsx'
|
@ -13,15 +13,16 @@ class Engine():
|
||||
self.CasesSuite = []
|
||||
self.rootpath = os.path.dirname(os.path.dirname(__file__))
|
||||
self.FolderPath = ReturnFolder
|
||||
self.projectCasesPath = str(os.path.join(GlobalPath['YMCaseScriptsPath']).replace("\\", "/"))
|
||||
self.TestSuiteName = str(os.path.join(GlobalPath[ProCfgData["ExecutionScope"]]).replace("\\", "/"))
|
||||
self.ReportName = "Reports"
|
||||
self.newName = "亿猫业务场景接口自动化测试报告"
|
||||
|
||||
def __execute(self):
|
||||
'''@Author:: Arthur Wu
|
||||
@Date:: 2024/5/9
|
||||
:return:
|
||||
'''
|
||||
for dirpath, dirnames, filenames in os.walk(self.projectCasesPath):
|
||||
for dirpath, dirnames, filenames in os.walk(self.TestSuiteName):
|
||||
for fn in filenames:
|
||||
if fn.startswith("test_"):
|
||||
caseScriptPath = os.path.join(dirpath, fn).replace("\\", "/")
|
||||
@ -35,7 +36,9 @@ class Engine():
|
||||
+ ' --workers=2 '+'--tests-per-worker=2',
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE).stdout.read()
|
||||
folder_path = os.path.join(self.FolderPath, 'html').replace('\\', '/')
|
||||
LOGGER.info("---[INFO] Allure html report generate complete !")
|
||||
return folder_path
|
||||
|
||||
def __move_file(self):
|
||||
rootpath = (os.getcwd()).replace("\\", "/")
|
||||
@ -65,14 +68,24 @@ class Engine():
|
||||
os.remove(file_path)
|
||||
print(f"已删除: {file_path}")
|
||||
|
||||
def __set_overview_title(self, index_path, new_name):
|
||||
title_filepath = os.path.join(index_path, "widgets", "summary.json")
|
||||
with open(title_filepath, 'rb') as f:
|
||||
params = json.load(f)
|
||||
params['reportName'] = new_name
|
||||
new_params = params
|
||||
with open(title_filepath, 'w', encoding="utf-8") as f:
|
||||
json.dump(new_params, f, ensure_ascii=False, indent=4)
|
||||
|
||||
def run_test_suite(self):
|
||||
txtPath = os.path.join(self.rootpath, "YiMao/ProcessData")
|
||||
self.__delete_pycache_dirs(self.rootpath)
|
||||
self.__delete_txt_files(txtPath)
|
||||
self.__execute()
|
||||
indexh5path = self.__execute()
|
||||
self.__set_overview_title(indexh5path, self.newName)
|
||||
returnList = []
|
||||
lastReportPath = self.__move_file()
|
||||
returnList.append(lastReportPath)
|
||||
# lastReportPath = self.__move_file()
|
||||
# returnList.append(lastReportPath)
|
||||
self.__delete_txt_files(txtPath)
|
||||
self.__delete_pycache_dirs(self.rootpath)
|
||||
return returnList
|
||||
@ -84,8 +97,8 @@ class NotificationModule():
|
||||
"Debug": "7aedbee7239870e3e653748a2889d8bf063c61efa9213c7099bd57476066dc86",
|
||||
"Formal": "80b026022a28166cfc9eebaf8f6a880cc06f56a14b8803e8d67e7fb3cb05844e"
|
||||
}
|
||||
# self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Debug"]}'
|
||||
self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Formal"]}'
|
||||
self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Debug"]}'
|
||||
# self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Formal"]}'
|
||||
self.ReportUrl = ProCfgData["ReportsURL"]
|
||||
self.ExecutionEnvironment = ProCfgData["ExecutionEnv"]
|
||||
|
||||
|
@ -4,7 +4,6 @@ from authlib.integrations.requests_client import OAuth2Session
|
||||
|
||||
|
||||
class SignatureYM():
|
||||
|
||||
def __init__(self):
|
||||
self.client_id = "95579765e4fe91af9962"
|
||||
self.client_secret = "3dcb964ede5d455f1d54623dad5e496bff468f81"
|
||||
@ -30,3 +29,51 @@ class SignatureYM():
|
||||
}
|
||||
return headers
|
||||
|
||||
class SignatureYM2():
|
||||
def __init__(self, Mac= '70:f7:54:07:a6:c0'):
|
||||
def __sission_id():
|
||||
import random, time
|
||||
def generate_24_digit_random_integer():
|
||||
timestamp = int(time.time() * 1000)
|
||||
random_number = random.randint(0, 99999999999999)
|
||||
combined_number = str(timestamp) + str(random_number)
|
||||
if len(combined_number) >= 24:
|
||||
return int(combined_number[:24])
|
||||
else:
|
||||
combined_number = combined_number.ljust(24, '0')
|
||||
return int(combined_number)
|
||||
random_integer = generate_24_digit_random_integer()
|
||||
return str(random_integer)
|
||||
self.SessionId = __sission_id()
|
||||
self.Mac = Mac
|
||||
|
||||
def _headers(self):
|
||||
headers = {
|
||||
'SessionId': self.SessionId,
|
||||
'Mac': self.Mac,
|
||||
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': '*/*',
|
||||
'Host': 'api.test.yimaogo.com',
|
||||
'Connection': 'keep-alive',
|
||||
'App_Version': '6.0.9.107',
|
||||
'Build_Number': '107',
|
||||
}
|
||||
return headers
|
||||
|
||||
class SignatureYM3():
|
||||
def __init__(self, GateMac= '74:ee:2a:df:67:4d'):
|
||||
self.GateMac = GateMac
|
||||
|
||||
def _headers(self):
|
||||
headers = {
|
||||
'GateMac': self.GateMac,
|
||||
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': '*/*',
|
||||
'Host': 'api.test.yimaogo.com',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
return headers
|
||||
|
||||
|
||||
|
@ -4,5 +4,9 @@
|
||||
# 1-执行环境:测试环境-test_env;灰度环境-gray_env
|
||||
ExecutionEnv: test_env
|
||||
|
||||
# 2-Reports URL
|
||||
# 2-执行范围:YMService、YMClient、YMBusiScenarios
|
||||
ExecutionScope: YMBusiScenarios
|
||||
|
||||
# 3-Reports URL
|
||||
ReportsURL: http://192.168.1.165
|
||||
|
||||
|
@ -14,7 +14,9 @@ GlobalPath = {
|
||||
"CfgPath": os.path.join(__RootPath, 'configs').replace("\\", "/"),
|
||||
"YMDataPath": os.path.join(__RootPath, 'YiMao/data').replace("\\", "/"),
|
||||
"YMCfgPath": os.path.join(__RootPath, 'YiMao/config').replace("\\", "/"),
|
||||
"YMCaseScriptsPath": os.path.join(__RootPath, 'YiMao/scripts').replace("\\", "/"),
|
||||
"YMService": os.path.join(__RootPath, 'YiMao/scripts/YMService').replace("\\", "/"),
|
||||
"YMClient": os.path.join(__RootPath, 'YiMao/scripts/YMClient').replace("\\", "/"),
|
||||
"YMBusiScenarios": os.path.join(__RootPath, 'YiMao/scripts/BusiScenarios').replace("\\", "/"),
|
||||
"YMReportPath": os.path.join(__RootPath, 'YiMao/report').replace("\\", "/")
|
||||
}
|
||||
GlobalParams = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user