Merge branch 'master' into lszyh

lszyh
zyh 1 month ago
commit c1ec294a1f
  1. 4
      app/store/controller/Goods.php
  2. 7
      app/store/model/Goods.php

@ -153,6 +153,8 @@ class Goods extends Controller
$model = new GoodsModel; $model = new GoodsModel;
$postform = $this->postForm(); $postform = $this->postForm();
$postform['merchant_id'] = $this->merchantId; $postform['merchant_id'] = $this->merchantId;
//处理子商城之后,设置store_id为0的情况
$postform['store_id'] = $this->storeId;
if ($model->add($postform)) { if ($model->add($postform)) {
return $this->renderSuccess('添加成功'); return $this->renderSuccess('添加成功');
} }
@ -173,6 +175,7 @@ class Goods extends Controller
// 商品详情 // 商品详情
$model = GoodsModel::detail($goodsId); $model = GoodsModel::detail($goodsId);
$params = $this->postForm(); $params = $this->postForm();
if ($model->isEmpty()) { if ($model->isEmpty()) {
return $this->renderError("该商品已不存在!"); return $this->renderError("该商品已不存在!");
} }
@ -187,6 +190,7 @@ class Goods extends Controller
// print_r($model->toArray()); // print_r($model->toArray());
//exit(); //exit();
$params['data_type'] = $model->data_type; $params['data_type'] = $model->data_type;
//$params['store_id'] = $this->storeId;
// 更新记录 // 更新记录
if ($model->edit($params)) { if ($model->edit($params)) {
return $this->renderSuccess('更新成功'); return $this->renderSuccess('更新成功');

@ -115,6 +115,7 @@ class Goods extends GoodsModel
// 事务处理 // 事务处理
$this->transaction(function () use ($data) { $this->transaction(function () use ($data) {
$data['data_type'] = 1; $data['data_type'] = 1;
// 添加商品 // 添加商品
$this->save($data); $this->save($data);
// 新增商品与分类关联 // 新增商品与分类关联
@ -145,9 +146,6 @@ class Goods extends GoodsModel
// 创建商品数据 // 创建商品数据
$data = $this->createData($data); $data = $this->createData($data);
// echo "<pre>";
// print_r($data);
// exit();
// 事务处理 // 事务处理
$ret = $this->transaction(function () use ($data, $goodsModel) { $ret = $this->transaction(function () use ($data, $goodsModel) {
@ -159,7 +157,6 @@ class Goods extends GoodsModel
$data['spu_id'] = 0; $data['spu_id'] = 0;
} }
// 更新商品 // 更新商品
$this->save($data); $this->save($data);
// 更新商品与分类关联 // 更新商品与分类关联
@ -342,7 +339,7 @@ class Goods extends GoodsModel
'newSpecList' => [], 'newSpecList' => [],
//'data_type' => 1,//数据类型 //'data_type' => 1,//数据类型
'newSkuList' => [], 'newSkuList' => [],
'store_id' => self::$storeId, //'store_id' => self::$storeId,
//'sale_areas' => $arr ? implode("、", $arr) : "", //'sale_areas' => $arr ? implode("、", $arr) : "",
]); ]);
if (isset($data['rules'])) { if (isset($data['rules'])) {

Loading…
Cancel
Save