威尼斯娱乐

ecshop二次开发

ecshop二次开发

威尼斯娱乐 资讯中心 ecshop二次开发 ecshop后台管理增加商品成本价和毛利润统计功能

ecshop后台管理增加商品成本价和毛利润统计功能

时间:2020-12-16
ecshop功能二次开发之后台管理增加成本价和毛利润统计功能在做ecshop二次开发的时候增加一个财务统计的功能!首先在订单中的商品信息【编辑】页面中,修改成本价。也可以在添加商品时添加成本的如果不做手工修改,则..

ecshop功能二次开发之后台管理增加成本价和毛利润统计功能

 在做ecshop二次开发的时候增加一个财务统计的功能!
首先在订单中的商品信息【编辑】页面中,修改成本价。也可以在添加商品时添加成本的如果不做手工修改,则使用默认的商品成本价(在商品信息里编辑的成本
价格)。我用的版本是ecshop2.7.2

第一步:修改数据库中的商品表ecs_goods和订单商品表ecs_order_goods,添加成本价字段cost_price
  把SQL语句列出来:
   alter table `ecs_goods` add column `cost_price` decimal (10,2) UNSIGNED  DEFAULT '0.00' NOT NULL  after `promote_price`
   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
  再最后添加
$_LANG['lab_cost_price']            = '成本价:';
$_LANG['notice_cost_price']         = '该商品进货价格(成本价,在商品添加时设置,也可以在商品编辑里面修改 。).';

第三步.修改admin/goods.php 把成本价格插入到数据库
  在两个(有两个地方需要修改)
  'promote_price' => 0,
  后新增一行添加
  'cost_price' => 0,
再在
  $shop_price = !empty($_POST['shop_price']) ? $_POST['shop_price'] : 0;
  后添加
  $cost_price = !empty($_POST['cost_price']) ? $_POST['cost_price'] : 0;

   
    if ($is_insert)
    {
         。。。。。源代码太多省略(了这个是真实商品和虚拟商品)
    }
    else
    {
          
         。。。。。源代码太多省略了
    }
修改成
   
    if ($is_insert)
    {
        if ($code == '')
        {
            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
                    "cat_id, brand_id, shop_price,cost_price, market_price, is_promote, promote_price, " .
                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
                    "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral)" .
                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
                    "'$brand_id', '$shop_price','$cost_price', '$market_price', '$is_promote','$promote_price', ".
                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', ".
                    " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
        }
        else
        {
           $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
                    "cat_id, brand_id, shop_price,cost_price, market_price, is_promote, promote_price, " .
                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
                   "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" .
                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
                    "'$brand_id', '$shop_price','$cost_price', '$market_price', '$is_promote','$promote_price', ".
                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', ".
                    " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral')";
        }
    }
    else
    {
       
        $sql = "SELECT goods_thumb, goods_img, original_img " .
                    " FROM " . $ecs->table('goods') .
                    " WHERE goods_id = '$_REQUEST[goods_id]'";
        $row = $db->getRow($sql);
        if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))
        {
            @unlink(ROOT_PATH . $row['goods_img']);
            @unlink(ROOT_PATH . $row['original_img']);
        }
        if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))
        {
            @unlink(ROOT_PATH . $row['goods_thumb']);
        }
        $sql = "UPDATE " . $ecs->table('goods') . " SET " .
                "goods_name = '$_POST[goods_name]', " .
                "goods_name_style = '$goods_name_style', " .
                "goods_sn = '$goods_sn', " .
                "cat_id = '$catgory_id', " .
                "brand_id = '$brand_id', " .
                "shop_price = '$shop_price', " .
  "cost_price = '$cost_price', " .
                "market_price = '$market_price', " .
                "is_promote = '$is_promote', " .
    

本文网址:/news/1027.html
0
QQ在线客服在线客服
用手机扫描二维码 关闭
二维码
XML 地图 | Sitemap 地图