ecshop 批量生成订单信息

php
/**
 * ecshop 给商品添加随机添加订单信息
 * @author Abner
 * qq :346882795
 * email: [email protected]
 * 
 * */


define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');





//取出所有商品的信息
$gsql = 'SELECT * FROM ' .$GLOBALS['ecs'] -> table('goods'). 'WHERE 1';
$gdata = $db -> getAll($gsql);


//根据商品id生成订单信息
foreach($gdata as $k => $v)
{
    //评论的数量
    $comment_num = $db->getOne("SELECT count(comment_id) id FROM " .$GLOBALS['ecs'] -> table('comment'). " WHERE `id_value` = {$v['goods_id']}");
    $goods_number = $comment_num + mt_rand(1,50);
    $ogsql = 'INSERT INTO' .$GLOBALS['ecs'] -> table('order_goods'). 
    "(`order_id`, `goods_id`, `goods_name`, `goods_sn`, `product_id`, `goods_number`, `market_price`, `goods_price`, `send_number`, `is_real`, `parent_id`, `is_gift`, `comment_state`, `shaidan_state`, `send_store_number`, `send_store_id`) VALUES ".
    "(7, {$v['goods_id']}, '{$v['goods_name']}', '{$v['goods_sn']}', 0, {$goods_number}, {$v['market_price']}, {$v['shop_price']}, 0, 1, 0, 0, 0, 0, 0, 0)";
    
    $res = $db -> query($ogsql);
    if($res)
        echo "{$v['goods_id']} 插入成功! 
"; else echo "{$v['goods_id']} 插入失败!
"; }

 

转载于:https://www.cnblogs.com/Abner3721/p/5522354.html

你可能感兴趣的:(ecshop 批量生成订单信息)