Cart.php 2.09 KB
<?php
/**
 * order 购物车
 * User: fengjb
 * Date: 2014-8-19
 * Time: PM2:30
 */
class YHMApi_App_V1_Cart extends YHMApi_App_V1_Base {
	
	/**
	 * 获取用户送货地址
	 * @param array $params
	 * @param string $fields
	 */
	public static function getDelivery(array $params, $fields = '*')
	{
		if (empty($params['uid'])) {
			return self::result(400, '用户id不能为空');
		}
		$uid = $params['uid'];
		$deliveryList=YHMDelivery_Models_Delivery_Client::getUserDelivery($uid);
		$data=array();
		if(!empty($deliveryList))
		{
			foreach($deliveryList as $d =>$val)
			{
				$data[$d]['delivery_name']=$val['delivery_name'];
				$data[$d]['area_code']=$val['area_code'];
				$data[$d]['address']=$val['address'];
				$data[$d]['zip_code']=$val['zip_code'];
				$data[$d]['mobile']=$val['mobile'];
				$data[$d]['is_default']=$val['is_default'];
			}
		}
		return self::result(200, '收货信息', $data);
	}
	
	/**
	 * 获取购物车商品信息
	 * @param array $params
	 * @param string $fields
	 */
	public static  function getGoods(array $params, $fields = '*')
	{
		$product_sku=empty($params['product_sku'])?0:(int)$params['product_sku'];
		$cart_id=empty($params['cart_id'])?0:(int)$params['cart_id'];
		if(empty($product_sku) && empty($cart_id))
		{
			return self::result(400, '参数错误', array());
		}
	    $data[]=array(
	    	'product_sku'=>77,
	    	'product_skc'=>8,
	    	'size_code'=>'XL',
	    	'last_price'=>3000,
	    	'buy_number'=>4
	    );
		return self::result(200, '商品信息', $data);
	}
	
	/**
	 * 提交购物车,生成订单,返回支付信息
	 * @param array $params
	 * @param string $fields
	 */
	public static function setOrders(array $params, $fields = '*')
	{
		$params=array(
			'buyer_uid'=>23,
			'store_id'=>1,
			'order_amount'=>100,
			'last_order_amount'=>90,
			'goodslist'=>array(array('order_code'=>23,'product_skc'=>8,'product_sku'=>77,'sales_price'=>100,'last_price'=>100,'num'=>1))
		);
		$synData=YHMCart_Orders_Ordinary::create($params);
		$data=array('order_code'=>600000003,'last_order_amount'=>65,'uid'=>23);
		return self::result(200, '订单信息', $data);
	}
	
}