def CreatePlayer(self): username = self.POST.get('username') phone = self.POST.get('phone') time = self.POST.get('time') area = self.POST.get('area') school = self.POST.get('school') where = self.POST.get('where') nowtime = datetime.datetime.now() age = int(nowtime.strftime('%Y')) - int(time[:4]) user = User.objects.filter(username=phone) try: if len(user) == 0: user = User.objects.create_user(username=phone, password='******') profile = UserProfile() profile.user_id = user.id profile.name = username profile.palace = area profile.role = '球员' profile.rights = 4 profile.date = time profile.age = age profile.school = school profile.save() player_basic = Player_Basic() player_basic.user_id = profile.id player_basic.position = where player_basic.where_from = self.user.id player_basic.save() return JsonResponse(Msg().Success(msg='添加成功'), safe=False) else: return JsonResponse(Msg().Success(msg='该手机号已被注册了'), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def PlayerQy(self): time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # print(time) if self.POST.get('p_chance') == 'true': p_year = self.POST.get('p_year') else: p_year = 0 try: signup = SignUp.objects.create(user_id=self.POST.get('user_id'), type=self.POST.get('type'), year=self.POST.get('year'), money=self.POST.get('money'), jiaoyi=self.POST.get('jiaoyi'), p_chance=self.POST.get('p_chance'), p_year=p_year, create_time=time) signup.save() UserProfile.objects.filter( user_id=self.POST.get('user_id')).update( team_id=UserProfile.objects.filter( user_id=self.user.id)[0].team_id) Player_Basic.objects.filter(user_id=UserProfile.objects.filter( user_id=self.POST.get('user_id'))[0].id).update(enable=0) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False) return JsonResponse(Msg().Success(msg='签约成功'), safe=False)
def showAllPlayer(self): global age1, age2 user = UserProfile.objects.get(user_id=self.user.id) page = int(self.POST.get('page')) limit = int(self.POST.get('limit')) team_id = user.team_id name = self.POST.get('p_name') age = self.POST.get('p_age') state = self.POST.get('p_state') position = self.POST.get('p_position') sex = self.POST.get('p_sex') # print(role, name, age, sex) if age == '': age1 = '0' age2 = 100 elif age == '1': age1 = 0 age2 = 20 elif age == '2': age1 = 20 age2 = 30 elif age == '3': age1 = 30 age2 = 100 try: player = UserProfile.objects.filter(team_id=team_id, name__icontains=name, sex__icontains=sex, age__range=[age1, age2], role="球员") basic = Player_Basic.objects.filter(state__icontains=state, position__icontains=position) count = 0 date = list() for i in player: for j in basic: if i.id == j.user_id: context = dict() context['userid'] = i.id context['name'] = i.name context['userpic'] = i.userpic context['sex'] = i.sex context['age'] = i.age context['position'] = j.position context['state'] = j.state context['palace'] = i.palace context['school'] = i.school context['specialty'] = Player_Data.objects.get( user_id=j.id).specialty count = count + 1 this_is_ceshi = count if page * limit >= count: date.append(context) else: pass # print(date) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False) return JsonResponse(Msg().Success(date=date, count=count), safe=False)
def Show_season(self): page = int(self.POST.get('page')) limit = int(self.POST.get('limit')) team_id = UserProfile.objects.get(user_id=self.user.id).team_id try: season = Season.objects.all()[limit * (page - 1):page * limit] count = len(season) now_season = TeamSet.objects.filter(team_id=team_id) date = list() if len(now_season) == 0 or now_season[0].nowseason is None: nowseason = None else: nowseason = now_season[0].nowseason for i in season: context = dict() context['id'] = i.id if str(i.id) == nowseason: context['is_now'] = 'true' else: context['is_now'] = 'false' context['name'] = i.name date.append(context) return JsonResponse(Msg().Success(date=date, count=count), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def PlayerSx(self): try: userid = self.POST.get('userid') height = self.POST.get('height') weight = self.POST.get('weight') body_fat = self.POST.get('body_fat') s_reach = self.POST.get('s_reach') wingspan = self.POST.get('wingspan') b_press = self.POST.get('b_press') s_run = self.POST.get('s_run') b_run = self.POST.get('b_run') f_basket = self.POST.get('f_basket') specialty = self.POST.get('specialty') player_data = Player_Data.objects.create( user_id=userid, height=height, weight=weight, body_fat=body_fat, s_reach=s_reach, wingspan=wingspan, b_press=b_press, s_run=s_run, b_run=b_run, f_basket=f_basket, specialty=specialty, ) player_data.save() Player_Basic.objects.filter(id=userid).update(enable=3) return JsonResponse(Msg().Success(msg='试训成功'), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Create_command(self): title = self.POST.get('title') main_player = self.POST.get('main_player') time = self.POST.get('time') all_player = self.POST.getlist('player[]') player = '' for i in all_player: player = player + str(i) + ',' sum_pass = self.POST.get('pass') sum_pull = self.POST.get('pull') team_id = UserProfile.objects.get(user_id=self.user.id).team_id create_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') if time == '': start_time = '2000-1-1' end_time = '2099-12-31' else: start_time = time.split(' 至 ')[0] end_time = time.split(' 至 ')[-1] try: command = Command.objects.create(title=title, main_player=main_player, player=player, sum_pass=sum_pass, sum_pull=sum_pull, create_time=create_time, start_time=start_time, end_time=end_time, team_id=team_id) command.save() return JsonResponse(Msg().Success(), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def CreateRole(self): username = self.POST.get('username') phone = self.POST.get('phone') time = self.POST.get('time') area = self.POST.get('area') school = self.POST.get('school') role = self.POST.get('role') nowtime = datetime.datetime.now() age = int(nowtime.strftime("%Y")) - int(time[:4]) user = User.objects.filter(username=phone) team_id = UserProfile.objects.get(user_id=self.user.id).team_id try: if len(user) == 0: user = User.objects.create_user(username=phone, password='******') profile = UserProfile() profile.user_id = user.id profile.name = username profile.palace = area if role == '教练': profile.rights = 2 else: profile.rights = 3 profile.role = role profile.date = time profile.age = age profile.school = school profile.team_id = team_id profile.save() return JsonResponse(Msg().Success(msg='添加成功)'), safe=False) else: return JsonResponse(Msg().Success(msg='该手机号码已被注册'), safa=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def ShowAll(self): try: team_id = UserProfile.objects.get(user_id=self.user.id).team_id global age1, age2 page = int(self.POST.get('page')) limit = int(self.POST.get('limit')) name = self.POST.get('name') age = self.POST.get('age') state = self.POST.get('state') where = self.POST.get('where') sex = self.POST.get('sex') if age == '': age1 = '0' age2 = 100 elif age == '1': age1 = 0 age2 = 20 elif age == '2': age1 = 20 age2 = 30 elif age == '3': age1 = 30 age2 = 100 player = UserProfile.objects.filter(team_id=None, name__icontains=name, sex__icontains=sex, age__range=[age1, age2]) basic = Player_Basic.objects.filter(where_from__in=[ x.user_id for x in UserProfile.objects.filter(team_id=team_id) ], state__icontains=state, position__icontains=where) date = list() count = 0 for i in player: for j in basic: if i.id == j.user_id: context = dict() context['userid'] = j.user_id context["userpic"] = i.userpic context["name"] = i.name context["sex"] = i.sex context["age"] = i.age context["state"] = j.state context["position"] = j.position context["palace"] = i.palace context["school"] = i.school context['where_from'] = UserProfile.objects.get( user_id=j.where_from).name count = count + 1 if count <= page * limit: date.append(context) else: pass return JsonResponse(Msg().Success(date=date, count=count), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def RemoveToJx(self): try: userid = self.POST.get('userid') Player_Basic.objects.filter(id=userid).update(enable=1) return JsonResponse(Msg().Success(msg='移除集训名单成功'), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Del_tatics(self): global context for i in self.POST: # print(i) context = i[1:len(i) - 1].strip(',').split(',') try: for i in context: Tactics.objects.filter(id=i).update(team_id=0) except Exception: return JsonResponse(Msg().Error('删除数据失败'), safe=False) return JsonResponse(Msg().Success(), safe=False)
def Select_season(self): try: season = Season.objects.all() data = list() for i in season: context = dict() context['id'] = i.id context['name'] = i.name data.append(context) return JsonResponse(Msg().Success(data), safe=False) except Exception: return JsonResponse(Msg().Error(), safe=False)
def Select_schedule(self): season_id = self.POST.get('season_id') player_id = self.POST.get('player_id') try: date = UserProfile.objects.get(user_id=self.user.id) team_date = Team.objects.get(id=date.team_id) player = Player_season.objects.filter(player_id=player_id, season_id=season_id) # 查询该球员的签约时间 create_time = SignUp.objects.get(user_id=UserProfile.objects.get( id=player_id).user_id).create_time.strftime( "%Y-%m-%d %H:%M:%S") times = int( time.mktime(time.strptime(create_time, "%Y-%m-%d %H:%M:%S"))) start_time = datetime.datetime(year=1, month=1, day=1, hour=0, minute=0, second=0) end_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") end_times = int( time.mktime(time.strptime(end_time, "%Y-%m-%d %H:%M:%S"))) """ 判断球员的签约时间是在当前时间之后还是之前,如果是之前,就查询赛程,如果是之后就返回空 """ data = list() if times - end_times > 0: return JsonResponse(Msg().Success(), safe=False) else: schedule = Schedule.objects.filter( Q(team_one=team_date.id) | Q(team_two=team_date.id), season_id=season_id, time__range=[create_time, end_time]) for i in schedule: if (len( Player_season.objects.filter( player_id=player_id, season_id=season_id, schedule_id=i.id)) == 0): content = dict() content['schedule_id'] = i.id content['msg'] = Team.objects.get( id=i.team_one).name + 'VS' + Team.objects.get( id=i.team_two).name + '(' + i.time.strftime( '%Y-%m-%d') + '-' + i.type + ')' data.append(content) else: pass # print(data) return JsonResponse(Msg().Success(data), safe=False) except Exception: return JsonResponse(Msg().Error(), safe=False)
def AddToJx(self): try: userid = self.POST.get('userid') user = Player_Basic.objects.filter(enable=1, user_id=userid) if len(user) > 0: Player_Basic.objects.filter(user_id=userid).update(enable=2) return JsonResponse(Msg().Success(msg='加入集训成功'), safe=False) else: return JsonResponse(Msg().Success(msg='该球员已在集训名单中'), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def DelPlyaer(self): userid = self.POST.get('userid') try: is_not = SignUp.objects.get(user_id=UserProfile.objects.get( id=userid).user_id).jiaoyi if is_not == 'true': return JsonResponse(Msg().Success(msg='该球员有交易否决权,不可解约')) else: UserProfile.objects.filter(id=userid).update(team_id=0) return JsonResponse(Msg().Success(msg='解约成功'), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Show_roles(self): team_id = UserProfile.objects.get(user_id=self.user.id).team_id data = TeamSet.objects.filter(team_id=team_id) date = list() msg = ['pg', 'sg', 'sf', 'pf', 'c'] msg_date = ['控球后卫', '得分后卫', '小前锋', '大前锋', '中锋'] try: if len(data) == 0: for i in msg_date: context = dict() context['postion'] = i date.append(context) return JsonResponse(Msg().Success(date=date), safe=False) else: num = TeamSet.objects.get(team_id=team_id) for i in msg: content = dict() if i == 'pg': a = num.pg elif i == 'sg': a = num.sg elif i == 'sf': a = num.sf elif i == 'pf': a = num.pf else: a = num.c content['postion'] = msg_date[msg.index(i)] if a is not None and a != '': content['setid'] = i content['id'] = UserProfile.objects.get(id=a).id content['name'] = UserProfile.objects.get(id=a).name content['age'] = UserProfile.objects.get(id=a).age content['rolepostion'] = Player_Basic.objects.get( user_id=UserProfile.objects.get(id=a).id).position content['time'] = round(Msg().ReturnNone( Player_season.objects.filter(player_id=a).aggregate(Avg('time'))['time__avg']), 2) content['score'] = round(Msg().ReturnNone( Player_season.objects.filter(player_id=a).aggregate(Avg('score'))['score__avg']), 2) content['assists'] = round(Msg().ReturnNone( Player_season.objects.filter(player_id=a).aggregate(Avg('assists'))['assists__avg']), 2) content['court'] = round(Msg().ReturnNone( Player_season.objects.filter(player_id=a).aggregate(Avg('all_court'))['all_court__avg']), 2) content['snatch'] = round(Msg().ReturnNone( Player_season.objects.filter(player_id=a).aggregate(Avg('snatch'))['snatch__avg']), 2) content['block_shot'] = round(Msg().ReturnNone( Player_season.objects.filter(player_id=a).aggregate(Avg('block_shot'))['block_shot__avg']), 2) else: pass date.append(content) except Exception as e: # 打印日志报错 print(e) return JsonResponse(Msg().Error(), safe=False) return JsonResponse(Msg().Success(date=date), safe=False)
def Select_coach(self): user = UserProfile.objects.get(user_id=self.user.id) team_id = user.team_id try: coach = UserProfile.objects.filter(team_id=team_id, rights=2) data = list() for i in coach: context = dict() context['id'] = i.id context['name'] = i.name data.append(context) # print(data) return JsonResponse(Msg().Success(data), safe=False) except Exception: return JsonResponse(Msg().Error('查询教练失败'), safe=False)
def Show_money(self): team_id = UserProfile.objects.get(user_id=self.user.id).team_id msg = TeamSet.objects.filter(team_id=team_id) date = list() context = dict() if len(msg) == 0: context['money'] = 0 context['max_money'] = 0 date.append(context) return JsonResponse(Msg().Success(date=date), safe=False) else: context['money'] = Msg().ReturnNone(msg[0].money) context['max_money'] = Msg().ReturnNone(msg[0].max_money) date.append(context) return JsonResponse(Msg().Success(date=date), safe=False)
def Select_player(self): user = UserProfile.objects.get(user_id=self.user.id) team_id = user.team_id try: player = UserProfile.objects.filter(team_id=team_id, rights=4) data = list() for i in player: context = dict() context['id'] = i.id context['name'] = i.name context['postion'] = Player_Basic.objects.get(user_id=UserProfile.objects.get(id=i.id).id).position data.append(context) # print(data) return JsonResponse(Msg().Success(data), safe=False) except Exception: return JsonResponse(Msg().Error('查询球员失败'), safe=False)
def Count_money(self): team_id = UserProfile.objects.get(user_id=self.user.id).team_id teamset = TeamSet.objects.filter(team_id=team_id) try: date = list() context = dict() if len(teamset) == 0: context['nowseason'] = '' context['player_money'] = 0.0 context['exceed_money'] = 0.0 context['real_money'] = 0.0 date.append(context) else: context['nowseason'] = Season.objects.get( id=TeamSet.objects.get(team_id=team_id).nowseason).name money = Msg().ReturnNone( TeamSet.objects.get(team_id=team_id).money) max_money = Msg().ReturnNone( TeamSet.objects.get(team_id=team_id).max_money) all_player = UserProfile.objects.filter(team_id=team_id, rights=4, role='球员') count_money = 0 for i in all_player: year = int(SignUp.objects.get(user_id=i.user_id).year) creata_time = int( SignUp.objects.get( user_id=i.user.id).create_time.strftime("%Y")) nowseason_time = int(context['nowseason'].split('-')[0]) if creata_time <= nowseason_time <= creata_time + year: count_money = count_money + round( int(SignUp.objects.get(user_id=i.user_id).money) / year, 2) # print(count_money) context['player_money'] = count_money if count_money > int(money): context['exceed_money'] = count_money - int(money) context['real_money'] = round( count_money + context['exceed_money'] * 2, 2) else: context['exceed_money'] = 0.0 context['real_money'] = round(count_money, 2) date.append(context) return JsonResponse(Msg().Success(date=date), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Select_team(self): all_team = Team.objects.exclude(id=1) data = list() for i in all_team: context = dict() context['id'] = i.id context['name'] = i.name data.append(context) return JsonResponse(Msg().Success(data), safe=False)
def Del_roles(self): msg = self.POST.get('setid') try: team_id = UserProfile.objects.get(user_id=self.user.id).team_id if msg == 'pg': TeamSet.objects.filter(team_id=team_id).update(pg='') elif msg == 'sg': TeamSet.objects.filter(team_id=team_id).update(sg='') elif msg == 'sf': TeamSet.objects.filter(team_id=team_id).update(sf='') elif msg == 'pf': TeamSet.objects.filter(team_id=team_id).update(pf='') elif msg == 'c': TeamSet.objects.filter(team_id=team_id).update(c='') except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False) return JsonResponse(Msg().Success(), safe=False)
def Select_myplayer(self): userid = self.POST.get('userid') date = list() try: all_msg = UserProfile.objects.filter(id=userid) context = dict() for i in all_msg: context['user_id'] = i.user_id context['user_pic'] = i.userpic context['name'] = i.name context['sex'] = i.sex context['phone'] = User.objects.get(id=i.user_id).username context['data'] = i.date.strftime('%Y-%m-%d') date.append(context) return JsonResponse(Msg().Success(date=date), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Update_tatic(self): # print(self.POST) global number global update_data for i in self.POST: update_data = json.loads(i) try: Tactics.objects.filter(id=number).update( title=update_data['title'], main_player=update_data['main_player'], start_player=update_data['start_player'], end_player=update_data['end_player'], file=picurl, context=update_data['context'], ) except Exception: return JsonResponse(Msg().Error(), safe=False) return JsonResponse(Msg().Success(), safe=False)
def P_tatics(self): global number try: tactics = Tactics.objects.filter(id=number) data = list() for i in tactics: context = dict() context['id'] = i.id context['title'] = i.title context['main_player'] = i.main_player context['start_player'] = i.start_player context['end_player'] = i.end_player context['file'] = i.file context['context'] = i.context context['create_time'] = i.create_time.strftime('%Y-%m-%d %H:%M:%S') data.append(context) except Exception: return JsonResponse(Msg().Error('战术查询失败'), safe=False) return JsonResponse(Msg().Success(data), safe=False)
def Title_context(self): title_id = self.POST.get('title_id') try: tactics = Tactics.objects.filter(id=title_id) data = list() for i in tactics: context = dict() context['id'] = i.id context['title'] = i.title context['main_player'] = UserProfile.objects.filter(id=i.main_player)[0].name context['start_player'] = UserProfile.objects.filter(id=i.start_player)[0].name context['end_player'] = UserProfile.objects.filter(id=i.end_player)[0].name context['file'] = i.file context['context'] = i.context context['create_time'] = i.create_time.strftime('%Y-%m-%d %H:%M:%S') data.append(context) except Exception: return JsonResponse(Msg().Error('战术查询失败'), safe=False) return JsonResponse(Msg().Success(data), safe=False)
def Update_setplayers(self): postion = self.POST.get('postion') player_id = self.POST.get('player_id') team_id = UserProfile.objects.get(user_id=self.user.id).team_id msg = TeamSet.objects.filter(team_id=team_id) if len(msg) == 0: try: if postion == '控球后卫': teamset = TeamSet.objects.create(team_id=team_id, pg=player_id) teamset.save() elif postion == '得分后卫': teamset = TeamSet.objects.create(team_id=team_id, sg=player_id) teamset.save() elif postion == '小前锋': teamset = TeamSet.objects.create(team_id=team_id, sf=player_id) teamset.save() elif postion == '大前锋': teamset = TeamSet.objects.create(team_id=team_id, pf=player_id) teamset.save() elif postion == '中锋': teamset = TeamSet.objects.create(team_id=team_id, c=player_id) teamset.save() return JsonResponse(Msg().Success(), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False) else: try: if postion == '控球后卫': TeamSet.objects.filter(team_id=team_id).update(pg=player_id) elif postion == '得分后卫': TeamSet.objects.filter(team_id=team_id).update(sg=player_id) elif postion == '小前锋': TeamSet.objects.filter(team_id=team_id).update(sf=player_id) elif postion == '大前锋': TeamSet.objects.filter(team_id=team_id).update(pf=player_id) elif postion == '中锋': TeamSet.objects.filter(team_id=team_id).update(c=player_id) return JsonResponse(Msg().Success(), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Show_playerfinance(self): page = int(self.POST.get('page')) limit = int(self.POST.get('limit')) team_id = UserProfile.objects.get(user_id=self.user.id).team_id all_player = UserProfile.objects.filter( team_id=team_id, rights=4, role='球员')[limit * (page - 1):page * limit] count = len(all_player) date = list() try: for i in all_player: context = dict() context['id'] = i.user_id context['name'] = i.name context['userpic'] = i.userpic context['age'] = i.age context['sex'] = i.sex money = SignUp.objects.get(user_id=i.user_id).money context['money'] = money context['p_chance'] = SignUp.objects.get( user_id=i.user.id).p_chance year = SignUp.objects.get(user_id=i.user.id).year for j in range(int(year)): if j != int(year) - 1: context['year' + str(j)] = round(int(money) / year, 2) else: context['year' + str(j)] = round( int(money) - round(int(money) / year, 2) * (int(year - 1)), 2) context['time'] = SignUp.objects.get( user_id=i.user.id).create_time.strftime('%Y-%m-%d') context['type'] = SignUp.objects.get(user_id=i.user.id).type context['p_year'] = SignUp.objects.get( user_id=i.user.id).p_year date.append(context) return JsonResponse(Msg().Success(date=date, count=count), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Update_money(self): team_id = UserProfile.objects.get(user_id=self.user.id).team_id date = TeamSet.objects.filter(team_id=team_id) try: if len(date) == 0: teamset = TeamSet.objects.create( team_id=team_id, money=self.POST.get('money'), max_money=self.POST.get('max_money') ) teamset.save() return JsonResponse(Msg().Success(), safe=False) else: TeamSet.objects.filter(team_id=team_id).update( money=self.POST.get('money'), max_money=self.POST.get('max_money') ) return JsonResponse(Msg().Success(), safe=False) except Exception as e: print(e) return JsonResponse(Msg().Error(), safe=False)
def Create_pic(self): # print(type(self.FILES.get('file'))) pic = self.FILES.get('file') picName = pic.name picStuff = os.path.splitext(picName)[1] picUUIDname = str(uuid.uuid1()) + picStuff # 设置文件上传到服务器的路径 uploadDirPath = os.path.join(os.getcwd(), 'app' + os.sep + 'static' + os.sep + 'image') # 设置上传文件的绝对路径 picAbsPath = uploadDirPath + os.sep + picUUIDname global picurl picurl = 'image/' + picUUIDname # 写出二进制数据到文件中 try: with open(picAbsPath, 'wb+')as fp: # 对文件进行分块处理 for chunk in pic.chunks(): fp.write(chunk) except: return JsonResponse(Msg().Error('图片上传失败'), safe=False) return JsonResponse(Msg().Success(), safe=False)
def Add_playerdata(self): # print(self.POST) global add_data for i in self.POST: add_data = json.loads(i) season_id = Schedule.objects.get(id=add_data['schedule_id']).season_id # print(season_id) # print(add_data['shoot']) Msg().ChangMsg(add_data['shoot']) # print(Msg().ChangMsg(add_data['shoot'])) try: """ 这里没有判断上场时间的问题,实际情况上上场时间为0不可能有数据(默认情况为0),然后 没有判断得分和投篮计算来的得分是否相等的情况,后续改进 """ player_data = Player_season.objects.create( player_id=add_data['player_id'], schedule_id=add_data['schedule_id'], time=add_data['time'], shoot=Msg().ChangMsg(add_data['shoot']).split('-')[0], hit_shoot=Msg().ChangMsg(add_data['shoot']).split('-')[-1], three_points=Msg().ChangMsg( add_data['three_points']).split('-')[0], hit_points=Msg().ChangMsg( add_data['three_points']).split('-')[-1], free_throw=Msg().ChangMsg( add_data['free_throw']).split('-')[0], hit_throw=Msg().ChangMsg( add_data['free_throw']).split('-')[-1], assists=add_data['assists'], all_court=float(add_data['front_court']) + float(add_data['back_court']), front_court=add_data['front_court'], back_court=add_data['back_court'], block_shot=add_data['block_shot'], snatch=add_data['snatch'], error=add_data['error'], break_rules=add_data['break_rules'], season_id=season_id, score=add_data['score'], team_id=UserProfile.objects.get(user_id=self.user.id).team_id) player_data.save() return JsonResponse(Msg().Success(), safe=False) except Exception: return JsonResponse(Msg().Error(), safe=False)