Пример #1
0
            //当前用户模式二分销等级佣金比
            $res112 = $sqlhelper->execute_dql1("select discount from ydcom_user_yongjin where fenxiao_rank={$d1}");
            $present_commission = $res112 / 100;
            //canget_commission可获得的比例
            $canget_commission = $up_commission - $present_commission;
            //f2分销2的最终佣金
            $f2 = $fencheng2 * $canget_commission;
            //将分成2写入写入数据库
            $res12 = $sqlhelper->execute_dql("select user_money,user_name from ydcom_users where user_id={$b2}");
            $row12 = mysql_fetch_array($res12);
            $user_name = $row12[1];
            $user_money = $row12[0] + $f2;
            //分成,跟新其余额
            $sqlhelper->execute_dql("update ydcom_users set user_money={$user_money} where user_id={$b2}");
            //write_affiliate_log($oid, $up_uid, $row['user_name'], $setmoney, $setpoint, $separate_by);
            write_affiliate_log($oid, $b2, $user_name, $f2, 0, 0);
            $time = time();
            $fyj = "分佣金";
            $sqlhelper->execute_dql("insert into ydcom_account_log(user_id,user_money,frozen_money,rank_points,pay_points,change_time,change_desc,change_type) values({$b2},{$f2},0,0,0,{$time},{$fyj},2)");
        } else {
            break;
        }
        $a2 = $b2;
        //b2就是上家id
        $b2 = $sqlhelper->execute_dql1("select parent_id from ydcom_users where user_id={$a2}");
    }
    echo "恭喜分成成功";
    $sqlhelper->execute_dql("update ydcom_order_info set is_separate=1 where order_id={$order_id}");
    $sqlhelper->close_connect();
}
function get_affiliate_ck()
Пример #2
0
                if (empty($up_uid) || empty($row['user_name'])) {
                    break;
                } else {
                    $info = sprintf($_LANG['separate_info'], $order_sn, $setmoney, $setpoint);
                    log_account_change($up_uid, $setmoney, 0, $setpoint, 0, $info);
                    write_affiliate_log($oid, $up_uid, $row['user_name'], $setmoney, $setpoint, $separate_by);
                }
            }
        } else {
            //推荐订单分成
            $row = $db->getRow("SELECT o.parent_id, u.user_name FROM " . $GLOBALS['ecs']->table('order_info') . " o" . " LEFT JOIN" . $GLOBALS['ecs']->table('users') . " u ON o.parent_id = u.user_id" . " WHERE o.order_id = '{$oid}'");
            $up_uid = $row['parent_id'];
            if (!empty($up_uid) && $up_uid > 0) {
                $info = sprintf($_LANG['separate_info'], $order_sn, $money, $point);
                log_account_change($up_uid, $money, 0, $point, 0, $info);
                write_affiliate_log($oid, $up_uid, $row['user_name'], $money, $point, $separate_by);
            } else {
                $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
                sys_msg($_LANG['edit_fail'], 1, $links);
            }
        }
        $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET is_separate = 1" . " WHERE order_id = '{$oid}'";
        $db->query($sql);
    }
    $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
    sys_msg($_LANG['edit_ok'], 0, $links);
}
function get_affiliate_ck()
{
    $affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
    empty($affiliate) && ($affiliate = array());
Пример #3
0
function affiliate_separate($db, $row, $oid, $affiliate, $separate_by)
{
    $order_sn = $row['order_sn'];
    if (empty($row['is_separate'])) {
        $affiliate['config']['level_point_all'] = (double) $affiliate['config']['level_point_all'];
        $affiliate['config']['level_money_all'] = (double) $affiliate['config']['level_money_all'];
        if ($affiliate['config']['level_point_all']) {
            $affiliate['config']['level_point_all'] /= 100;
        }
        if ($affiliate['config']['level_money_all']) {
            $affiliate['config']['level_money_all'] /= 100;
        }
        $money = round($affiliate['config']['level_money_all'] * $row['goods_amount'], 2);
        $integral = integral_to_give(array('order_id' => $oid, 'extension_code' => ''));
        $point = round($affiliate['config']['level_point_all'] * intval($integral['rank_points']), 0);
        if (empty($separate_by)) {
            // 推荐注册分成
            $num = count($affiliate['item']);
            for ($i = 0; $i < $num; $i++) {
                $affiliate['item'][$i]['level_point'] = (double) $affiliate['item'][$i]['level_point'];
                $affiliate['item'][$i]['level_money'] = (double) $affiliate['item'][$i]['level_money'];
                if ($affiliate['item'][$i]['level_point']) {
                    $affiliate['item'][$i]['level_point'] /= 100;
                }
                if ($affiliate['item'][$i]['level_money']) {
                    $affiliate['item'][$i]['level_money'] /= 100;
                }
                $setmoney = round($money * $affiliate['item'][$i]['level_money'], 2);
                $setpoint = round($point * $affiliate['item'][$i]['level_point'], 0);
                $row = $db->getRow("SELECT o.parent_id as user_id,u.user_name FROM " . $GLOBALS['ecs']->table('users') . " o" . " LEFT JOIN" . $GLOBALS['ecs']->table('users') . " u ON o.parent_id = u.user_id" . " WHERE o.user_id = '{$row['user_id']}'");
                $up_uid = $row['user_id'];
                if (empty($up_uid) || empty($row['user_name'])) {
                    break;
                } else {
                    $info = sprintf($_LANG['separate_info'], $order_sn, $setmoney, $setpoint);
                    log_account_change($up_uid, $setmoney, 0, $setpoint, 0, $info);
                    write_affiliate_log($oid, $up_uid, $row['user_name'], $setmoney, $setpoint, $separate_by);
                }
            }
        } else {
            // 推荐订单分成
            $row = $db->getRow("SELECT o.parent_id, u.user_name FROM " . $GLOBALS['ecs']->table('order_info') . " o" . " LEFT JOIN" . $GLOBALS['ecs']->table('users') . " u ON o.parent_id = u.user_id" . " WHERE o.order_id = '{$oid}'");
            $up_uid = $row['parent_id'];
            if (!empty($up_uid) && $up_uid > 0) {
                $info = sprintf($_LANG['separate_info'], $order_sn, $money, $point);
                log_account_change($up_uid, $money, 0, $point, 0, $info);
                write_affiliate_log($oid, $up_uid, $row['user_name'], $money, $point, $separate_by);
            } else {
                $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
                sys_msg($_LANG['edit_fail'], 1, $links);
            }
        }
        $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET is_separate = 1" . " WHERE order_id = '{$oid}'";
        $db->query($sql);
    }
}