Example #1
0
 /**
  * 操作数据库
  * @param int $tid 帖子id
  * @param int $fid 版块id
  */
 function insertData($tid, $fid)
 {
     /*操作数据库*/
     global $action, $atc_title;
     $this->data['default'] = $this->data['act']['0'];
     $this->data['default']['tid'] = $tid;
     $this->data['default']['fid'] = $fid;
     $this->data['default']['actmid'] = $this->actmid;
     $this->data['user'] = array();
     !S::isArray($this->data['act']['1']) && ($this->data['act']['1'] = array());
     foreach ($this->data['act']['1'] as $key => $value) {
         if ($value) {
             $this->data['user'][$key] = $value;
         }
     }
     $this->data['user']['tid'] = $tid;
     $this->data['user']['fid'] = $fid;
     unset($this->data['act']);
     $defaultValueTableName = getActivityValueTableNameByActmid();
     $userDefinedValueTableName = getActivityValueTableNameByActmid($this->actmid, 1, 1);
     $this->db->pw_update("SELECT tid FROM {$defaultValueTableName} WHERE tid=" . S::sqlEscape($tid), "UPDATE {$defaultValueTableName} SET " . S::sqlSingle($this->data['default']) . "WHERE tid=" . S::sqlEscape($tid), "INSERT INTO {$defaultValueTableName} SET " . S::sqlSingle($this->data['default']));
     $this->db->pw_update("SELECT tid FROM {$userDefinedValueTableName} WHERE tid=" . S::sqlEscape($tid), "UPDATE {$userDefinedValueTableName} SET " . S::sqlSingle($this->data['user']) . "WHERE tid=" . S::sqlEscape($tid), "INSERT INTO {$userDefinedValueTableName} SET " . S::sqlSingle($this->data['user']));
     $subject = $this->db->get_value('SELECT subject FROM pw_threads WHERE tid=' . S::sqlEscape($tid));
     if ($subject) {
         $this->db->update('UPDATE pw_activitypaylog SET subject=' . S::sqlEscape($subject) . ' WHERE tid=' . S::sqlEscape($tid));
     }
     /*选择支付宝+没有绑定支付宝+没有通过支付宝实名认证 or 创建AA活动号*/
     if ($this->data['default']['paymethod'] == 1) {
         $tradeinfo = $this->db->get_one("SELECT tradeinfo FROM pw_memberinfo WHERE uid=" . S::sqlEscape($this->winduid));
         $tradeinfo = unserialize($tradeinfo['tradeinfo']);
         $alipay = $tradeinfo['alipay'];
         $isBinded = $tradeinfo['isbinded'];
         $isCertified = $tradeinfo['iscertified'];
         if (!$alipay || $isBinded != 'T' || $isCertified != 'T') {
             //选择支付宝+没有绑定支付宝+没有通过支付宝实名认证
             $this->db->update("UPDATE {$defaultValueTableName} SET iscertified=0 WHERE tid=" . S::sqlEscape($tid));
         } elseif ($alipay && $isBinded == 'T' && $isCertified == 'T') {
             //绑定支付宝+通过支付宝实名认证
             $this->db->update("UPDATE {$defaultValueTableName} SET iscertified=1 WHERE tid=" . S::sqlEscape($tid));
             require_once R_P . 'lib/activity/alipay_push.php';
             $alipayPush = new AlipayPush();
             if ($action == 'new') {
                 $alipayPush->create_aa_payment($tid, $this->winduid, $this->actmid, $atc_title);
                 //创建AA活动号
             } elseif ($action == 'modify') {
                 $alipayPush->modify_aa_payment($tid, $this->actmid, $atc_title);
                 //修改AA活动号
             }
         }
     }
     /*选择支付宝+没有绑定支付宝+没有通过支付宝实名认证 or 创建AA活动号*/
     /*附件上传*/
     L::loadClass('activityupload', 'upload', false);
     $img = new ActivityUpload($tid, $this->actmid);
     PwUpload::upload($img);
     require_once R_P . 'require/functions.php';
     pwFtpClose($GLOBALS['ftp']);
 }
        $signupermsg = $memberdb['isadditional'] ? 'activity_payed2_signuper_content' : 'activity_payed_signuper_content';
        M::sendNotice(array($memberdb['username']), array('title' => getLangInfo('writemsg', 'activity_payed_signuper_title', array('uid' => $memberdb['authorid'], 'username' => $memberdb['author'], 'tid' => $tid, 'subject' => $memberdb['subject'], 'totalcash' => $memberdb['totalcash'])), 'content' => getLangInfo('writemsg', $signupermsg, array('uid' => $memberdb['fromuid'], 'username' => $memberdb['fromusername'], 'tid' => $tid, 'subject' => $memberdb['subject'], 'totalcash' => $memberdb['totalcash']))), 'notice_active', 'notice_active');
    }
    paymsg("read.php?tid={$tid}", 'act_aa_detail_success');
} elseif ($action == 'refund_aa_payment') {
    //退款
    S::gp(array('is_success', 'out_trade_no', 'refund_fee'));
    //创建订单有问题。
    $is_success != 'T' && paymsg("read.php?tid={$tid}", 'act_refund_alipay_fail');
    list(, $tid, $actuid) = explode("_", $out_trade_no);
    $ifpay = $db->get_value("SELECT ifpay FROM pw_activitymembers WHERE actuid=" . S::sqlEscape($actuid));
    if ($ifpay != 1) {
        //未收到支付通知,但退款通知过来
        /*查询订单状态*/
        require_once R_P . 'lib/activity/alipay_push.php';
        $alipayPush = new AlipayPush();
        $alipayPush->query_aa_detail_payment($tid, $actuid);
        /*查询订单状态*/
    }
    $memberdb = $db->get_one("SELECT am.ifpay,am.actmid,am.uid,am.username,am.totalcash,am.refundreason,am.refundcost,am.totalcash,am.isadditional,am.isrefund,t.subject,t.authorid,t.author FROM pw_activitymembers am LEFT JOIN pw_threads t ON am.tid=t.tid WHERE actuid=" . S::sqlEscape($actuid));
    $memberdb['ifpay'] != 1 && paymsg("read.php?tid={$tid}", 'act_refund_fail');
    if ($memberdb['isrefund']) {
        //退款交易无法操作
        paymsg("read.php?tid={$tid}", 'act_undefined_operate');
    }
    $defaultValueTableName = getActivityValueTableNameByActmid();
    $defaultValue = $db->get_one("SELECT paymethod FROM {$defaultValueTableName} WHERE tid=" . S::sqlEscape($tid));
    $defaultValue['paymethod'] != 1 && paymsg("read.php?tid={$tid}", 'act_undefined_operate');
    //只有支付方式为支付宝才可以退款
    $tempcost = $db->get_value("SELECT SUM(totalcash) as sum FROM pw_activitymembers WHERE isrefund=1 AND fupid=" . S::sqlEscape($actuid));
    if ($refund_fee > number_format($memberdb['totalcash'] - $tempcost, 2, '.', '')) {
Example #3
0
 /**
  * 返回活动是否认证
  * @param array $data 字段的数据 形如array(int 行ID => array(int 字段ID => array 字段内容))
  * @param int $tid 帖子id
  * @param int $actmid 分类id
  * @return string HTML
  * @access private
  */
 function isCertified($data, $tid, $actmid)
 {
     global $subject, $tdtime;
     $isCertifiedHtml = '';
     $signupStaus = true;
     $defaultValueTableName = getActivityValueTableNameByActmid();
     if (!$data['iscertified'] && $data['paymethod'] == 1) {
         $tradeinfo = $this->db->get_value("SELECT tradeinfo FROM pw_memberinfo WHERE uid=" . S::sqlEscape($data['authorid']));
         $tradeinfo = unserialize($tradeinfo);
         $alipay = $tradeinfo['alipay'];
         $isBinded = $tradeinfo['isbinded'];
         $isCertified = $tradeinfo['iscertified'];
         if ($isBinded != 'T') {
             //尚未绑定
             if ($data['authorid'] == $this->winduid) {
                 $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_unbind_alipay') . '</p>';
             } else {
                 $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_author_unbind') . '</p>';
             }
         } elseif ($isCertified != 'T') {
             //尚未实名认证
             require_once R_P . 'lib/activity/alipay_push.php';
             $alipayPush = new AlipayPush();
             $is_success = $alipayPush->user_query($data['authorid']);
             //查询是否实名认证
             if ($is_success != 'T') {
                 if ($data['authorid'] == $this->winduid) {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_unauth_alipay') . '</p>';
                 } else {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_author_unpass') . '</p>';
                 }
             } else {
                 $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_activity_unNo') . '</p>';
                 $this->db->update("UPDATE {$defaultValueTableName} SET iscertified=1 WHERE tid=" . S::sqlEscape($tid));
                 //活动通过认证
             }
         } else {
             $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_activity_unNo') . '</p>';
             $this->db->update("UPDATE {$defaultValueTableName} SET iscertified=1 WHERE tid=" . S::sqlEscape($tid));
             //活动通过认证
         }
         $signupStaus = false;
     } elseif ($data['iscertified'] && !$data['batch_no'] && $data['paymethod'] == 1) {
         require_once R_P . 'lib/activity/alipay_push.php';
         $alipayPush = new AlipayPush();
         $certStatus = $alipayPush->create_aa_payment($tid, $data['authorid'], $actmid, $subject);
         //创建AA活动号
         if ($certStatus != 'T') {
             if ($certStatus == 'AA_FAIL_TO_CREATE_AA_NOT_T') {
                 if ($data['authorid'] == $this->winduid) {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_alipayinfo_un') . '</p>';
                 } else {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_alipayAccount') . '</p>';
                 }
             } elseif ($certStatus == 'AA_FAIL_TO_CREATE_AA_FREEZED') {
                 if ($data['authorid'] == $this->winduid) {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_alipay_freeze') . '</p>';
                 } else {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_author_freeze') . '</p>';
                 }
             } elseif ($certStatus == 'AA_FAIL_TO_CREATE_AA_NEED_CERTIFY') {
                 if ($data['authorid'] == $this->winduid) {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_unauth_alipay') . '</p>';
                 } else {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_alipayAccount') . '</p>';
                 }
             } elseif ($certStatus == 'AA_FAIL_TO_CREATE_AA_BEYOND_LIMIT' && $data['signupstarttime'] > $tdtime && $data['signupstarttime'] < $tdtime + 86400) {
                 //报名时间不是今天
                 if ($data['authorid'] == $this->winduid) {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_max_activity') . '</p>';
                 } else {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_max_activity2') . '</p>';
                 }
             } else {
                 if ($data['authorid'] == $this->winduid) {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_fail_No') . '</p>';
                 } else {
                     $isCertifiedHtml .= '<p class="aa_err">' . getLangInfo('other', 'act_err_system_error') . '</p>';
                 }
             }
             $signupStaus = false;
         }
     }
     return array($signupStaus, $isCertifiedHtml);
 }