Cart.php
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?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);
}
}