|
@@ -6,39 +6,16 @@
|
|
|
class Product extends MongoAr
|
|
|
{
|
|
|
public $_id;
|
|
|
-
|
|
|
public $name;//服务的名字
|
|
|
-
|
|
|
- public $pet_types=array();//产品关联的宠物类型数组
|
|
|
-
|
|
|
- public $min_weight=0;//产品关联的最少体重 kg为单位
|
|
|
- public $max_weight;//产品关联的最大体重 kg为单位 0为不限制最大体重
|
|
|
-
|
|
|
- public $price;//商品的价格 单位:元
|
|
|
-
|
|
|
- public $dianping_price;//点评优惠价格
|
|
|
-
|
|
|
public $status=0;//产品状态 0=>暂停使用 1=>正常使用 -1=>已删除
|
|
|
-
|
|
|
- public $order=0;//产品权重
|
|
|
-
|
|
|
- public $sale_count = 0;
|
|
|
-
|
|
|
- public $cost_time = 0; //完成单项服务所需花费的时间
|
|
|
-
|
|
|
- public $is_extra = 0;//是否是附加服务 1=>附加服务 0=>非附加服务
|
|
|
-
|
|
|
- public $type;//服务的适用类型 array(1=>array("name"=>"宠物洗澡"),2=>array("name"=>"宠物剪毛"),3=>array("name"=>"宠物美容"))
|
|
|
-
|
|
|
+ public $order=0;//产品权重
|
|
|
+ public $type;//服务的适用类型
|
|
|
public $desc;//图文介绍 json格式 [{ // 图文详情"type": 1, // 1: 图片url, 2: 纯文本 "content": "http://a.big.jpg"}, {"type": 1,"content": "http://b.big.jpg"}, {"type": 2,"content": "描述文案..."}, // ... ]
|
|
|
+ public $pics=array();//七牛的地址 array('url'=>'http://xxx.qiniudn.com/1414476356856.jpg','height'=>1180,'width'=>2340)
|
|
|
|
|
|
- public $introduction;//产品的简要介绍
|
|
|
-
|
|
|
- public $orderAmount;//产品的销量
|
|
|
+ public $price;//商品的单价 单位:元
|
|
|
|
|
|
- public $pics=array();//帖子中的图片 七牛的地址 array('url'=>'http://wozhua-avatars.qiniudn.com/1414476356856.jpg','height'=>1180,'width'=>2340)
|
|
|
-
|
|
|
- public $service_type;//服务类型 狗洗澡、猫洗澡、狗体外驱虫、狗体内驱虫等
|
|
|
+ public $extra;//array('types'=>array(array('type'=>'一室一卫','price'=>180),array('type'=>'二室一卫','price'=>280)))
|
|
|
|
|
|
public static $status_option = array(
|
|
|
0 => array('name' => '暂停使用'),
|
|
@@ -76,37 +53,21 @@ class Product extends MongoAr
|
|
|
public function parseRow($row,$output=array()){
|
|
|
$newRow = array();
|
|
|
$newRow['id'] = (string)$row['_id'];
|
|
|
-
|
|
|
- $pet_types = array();
|
|
|
- $t_type = new ZPetType();
|
|
|
- if(isset($row['pet_types'])&&is_array($row['pet_types'])){
|
|
|
- $types = $t_type->getTypeInfo($row['pet_types']);
|
|
|
-
|
|
|
- $pet_types = PetTypes::model()->parse($types,true,array('name', 'id'));
|
|
|
- }
|
|
|
- $newRow['pet_types'] = $pet_types;
|
|
|
- if(!isset($newRow['pet_types'])||empty($newRow['pet_types'])){
|
|
|
- $newRow['pet_types']=CommonFn::$empty;
|
|
|
- }
|
|
|
-
|
|
|
- $newRow['min_weight'] = CommonFn::get_val_if_isset($row,'min_weight',0);
|
|
|
- $newRow['max_weight'] = CommonFn::get_val_if_isset($row,'max_weight',0);
|
|
|
-
|
|
|
$newRow['price'] = CommonFn::get_val_if_isset($row,'price',100);
|
|
|
- $newRow['dianping_price'] = CommonFn::get_val_if_isset($row,'dianping_price',$newRow['price']);
|
|
|
+
|
|
|
$newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
|
|
|
$newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
|
|
|
- $newRow['introduction'] = CommonFn::get_val_if_isset($row,'introduction','');
|
|
|
|
|
|
$newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
|
|
|
|
|
|
- $newRow['cost_time'] = CommonFn::get_val_if_isset($row,'cost_time',0);
|
|
|
- $newRow['is_extra'] = CommonFn::get_val_if_isset($row,'is_extra',0);
|
|
|
+
|
|
|
$newRow['order'] = CommonFn::get_val_if_isset($row,'order',1);
|
|
|
|
|
|
$newRow['type'] = CommonFn::get_val_if_isset($row,'type',1);
|
|
|
$newRow['type_str'] = Yii::app()->params['o2o_service'][$newRow['type']]['name'];
|
|
|
|
|
|
+ $newRow['extra'] = CommonFn::get_val_if_isset($row,'extra',array());
|
|
|
+
|
|
|
$newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
|
|
|
$newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
|
|
|
$newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
|
|
@@ -116,7 +77,6 @@ class Product extends MongoAr
|
|
|
$newRow['pics'] = CommonFn::$empty;
|
|
|
}
|
|
|
|
|
|
- $newRow['service_type'] = CommonFn::get_val_if_isset($row, 'service_type', 100);
|
|
|
|
|
|
if(APPLICATION=='api'){
|
|
|
//unset($newRow['status']);
|
|
@@ -128,86 +88,4 @@ class Product extends MongoAr
|
|
|
return $this->output($newRow,$output);
|
|
|
}
|
|
|
|
|
|
- public function parseRowForDianping($row){
|
|
|
- $newRow = array();
|
|
|
-
|
|
|
- $newRow['min_weight'] = CommonFn::get_val_if_isset($row,'min_weight',0);
|
|
|
- $newRow['max_weight'] = CommonFn::get_val_if_isset($row,'max_weight',0);
|
|
|
- $newRow['price'] = CommonFn::get_val_if_isset($row,'price',100);
|
|
|
- $newRow['orderAmount'] = CommonFn::get_val_if_isset($row,'orderAmount',100);
|
|
|
- $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
|
|
|
- $newRow['type'] = CommonFn::get_val_if_isset($row,'type',1);
|
|
|
- $newRow['productId'] = (string)$row['_id'];//第三方产品id
|
|
|
- $newRow['productName'] =CommonFn::get_val_if_isset($row,'name','握爪上门服务'); //产品名称
|
|
|
- $newRow['orderAmount'] = 500; //产品近期销量
|
|
|
- $newRow['duration'] = 120; //产品服务耗时,以分钟为单位
|
|
|
- $newRow['abstract'] = '上门宠物服务'; //用于展现在产品列表页的一行内容
|
|
|
-
|
|
|
- $newRow['description'] = CommonFn::get_val_if_isset($row,'introduction',''); //产品描述
|
|
|
-
|
|
|
- $newRow['details'] = json_decode(CommonFn::get_val_if_isset($row,'desc','[]')); //jsonArray 图文详情,目前支持两种类型: 1图片url,2纯文本。content总长度不能超过4000字节 json总长度不超过4000
|
|
|
-
|
|
|
- $newRow['originalPrice'] = ceil(CommonFn::get_val_if_isset($row,'price',100)); //float 原始价格,以元为单位
|
|
|
- $newRow['dianping_price'] = ceil(CommonFn::get_val_if_isset($row,'dianping_price',0)); //真实价格
|
|
|
- $newRow['settlePrice'] = $newRow['originalPrice']; //真实价格
|
|
|
- $newRow['minOrders'] = 1; //最小下单份数
|
|
|
- $newRow['maxOrders'] = 1; //最大下单份数
|
|
|
- $newRow['imageUrls'] = CommonFn::get_val_if_isset($row,'pics',array()); // jsonArray 多张产品图片。图片大小640×360 单一url小于256
|
|
|
- $temp_image = array();
|
|
|
- foreach ($newRow['imageUrls'] as $value) {
|
|
|
- $temp_image[] = $value['url'];
|
|
|
- }
|
|
|
- $newRow['imageUrls'] = $temp_image;
|
|
|
- $newRow['thumbUrl'] = ''; //string 预览图,图片大小 140×140 256
|
|
|
- if($newRow['imageUrls'] && $newRow['imageUrls'][0]){
|
|
|
- $newRow['thumbUrl'] = $newRow['imageUrls'][0];
|
|
|
- unset($newRow['imageUrls'][0]);
|
|
|
- }
|
|
|
-
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->status('==',1);
|
|
|
- if($newRow['type']){
|
|
|
- $criteria->type('==',$newRow['type']);
|
|
|
- }
|
|
|
- if(isset($row['pet_types'])){
|
|
|
- $criteria->pet_types('==',$row['pet_types']);
|
|
|
- }
|
|
|
- $criteria->max_weight('>=',$newRow['max_weight']);
|
|
|
- $model = new Product();
|
|
|
- $criteria->is_extra('==',1);
|
|
|
- $extra_products = $model->findAll($criteria);
|
|
|
- $extra_products = CommonFn::getRows($extra_products);
|
|
|
- $extra_products = $model->parse($extra_products);
|
|
|
- $packageList = array();
|
|
|
- $i = 1;
|
|
|
- $package = array();
|
|
|
- $package['packageId'] = "1";
|
|
|
- $package['packageName'] = $newRow['productName'];
|
|
|
- $package['originalPrice'] = $newRow['originalPrice'];
|
|
|
- $package['settlePrice'] = $newRow['settlePrice'];
|
|
|
- $package['duration'] = 0;
|
|
|
- $packageList[] = $package;
|
|
|
- foreach ($extra_products as $e_product) {
|
|
|
- $package['packageId'] = $e_product['id'];
|
|
|
- if(mb_substr($e_product['name'],-2,2,'utf-8') == '染色'){
|
|
|
- $e_product['name'] = '染色';
|
|
|
- }
|
|
|
- if(mb_substr($newRow['productName'],-3,3,'utf-8') == 'SPA'){
|
|
|
- $package['packageName'] = mb_substr($newRow['productName'],-3,3,'utf-8').'+'.$e_product['name'];
|
|
|
- }else{
|
|
|
- $package['packageName'] = mb_substr($newRow['productName'],-2,2,'utf-8').'+'.$e_product['name'];
|
|
|
- }
|
|
|
- $package['originalPrice'] = $e_product['price'] + $newRow['originalPrice'];
|
|
|
- // $package['settlePrice'] = $e_product['dianping_price'] + $newRow['dianping_price'];
|
|
|
- $package['settlePrice'] = $package['originalPrice'];
|
|
|
- $package['duration'] = 0;
|
|
|
- $packageList[] = $package;
|
|
|
- }
|
|
|
- $newRow['packageList'] = $packageList;
|
|
|
-
|
|
|
- $newRow['imageUrls'] = array_values($newRow['imageUrls']);
|
|
|
- $newRow['rank'] = 10000 - CommonFn::get_val_if_isset($row,'order',1); //int 控制排序,越小越靠前
|
|
|
- return $newRow;
|
|
|
- }
|
|
|
-
|
|
|
}
|