/** * 编辑邀请码类型 * @author 郑钟良<*****@*****.**> */ public function edit() { $aId = I('id', 0, 'intval'); $is_edit = $aId ? 1 : 0; $title = $is_edit ? L('_EDIT_') : L('_NEW_'); if (IS_POST) { $data['title'] = I('post.title', '', 'op_t'); $data['length'] = I('post.length', 0, 'intval'); $data['time_num'] = I('post.time_num', 0, 'intval'); $data['time_unit'] = I('post.time_unit', 'second', 'op_t'); $data['cycle_num'] = I('post.cycle_num', 0, 'intval'); $data['cycle_time_num'] = I('post.cycle_time_num', 0, 'intval'); $data['cycle_time_unit'] = I('post.cycle_time_unit', 'second', 'op_t'); $data['roles'] = I('post.roles', array()); $data['auth_groups'] = I('post.auth_groups', array()); $data['pay_score_type'] = I('post.pay_score_type', 1, 'intval'); $data['pay_score'] = I('post.pay_score', 0, 'intval'); $data['income_score_type'] = I('post.income_score_type', 1, 'intval'); $data['income_score'] = I('post.income_score', 0, 'intval'); $data['is_follow'] = I('post.is_follow', 0, 'intval'); if ($is_edit) { $data['id'] = $aId; $result = $this->inviteTypeModel->saveData($data); } else { $result = $this->inviteTypeModel->addData($data); } if ($result) { $this->success($title . L('_INVITATION_CODE_TYPE_SUCCESS_'), U('Invite/index')); } else { $this->error($title . L('_INVITATION_CODE_TYPE_FAILED_') . $this->inviteTypeModel->getError()); } } else { if ($is_edit) { $map['id'] = $aId; $data = $this->inviteTypeModel->getData($map); $data['time'] = explode(' ', $data['time']); $data['time_num'] = $data['time'][0]; $data['time_unit'] = $data['time'][1]; $data['cycle_time'] = explode(' ', $data['cycle_time']); $data['cycle_time_num'] = $data['cycle_time'][0]; $data['cycle_time_unit'] = $data['cycle_time'][1]; } $data['length'] = $data['length'] ? $data['length'] : 11; $score_option = $this->_getMemberScoreType(); $role_option = $this->_getRoleOption(); $auth_group_option = $this->_getAuthGroupOption(); $is_follow_option = array(0 => L('_NO_'), 1 => L('_YES_')); $builder = new AdminConfigBuilder(); $builder->title($title . L('_INVITATION_CODE_TYPE_')); $builder->keyId()->keyTitle()->keyText('length', L('_INVITE_CODE_LENGTH_'))->keyMultiInput('time_num|time_unit', L('_LONG_'), L('_TIME_UNIT_'), array(array('type' => 'text', 'style' => 'width:295px;margin-right:5px'), array('type' => 'select', 'opt' => get_time_unit(), 'style' => 'width:100px')))->keyInteger('cycle_num', L('_PERIOD_CAN_BUY_A_FEW_'))->keyMultiInput('cycle_time_num|cycle_time_unit', L('_PERIOD_IS_LONG_'), L('_TIME_UNIT_'), array(array('type' => 'text', 'style' => 'width:295px;margin-right:5px'), array('type' => 'select', 'opt' => get_time_unit(), 'style' => 'width:100px')))->keyChosen('roles', L('_BINDING_IDENTITY_'), '', $role_option)->keyChosen('auth_groups', L('_ALLOWS_USERS_TO_BUY_'), '', $auth_group_option)->keyMultiInput('pay_score_type|pay_score', L('_EVERY_INVITATION_AMOUNT_'), L('_SCORE_NUMBER_'), array(array('type' => 'select', 'opt' => $score_option, 'style' => 'width:100px;margin-right:5px'), array('type' => 'text', 'style' => 'width:295px')))->keyMultiInput('income_score_type|income_score', L('_EACH_INVITATION_WAS_SUCCESSFUL_'), L('_SCORE_NUMBER_'), array(array('type' => 'select', 'opt' => $score_option, 'style' => 'width:100px;margin-right:5px'), array('type' => 'text', 'style' => 'width:295px')))->keyRadio('is_follow', L('_SUCCESS_IS_CONCERNED_WITH_EACH_OTHER_'), '', $is_follow_option)->buttonSubmit()->buttonBack()->data($data)->display(); } }
/** * 编辑邀请码类型 * @author 郑钟良<*****@*****.**> */ public function edit() { $aId = I('id', 0, 'intval'); $is_edit = $aId ? 1 : 0; $title = $is_edit ? "编辑" : "新增"; if (IS_POST) { $data['title'] = I('post.title', '', 'op_t'); $data['length'] = I('post.length', 0, 'intval'); $data['time_num'] = I('post.time_num', 0, 'intval'); $data['time_unit'] = I('post.time_unit', 'second', 'op_t'); $data['cycle_num'] = I('post.cycle_num', 0, 'intval'); $data['cycle_time_num'] = I('post.cycle_time_num', 0, 'intval'); $data['cycle_time_unit'] = I('post.cycle_time_unit', 'second', 'op_t'); $data['roles'] = I('post.roles', array()); $data['auth_groups'] = I('post.auth_groups', array()); $data['pay_score_type'] = I('post.pay_score_type', 1, 'intval'); $data['pay_score'] = I('post.pay_score', 0, 'intval'); $data['income_score_type'] = I('post.income_score_type', 1, 'intval'); $data['income_score'] = I('post.income_score', 0, 'intval'); $data['is_follow'] = I('post.is_follow', 0, 'intval'); if ($is_edit) { $data['id'] = $aId; $result = $this->inviteTypeModel->saveData($data); } else { $result = $this->inviteTypeModel->addData($data); } if ($result) { $this->success($title . '邀请码类型成功!', U('Invite/index')); } else { $this->error($title . '邀请码类型失败!' . $this->inviteTypeModel->getError()); } } else { if ($is_edit) { $map['id'] = $aId; $data = $this->inviteTypeModel->getData($map); $data['time'] = explode(' ', $data['time']); $data['time_num'] = $data['time'][0]; $data['time_unit'] = $data['time'][1]; $data['cycle_time'] = explode(' ', $data['cycle_time']); $data['cycle_time_num'] = $data['cycle_time'][0]; $data['cycle_time_unit'] = $data['cycle_time'][1]; } $data['length'] = $data['length'] ? $data['length'] : 11; $score_option = $this->_getMemberScoreType(); $role_option = $this->_getRoleOption(); $auth_group_option = $this->_getAuthGroupOption(); $is_follow_option = array(0 => '否', 1 => '是'); $builder = new AdminConfigBuilder(); $builder->title($title . '邀请码类型'); $builder->keyId()->keyTitle()->keyText('length', '邀请码长度')->keyMultiInput('time_num|time_unit', '有效时长', '时间+单位', array(array('type' => 'text', 'style' => 'width:295px;margin-right:5px'), array('type' => 'select', 'opt' => get_time_unit(), 'style' => 'width:100px')))->keyInteger('cycle_num', '周期内可购买个数')->keyMultiInput('cycle_time_num|cycle_time_unit', '周期时长', '时间+单位', array(array('type' => 'text', 'style' => 'width:295px;margin-right:5px'), array('type' => 'select', 'opt' => get_time_unit(), 'style' => 'width:100px')))->keyChosen('roles', '绑定角色', '', $role_option)->keyChosen('auth_groups', '允许购买的用户组', '', $auth_group_option)->keyMultiInput('pay_score_type|pay_score', '每个邀请额度消费', '积分类型+个数', array(array('type' => 'select', 'opt' => $score_option, 'style' => 'width:100px;margin-right:5px'), array('type' => 'text', 'style' => 'width:295px')))->keyMultiInput('income_score_type|income_score', '每个邀请成功后获得', '积分类型+个数', array(array('type' => 'select', 'opt' => $score_option, 'style' => 'width:100px;margin-right:5px'), array('type' => 'text', 'style' => 'width:295px')))->keyRadio('is_follow', '成功后是否互相关注', '', $is_follow_option)->buttonSubmit()->buttonBack()->data($data)->display(); } }
function warning($item, $val) { $this->state = false; $this->info = '操作频繁,请' . $val['time_number'] . get_time_unit($val['time_unit']) . '后再试'; $this->url = U('home/index/index'); }
function warning($item, $val) { $this->state = false; $this->info = L('_OPERATION_IS_FREQUENT_PLEASE_') . $val['time_number'] . get_time_unit($val['time_unit']) . L('_AND_THEN_'); $this->url = U('home/index/index'); }
private function getTimeUnit() { return get_time_unit(); }