ecshop订单状态对应值:
order_status有5中状态,并且当客户确认收货后,order_status的数值不一定是1也有可能是5。
order_status = 0表示订单未确认
order_status = 1表示订单已经确认
order_status = 2表示订单已经取消
pay_status = 0表示未付款
pay_status = 2表示已付款
shipping_status = 3表示已配货
shipping_status = 1表示已发货
shipping_status = 2表示已收货
ecshop商品分类列表,商品按照销量排序,网上有些方法是判断ecs_order_info.order_status=1来判断订单完成状态,当在ecshop3.6测试发现,当客户确认订单后,order_status=5而非1,截图如下:
截图可以看到,客户确认后,但未发货,而order_status=1,所以取order_status=1作为判断销售完成情况,并不对!
考虑到客户购买商品后,虽然收到货物,但是也不一定会登录后台,点击确认收货,所以在这里只要判断pay_status=2,即客户已付款即可。
找到category.php中category_get_goods方法的sql语句,修改如下:
$sql = 'SELECT (SELECT sum(goods_number) FROM ecs_order_goods where goods_id=g.goods_id and order_id in (select order_id from ecs_order_info where pay_status=2)) as sales, g.goods_id, g.goods_name,g.goods_number,g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE $where $ext ORDER BY $sort $order";
同时 $sort中设置按销量排序标志,比如sales
剩下的工作,就比较简单了,就不再赘述。