/**
  * 登记债权转让
  * @param int $transfer_id  转让id
  * @param int $t_user_id  受让用户ID
  * @return string
  */
 public function RegisterCretansfer()
 {
     //echo 'sss'; exit;
     $transfer_id = intval(strim($_REQUEST['id']));
     $t_user_id = intval(strim($_REQUEST['t_user_id']));
     $paypassword = strim($_REQUEST['paypassword']);
     require_once APP_ROOT_PATH . "app/Lib/deal_func.php";
     //print_r($_REQUEST);
     //常用状态检查
     $result = check_trans($transfer_id, $paypassword);
     //print_r($result); exit;
     if ($result['status'] == 0) {
         showErr($result['show_err'], 0);
     } else {
         $transfer = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_load_transfer where id = " . $transfer_id);
         $deal_id = intval($transfer['deal_id']);
         $user_id = intval($transfer['user_id']);
         $deal = get_deal($deal_id, 0);
         // $GLOBALS['db']->getRow("select * from ".DB_PREFIX."deal where id = ".$deal_id);
         if (!empty($deal)) {
             if (!empty($deal['ips_bill_no'])) {
                 $user = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $user_id);
                 $tuser = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $t_user_id);
                 if (empty($user['ips_acct_no']) || empty($tuser['ips_acct_no'])) {
                     showErr('有一方未申请 ips 帐户', 0);
                 } else {
                     $class_name = 'Ips';
                     require_once APP_ROOT_PATH . "system/collocation/" . $class_name . "_collocation.php";
                     $collocation_class = $class_name . "_collocation";
                     $collocation_object = new $collocation_class();
                     $collocation_code = $collocation_object->RegisterCretansfer($transfer_id, $t_user_id);
                     print_r($collocation_code);
                 }
             } else {
                 showErr('该标还未发布托管登记', 0);
             }
         } else {
             showErr('标的ID不存在:' . $deal_id, 0);
         }
     }
 }
Esempio n. 2
0
    } elseif (get_post('PayType') == PT_SUPPLIER && !get_post('person_id')) {
        display_error(_("You have to select supplier."));
        set_focus('person_id');
        $input_error = 1;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['bank_account']), $_POST['date_'], true)) {
        $input_error = 1;
    }
    if (isset($_POST['settled_amount']) && in_array(get_post('PayType'), array(PT_SUPPLIER, PT_CUSTOMER)) && input_num('settled_amount') <= 0) {
        display_error(_("Settled amount have to be positive number."));
        set_focus('person_id');
        $input_error = 1;
    }
    return $input_error;
}
if (isset($_POST['Process']) && !check_trans()) {
    begin_transaction();
    $_SESSION['pay_items'] =& $_SESSION['pay_items'];
    $new = $_SESSION['pay_items']->order_id == 0;
    add_new_exchange_rate(get_bank_account_currency(get_post('bank_account')), get_post('date_'), input_num('_ex_rate'));
    $trans = write_bank_transaction($_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id, $_POST['bank_account'], $_SESSION['pay_items'], $_POST['date_'], $_POST['PayType'], $_POST['person_id'], get_post('PersonDetailID'), $_POST['ref'], $_POST['memo_'], true, input_num('settled_amount', null));
    $trans_type = $trans[0];
    $trans_no = $trans[1];
    new_doc_date($_POST['date_']);
    $_SESSION['pay_items']->clear_items();
    unset($_SESSION['pay_items']);
    commit_transaction();
    if ($new) {
        meta_forward($_SERVER['PHP_SELF'], $trans_type == ST_BANKPAYMENT ? "AddedID={$trans_no}" : "AddedDep={$trans_no}");
    } else {
        meta_forward($_SERVER['PHP_SELF'], $trans_type == ST_BANKPAYMENT ? "UpdatedID={$trans_no}" : "UpdatedDep={$trans_no}");
Esempio n. 3
0
function dotrans($id, $paypassword)
{
    $paypassword = strim($paypassword);
    $id = intval($id);
    $root = array();
    $root["status"] = 0;
    //0:出错;1:正确;
    $result = check_trans($id, $paypassword);
    if ($result['status'] == 0) {
        $root["show_err"] = $result["show_err"];
        return $root;
    }
    if ($result['status'] == 2) {
        $root["status"] = 2;
        $root["jump"] = APP_ROOT . "/index.php?ctl=collocation&act=RegisterCretansfer&id={$id}&t_user_id=" . $GLOBALS['user_info']['id'] . "&paypassword="******"transfer"];
    $deal_id = $result["deal_id"];
    if ($transfer) {
        if (floatval($transfer['transfer_amount']) > floatval($GLOBALS['user_info']['money'])) {
            $root["show_err"] = "账户余额不足";
            return $root;
        }
        $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_load_transfer set t_user_id = " . $GLOBALS['user_info']['id'] . ",transfer_time='" . TIME_UTC . "' WHERE id=" . $id . " and t_user_id =0 AND status=1 AND near_repay_time- " . TIME_UTC . " + 24*3600 - 1 > 0 ");
        if ($GLOBALS['db']->affected_rows()) {
            require APP_ROOT_PATH . "/system/libs/user.php";
            //承接人扣除转让费
            modify_account(array("money" => -floatval($transfer['transfer_amount'])), $GLOBALS['user_info']['id'], "债:Z-" . $transfer['load_id'] . ",承接金");
            //转让人接受转让费
            modify_account(array("money" => floatval($transfer['transfer_amount'])), $transfer['user_id'], "债:Z-" . $transfer['load_id'] . ",转让金");
            $user_load_transfer_fee = $GLOBALS['db']->getOne("SELECT user_load_transfer_fee FROM " . DB_PREFIX . "deal WHERE id=" . $deal_id);
            //扣除转让人的手续费
            if (trim($user_load_transfer_fee) != "") {
                $transfer_fee = $transfer['transfer_amount'] * floatval(trim($user_load_transfer_fee));
                if ($transfer_fee != 0) {
                    $transfer_fee = $transfer_fee / 100;
                }
                modify_account(array("money" => -floatval($transfer_fee)), $transfer['user_id'], "债:Z-" . $transfer['load_id'] . ",转让管理费");
            }
            dotrans_ok($id);
            $root["status"] = 1;
            //0:出错;1:正确;
            $root["show_err"] = "转让成功";
            return $root;
        } else {
            $root["show_err"] = "转让失败";
            return $root;
        }
    } else {
        $root["show_err"] = "债权转让不存在";
        return $root;
    }
}