Example #1
0
        $sql = "UPDATE " . $GLOBALS['ecs']->table('affiliate_log') . " SET separate_type = '{$flag}'" . " WHERE log_id = '{$logid}'";
        $db->query($sql);
    }
    $links[] = array('text' => $_LANG['affiliate_ck'], 'href' => 'affiliate_ck.php?act=list');
    sys_msg($_LANG['edit_ok'], 0, $links);
} elseif ($_REQUEST['act'] == 'separate') {
    include_once ROOT_PATH . 'includes/lib_order.php';
    require_once 'SqlHelper.php';
    $sqlhelper = new SqlHelper();
    $affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
    empty($affiliate) && ($affiliate = array());
    $separate_by = $affiliate['config']['separate_by'];
    $oid = (int) $_REQUEST['oid'];
    $order_id = $oid;
    //根据订单Id求买家id
    $user_id = $sqlhelper->execute_dql1("select user_id from ydcom_order_info where order_id={$order_id}");
    //第1步查询出该笔订单的能产生的佣金
    $fencheng1 = 0;
    $fencheng2 = 0;
    //根据order_id查表ydcom_order_goods中的goods_id
    $res0 = $sqlhelper->execute_dql("select goods_id,goods_price from ydcom_order_goods where order_id={$order_id} ");
    while ($row0 = mysql_fetch_array($res0)) {
        $goods_id = $row0[0];
        $goods_price = $row0[1];
        //根据goods_id查ydcom_goods中的fengcheng1,和fengcheng2;
        $res02 = $sqlhelper->execute_dql("select fencheng1,fencheng2 from ydcom_goods where goods_id={$goods_id} ");
        while ($row02 = mysql_fetch_array($res02)) {
            $fencheng1 += $row02[0] * $goods_price;
            $fencheng2 += $row02[1] * $goods_price;
        }
    }