public function config() { $field = D('Ucenter/Score')->getTypeList(array('status' => 1)); $configBuilder = new AdminConfigBuilder(); $data = $configBuilder->callback('configCallback')->handleConfig(); $param = array(); $param['opt'] = $field; $de_data = $data['RE_FIELD']; $param['jsonData'] = $de_data; $param['data'] = json_decode($de_data, true); $param_w = array(); $param_w['opt'] = $field; $w_data = $data['WITHDRAW_FIELD']; $param_w['jsonData'] = $w_data; $param_w['data'] = json_decode($w_data, true); $configBuilder->title('充值设置')->data($data)->keyBool('OPEN_RECHARGE', '开启充值')->keyTextArea('RECHARGE_AMOUNT', '充值面额', '一行一个')->keyBool('CAN_INPUT', '允许自由充值')->keyText('MIN_AMOUNT', '最小充值面额,0为不限制,只对自由充值开启有效')->keyCheckBox('METHOD', '支付方式', '选择支付种类', array('alipay' => '支付宝'))->keyUserDefined('RE_FIELD', '支持充值的积分类型', '选择支持充值的积分类型和积分的兑率,如填写100则表示1RMB=100积分', T('Recharge@Recharge/config'), $param)->keyDefault('METHOD', 'alipay')->keyDefault('MIN_AMOUNT', 0)->keyBool('OPEN_WITHDRAW', '开启提现')->keyTextArea('WITHDRAW_AMOUNT', '提现面额', '一行一个')->keyBool('WITHDRAW_CAN_INPUT', '允许自由提现')->keyText('WITHDRAW_MIN_AMOUNT', '最小提现面额,0为不限制,只对自由提现开启有效')->keyCheckBox('WITHDRAW_METHOD', '支付方式', '选择支付种类', array('alipay' => '支付宝'))->keyUserDefined('WITHDRAW_FIELD', '支持提现的积分类型', '选择支持提现的积分类型和积分的兑率,如填写100则表示100积分=1RMB', T('Recharge@Recharge/config'), $param_w)->keyDefault('WITHDRAW_METHOD', 'alipay')->keyDefault('WITHDRAW_MIN_AMOUNT', 0)->group('充值设置', 'OPEN_RECHARGE,RECHARGE_AMOUNT,CAN_INPUT,MIN_AMOUNT,METHOD,RE_FIELD')->group('提现设置', 'OPEN_WITHDRAW,WITHDRAW_AMOUNT,WITHDRAW_CAN_INPUT,WITHDRAW_MIN_AMOUNT,WITHDRAW_METHOD,WITHDRAW_FIELD'); if (check_is_in_config('alipay', $data['METHOD'])) { $configBuilder->keyText('ALIPAY_PARTNER', '合作身份者id', '以2088开头的16位纯数字')->keyText('ALIPAY_SELLER_EMAIL', '收款支付宝账号')->keyText('ALIPAY_KEY', '安全检验码', '以数字和字母组成的32位字符')->group('支付宝配置', 'ALIPAY_PARTNER,ALIPAY_SELLER_EMAIL,ALIPAY_KEY'); } $configBuilder->buttonSubmit()->buttonBack(); $configBuilder->display(); }
protected function sendWeibo($aPostId, $isEdit, $group) { if (M('Module')->checkInstalled('Weibo')) { $postUrl = "http://{$_SERVER['HTTP_HOST']}" . U('Group/Index/detail', array('id' => $aPostId)); $post = M('GroupPost')->getPost($aPostId); $type = 'feed'; $feed_data = array(); //解析并成立图片数据 $arr = array(); preg_match_all("/<[img|IMG].*?src=[\\'|\"](.*?(?:[\\.gif|\\.jpg|\\.png]))[\\'|\"].*?[\\/]?>/", $post['content'], $arr); //匹配所有的图片 if (!empty($arr[0])) { $feed_data['attach_ids'] = array(); $dm = __ROOT__; //前缀图片多余截取 $max = count($arr[1]) > 9 ? 9 : count($arr[1]); for ($i = 0; $i < $max; $i++) { $tmparray = strpos($arr[1][$i], $dm); $is_local = !is_bool($tmparray); if ($is_local) { $path = cut_str($dm, $arr[1][$i], 'l'); $result_id = M('Home/Picture')->where(array('path' => $path))->getField('id'); } else { $path = $arr[1][$i]; $result_id = M('Home/Picture')->where(array('path' => $path))->getField('id'); } if (!$result_id) { $dr = ''; if (is_bool(strpos($path, 'http://'))) { $dr = 'local'; } $result_id = M('Home/Picture')->add(array('type' => $dr, 'path' => $path, 'url' => $path, 'status' => 1, 'create_time' => time())); } $feed_data['attach_ids'][] = $result_id; } $feed_data['attach_ids'] = implode(',', $feed_data['attach_ids']); } $feed_data['attach_ids'] != false && ($type = "image"); if (M('Common/Module')->isInstalled('Weibo')) { //安装了轻博客模块 if ($isEdit && check_is_in_config('edit_group_post', modC('GROUP_POST_SEND_WEIBO', 'add_group_post,edit_group_post', 'GROUP'))) { M('Weibo')->addWeibo(is_login(), "我在群组【{$group['title']}】里更新了帖子【" . $post['title'] . "】:" . $postUrl, $type, $feed_data); } if (!$isEdit && check_is_in_config('add_group_post', modC('GROUP_POST_SEND_WEIBO', 'add_group_post,edit_group_post', 'GROUP'))) { M('Weibo')->addWeibo(is_login(), "我在群组【{$group['title']}】里发表了一个新的帖子【" . $post['title'] . "】:" . $postUrl, $type, $feed_data); } } } }
private function createWithdraw() { $loginUid = is_login(); $this->checkActionLimit('create_withdraw', 'RechargeWithdraw', 0, $loginUid); if (!$loginUid) { $this->error('请登陆后再操作'); } $aAmount = I('post.amount', 0, 'floatval'); $aMethod = I('post.method', '', 'op_t'); $aField = I('post.field', '', 'intval'); $aAccountInfo = I('post.account_info', '', 'op_t'); if (strlen($aAccountInfo) <= 0) { $this->error('请填写完整的收款信息。'); } $method = modC('WITHDRAW_METHOD', 'alipay', 'recharge'); if (!check_is_in_config($aMethod, $method)) { $this->error('不支持该支付方式,请尝试其他支付方式'); } $aAmount = number_format($aAmount, 2, ".", ""); $minAmount = modC('WITHDRAW_MIN_AMOUNT', 0, 'recharge'); if ($aAmount <= 0) { $this->error('提现金额不能小于等于0。'); } $canInput = modC('WITHDRAW_CAN_INPUT', 1, 'recharge'); if ($canInput && $aAmount < $minAmount && $minAmount != 0) { $this->error('最小提现金额不能小于' . $minAmount . '。'); } $type = get_withdraw_type($aField); $memberModel = D('Member'); $score = $memberModel->where(array('uid' => $loginUid))->getField('score' . $aField); $forzen_count = $type['UNIT'] * $aAmount; if ($score - $forzen_count < 0) { $this->error('余额不足,无法提现。提现需' . $forzen_count . ',账户余额' . $score); } $result = $memberModel->where(array('uid' => $loginUid))->setDec('score' . $aField, $forzen_count); clean_query_user_cache($loginUid, 'score' . $aField); if (!$result) { $this->error('冻结账户余额失败。'); } $data['field'] = $aField; $data['amount'] = $aAmount; $data['method'] = $aMethod; $data['uid'] = $loginUid; $data['account_info'] = $aAccountInfo; $data['frozen_amount'] = $forzen_count; $withdraw_id = D('Withdraw')->addWithdraw($data); return $withdraw_id; }
public function createGroup() { $aGroupId = I('post.group_id', 0, 'intval'); $aGroupType = I('post.group_type', 0, 'intval'); $aTitle = I('post.title', '', 'text'); $aDetail = I('post.detail', '', 'text'); $aLogo = I('post.logo', 0, 'intval'); $aType = I('post.type', 0, 'intval'); $aBackground = I('post.background', 0, 'intval'); $aMemberAlias = I('post.member_alias', '成员', 'text'); if (empty($aTitle)) { $this->error('请填写群组名称'); } if (utf8_strlen($aTitle) > 20) { $this->error('群组名称最多20个字'); } if ($aGroupType == -1) { $this->error('请选择群组分类'); } if (empty($aDetail)) { $this->error('请填写群组介绍'); } $isEdit = $aGroupId ? true : false; if ($isEdit) { $this->requireLogin(); $this->requireGroupExists($aGroupId); $this->checkActionLimit('edit_group', 'Group', $aGroupId, is_login(), true); $this->checkAuth('Group/Index/editGroup', get_group_admin($aGroupId), '您无编辑群组权限'); } else { $this->checkActionLimit('add_group', 'Group', 0, is_login(), true); $this->checkAuth('Group/Index/addGroup', -1, '您无添加群组权限'); } $need_verify = modC('GROUP_NEED_VERIFY', 0, 'GROUP'); $model = D('Group/Group'); if ($isEdit) { $data = array('id' => $aGroupId, 'type_id' => $aGroupType, 'title' => $aTitle, 'detail' => $aDetail, 'logo' => $aLogo, 'type' => $aType, 'background' => $aBackground, 'member_alias' => $aMemberAlias); $data['status'] = $need_verify ? 0 : 1; $result = $model->editGroup($data); $group_id = $aGroupId; } else { $data = array('type_id' => $aGroupType, 'title' => $aTitle, 'detail' => $aDetail, 'logo' => $aLogo, 'type' => $aType, 'uid' => is_login(), 'background' => $aBackground, 'member_alias' => $aMemberAlias); $data['status'] = $need_verify ? 0 : 1; $result = $model->createGroup($data); if (!$result) { $this->error('创建群组失败:' . $model->getError()); } $group_id = $result; //向GroupMember表添加创建者成员 D('GroupMember')->addMember(array('uid' => is_login(), 'group_id' => $group_id, 'status' => 1, 'position' => 3)); } if ($need_verify) { $message = '创建成功,请耐心等候管理员审核。'; // 发送消息 D('Message')->sendMessage(1, get_nickname(is_login()) . "创建了群组【{$aTitle}】,快去审核吧。", '群组创建审核', U('admin/group/unverify'), is_login()); $this->success($message, U('group/index/index')); } // 发送微博 if (D('Module')->checkInstalled('Weibo')) { $postUrl = "http://{$_SERVER['HTTP_HOST']}" . U('Group/Index/group', array('id' => $group_id)); if ($isEdit && check_is_in_config('edit_group', modC('GROUP_SEND_WEIBO', 'add_group,edit_group', 'GROUP'))) { D('Weibo')->addWeibo(is_login(), "我修改了群组【" . $aTitle . "】:" . $postUrl); } if (!$isEdit && check_is_in_config('add_group', modC('GROUP_SEND_WEIBO', 'add_group,edit_group', 'GROUP'))) { D('Weibo')->addWeibo(is_login(), "我创建了一个新的群组【" . $aTitle . "】:" . $postUrl); } } //显示成功消息 $message = $isEdit ? '编辑成功。' : '发表成功。'; $url = $isEdit ? 'refresh' : U('group/index/group', array('id' => $group_id)); $this->success($message, $url); }