搜索
查看: 2480|回复: 0

[安装使用(新手)] Ecshop后台管理增加毛利润统计和成本价功能

[复制链接]

70

主题

81

帖子

2万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
20277

最佳新人活跃会员宣传达人

发表于 2017-3-1 15:43:30 | 显示全部楼层 |阅读模式
首先在订单中的商品信息【编辑】页面中,修改成本价。也可以在添加商品时添加成本的如果不做手工修改,则使用默认的商品成本价(在商品信息里编辑的成本
价格)。

第一步:修改数据库中的商品表ecs_goods和订单商品表ecs_order_goods,添加成本价字段cost_price
  把SQL语句列出来:

  1. alter table `ecs_goods` add column `cost_price` decimal (10,2) UNSIGNED  DEFAULT '0.00' NOT NULL  after `promote_price`
  2.    alter table `ecs_order_goods` add column `cost_price` decimal (10,2)  DEFAULT '0.00' NOT NULL  after `market_price`
复制代码
这里是加在了字段promote_price 和market_price后面
第二步.增加语言包 ,需要修改languages\zh_cn\admin\goods.php
  再最后添加

  1. $_LANG['lab_cost_price']            = '成本价:';
  2. $_LANG['notice_cost_price']         = '该商品进货价格(成本价,在商品添加时设置,也可以在商品编辑里面修改 。).';
复制代码
第三步.修改admin/goods.php 把成本价格插入到数据库
  在两个(有两个地方需要修改)
  1. 'promote_price' => 0,
复制代码

后新增一行添加
  1. 'cost_price' => 0,
复制代码
再在
  1. $shop_price = !empty($_POST['shop_price']) ? $_POST['shop_price'] : 0;
复制代码
后添加
  1. $cost_price = !empty($_POST['cost_price']) ? $_POST['cost_price'] : 0;
复制代码



  1. if ($is_insert)
  2.     {
  3.          。。。。。源代码太多省略(了这个是真实商品和虚拟商品)
  4.     }
  5.     else
  6.     {
  7.          
  8.          。。。。。源代码太多省略了
  9.     }
复制代码
修改成
  1. if ($is_insert)
  2.     {
  3.         if ($code == '')
  4.         {
  5.             $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
  6.                     "cat_id, brand_id, shop_price,cost_price, market_price, is_promote, promote_price, " .
  7.                     "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
  8.                     "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
  9.                     "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral)" .
  10.                 "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
  11.                     "'$brand_id', '$shop_price','$cost_price', '$market_price', '$is_promote','$promote_price', ".
  12.                     "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
  13.                     "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
  14.                     " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', ".
  15.                     " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
  16.         }
  17.         else
  18.         {
  19.            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
  20.                     "cat_id, brand_id, shop_price,cost_price, market_price, is_promote, promote_price, " .
  21.                     "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
  22.                     "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
  23.                    "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" .
  24.                 "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
  25.                     "'$brand_id', '$shop_price','$cost_price', '$market_price', '$is_promote','$promote_price', ".
  26.                     "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
  27.                     "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
  28.                     " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', ".
  29.                     " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral')";
  30.         }
  31.     }
  32.     else
  33.     {
  34.       
  35.         $sql = "SELECT goods_thumb, goods_img, original_img " .
  36.                     " FROM " . $ecs->table('goods') .
  37.                     " WHERE goods_id = '$_REQUEST[goods_id]'";
  38.         $row = $db->getRow($sql);
  39.         if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))
  40.         {
  41.             @unlink(ROOT_PATH . $row['goods_img']);
  42.             @unlink(ROOT_PATH . $row['original_img']);
  43.         }
  44.         if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))
  45.         {
  46.             @unlink(ROOT_PATH . $row['goods_thumb']);
  47.         }
  48.         $sql = "UPDATE " . $ecs->table('goods') . " SET " .
  49.                 "goods_name = '$_POST[goods_name]', " .
  50.                 "goods_name_style = '$goods_name_style', " .
  51.                 "goods_sn = '$goods_sn', " .
  52.                 "cat_id = '$catgory_id', " .
  53.                 "brand_id = '$brand_id', " .
  54.                 "shop_price = '$shop_price', " .
  55.   "cost_price = '$cost_price', " .
  56.                 "market_price = '$market_price', " .
  57.                 "is_promote = '$is_promote', " .
  58.                 "promote_price = '$promote_price', " .
  59.                 "promote_start_date = '$promote_start_date', " .
  60.                 "promote_end_date = '$promote_end_date', ";
  61.       
  62.         if ($goods_img)
  63.         {
  64.             $sql .= "goods_img = '$goods_img', original_img = '$original_img', ";
  65.         }
  66.        if ($goods_thumb)
  67.         {
  68.             $sql .= "goods_thumb = '$goods_thumb', ";
  69.         }
  70.         if ($code != '')
  71.         {
  72.             $sql .= "is_real=0, extension_code='$code', ";
  73.         }
  74.         $sql .= "keywords = '$_POST[keywords]', " .
  75.                 "goods_brief = '$_POST[goods_brief]', " .
  76.                 "seller_note = '$_POST[seller_note]', " .
  77.                 "goods_weight = '$goods_weight'," .
  78.                 "goods_number = '$goods_number', " .
  79.                 "warn_number = '$warn_number', " .
  80.                 "integral = '$_POST[integral]', " .
  81.                 "give_integral = '$give_integral', " .
  82.                 "rank_integral = '$rank_integral', " .
  83.                 "is_best = '$is_best', " .
  84.                 "is_new = '$is_new', " .
  85.                 "is_hot = '$is_hot', " .
  86.                 "is_on_sale = '$is_on_sale', " .
  87.                 "is_alone_sale = '$is_alone_sale', " .
  88.                 "goods_desc = '$_POST[goods_desc]', " .
  89.                 "last_update = '". gmtime() ."', ".
  90.                 "goods_type = '$goods_type' " .
  91.                 "WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";
  92.     }
复制代码
(第三步 主要是在插入数据库时,把成本价(cost_price)的值插入到数据库)
第四步.下面应该在商品编辑页读取和显示成本价格,需要修改admin/templates/goods_info.dwt
找到代码

  1.   <tr>
  2.             <td class="label">{$lang.lab_market_price}</td>
  3.             <td><input type="text" name="market_price" value="{$goods.market_price}" size="20" />
  4.               <input type="button" value="{$lang.integral_market_price}" onclick="integral_market_price()" />
  5.             </td>
  6.         </tr>
复制代码
在这段代码之后添加显示成本价格的表格
  1. <!--新增 成本价 begin -->
  2.           <tr>
  3.             <td class="label">{$lang.lab_cost_price}</td>
  4.             <td><input type="text" name="cost_price" value="{$goods.cost_price}" size="20" />
  5.             <br />
  6.      <span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="minNumber">{$lang.notice_cost_price}</span></td>   
  7.             </td>
  8.           </tr>
  9.   <!-- 成本价 end -->
复制代码
这样就把就完成了在商品添加时增加商品的成本价和在商品列表页编辑商品页显示成本价的功能

1.修改订单的语言文件languages\zh_cn\a
心怀梦想
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

前身为模板家园。国内NO.1电商解决方案平台

五年来一直为电商系统做优质的服务而不断努力着!

Copyright © 2011-2016 cybn.Cn. Powered by Discuz!

返回顶部 返回列表