Merge branch 'master' into lszyh

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

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

@ -115,6 +115,7 @@ class Goods extends GoodsModel
// 事务处理
$this->transaction(function () use ($data) {
$data['data_type'] = 1;
// 添加商品
$this->save($data);
// 新增商品与分类关联
@ -141,13 +142,10 @@ class Goods extends GoodsModel
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit(array $data, $goodsModel = null): bool
{
{
// 创建商品数据
$data = $this->createData($data);
// echo "<pre>";
// print_r($data);
// exit();
// 事务处理
$ret = $this->transaction(function () use ($data, $goodsModel) {
@ -158,8 +156,7 @@ class Goods extends GoodsModel
} else {
$data['spu_id'] = 0;
}
// 更新商品
$this->save($data);
// 更新商品与分类关联
@ -342,7 +339,7 @@ class Goods extends GoodsModel
'newSpecList' => [],
//'data_type' => 1,//数据类型
'newSkuList' => [],
'store_id' => self::$storeId,
//'store_id' => self::$storeId,
//'sale_areas' => $arr ? implode("、", $arr) : "",
]);
if (isset($data['rules'])) {

Loading…
Cancel
Save