|
@@ -24,6 +24,7 @@ from io import BytesIO
|
|
from config import settings
|
|
from config import settings
|
|
from common import YzyApi
|
|
from common import YzyApi
|
|
from extensions import logger
|
|
from extensions import logger
|
|
|
|
+from common.enc import mpfun
|
|
|
|
|
|
router = APIRouter()
|
|
router = APIRouter()
|
|
|
|
|
|
@@ -74,4 +75,83 @@ async def get_qrcode2(
|
|
'''
|
|
'''
|
|
detail_url = "{}{}".format(settings.YZY_WEB_ROOT, redirect_url)
|
|
detail_url = "{}{}".format(settings.YZY_WEB_ROOT, redirect_url)
|
|
|
|
|
|
- return RedirectResponse(detail_url)
|
|
|
|
|
|
+ return RedirectResponse(detail_url)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@router.post("/check")
|
|
|
|
+async def check(
|
|
|
|
+ request: Request,
|
|
|
|
+ db: Session = Depends(get_db),
|
|
|
|
+ body = Depends(remove_xss_json)
|
|
|
|
+):
|
|
|
|
+ time.sleep(2.0)
|
|
|
|
+
|
|
|
|
+ event_id = body['event_id']
|
|
|
|
+ nick_name = body['nick_name']
|
|
|
|
+ dept_name = body['dept_name']
|
|
|
|
+ phone = body['phone']
|
|
|
|
+ duties = body['duties']
|
|
|
|
+ type_ = body['type']
|
|
|
|
+
|
|
|
|
+ dept_id = 0
|
|
|
|
+ yzy_account = ''
|
|
|
|
+ contact_info = db.query(EmergencyContactInfo).filter(and_(EmergencyContactInfo.del_flag == "0", EmergencyContactInfo.yue_gov_ease_phone == mpfun.enc_data(phone))).first()
|
|
|
|
+ if contact_info is not None:
|
|
|
|
+ yzy_account = phone
|
|
|
|
+ contact_info = get_model_dict(contact_info)
|
|
|
|
+ dept_id = contact_info['unit_id']
|
|
|
|
+
|
|
|
|
+ if type_ == '1':
|
|
|
|
+ # 签名
|
|
|
|
+ row = db.query(EventCheckin).filter(and_(EventCheckin.event_id == event_id, EventCheckin.phone == phone)).first()
|
|
|
|
+ if row is None:
|
|
|
|
+ event_checkin = EventCheckin(
|
|
|
|
+ event_id = event_id,
|
|
|
|
+ user_id = 0,
|
|
|
|
+ user_name = '',
|
|
|
|
+ nick_name = nick_name,
|
|
|
|
+ dept_id = dept_id,
|
|
|
|
+ dept_name = dept_name,
|
|
|
|
+ sign_time = datetime.now(),
|
|
|
|
+ yzy_account = yzy_account,
|
|
|
|
+ duties = duties,
|
|
|
|
+ phone = phone,
|
|
|
|
+ del_flag = '0'
|
|
|
|
+ )
|
|
|
|
+ db.add(event_checkin)
|
|
|
|
+ db.commit()
|
|
|
|
+ db.refresh(row)
|
|
|
|
+ else:
|
|
|
|
+ row.sign_time = datetime.now()
|
|
|
|
+ row.nick_name = nick_name
|
|
|
|
+ row.dept_name = dept_name
|
|
|
|
+ row.duties = duties
|
|
|
|
+ row.phone = phone
|
|
|
|
+ row.del_flag = '0'
|
|
|
|
+ db.commit()
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ 'code': 200,
|
|
|
|
+ 'msg': '签到成功',
|
|
|
|
+ 'data': {
|
|
|
|
+ 'sign_time': get_datetime_str(row.sign_time)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ elif type_ == '2':
|
|
|
|
+ # 取消签名
|
|
|
|
+ row = db.query(EventCheckin).filter(and_(EventCheckin.event_id == event_id, EventCheckin.phone == phone)).first()
|
|
|
|
+ if row is None:
|
|
|
|
+ return {
|
|
|
|
+ 'code': 200,
|
|
|
|
+ 'msg': '签退成功'
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ row.sign_time = datetime.now()
|
|
|
|
+ row.del_flag = '1'
|
|
|
|
+ db.commit()
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ 'code': 200,
|
|
|
|
+ 'msg': '签退成功'
|
|
|
|
+ }
|