ecshop中用红包来打折扣

2009-10-26 17:28 来源:www.chinab4c.com 作者:ecshop专家

1:validate_bonus动作中.

  $order['bonus_kill'] = $bonus['type_money'];
 $order['send_type'] = $bonus['send_type'];

 2:order_fee函数中.

  if (!empty($order['bonus_id']))//通过ID传递进去
    {
        $bonus          = bonus_info($order['bonus_id']);
        //这里是用户折扣红包
        if($bonus['send_type'] == 5){
         $total['bonus'] = ($bonus['type_money']*$total['goods_price'])/100;
        }else{
          $total['bonus'] = $bonus['type_money'];
        }
    }
    $total['bonus_formated'] = price_format($total['bonus'], false);

    /* 线下红包 */
     if (!empty($order['bonus_kill']))//通过直接输入红包序号.
    {
        $bonus          = bonus_info(0,$order['bonus_kill']);
      
        if($order['send_type'] == 5){//折扣红包
         $total['bonus_kill'] = ($order['bonus_kill']*$total['goods_price'])/100;
        }else{
          $total['bonus_kill'] = $order['bonus_kill'];
        }
        $total['bonus_kill_formated'] = price_format($total['bonus_kill'], false);
    }

  3:分发红包

    elseif ($_REQUEST['send_by'] == 5)
    {
      $bonus = array();
     $sql = 'SELECT type_id, type_name, type_money FROM ' . $GLOBALS['ecs']->table('bonus_type') .
            ' WHERE send_type = 5';
     $res = $GLOBALS['db']->query($sql);
 
     while ($row = $GLOBALS['db']->fetchRow($res))
     {
         $bonus[$row['type_id']] = $row['type_name'].' [' .sprintf($GLOBALS['_CFG']['currency_format'], $row['type_money']).']';
     }
     $smarty->assign('type_list',    $bonus);

        $smarty->display('bonus_by_print.htm');
    }

4:bonus_list中

   elseif ($bonus_type['send_type'] == 5)
    {
        $smarty->assign('show_bonus_sn', 1);
    }

 5:红包详情

<input type="radio" name="send_type" value="4" {if $bonus_arr.send_type eq 4} checked="true" {/if} onClick="showunit(4)"  />注册发放 
   <input type="radio" name="send_type" value="5" {if $bonus_arr.send_type eq 5} checked="true" {/if} onClick="showunit(5)"  />折扣红包   </td>

document.forms['theForm'].elements['selbtn1'].disabled  = (get_value != 1 && get_value != 2&& get_value != 4&& get_value != 5);
  document.forms['theForm'].elements['selbtn2'].disabled  = (get_value != 1 && get_value != 2&& get_value != 4&& get_value != 5);

 6:bonus_type.htm

  <td align="right">
        {if $type.send_type neq 4}
     {if $type.send_type eq 3}
        <a href="bonus.php?act=gen_excel&tid={$type.type_id}">{$lang.report_form}</a> |
        {/if}
        {if $type.send_type neq 2}
        <a href="bonus.php?act=send&amp;id={$type.type_id}&amp;send_by={$type.send_type}">{$lang.send}</a> |
        {/if}
  {/if}
        <a href="bonus.php?act=bonus_list&amp;bonus_type={$type.type_id}">{$lang.view}</a> |
        <a href="bonus.php?act=edit&amp;type_id={$type.type_id}">{$lang.edit}</a> |
        <a href="javascript:;" onclick="listTable.remove({$type.type_id}, '{$lang.drop_confirm}')">{$lang.remove}</a></span></td>

 7:lib_orders.php中的user_bonus()函数修该成

  $sql = "SELECT t.type_id, t.type_name, t.type_money, t.send_type,b.bonus_id "

 8:checkout动作中。

  <select name="bonus" onchange="changeBonus(this.value)" id="ECS_BONUS" style="border:1px solid #ccc;">
                  <option value="0" {if $order.bonus_id eq 0}selected{/if}>{$lang.please_select}</option>
                  <!-- {foreach from=$bonus_list item=bonus} -->
      {if $bonus.send_type == 5}
      <option value="{$bonus.bonus_id}" {if $order.bonus_id eq $bonus.bonus_id}selected{/if}>{$bonus.type_name}[享受折扣{$bonus.type_money}%]</option>
      {else}
       <option value="{$bonus.bonus_id}" {if $order.bonus_id eq $bonus.bonus_id}selected{/if}>{$bonus.type_name}[{$bonus.bonus_money_formated}]</option>
       {/if}
                
                  <!-- {/foreach} -->
                </select>
 

9:get_user_bouns_list()函数中

  SELECT u.bonus_sn, u.order_id, b.type_name,b.send_type, b.type_money, b.min_goods_amount, b.use_start_date, b.use_end_date

10:user_transaction.dwt中的bonus动作中。

   {if $item.send_type == 5}
    <td align="center" bgcolor="#FFFFFF">{$item.type_money}%</td>
    {else}
     <td align="center" bgcolor="#FFFFFF">{$item.type_money}</td>
    {/if}

    相关文章:

    ecshop红包下发的功能分析

    使用ecshop红包验证分析
    来源:中国B4C电子商务