ecshop功能二次開發(fā)之后臺管理增加成本價和毛利潤統(tǒng)計功能_第1頁
ecshop功能二次開發(fā)之后臺管理增加成本價和毛利潤統(tǒng)計功能_第2頁
ecshop功能二次開發(fā)之后臺管理增加成本價和毛利潤統(tǒng)計功能_第3頁
ecshop功能二次開發(fā)之后臺管理增加成本價和毛利潤統(tǒng)計功能_第4頁
ecshop功能二次開發(fā)之后臺管理增加成本價和毛利潤統(tǒng)計功能_第5頁
已閱讀5頁,還剩14頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、ecshop 功能二次開發(fā)之后臺管理增加本錢價和毛利潤統(tǒng)計功能ecshop 功能二次開發(fā)之后臺管理增加本錢價和毛利潤統(tǒng)計功能ecshop 功能二次開發(fā)之后臺管理增加本錢價和毛利潤統(tǒng)計功能在做 ecshop 二次開發(fā)的時候增加一個財務(wù)統(tǒng)計的功能!首先在訂單中的商品信息【編輯】頁面中,修改本錢價。也可以在添加商品時添加本錢的 如果不做手工修改,那么使用默認的商品本錢價在商品信息里編輯的本錢第一步:修改數(shù)據(jù)庫中的商品表ecs_goods 和訂單商品表ecs_order_goods ,添加本錢價字段cost_price把SQLS句列出來:alter table 'ecs_goods'

2、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' NOTNULL after 'market_price' 這里是加在了字段promote_price 和 market_price 后面第

3、二步 . 增加語言包 ,需要修改languageszh_cnadmingoods.php再最后添加 /* 新增 - 本錢價*/$_LANG'lab_cost_price' = '本錢價 :'$_LANG'notice_cost_price' = '該商品進貨價格( 本錢價,在商品添加時設(shè)置,也可以在商品編輯里面修改 。 ).'在兩個有兩個地方需要修改'promote_price' => 0, 后新增一行添加'cost_price' => 0,再在$shop_price = !empty(

4、$_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 = &quo

5、t;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, g

6、oods_brief,goods_weight, goods_number,give_integral, is_best, is_new, is_hot,"seller_note, warn_number, integral,"is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral)" ."VALUES ('$_POSTgoods_name', '$goods_name_style', '$goo

7、ds_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&#

8、39;, '$original_img', "."'$_POSTkeywords','$_POSTgoods_brief', '$_POSTseller_note', '$goods_weight', '$goods_number',"." '$warn_number', '$_POSTintegral', '$give_integral', '$is_best', '$is_new

9、9;, '$is_hot', '$is_on_sale', '$is_alone_sale', "."'$_POSTgoods_desc', '" . gmtime() . "''". gmtime() ."', '$goods_type', '$rank_integral')"else$sql = "INSERT INTO " . $ecs->table('goo

10、ds') . " (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,give_integral, is_best, is_new, is_

11、hot,"seller_note, warn_number, integral, is_real, " ."is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" ."VALUES ('$_POSTgoods_name', '$goods_name_style', '$goods_sn', '$catgory_id', &quo

12、t; ."'$brand_id','$shop_price','$cost_price', '$market_price','$is_promote','$promote_price', "."'$promote_start_date','$promote_end_date', '$goods_img', '$goods_thumb','$original_img', ".&quo

13、t;'$_POSTkeywords','$_POSTgoods_brief', '$_POSTseller_note', '$goods_weight', '$goods_number',"." '$warn_number', '$_POSTintegral', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sal

14、e', '$is_alone_sale', "."'$_POSTgoods_desc', '" . gmtime() . "''". gmtime() ."', '$goods_type', '$code', '$rank_integral')"else/* 如果有上傳圖片,刪除原來的商品圖 */$sql = "SELECT goods_thumb, goods_img, original_img

15、 " ." FROM " . $ecs->table('goods') ." WHERE goods_id ='$_REQUESTgoods_id'"$row = $db->getRow($sql);if ($proc_thumb && $goods_img && $row'goods_img'&& !goods_parse_url($row'goods_img')unlink(ROOT_PATH . $row'g

16、oods_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') .

17、" SET " ."goods_name = '$_POSTgoods_name', " ."goods_name_style = '$goods_name_style', " ."goods_sn = '$goods_sn', " ."cat_id = '$catgory_id', " ."brand_id = '$brand_id', " ."shop_price = '$s

18、hop_price', " ."cost_price = '$cost_price', " ."market_price = '$market_price', " ."is_promote = '$is_promote', " ."promote_price = '$promote_price', " ."promote_start_date= '$promote_start_date', "pro

