...
|
...
|
@@ -21,7 +21,7 @@ class Litestoregoods extends Model |
|
|
'spec_type_text',
|
|
|
'deduct_stock_type_text',
|
|
|
'goods_status_text',
|
|
|
'is_delete_text'
|
|
|
'is_delete_text',
|
|
|
];
|
|
|
|
|
|
|
...
|
...
|
@@ -36,32 +36,32 @@ class Litestoregoods extends Model |
|
|
|
|
|
public function getSpecTypeList()
|
|
|
{
|
|
|
return ['10' => __('Spec_type 10'),'20' => __('Spec_type 20')];
|
|
|
return ['10' => __('Spec_type 10'), '20' => __('Spec_type 20')];
|
|
|
}
|
|
|
|
|
|
public function getDeductStockTypeList()
|
|
|
{
|
|
|
return ['10' => __('Deduct_stock_type 10'),'20' => __('Deduct_stock_type 20')];
|
|
|
return ['10' => __('Deduct_stock_type 10'), '20' => __('Deduct_stock_type 20')];
|
|
|
}
|
|
|
|
|
|
public function getMakeforList()
|
|
|
{
|
|
|
return ['1' => __('Makefor 1'),'2' => __('Makefor 2')];
|
|
|
return ['1' => __('Makefor 1'), '2' => __('Makefor 2')];
|
|
|
}
|
|
|
|
|
|
public function getIsIndexList()
|
|
|
{
|
|
|
return ['0' => __('Is_index 0'),'1' => __('Is_index 1')];
|
|
|
return ['0' => __('Is_index 0'), '1' => __('Is_index 1')];
|
|
|
}
|
|
|
|
|
|
public function getGoodsStatusList()
|
|
|
{
|
|
|
return ['10' => __('Goods_status 10'),'20' => __('Goods_status 20')];
|
|
|
return ['10' => __('Goods_status 10'), '20' => __('Goods_status 20')];
|
|
|
}
|
|
|
|
|
|
public function getIsDeleteList()
|
|
|
{
|
|
|
return ['0' => __('Is_delete 0'),'1' => __('Is_delete 1')];
|
|
|
return ['0' => __('Is_delete 0'), '1' => __('Is_delete 1')];
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -118,7 +118,7 @@ class Litestoregoods extends Model |
|
|
*/
|
|
|
public function spec()
|
|
|
{
|
|
|
return $this->hasMany('Litestoregoodsspec','goods_id','goods_id');
|
|
|
return $this->hasMany('Litestoregoodsspec', 'goods_id', 'goods_id');
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -126,7 +126,7 @@ class Litestoregoods extends Model |
|
|
*/
|
|
|
public function specRel()
|
|
|
{
|
|
|
return $this->belongsToMany('Litestorespecvalue', 'litestore_goods_spec_rel','spec_value_id','goods_id');
|
|
|
return $this->belongsToMany('Litestorespecvalue', 'litestore_goods_spec_rel', 'spec_value_id', 'goods_id');
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -146,7 +146,7 @@ class Litestoregoods extends Model |
|
|
* @param $isUpdate
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
public function addGoodsSpec(&$data,$params,$specparams,$isUpdate = false)
|
|
|
public function addGoodsSpec(&$data, $params, $specparams, $isUpdate = false)
|
|
|
{
|
|
|
// 更新模式: 先删除所有规格
|
|
|
$model = new Litestoregoodsspec;
|
...
|
...
|
@@ -154,19 +154,22 @@ class Litestoregoods extends Model |
|
|
// 添加规格数据
|
|
|
if ($data['spec_type'] === '10') {
|
|
|
// 单规格
|
|
|
$specparams['discount'] = (round($specparams['line_price'] / $specparams['goods_price'], 2) * 100) . '折';
|
|
|
$this->spec()->save($specparams);
|
|
|
} else if ($data['spec_type'] === '20') {
|
|
|
// 添加商品与规格关系记录
|
|
|
$model->addGoodsSpecRel($this['goods_id'],$params['spec_attr']);
|
|
|
$model->addGoodsSpecRel($this['goods_id'], $params['spec_attr']);
|
|
|
// 添加商品sku
|
|
|
$model->addSkuList($this['goods_id'],$params['spec_list']);
|
|
|
$model->addSkuList($this['goods_id'], $params['spec_list']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function removesku(){
|
|
|
public function removesku()
|
|
|
{
|
|
|
// 删除商品sku
|
|
|
(new Litestoregoodsspec)->removeAll($this['goods_id']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取规格信息
|
|
|
*/
|
...
|
...
|
|