订单红包发送单一最大值

ecshop

17-12-17 12:25:33

include/lib_order.php


get_total_bonus函数  下单之前反馈给用户可以见的值

 /* 按订单发的红包 */

    $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 ";

修改如下

 /* 按订单发最大的红包 */
$sql="   SELECT type_money FROM `jzhlsm`.`ecs_bonus_type` WHERE send_type = '".SEND_BY_ORDER."' AND send_start_date <= '$today' AND send_end_date >= '$today' AND min_amount > 0 and $amount>min_amount order by  type_money desc  limit 1";


order_bonus函数 取得发送红包列表

/* 查询按订单发的红包 */
    $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' ";

 /* 按照最大值发放单一红包 */

$sql="   SELECT type_id, type_money,1 as number FROM `jzhlsm`.`ecs_bonus_type` WHERE send_type = '".SEND_BY_ORDER."' AND send_start_date <= '$today' AND send_end_date >= '$today' AND min_amount > 0 and $amount>min_amount order by  type_money desc  limit 1";



return_order_bonus函数  管理员取消发货 删除红包

 $sql = "DELETE FROM " . $GLOBALS['ecs']->table('user_bonus') .
                    " WHERE bonus_type_id = '$bonus[type_id]' " .
                    "AND user_id = '$user_id' " .
                    "AND order_id = '0' LIMIT 1" . $bonus['number'];
修改

  $sql = "DELETE FROM " . $GLOBALS['ecs']->table('user_bonus') .
                    " WHERE bonus_type_id = '$bonus[type_id]' " .
                    "AND user_id = '$user_id' " .
                    "AND order_id = '0' LIMIT 1" ;