|
@@ -1414,3 +1414,39 @@ def download_top3_imgs(request):
|
|
|
return tmpzip
|
|
|
#return imgData
|
|
|
|
|
|
+
|
|
|
+def update_stock_usernum(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ stock_date = kwargs.get("stock_date")
|
|
|
+ qset = cm.UserStock.objects.filter(stock_date=stock_date,fund__gt=0)
|
|
|
+ qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id"),total_fund=Sum("fund")).order_by("-count")
|
|
|
+ cm.Stock.objects.update(stock_date=None)
|
|
|
+ for q in qset:
|
|
|
+ stock_id = q["stock_id"]
|
|
|
+ count = q["count"]
|
|
|
+ cm.Stock.objects.filter(id=stock_id).update(user_num=count,stock_date=stock_date)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+def get_stock_list(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ name = kwargs.get("name")
|
|
|
+ stock_date = kwargs.get("stock_date")
|
|
|
+ qset = cm.Stock.objects.all()
|
|
|
+ if name:
|
|
|
+ qset = qset.filter(name__icontains=name)
|
|
|
+ if stock_date:
|
|
|
+ qset = qset.filter(stock_date=stock_date)
|
|
|
+
|
|
|
+ data = list(qset.order_by("-user_num").values())
|
|
|
+ page = int(kwargs.get("page",1))
|
|
|
+ page_size = int(kwargs.get("page_size",20))
|
|
|
+ if page and page_size:
|
|
|
+ total,data = ccf.get_page_list(data,page,page_size)
|
|
|
+ return total,data
|
|
|
+ else:
|
|
|
+ return len(data),data
|
|
|
+
|
|
|
+
|