作者 何书鹏
1 个管道 的构建 通过 耗费 3 秒

订单详情完善

... ... @@ -133,6 +133,7 @@ class Order extends Model
'goods_price' => $goods['goods_price'],
'goods_num' => $goods['goods_num'],
'user_size_id' => !empty($goods['user_size']) ? $goods['user_size']['id'] : 0,
'make_type' => $goods['make_type'],
'goods_style' => $goods['goods_style'],
'spec_sku_id' => $goods['goods_sku']['spec_sku_id'],
'goods_attr' => $goods['goods_sku']['goods_attr'],
... ... @@ -196,7 +197,7 @@ class Order extends Model
$filter['refund_status'] = '0';
break;
}
return $this->with('goods')
return $this->with(['goods'=>['user_size']])
->where('user_id', $user_id)
->where('order_status', '<>', '2')
->where($filter)
... ... @@ -213,7 +214,7 @@ class Order extends Model
'id' => $order_id,
'user_id' => $user_id,
'order_status' => ['<>', '2']
], ['goods' => ['goods','spec'], 'address'])) {
], ['goods' => ['goods','user_size','spec'], 'address'])) {
$this->setError('订单不存在');
return false;
}
... ...
... ... @@ -14,7 +14,8 @@ class OrderGoods extends Model
// 追加属性
protected $append = [
'goods_style_text'
'goods_style_text',
'make_type_text'
];
/**
... ... @@ -22,7 +23,14 @@ class OrderGoods extends Model
*/
public function goods()
{
return $this->belongsTo('Goods');
return $this->belongsTo('Goods', 'goods_id')->setEagerlyType(0);
}
/**
* 尺寸
*/
public function userSize(){
return $this->belongsTo('UserSize', 'user_size_id')->setEagerlyType(0);
}
/**
... ... @@ -59,4 +67,12 @@ class OrderGoods extends Model
}
return $goods_style_text;
}
/**
* 定制项名称
*/
public function getMakeTypeTextAttr($value,$data){
$make_type_arr = ['0'=>'','1'=>'模特款','2'=>'自定义'];
return $make_type_arr[$data['make_type']];
}
}
... ...
... ... @@ -138,7 +138,7 @@ class UserSize extends Model
$size_text = array_merge([
['style_name'=>'身高','style_type'=>'1','style_value'=>$data['height'].'CM'],
['style_name'=>'体重','style_type'=>'1','style_value'=>$data['weight'].'KG'],
['style_name'=>'腰围','style_type'=>'1','style_value'=>$data['waistline']],
['style_name'=>'腰围','style_type'=>'1','style_value'=>!empty($data['waistline']) ? $data['waistline'] : '未填写'],
],$size_text);
return $size_text;
}
... ...