求代码帝啊
2016-07-07 15:03 来源:www.chinab4c.com 作者:ecshop专家
sale_general.php里面,我想把利润也弄进去。。。 利润=售价-成本价 已经在数据库里面的goods表跟ord_goods表加多一个字段 现在想把这个利润也弄进销售概况里面去~ 无奈能力有限~~~ 求代码帝帮忙~ /* 分组统计订单数和销售额:已发货时间为准 */ $format = ($query_type == 'year') ? '%Y' : '%Y-%m'; $sql = "SELECT DATE_FORMAT(FROM_UNIXTIME(oi.shipping_time), '$format') AS period, COUNT(*) AS order_count, " . "SUM(oi.goods_amount + oi.shipping_fee + oi.insure_fee + oi.pay_fee + oi.pack_fee + oi.card_fee - oi.discount) AS order_amount, " . "og.order_id, og.goods_number AS goods_num, og.cost_price, og.goods_price, (og.goods_price-og.cost_price)*og.goods_number as gross_profit, oi.order_id ". "FROM " . $ecs->table('order_info') ." AS oi, ".$ecs->table('order_goods')." AS og ". " WHERE (order_status = '" . OS_CONFIRMED . "' OR order_status >= '" . OS_SPLITED . "')" . " AND oi.order_id = og.order_id". " AND (pay_status = '" . PS_PAYED . "' OR pay_status = '" . PS_PAYING . "') " . " AND (shipping_status = '" . SS_SHIPPED . "' OR shipping_status = '" . SS_RECEIVED . "') " . " AND shipping_time >= '$start_time' AND shipping_time <= '$end_time'" . " GROUP BY period "; 这样做好像不行~~~ print_r ($data_list); 的结果 Array ( [0] => Array ( [period] => 2010-04 [order_count] => 4 [order_amount] => 8667.38 [order_id] => 24 [goods_num] => 1 [cost_price] => 0.00 [goods_price] => 16.39 [gross_profit] => 16.39 ) [1] => Array ( [period] => 2010-05 [order_count] => 13 [order_amount] => 2098.54 [order_id] => 43 [goods_num] => 1 [cost_price] => 20.00 [goods_price] => 39.00 [gross_profit] => 19.00 ) ) gross_profit是利润 明显只有统计一个订单 [order_id] => 24 |
回答:
没问题啊。你直接做减法.就可以了.. |
没问题啊。你直接做减法.就可以了.. 厄,不是直接做减法的问题~ 是无法统计出一个年度,或者一个季度的利润 因为统计出来的只能是一个年度或者一个季度的里面某一个订单~~~就一个 |
SUM((og.goods_price-og.cost_price)*og.goods_number) 原来这样才行呢~~~ |
最近更新
常用插件
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...
ecshop热门问答
ecshop热门资料
ecshop浏览次数
ecshopuri
ecshop截至日期
ecshop新闻快讯置顶套红功能
ecshop分辨率
ecshop平安
ecshop代金
ecshop繁体字
ecshop后台管理员
ecshopthumb
ecshopregion
ecshop拍卖商品
ecshop快递单号
ecshop界面
ecshopcart
ecshop代替
ecshop欧宝
ecshop1062
ecshopcategories
ecshop三给分类
ecshop浏览量
ecshop新浪微博
ecshop转向
ecshopxhr
ecshopTemporarily
ecshop冲突
zencart销售数量
ecshopArray
ecshop内衣
ecshop222