19、mote_end_date = '$promote_end_date', "/* 如果有上傳圖片,需要更新數(shù)據(jù)庫*/if ($goods_img)$sql"goods_img = '$goods_img', original_img'$original_img', "if ($goods_thumb)$sql .= "goods_thumb = '$goods_thumb', "if ($code != '')$sql .= "is_real=0, ext

20、ension_code='$code', "$sql .= "keywords = '$_POSTkeywords',goods_brief = '$_POSTgoods_brief', " . seller_note = '$_POSTseller_note', " . goods_weight = '$goods_weight'," . goods_number = '$goods_number', " . warn_number =

21、'$warn_number', " . integral = '$_POSTintegral', " . give_integral = '$give_integral', " . rank_integral = '$rank_integral', " . is_best = '$is_best', " . is_new = '$is_new', " .is_hot = '$is_hot', " .is_on_sa

22、le = '$is_on_sale', " .is_alone_sale = '$is_alone_sale', " .goods_desc = '$_POSTgoods_desc', " .last_update = '". gmtime() ."', ".goods_type = '$goods_type' " .WHERE goods_id = '$_REQUESTgoods_id' LIMIT1"主要是在插入數(shù)據(jù)

23、庫時,把本錢價 cost_price 的值插入到數(shù)據(jù)庫第四步 . 下面應(yīng)該在商品編輯頁讀取和顯示本錢價格,需要修改admin/templates/goods_info.dwt找到代碼 <tr><td class="label">$lang.lab_market_price</td><td><input type="text" name="market_price"value="$goods.market_price" size="20" /&

24、gt;<input type="button"value="$egral_market_price" onclick="integral_market_price()" /></td></tr>在這段代碼之后添加顯示本錢價格的表格<!- 新增 本錢價begin -><tr><td class="label">$lang.lab_cost_price</td><td><input type="

25、;text" name="cost_price"value="$goods.cost_price" size="20" /><br /><span class="notice-span" if$help_openstyle="display:block" else style="display:none" /if id="minNumber">$lang.notice_cost_price</span>&

26、lt;/td></td></tr><!-本錢價end ->這樣就把就完成了在商品添加時增加商品的本錢價和在商品列表頁編輯商品頁顯示本錢價的功能ecshop 功能二次開發(fā) 關(guān)于后臺管理增加本錢價和毛利潤統(tǒng)計功能最后新增: $_LANG'cost_price' = ' 本錢價 '把 <th colspan="7" scope="col"> 修改成 <th colspan="8" scope="col">在 <td s

27、cope="col"><divalign="center"><strong>$lang.storage</strong></div></td>代碼之后插入<td scope="col"><divalign="center"><strong>$lang.cost_price</strong></div></t d>在 <td><div align="ri

28、ght">$goods.storage</div></td>代碼之后插入<td><divalign="right">$goods.cost_price</div></td>將$sql = "SELECT o.*, g.goods_number AS storage, o.goods_attr, IFNULL(b.brand_name, '') AS brand_name " ."FROM " . $ecs->table(

29、9;order_goods') . " AS o "."LEFT JOIN " . $ecs->table('goods') . " AS g ON o.goods_id = g.goods_id " ."LEFT JOIN " . $ecs->table('brand') . " AS b ON g.brand_id = b.brand_id " ."WHERE o.order_id = '$orderorder_id

30、9; "修改成$sql = "SELECT o.*, g.goods_number ASstorage,if(o.cost_price>0,o.cost_price,g.cost_price) AS cost_price, o.goods_attr, IFNULL(b.brand_name, '') AS brand_name " ."FROM " . $ecs->table('order_goods') . " AS o "."LEFT JOIN " . $e

31、cs->table('goods') . " AS g ON o.goods_id = g.goods_id " ."LEFT JOIN " . $ecs->table('brand') . " AS b ONg.brand_id = b.brand_id"WHERE o.order_id = '$orderorder_id' "在/* 取得參數(shù) */$goods_price =floatval($_POST'goods_price'$key);之后

32、插入 $cost_price = floatval($_POST'cost_price'$key);將/* 修改 */$sql = "UPDATE " .$ecs->table('order_goods') ."SETgoods_price = '$goods_price',"goods_number = '$goods_number', " ."goods_attr = '$goods_attr' " ."WHERE rec_i

33、d = '$rec_id' LIMIT 1"修改成 $sql = "UPDATE " . $ecs->table('order_goods') ." SET goods_price ='$goods_price',cost_price = '$cost_price', " ."goods_number = '$goods_number', " ."goods_attr = '$goods_attr' "

