62 lines
3.5 KiB
Python
62 lines
3.5 KiB
Python
import pydash
|
|||
|
|
from django.forms import model_to_dict
|
||
|
|
from rest_framework import status
|
||
|
|
from rest_framework.decorators import action
|
||
|
|
from rest_framework.request import Request
|
||
|
|
from rest_framework.response import Response
|
||
|
|
from rest_framework.viewsets import ViewSet
|
||
|
|
|
||
|
|
from sixGuoDjango import ResData, BaseResponse
|
||
|
|
from wechat_数据库.洗衣液商品数据库.六果洗衣液商品 import goods商品
|
||
|
|
|
||
|
|
|
||
|
|
class 幸运拼团分享接口ViewSets(ViewSet):
|
||
|
|
@action(detail=False, methods=["post"], url_path="message_lucky")
|
||
|
|
def 幸运拼团群分享接口奖励积分(self, request: Request):
|
||
|
|
""""""
|
||
|
|
self_user_unionid = request.data.get("self_user_unionid", None)
|
||
|
|
self_mini_openid = request.data.get("self_mini_openid", None)
|
||
|
|
# 如果需要携带参数, 需要在路由的后面 ? 添加 key=value的格式;
|
||
|
|
page_path = request.data.get("page_path", None)
|
||
|
|
idKey = request.data.get("idKey", None)
|
||
|
|
print("🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 难道我没有拿到值的吗?", idKey)
|
||
|
|
参团商品对象 = goods商品.objects.get(id_主键_goods商品=idKey)
|
||
|
|
goods数据 = model_to_dict(instance=参团商品对象, fields=None)
|
||
|
|
分享图片链接 = pydash.get(obj=goods数据, path="goods商品数据.商品图片.主图.0")
|
||
|
|
messageData = {
|
||
|
|
"title": "🧧🧧🧧洗衣液,居然还可以这样买!!!!",
|
||
|
|
"path": f"{page_path}?superior_unionid={self_user_unionid}&shareType=幸运拼团",
|
||
|
|
"imageUrl": 分享图片链接,
|
||
|
|
}
|
||
|
|
httpResData = BaseResponse(resData=ResData(listData=[""], dictData=messageData), ).model_dump()
|
||
|
|
return Response(data=httpResData, status=status.HTTP_200_OK)
|
||
|
|
|
||
|
|
@action(detail=False, methods=["post"], url_path="timeline_lucky")
|
||
|
|
def 幸运拼团朋友圈分享的奖励接口(self, request: Request):
|
||
|
|
""""""
|
||
|
|
self_user_unionid = request.data.get("self_user_unionid", None)
|
||
|
|
self_mini_openid = request.data.get("self_mini_openid", None)
|
||
|
|
page_path = request.data.get("page_path", None)
|
||
|
|
# 如果需要携带参数, 需要在路由的后面 ? 添加 key=value的格式
|
||
|
|
idKey = request.data.get("idKey", None)
|
||
|
|
print("\n🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 \n", idKey)
|
||
|
|
# goods = goods商品.objects.get(idKey=idKey)
|
||
|
|
goods = goods商品.objects.get(id_主键_goods商品=idKey)
|
||
|
|
goods数据 = model_to_dict(instance=goods, fields=None)
|
||
|
|
分享图片链接 = pydash.get(obj=goods数据, path="goods商品数据.商品图片.主图.0")
|
||
|
|
print("🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 ", 分享图片链接)
|
||
|
|
messageData = {
|
||
|
|
"title": "🧧🧧🧧洗衣液,居然还可以这样买!!!!",
|
||
|
|
"path": f"{page_path}",
|
||
|
|
"imageUrl": "https://hudie.xiao.band/icon/Ll8-7G-3PFWEc6e26d282e20a598c05c15161ea19b5e.png",
|
||
|
|
"query": f"superior_unionid={self_user_unionid}"
|
||
|
|
}
|
||
|
|
积分朋友圈数据 = {
|
||
|
|
"title": "🧧🧧🧧洗衣液,居然还可以这样买!!!!",
|
||
|
|
"path": f"{page_path}",
|
||
|
|
"imageUrl": 分享图片链接,
|
||
|
|
"query": f"superior_unionid={self_user_unionid}&shareType=商品详情分享朋友圈"
|
||
|
|
}
|
||
|
|
httpResData = BaseResponse(resData=ResData(listData=[""], dictData=积分朋友圈数据), ).model_dump()
|
||
|
|
return Response(data=httpResData, status=status.HTTP_200_OK)
|