def post(self, request, category_id): record_id_list = request.JSON.get('record_id', []) record_id_list = [get_int(i) for i in record_id_list if get_int(i)] if not record_id_list: return JsonResponse({ 'status': 'form_error', 'msg': '请选择需要分类的简历', }) user = request.user category = get_object_or_404( BuyResumeCategory, user=user, id=category_id, ) resume_list = list(ResumeBuyRecord.objects.filter( id__in=record_id_list, user=user, )) self.action(category, resume_list) return JsonResponse({ 'status': 'ok', 'msg': 'ok', })
def post(self, request, category_id): record_id_list = request.JSON.get('record_id', []) record_id_list = [get_int(i) for i in record_id_list if get_int(i)] if not record_id_list: return JsonResponse({ 'status': 'form_error', 'msg': '请选择需要分类的简历', }) user = request.user category = get_object_or_404( BuyResumeCategory, user=user, id=category_id, ) resume_list = list( ResumeBuyRecord.objects.filter( id__in=record_id_list, user=user, )) self.action(category, resume_list) return JsonResponse({ 'status': 'ok', 'msg': 'ok', })
def clean_salary_min(self): salary_min = self.data['salary_min'] salary_min = get_int(salary_min) salary_max = self.data['salary_max'] salary_max = get_int(salary_max) if salary_min == 0 and salary_max == 1000000: return salary_min if salary_min < 1000 or salary_min > 1000001: raise forms.ValidationError(u'最小薪资有误,薪资数在1000~1000000之间') return salary_min
def normalize_form_data(self, post_data): post_data['citys'] = [ i.get('id', 0) for i in post_data.get('citys', []) if get_int(i.get('id')) ] post_data['job_domains'] = [ i.get('id') for i in post_data.get('job_domain', []) if get_int(i.get('id')) ] post_data['title'] = ','.join(post_data.get('title', [])) return post_data
def get_work_years(self): work_years_min = get_int(self.request.GET.get('work_years_min', '')) work_years_max = get_int(self.request.GET.get('work_years_max', '')) work_years = '' if work_years_min and not work_years_max: work_years_max = 20 work_years = '%s,%s' % (work_years_min, work_years_max) if not work_years_min and work_years_max: work_years_min = 0 work_years = '%s,%s' % (work_years_min, work_years_max) if work_years_min and work_years_max: work_years = '%s,%s' % (work_years_min, work_years_max) return work_years
def api_post_data(self, post_data): post_data['company_prefer'] = list(CompanyCategoryPrefer.objects.filter( id__in=[get_int(i) for i in post_data.get('company_prefer', []) if get_int(i)] ).values_list( 'code_name', flat=True, )) post_data['job_domain'] = list(CompanyCategory.objects.filter( id__in=[get_int(i) for i in post_data.get('job_domain') if get_int(i)] ).values_list( 'category', flat=True, )) return post_data
def get_advance_work_years(self): work_years_min = get_int(self.request.GET.get('work_years_min', '')) work_years_max = get_int(self.request.GET.get('work_years_max', '')) if work_years_min and not work_years_max: work_years_max = 30 if not work_years_min and work_years_max: work_years_min = 0 if work_years_min > 20 or work_years_max > 30 or work_years_min > work_years_max: return '' if work_years_min < 0 or work_years_max < 0 or (not work_years_min and not work_years_max): return '' return '%s,%s' % (work_years_min, work_years_max)
def clean_salary_max(self): salary_min = self.data['salary_min'] salary_min = get_int(salary_min) salary_max = self.data['salary_max'] salary_max = get_int(salary_max) if salary_min == 0 and salary_max == 1000000: return salary_max if salary_max < 1000 or salary_max > 10000001: raise forms.ValidationError(u'最大薪资有误,薪资数在1000~1000000之间') if salary_min > salary_max: raise forms.ValidationError(u'最大薪资小于最小薪资,请重新填写') if salary_min * 2 < salary_max: raise forms.ValidationError(u'最高薪资不能高于最低薪资的两倍,请重新填写') return salary_max
def get_advance_age(self): age_min = get_int(self.request.GET.get('age_min', '')) age_max = get_int(self.request.GET.get('age_max', '')) if age_min and not age_max: age_max = 60 if not age_min and age_max: age_min = 0 if age_min > 40 or age_max > 60 or age_min > age_max: return '' if age_min < 0 or age_max < 0 or (not age_min and not age_max): return '' return '%s,%s' % (age_min, age_max)
def get_level_by_type(self, level_type): level_meta = { 0: { 'exp_key': 'download_count', 'ratio_key': 'download_ratio', }, 1: { 'exp_key': 'interview_count', 'ratio_key': 'interview_ratio', }, 2: { 'exp_key': 'taking_work_count', 'ratio_key': 'taking_work_ratio', }, } setting = level_meta[level_type] exp = get_int(self.exp_state.__dict__[setting['exp_key']]) for i in self.level_manage: if i['level_type'] != level_type: continue if i['exp'] <= exp < i['next_exp']: i['user_exp'] = exp return i return { 'user_exp': exp, }
def get_query_keyword(self): keyword = self.request.GET.get('query', '') if not keyword: return {} user = self.request.user page = get_int(self.request.GET.get('page', 0)) page = 0 if page - 1 < 0 else page - 1 feed_id_list = UserAcceptTask.objects.filter(user=user, ).values_list( 'feed__feed_obj_id', flat=True, ) search_params = { 'start': 0, 'size': 100, 'feed_type': 1, 'keywords': keyword, 'ids_list': ','.join(list(feed_id_list)) } search_result = ParseUtils.search_job(search_params) feed_data = search_result.get('data', {}).get('results', []) return { 'feed__feed_obj_id__in': [i['id'] for i in feed_data if i.get('id')] }
def get(self, request, uidb64, activation_key): if uidb64 is not None and activation_key is not None: uid = get_int(urlsafe_base64_decode(uidb64)) user = get_object_or_404(User, id=uid) ret = default_token_generator.check_token(user, activation_key) if ret: user_profile = user.get_profile() user_profile.is_email_bind = True user_profile.guide_switch = True user_profile.save() # 开始登录 user.backend = 'django.contrib.auth.backends.ModelBackend' login(request, user) return render( request, self.template, { 'status': 'ok', 'msg': u'绑定接收邮箱成功', }, ) return render(request, self.template, { 'status': 'error', 'msg': u'无效的激活链接', })
def query_reco_time(self, query_cond): title_match = get_int(self.request.GET.get('title_match', 0)) if title_match: return query_cond reco_time = abs(get_int(self.request.GET.get('reco_time', 0))) if not reco_time or reco_time < 0: return query_cond if reco_time > 30: reco_time = 30 today = get_today() start_date = today + datetime.timedelta(days=-reco_time) query_cond.update({'display_time__gte': start_date}) return query_cond
def post(self, request): email = request.POST.get('email', '') if error_email(email): return JsonResponse({ 'status': 'form_error', 'msg': '邮件格式错误', }) feed_id_list = request.POST.get('feed_id_list', '').split(',') if not feed_id_list: return JsonResponse({ 'status': 'form_error', 'msg': '请选择要发送的职位', }) contact_id = get_int(self.request.POST.get('contact_id', '')) candidate = self.get_candidate(contact_id) self.send_email(email, feed_id_list, candidate) candidate.has_contact = True candidate.save() return JsonResponse({ 'status': 'ok', 'msg': '发送成功', })
def post(self, request): admin_id = request.POST.get('admin_id', 0) admin = get_object_or_none( User, id=get_int(admin_id), is_staff=True, ) contact_id_list = request.POST.get('contact_id_list', '') contact_id_list = contact_id_list.split(',') if not contact_id_list: return JsonResponse({ 'status': 'contact_error', 'msg': '请选择联系人信息', }) self.assign_contact(admin, contact_id_list) admin_name = '' if admin is None else admin.username return JsonResponse({ 'status': 'ok', 'msg': '分配成功', 'admin_name': admin_name })
def get_advance_salary(self): MAX_SALARY = 1000000 MIN_SALARY = 1000 salary_min = get_int(self.request.GET.get('salary_min', '')) salary_max = get_int(self.request.GET.get('salary_max', '')) if salary_min and not salary_max: salary_max = MAX_SALARY if not salary_min and salary_max: salary_min = MIN_SALARY if salary_min > MAX_SALARY or salary_max > MAX_SALARY or salary_min > salary_max: return '' if salary_min < 0 or salary_max < 0 or (not salary_min and not salary_max): return '' return '%s,%s' % (salary_min, salary_max)
def query_admin(self): admin_id = get_int(self.request.GET.get('admin_id')) if admin_id == -1: return {} if not admin_id: return {'user__crm_client_info__admin_id': self.request.user.id} return {'user__crm_client_info__admin_id': admin_id}
def post(self, request): client_id = get_int(request.POST.get('client_id')) CRMClientInfo.objects.filter(client__id=client_id).update(admin=None) return JsonResponse({ 'status': 'ok', 'msg': '取消成功' })
def _get_week_point_point(self, user, *args, **kwargs): ''' 每周给用户添加聘点 每周一凌晨会给用户添加上一周使用的聘点 添加逻辑 计算出用户上一周消费的聘点(下载,企业名片发送和返点) 消费聘点大于每周配置聘点则给用户反每周配置聘点 消费聘点小于每周配置聘点则给用户返回消费聘点 ''' vip_user = kwargs.get('vip_user') role_point = vip_user.custom_point aggregate_record = user.pointrecord_set.filter( record_time__gte=get_previous_monday(), record_time__lt=get_monday(), record_type__in=['download_resume', 'accu_return_point', 'send_company_card'], ).aggregate( download_point=Sum('point'), ) download_points = abs(get_int(aggregate_record.get('download_point', 0) or 0)) if download_points >= role_point: return role_point return download_points
def get(self, request, uidb64, activation_key): if uidb64 is not None and activation_key is not None: uid = get_int(urlsafe_base64_decode(uidb64)) user = get_object_or_404(User, id=uid) ret = default_token_generator.check_token( user, activation_key ) if ret: user_profile = user.get_profile() user_profile.is_email_bind = True user_profile.guide_switch = True user_profile.save() # 开始登录 user.backend = 'django.contrib.auth.backends.ModelBackend' login(request, user) return render( request, self.template, { 'status': 'ok', 'msg': u'绑定接收邮箱成功', }, ) return render( request, self.template, { 'status': 'error', 'msg': u'无效的激活链接', } )
def deduction_self_point(self, user, uservip): active_time = uservip.active_time expire_time = uservip.expire_time uservip_point = uservip.vip_role.pinbot_point record_type_list = ( 'download_resume', 'accu_return_point', 'send_company_card', ) aggregate_record = user.pointrecord_set.filter( record_time__gte=active_time, record_time__lt=expire_time, record_type__in=record_type_list, ).aggregate( rest_point=Sum('point'), ) download_point = get_int(aggregate_record.get('rest_point', 0) or 0) rest_point = download_point + uservip_point if rest_point <= 0: return 'not_add', 0 pinbot_point = self._get_pinbot_point(user) current_point = pinbot_point.point rest_point = current_point if rest_point >= current_point else rest_point vip_name = uservip.vip_role.vip_name deduction_point = -rest_point record_type = 'deduction_self_point' detail = '{0}到期扣除聘点'.format(vip_name) point_rule = 'deduction_self_point' return self.add_point(user, deduction_point, record_type, detail, point_rule)
def get_query_keyword(self): keyword = self.request.GET.get('query', '') if not keyword: return {} user = self.request.user page = get_int(self.request.GET.get('page', 0)) page = 0 if page - 1 < 0 else page - 1 feed_id_list = UserAcceptTask.objects.filter( user=user, ).values_list( 'feed__feed_obj_id', flat=True, ) search_params = { 'start': 0, 'size': 100, 'feed_type': 1, 'keywords': keyword, 'ids_list': ','.join(list(feed_id_list)) } search_result = ParseUtils.search_job(search_params) feed_data = search_result.get('data', {}).get('results', []) return { 'feed__feed_obj_id__in': [i['id'] for i in feed_data if i.get('id')] }
def search_result(self, feed_id): request = self.request start = get_int(self.request.GET.get('start', 0)) read_id_list = UserReadResume.objects.filter( user=request.user, feed_id=str(feed_id)).values_list('resume_id') read_id_list = set([get_oid(res[0]) for res in read_id_list if res]) return feed_group_search_ajax(start, feed_id, read_id_list)
def post(self, request): payload = request.JSON bookin_type = get_int(payload.get('bookin_type')) if bookin_type not in [1, 2]: return JsonResponse({ 'status': 'error', 'msg': '报名失败,参数错误', }) userprofile = request.user.userprofile bookin = NewIndustryBookin( user=userprofile, type=bookin_type ) bookin.save() if bookin: return JsonResponse({ 'status': 'ok', 'msg': '报名成功', }) return JsonResponse({ 'status': 'error', 'msg': '报名失败,请重试', })
def get_mark_count(self): user_id = self.request.user.id query = ResumeBuyRecord.objects.raw( ''' SELECT `transaction_resumebuyrecord`.`id`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` IN ("invite_interview", "next_interview", "join_interview") THEN 1 ELSE 0 END ) AS `invite_interview`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "next_interview" THEN 1 ELSE 0 END ) AS `next_interview`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "send_offer" THEN 1 ELSE 0 END ) AS `send_offer`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "entry" THEN 1 ELSE 0 END ) AS `entry`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "eliminate" THEN 1 ELSE 0 END ) AS `eliminate`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "no_will" THEN 1 ELSE 0 END ) AS `no_will`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "break_invite" THEN 1 ELSE 0 END ) AS `break_invite`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "unconfirm" THEN 1 ELSE 0 END ) AS `unconfirm`, SUM( CASE WHEN `system_resumemarksetting`.`code_name` = "pending" THEN 1 ELSE 0 END ) AS `pending`, SUM( CASE WHEN `transaction_resumebuyrecord`.`status` = "LookUp" AND `transaction_downloadresumemark`.`id` is NULL THEN 1 ELSE 0 END ) AS `unmark`, count(*) AS `total` FROM `transaction_resumebuyrecord` LEFT OUTER JOIN `transaction_downloadresumemark` ON ( `transaction_resumebuyrecord`.`id` = `transaction_downloadresumemark`.`buy_record_id` ) LEFT OUTER JOIN `system_resumemarksetting` ON ( `transaction_downloadresumemark`.`current_mark_id` = `system_resumemarksetting`.`id` ) WHERE `transaction_resumebuyrecord`.`user_id` = %s ''', [user_id])[0] record = { 'total': query.total, 'invite_interview': query.invite_interview, 'next_interview': query.next_interview, 'send_offer': query.send_offer, 'entry': query.entry, 'eliminate': query.eliminate, 'no_will': query.no_will, 'pending': query.pending, 'break_invite': query.break_invite, 'unconfirm': query.unconfirm, 'unmark': query.unmark, } record = {key: get_int(value) for key, value in record.items()} return record
def post(self, request): money = get_int(request.POST.get('money') or 0) if money <= 0: return JsonResponse({ 'status': 'money_error', 'msg': '提现金额必须是大于0的整数', }) user = request.user pinbot_point = coin_utils._get_pinbot_point(user) if money > pinbot_point.coin: return JsonResponse({ 'status': 'no_coin', 'msg': '金币不足', }) now = datetime.datetime.now() has_withdraw = get_object_or_none( WithdrawRecord, user=user, verify_status__in=(0, 1), create_time__year=now.year, create_time__month=now.month, ) if has_withdraw: return JsonResponse({ 'status': 'has_withdraw', 'msg': '您本月已经提现过一次,请下个月再来', }) withdraw = WithdrawRecord.objects.create( user=user, money=money, ) order = UserOrder.objects.create( user=user, order_price=-money, actual_price=-money, item=withdraw, order_desc='提现', order_type=5, ) order.order_id = create_order_id() order.save() ItemRecord.objects.create( num=1, total_price=order.order_price, order=order, item=withdraw, ) return JsonResponse({ 'status': 'ok', 'msg': '提现请求提交成功', })
def api_post_data(self, post_data): post_data['company_prefer'] = list( CompanyCategoryPrefer.objects.filter(id__in=[ get_int(i) for i in post_data.get('company_prefer', []) if get_int(i) ]).values_list( 'code_name', flat=True, )) post_data['job_domain'] = list( CompanyCategory.objects.filter(id__in=[ get_int(i) for i in post_data.get('job_domain') if get_int(i) ]).values_list( 'category', flat=True, )) return post_data
def get_feed_list(self, feed_id): feed_id = get_oid(feed_id) if not feed_id: return [] page = get_int(self.request.GET.get('start', '0')) if page < 0: page = 0 query_cond = self.get_query_cond() query_cond.update({'feed': feed_id}) feed_result_list = FeedResult.objects( resume_source__ne='talent_partner', **query_cond).only(*self.only_fields).skip( self.page_count * page).limit(self.page_count).order_by( *self.get_sort_cond()).select_related() feed_result_dict_list = [] for f in feed_result_list: try: work_years = f.resume.get_work_years() feed_dict = mongo_to_dict(f, []) feed_result_dict_list.append(feed_dict) feed_dict['resume']['work_years'] = work_years except AttributeError: # 处理由于删除重复简历,导致的推荐结果缺失问题 django_log.error('resume not exists %s' % f.resume.id) continue feed_query_count = FeedResult.objects(**query_cond).count() tomorrow = get_tomommow() total_count = 13 * FeedResult.objects(feed=feed_id).count() total_recommend_count = FeedResult.objects( feed=feed_id, published=True, is_recommended=True, display_time__lt=tomorrow, ).count() newest_recommend_count = FeedResult.objects( feed=feed_id, user_read_status__ne='read', published=True, ).count() return { 'start': page, 'next_start': page + 1 if feed_result_dict_list else -1, 'data': feed_result_dict_list, 'total_recommend_count': total_recommend_count, 'total_count': total_count, 'newest_recommend_count': newest_recommend_count, 'feed_query_count': feed_query_count, }
def get_order_info(self): pid = get_int(self.request.GET.get('pid', '')) info_model = get_object_or_404(self.model, pk=pid) order_info = { 'price': info_model.price, 'product_name': info_model.product_name, 'product_type': info_model.get_product_type, } return order_info
def clean_feed_count(self): feed_service = self.data['feed_service'] if not feed_service: return 0 feed_count = get_int(self.data['feed_count']) if feed_count < 1: raise forms.ValidationError(u'订阅数至少需要一个') return feed_count
def post(self, request, record_id): operation = get_int(request.POST.get('operation') or 0) verify_remark = request.POST.get('verify_remark', '') if operation not in (1, 2): return JsonResponse({ 'result': 'fail', 'new_data': { 'offline_pay': u'请选择操作' }, 'new_html': { 'offline_pay': u'请选择操作' }, }) withdraw_record = get_object_or_none( WithdrawRecord, id=record_id, ) if not withdraw_record: return JsonResponse({ 'result': 'fail', 'new_data': { 'offline_pay': u'无法找到记录' }, 'new_html': { 'offline_pay': u'无法找到记录' }, }) user = withdraw_record.user pinbot_point = coin_utils._get_pinbot_point(user) if operation == 1 and pinbot_point.coin - withdraw_record.money < 0: return JsonResponse({ 'result': 'fail', 'new_data': { 'offline_pay': u'金币数不够' }, 'new_html': { 'offline_pay': u'金币数不够' }, }) self.save_withdraw_record(withdraw_record, operation, verify_remark) self.save_userorder(withdraw_record, operation, verify_remark) self.save_pinbot_coin(withdraw_record, operation) return JsonResponse({ 'result': 'success', 'new_data': { 'offline_pay': u'操作成功' }, 'new_html': { 'offline_pay': u'操作成功' }, })
def post(self, request, resume_task_id): coin = get_int(request.POST.get('coin')) if not coin: return JsonResponse({ 'result': 'form_error', 'new_data': {'offline_pay_success': u'金币错误'}, 'new_html': {'offline_pay_success': u'金币错误'}, }) user_task_resume = UserTaskResume.objects.select_related( 'task__feed', 'resume', 'resume__user', ).get( id=resume_task_id, ) self.grant_method( user_task_resume.task.feed.feed_obj_id, user_task_resume.resume.resume_id, coin, ) if self.grant_type == 'normal': user = user_task_resume.resume.user level_utils = PartnerLevelUtils(user) level_status = level_utils.get_taking_work_level() if level_status['level'] > 1: update_fields = { 'verify': False, 'extra_grant': True, } else: update_fields = { 'verify': False } UserTaskResume.objects.filter( id=resume_task_id, ).update( **update_fields ) if self.grant_type == 'extra': UserTaskResume.objects.filter( id=resume_task_id, ).update( extra_grant=False, ) return JsonResponse({ 'result': 'success', 'new_data': {'offline_pay_success': u'奖励成功'}, 'new_html': {'offline_pay_success': u'奖励成功'}, })
def get_db_query(self): query = {} source = self.request.GET.get('source', '') if source in ('51job', 'zhilian', 'talent_partner', 'brick'): query['source'] = source has_contact = self.request.GET.get('has_contact', '') if has_contact in ('0', '1'): query['candidate__has_contact'] = True if get_int(has_contact) else False admin_id = get_int(self.request.GET.get('admin_id', '')) if admin_id: query['candidate__admin__id'] = admin_id tag_list = self.request.GET.getlist('tag_list', []) if tag_list: query['candidate__tags__id__in'] = tag_list return query
def user_exp_state(self): ''' 根据用户的奖励记录返回用户的经验状态 返回: # 查看数量 check_count # 下载数量 download_count # 面试数量 interview_count # 入职数量 taking_work_count # 下载率 下载/查看 download_ratio # 面试率 面试/下载 interview_ratio 入职率 面试/入职 taking_work_ratio ''' exp_state = TaskCoinRecord.objects.raw(''' SELECT `partner_taskcoinrecord`.`id`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'check' THEN 1 ELSE 0 END) AS `check_count`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'download' THEN 1 ELSE 0 END) AS `download_count`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'interview' THEN 1 ELSE 0 END) AS `interview_count`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'taking_work' THEN 1 ELSE 0 END) AS `taking_work_count` FROM `partner_taskcoinrecord`, `partner_uploadresume` WHERE `partner_taskcoinrecord`.`upload_resume_id` = `partner_uploadresume`.`id` and `partner_uploadresume`.`user_id` = %s ''' % self.user.id)[0] exp_state.download_count = get_int(exp_state.download_count) exp_state.interview_count = get_int(exp_state.interview_count) exp_state.taking_work_count = get_int(exp_state.taking_work_count) exp_state.download_ratio = float(exp_state.download_count) / float( exp_state.check_count) if exp_state.check_count > 0 else 0 exp_state.interview_ratio = float(exp_state.interview_count) / float( exp_state.download_count) if exp_state.download_count > 0 else 0 exp_state.taking_work_ratio = float( exp_state.taking_work_count) / float( exp_state.interview_count ) if exp_state.interview_count > 0 else 0 return exp_state
def post(self, request, resume_task_id): coin = get_int(request.POST.get('coin')) if not coin: return JsonResponse({ 'result': 'form_error', 'new_data': { 'offline_pay_success': u'金币错误' }, 'new_html': { 'offline_pay_success': u'金币错误' }, }) user_task_resume = UserTaskResume.objects.select_related( 'task__feed', 'resume', 'resume__user', ).get(id=resume_task_id, ) self.grant_method( user_task_resume.task.feed.feed_obj_id, user_task_resume.resume.resume_id, coin, ) if self.grant_type == 'normal': user = user_task_resume.resume.user level_utils = PartnerLevelUtils(user) level_status = level_utils.get_taking_work_level() if level_status['level'] > 1: update_fields = { 'verify': False, 'extra_grant': True, } else: update_fields = {'verify': False} UserTaskResume.objects.filter( id=resume_task_id, ).update(**update_fields) if self.grant_type == 'extra': UserTaskResume.objects.filter(id=resume_task_id, ).update( extra_grant=False, ) return JsonResponse({ 'result': 'success', 'new_data': { 'offline_pay_success': u'奖励成功' }, 'new_html': { 'offline_pay_success': u'奖励成功' }, })
def get_age(birthday): if birthday is not None: birthday = birthday.replace('年', '-').replace('月', '-').replace('日', '') year = datetime.date.today().year if len(birthday.split('-')) >= 1: return year - get_int(birthday.split('-')[0]) else: return 20 else: return 0
def get_age(birthday): if birthday is not None: birthday = birthday.replace( '年', '-').replace('月', '-').replace('日', '') year = datetime.date.today().year if len(birthday.split('-')) >= 1: return year - get_int(birthday.split('-')[0]) else: return 20 else: return 0
def get(self, request): order_id = get_int(request.GET.get('obj_id', '')) UserOrder.objects.filter( id=order_id, user=request.user, ).update( is_delete=True, ) return JsonResponse({ 'status': 'ok', 'msg': 'ok' })
def user_exp_state(self): ''' 根据用户的奖励记录返回用户的经验状态 返回: # 查看数量 check_count # 下载数量 download_count # 面试数量 interview_count # 入职数量 taking_work_count # 下载率 下载/查看 download_ratio # 面试率 面试/下载 interview_ratio 入职率 面试/入职 taking_work_ratio ''' exp_state = TaskCoinRecord.objects.raw( ''' SELECT `partner_taskcoinrecord`.`id`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'check' THEN 1 ELSE 0 END) AS `check_count`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'download' THEN 1 ELSE 0 END) AS `download_count`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'interview' THEN 1 ELSE 0 END) AS `interview_count`, SUM(CASE WHEN `partner_taskcoinrecord`.`record_type` = 'taking_work' THEN 1 ELSE 0 END) AS `taking_work_count` FROM `partner_taskcoinrecord`, `partner_uploadresume` WHERE `partner_taskcoinrecord`.`upload_resume_id` = `partner_uploadresume`.`id` and `partner_uploadresume`.`user_id` = %s ''' % self.user.id )[0] exp_state.download_count = get_int(exp_state.download_count) exp_state.interview_count = get_int(exp_state.interview_count) exp_state.taking_work_count = get_int(exp_state.taking_work_count) exp_state.download_ratio = float(exp_state.download_count) / float(exp_state.check_count) if exp_state.check_count > 0 else 0 exp_state.interview_ratio = float(exp_state.interview_count) / float(exp_state.download_count) if exp_state.download_count > 0 else 0 exp_state.taking_work_ratio = float(exp_state.taking_work_count) / float(exp_state.interview_count) if exp_state.interview_count > 0 else 0 return exp_state
def get_order_info(self): order_id = get_int(self.request.GET.get('order_id', '')) order_record_query = ItemRecord.objects.filter( order__id=order_id, ) if not order_record_query: raise Http404 order_item = order_record_query[0].item order_info = { 'price': order_item.get_price(), 'product_name': order_item.get_product_name(), } return order_info
def post(self, request, task_id, resume_id): user = request.user now = datetime.datetime.now() task_query = UserAcceptTask.objects.select_related( 'feed', 'feed__user', ).filter( user=user, id=task_id, feed__deleted=False, feed__feed_expire_time__gt=now, ) if not task_query: raise Http404 task = task_query[0] task_resume_query = task.task_resumes.filter( resume__id=resume_id ) if not task_resume_query: raise Http404 task_resume = task_resume_query[0] msg_type = get_int(request.POST.get('msg_type', 0)) if msg_type not in self.notify_msg_meta.keys(): return JsonResponse({ 'status': 'form_error', 'msg': '请选择正确的站内信', }) self.set_send_cache(task_id, resume_id) follow_record = self.save_follow_record(task_resume) desc = self.notify_msg_meta[msg_type] % PartnerNotify.resume_follow_url(follow_record.id) PartnerNotify.follow_resume_notify( task.feed.user, desc, ) follow_record.desc = desc follow_record.save() return JsonResponse({ 'status': 'ok', 'msg': '跟进成功', })
def query_order_type(self, query_cond): record_type = get_int(self.request.GET.get('record_type', '')) query_keys = dict(UserOrder.ORDER_TYPE_META).keys() if record_type == -1: query_cond.update({'order_type__in': [1, 2, 3, 4, 6]}) return query_cond if record_type == -2: query_cond.update({'order_type': 5}) return query_cond if record_type not in query_keys: return query_cond query_cond.update({'order_type': record_type}) return query_cond
def get(self, request, feed_id): count = get_int(request.GET.get('recruit_num', '')) if not count: return JsonResponse({ 'status': 'count_error', 'msg': '招聘数量必须大于0', }) Feed.objects.filter( id=feed_id, ).update( recruit_num=count, ) return JsonResponse({ 'status': 'ok', 'msg': '修改成功', })