34、."WHERE rec_id = '$rec_id' LIMIT 1"在/* 標記訂單為已確認*/update_order($order_id,array('order_status' => OS_CONFIRMED, 'confirm_time' => gmtime();之后插入 /* 計算并插入商品的本錢*/$sql_cost = "UPDATE ".$GLOBALS'ecs'->table('order_goods')." as og,&qu

35、ot;.$GLOBALS'ecs'->table('goods')." as g SET og.cost_price = g.cost_price " ." WHERE og.goods_id = g.goods_id"." AND og.order_id = '$order_id' and og.cost_price=0"$GLOBALS'db'->query($sql_cost);在 /* 標記訂單為已確認*/update_order($order_id,

36、 array('order_status' => OS_CONFIRMED, 'confirm_time' => gmtime();update_order_amount($order_id);之后插入 /* 計算并插入商品的本錢*/$sql_cost = "UPDATE ".$GLOBALS'ecs'->table('order_goods')." as og,".$GLOBALS'ecs'->table('goods')."

37、; as g SET og.cost_price = g.cost_price " ." WHERE og.goods_id = g.goods_id"." AND og.order_id = '$order_id' and og.cost_price=0"$GLOBALS'db'->query($sql_cost);將/* 取得商品信息 */$goods_id = $_REQUEST'goods_id'$sql = "SELECT goods_id, c.cat_name, go

38、ods_sn, goods_name, b.brand_name, " ."goods_number, market_price, shop_price, promote_price, " ."promote_start_date, promote_end_date, goods_brief, goods_type, is_promote " ."FROM " . $ecs->table('goods') . " AS g " ." AS"LEFT JOIN &q

39、uot; . $ecs->table('brand') . " AS b ON g.brand_id = b.brand_id " ."LEFTJOIN " . $ecs->table('category')c ON g.cat_id = c.cat_id " ." WHERE goods_id = '$goods_id'"修改成/* 取得商品信息 */$goods_id = $_REQUEST'goods_id'$sql = "SELEC

40、T goods_id, c.cat_name, goods_sn, goods_name, b.brand_name, " ."goods_number, market_price, shop_price,cost_price, promote_price, " ."promote_start_date, promote_end_date, goods_brief, goods_type, is_promote " ."FROM " . $ecs->table('goods') . " AS

41、g " ."LEFT JOIN " . $ecs->table('brand') . " AS bON g.brand_id = b.brand_id " ."LEFTJOIN " . $ecs->table('category') . " ASc ON g.cat_id = c.cat_id " ." WHERE goods_id = '$goods_id'"修改 order_goods 函數(shù)的 SQLiS句,將 $sql

42、= "SELECTrec_id, goods_id, goods_name, goods_sn, market_price, goods_number," ."goods_price, goods_attr, is_real, parent_id, is_gift, " ."goods_price * goods_number AS subtotal, extension_code " ."FROM " . $GLOBALS'ecs'->table('order_goods')

43、 ." WHERE order_id = '$order_id'"修改成 $sql = "SELECT o.rec_id, o.goods_id, o.goods_name, o.goods_sn, o.market_price, o.goods_number, " ."o.goods_price,if(o.cost_price>0,o.cost_price,g.cost_price)AS cost_price, o.goods_attr, o.is_real, o.parent_id, o.is_gift, "

44、 ."o.goods_price * o.goods_number AS subtotal, o.extension_code " ."FROM " . $GLOBALS'ecs'->table('order_goods') . " AS o "."LEFT JOIN " . $GLOBALS'ecs'->table('goods') ." AS g ON o.goods_id = g.goods_id " ."

45、; WHERE order_id = '$order_id'"在<th scope="col">$lang.goods_attr</th>之后插入 <th scope="col">$lang.cost_price</th>在 <td><textarea name="goods_attr" cols="30"rows="$goods.rows">$goods.goods_attr</textar

46、ea></td>之后插入 <td><input name="cost_price" type="text" style="text-align:right" value="$goods.cost_price" size="10" /></td>在 <tr><th>$lang.goods_price</th><td id="add_price">&nbsp;</t

47、d> </tr>之后插入 <tr><th>$lang.cost_price</th><td id="cost_price">&nbsp;</td> </tr>在 document.getElementById('add_price').innerHTML = ''之后插入 document.getElementById('cost_price').innerHTML = ;在 document.getElementById(

48、9;add_price').innerHTML = priceHtml;之后插入 document.getElementById('cost_price').innerHTML = '<input type="text" name="cost_price" value="'+result.cost_price+'" />'ecshop 功能二次開發(fā) 關(guān)于后臺管理增加本錢價和毛利潤統(tǒng)計功能三毛利潤顯示在報表統(tǒng)計的銷售明細里并且增加了本錢匯總1. 首先要修改對應(yīng)的語言文件

49、languageszh_cnadminstatistic.php在最后新增 /* 新增 本錢 毛利潤 */ $_LANG'cost_price' = ' 本錢價 ' $_LANG'gross_profit' = ' 毛利潤 ' $_LANG'sale_total' = '銷售收入:'$_LANG'cost_total' = '本錢匯總:'$_LANG'gross_profit_total' = ' 毛利潤合計: ' $_LANG'

50、;gross_profit_rate' = ' 本錢毛利率: '在 <th>$lang.sell_price</th> 之后插入<th>$lang.cost_price</th><th>$lang.gross_profit</th>在 <td align="right">$list.sales_price</td>之后插入 <td align="right">$list.cost_price</td><td

51、 align="right">$list.gross_profit</td>在 foreachelse<tr><td class="no-records"colspan="10">$lang.no_records</td></tr>/foreach之后插入if $sale_total<tr align="center"><td align="right" colspan="4">$lan

52、g.sale_total</td><td align="right">$sale_total</td><td align="right">$lang.cost_total</td><td align="right">$cost_total</td></tr><tr align="center"><td align="right"colspan="4">$la

53、ng.gross_profit_total</td><td align="right">$gross_profit_total</td><td align="right">$lang.gross_profit_rate</td><td align="right">$gross_profit_rate</td></tr>/if將 $sql = 'SELECTog.goods_id, og.goods_sn, og.goods_name

54、, og.goods_number AS goods_num, og.goods_price '.'AS sales_price, oi.add_time AS sales_time, oi.order_id, oi.order_sn '."FROM " . $ecs->table('order_goods')." AS og,".$ecs->table('order_info')." AS oi ".$where. " ORDER BY sales_tim

55、e DESC, goods_num DESC"修改成 $sql = 'SELECTog.goods_id, og.goods_sn, og.goods_name, og.goods_number AS goods_num, og.cost_price, og.goods_price '.'ASsales_price,(og.goods_price-og.cost_price)*og.goods_numberas gross_profit, oi.add_time AS sales_time, oi.order_id, oi.order_sn '.&qu

56、ot;FROM " . $ecs->table('order_goods')." AS og, ".$ecs->table('order_info')." AS oi ".$where. " ORDER BY sales_time DESC, goods_num DESC"將 while ($items = $db->fetchRow($res) $items'sales_price' =price_format($items'sales_price&

57、#39;);$items'sales_time' =local_date($_CFG'time_format', $items'sales_time');$goods_sales_list = $items;修改成$sale_total = $cost_total = $gross_profit_total=$gross_profit_rate = 0;while ($items = $db->fetchRow($res)$sale_total += $items'sales_price' * $items'good

58、s_num'$cost_total += $items'cost_price' *$items'goods_num'$gross_profit_total += $items'gross_profit'$items'cost_price' =price_format($items'cost_price');$items'gross_profit' =price_format($items'gross_profit');$items'sales_price' =

59、price_format($items'sales_price');$items'sales_time' =local_date($_CFG'time_format', $items'sales_time');$goods_sales_list = $items;$total_isdisplay = false;if($sale_total>0)$total_isdisplay = true;$gross_profit_rate =round($gross_profit_total*100/$sale_total,2).&#

60、39;%' /毛利 /銷售收入$sale_total = price_format($sale_total);$cost_total = price_format($cost_total);$gross_profit_total = price_format($gross_profit_total); $_CFG'lang');$sale_total);$cost_total);在 $smarty->assign('cfg_lang', 之后插入$smarty->assign('sale_total', $smarty->

61、;assign('cost_total', $smarty->assign('gross_profit_total',$gross_profit_total);$smarty->assign('gross_profit_rate',$gross_profit_rate);在 echo ecs_iconv(EC_CHARSET,'GB2312', $_LANG'sell_price') "t"之后插入 echo ecs_iconv(EC_CHARSET, 'GB2312'

62、;, $_LANG'cost_price') . "t"echo ecs_iconv(EC_CHARSET,'GB2312', $_LANG'gross_profit') "t"將 foreach ($goods_sales_list AS $key => $value)echo ecs_iconv(EC_CHARSET, 'GB2312', $value'goods_name') . "t"echo ecs_iconv(EC_CHARSET, 'GB2312', ' ' .$value'order_sn' . ' ') . "t"echo ecs_iconv(EC_CHARSET, 'GB2312', $value

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論