|
|
@ -44,13 +44,21 @@ class EnrollModuleUniapp extends Uniapp |
|
|
$form_data = $_GPC['form_data']; |
|
|
$form_data = $_GPC['form_data']; |
|
|
$template_type = $_GPC['template_type']; |
|
|
$template_type = $_GPC['template_type']; |
|
|
$activities_id = $_GPC['activities_id']; |
|
|
$activities_id = $_GPC['activities_id']; |
|
|
|
|
|
$enroll_data = $_GPC['enroll_data']; |
|
|
|
|
|
|
|
|
if (empty($diyformid) || !is_numeric($diyformid)) throw new Exception('表单id不能为空'); |
|
|
if (empty($diyformid) || !is_numeric($diyformid)) throw new Exception('表单id不能为空'); |
|
|
if (empty($form_data)) throw new Exception('表单数据不能为空'); |
|
|
if (empty($form_data)) throw new Exception('表单数据不能为空'); |
|
|
|
|
|
if (empty($enroll_data)) throw new Exception('表单填写数据不能为空'); |
|
|
if (empty($template_type)) throw new Exception('模板类型不能为空'); |
|
|
if (empty($template_type)) throw new Exception('模板类型不能为空'); |
|
|
if (!in_array($template_type,array_keys(FormTemplate::$template_type))) throw new Exception('模板类型数据错误'); |
|
|
if (!in_array($template_type,array_keys(FormTemplate::$template_type))) throw new Exception('模板类型数据错误'); |
|
|
if (empty($activities_id) || !is_numeric($activities_id)) throw new Exception('活动id不能为空'); |
|
|
if (empty($activities_id) || !is_numeric($activities_id)) throw new Exception('活动id不能为空'); |
|
|
|
|
|
|
|
|
|
|
|
$enroll_data = json_decode(html_entity_decode($enroll_data),true); |
|
|
|
|
|
foreach ($enroll_data as $item) { |
|
|
|
|
|
if (!isset($item['name'])) throw new Exception('表单填写数据字段不能为空'); |
|
|
|
|
|
if (!isset($item['value'])) throw new Exception('表单填写数据值不能为空'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$activitiesData = FormTemplate::getTemplateTableData($template_type,$activities_id); |
|
|
$activitiesData = FormTemplate::getTemplateTableData($template_type,$activities_id); |
|
|
if (empty($activitiesData)) throw new Exception('该活动不存在'); |
|
|
if (empty($activitiesData)) throw new Exception('该活动不存在'); |
|
|
|
|
|
|
|
|
@ -60,6 +68,8 @@ class EnrollModuleUniapp extends Uniapp |
|
|
$diyFormInfo = html_entity_decode($form_data); |
|
|
$diyFormInfo = html_entity_decode($form_data); |
|
|
$diyFormInfo = base64_encode($diyFormInfo); |
|
|
$diyFormInfo = base64_encode($diyFormInfo); |
|
|
|
|
|
|
|
|
|
|
|
// 开启事务 |
|
|
|
|
|
pdo_begin(); |
|
|
$insert = [ |
|
|
$insert = [ |
|
|
'uniacid' => $_W['uniacid'], |
|
|
'uniacid' => $_W['uniacid'], |
|
|
'mid' => $mid, |
|
|
'mid' => $mid, |
|
|
@ -70,8 +80,21 @@ class EnrollModuleUniapp extends Uniapp |
|
|
'create_time' => date("Y-m-d H:i:s",time()) |
|
|
'create_time' => date("Y-m-d H:i:s",time()) |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
pdo_insert(PDO_NAME . 'member_enroll',$insert); |
|
|
$insertRes = pdo_insert(PDO_NAME . 'member_enroll',$insert); |
|
|
|
|
|
if (!$insertRes) { |
|
|
|
|
|
pdo_rollback(); |
|
|
|
|
|
throw new Exception('报名失败'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$enroll_id = pdo_insertid(); |
|
|
|
|
|
|
|
|
|
|
|
$createRes = MemberEnrollData::create($enroll_data,$enroll_id); |
|
|
|
|
|
if (!$createRes) { |
|
|
|
|
|
pdo_rollback(); |
|
|
|
|
|
throw new Exception('报名失败'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pdo_commit(); |
|
|
$this->renderSuccess('报名成功'); |
|
|
$this->renderSuccess('报名成功'); |
|
|
} catch (Exception $e) { |
|
|
} catch (Exception $e) { |
|
|
$this->renderError($e->getMessage()); |
|
|
$this->renderError($e->getMessage()); |
|
|
|