ecshop红包多个发放问题【按订单金额发放红包会导致多个发放解决方案】

问题描述:ECSHOP设置了3种订单红包,满100元(送10元红包)、500元(送30元红包)、1000元(送50元红包)
问题情况:当用户订单为1100元时,红包发放情况为:发10元红包11个、发30元红包2个、发50元红包1个
解决描述:100>订单金额<500时只发一个10元红包。500>订单金额<1000时只发一个30元红包,1000>订单金额只发一个50元。ECSHOP插件网提供全网独家完美解决方案如下:
打开includes\lib_order.php文件,搜索如下代码:
    /* 按订单发的红包 */
    $sql = "SELECT FLOOR('$amount' / min_amount) * type_money " .
            "FROM " . $GLOBALS['ecs']->table('bonus_type') .
            " WHERE send_type = '" . SEND_BY_ORDER . "' " .
            " AND send_start_date <= '$today' " .
            "AND send_end_date >= '$today' " .
            "AND min_amount ";
    $order_total = floatval($GLOBALS['db']->getOne($sql));
很显然凡是比较最低订单金额大的订单,都会导致发放数个红包,我们其实只要发的是最大的红包那个就可以了,目前最新ECSHOP3.0版本依旧存在此问题官网尚未解决。所以我们完善将以上代码修改如下
    /* 按订单发的红包 */
    $sql = "SELECT FLOOR('$amount' / min_amount) * type_money " .
            "FROM " . $GLOBALS['ecs']->table('bonus_type') .
            " WHERE send_type = '" . SEND_BY_ORDER . "' " .
            " AND send_start_date <= '$today' " .
            "AND send_end_date >= '$today' " .
            "AND min_amount > 0 AND min_amount <= '$amount' ORDER BY min_amount DESC LIMIT 1 ";
    $order_total = floatval($GLOBALS['db']->getOne($sql));
就是说订单额度的红包发放条件,取一个即可。
再搜索如下代码
    /* 查询按订单发的红包 */
    $sql = "SELECT type_id, type_moneNULLR('$amount' / min_amount), 1) AS number " .
            "FROM " . $GLOBALS['ecs']->table('bonus_type') .
            "WHERE send_type = '" . SEND_BY_ORDER . "' " .
            "AND send_start_date <= '$order_time' " .
            "AND send_end_date >= '$order_time' " .
    $list = array_merge($list, $GLOBALS['db']->getAll($sql));
将以上代码修改如下
    /* 查询按订单发的红包 */
    $sql = "SELECT type_id, type_money, IFNULL(FLOOR('$amount' / min_amount), 1) AS number " .
            "FROM " . $GLOBALS['ecs']->table('bonus_type') .
            "WHERE send_type = '" . SEND_BY_ORDER . "' " .
            "AND send_start_date <= '$order_time' " .
            "AND send_end_date >= '$order_time' " .
            "AND min_amount > 0 AND min_amount <= '$amount' ORDER BY min_amount DESC LIMIT 1 ";
    $list = array_merge($list, $GLOBALS['db']->getAll($sql));

本文原创地址:https://www.ecshop.cx/article-309.html
版权所有 © 转载时必须以链接形式注明出处!

觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。

实时购买动态 ×

勇敢的心_5会员 在 2019-10-29 购买了 ECSHOP商品副标题插件带商品自定义TITLE主标题