Magento选择随机客户

时间:2016-10-28 12:15:06

标签: magento admin magento-1.9 customer

我已经开发了一个Magento网站,我想在{{1}内选择 customer 每个时间段 $ 1000 并从order给他奖励。

有关于此的任何建议吗?

1 个答案:

答案 0 :(得分:0)

Magento使用mysql DB。

我真的不知道数据库架构。查找为您提供所有订单的查询>给定时间间隔1000美元。 然后从结果中选择一个随机行。请参阅回答Mysql 1 Random Row

这样的东西
public partial class Window1 : Window
{
    public Window1()
    {
        InitializeComponent();
        wbMain.Navigated += new NavigatedEventHandler(wbMain_Navigated);
    }

    void wbMain_Navigated(object sender, NavigationEventArgs e)
    {
        SetSilent(wbMain, true); // make it silent
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        wbMain.Navigate(new Uri("... some url..."));
    }
}


public static void SetSilent(WebBrowser browser, bool silent)
{
    if (browser == null)
        throw new ArgumentNullException("browser");

    // get an IWebBrowser2 from the document
    IOleServiceProvider sp = browser.Document as IOleServiceProvider;
    if (sp != null)
    {
        Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
        Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E");

        object webBrowser;
        sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser);
        if (webBrowser != null)
        {
            webBrowser.GetType().InvokeMember("Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { silent });
        }
    }
}


[ComImport, Guid("6D5140C1-7436-11CE-8034-00AA006009FA"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IOleServiceProvider
{
  [PreserveSig]
  int QueryService([In] ref Guid guidService, [In] ref Guid riid, [MarshalAs(UnmanagedType.IDispatch)] out object ppvObject);
}

实际上可行。 它将有SELECT DISTINCT customer_id from sales_order WHERE created_at between ? and ? AND grand_total > 1000 ORDER BY RAND() LIMIT 1 ,您可以在customer_id表中查找。

因为我在查询中使用customer_entity,即使客户下达超过1美元的订单,他也只有一次机会获胜,就像在给定时间间隔内仅下1美元订单的其他客户一样。 / p>