lqmac 6 months ago
parent 3e6617f9c8
commit 507c8efcb8
  1. 5
      app/admin/controller/Goods.php
  2. 16
      app/admin/controller/Store.php
  3. 1
      app/store/controller/Goods.php
  4. 9
      app/store/model/Goods.php

@ -135,11 +135,13 @@ class Goods extends Controller
{ {
// 商品详情 // 商品详情
$model = GoodsModel::detail($goodsId); $model = GoodsModel::detail($goodsId);
$params = $this->postForm();
$params['data_type'] = $model->data_type;
// echo "<pre>"; // echo "<pre>";
// print_r($model); // print_r($model);
// exit(); // exit();
// 更新记录 // 更新记录
if ($model->edit($this->postForm(), $model)) { if ($model->edit($params, $model)) {
//更新来源数据为当前数据的商品 //更新来源数据为当前数据的商品
@ -178,6 +180,7 @@ class Goods extends Controller
'is_jd_remove' => $goods_sku->is_jd_remove, 'is_jd_remove' => $goods_sku->is_jd_remove,
'goods_no_other' => $goods_sku->goods_no_other, 'goods_no_other' => $goods_sku->goods_no_other,
'link_other' => $goods_sku->link_other, 'link_other' => $goods_sku->link_other,
'data_type' => $goods_sku->data_type,
// 'is_pool' => $goods_sku->is_pool, // 'is_pool' => $goods_sku->is_pool,
// 'is_sale' => $goods_sku->is_sale, // 'is_sale' => $goods_sku->is_sale,
'update_time' => time(), 'update_time' => time(),

@ -373,8 +373,11 @@ class Store extends Controller
* @param int $storeId [description] * @param int $storeId [description]
* @return [type] [description] * @return [type] [description]
*/ */
public function deleteGoods(int $storeId): Json public function deleteGoods(): Json
{ {
$params = $this->postData();
$storeId = $params['storeId'] ?? 0;
$type = $params['type'] ?? 0;
ini_set('memory_limit', '1024M'); ini_set('memory_limit', '1024M');
set_time_limit(0); set_time_limit(0);
$model = StoreModel::detail($storeId); $model = StoreModel::detail($storeId);
@ -383,11 +386,12 @@ class Store extends Controller
} }
//删除分类 //删除分类
if ($type == "cate") {
Category::where('store_id', $storeId)->delete(); Category::where('store_id', $storeId)->delete();
// GoodsSku::where('store_id', $storeId)->delete(); return $this->renderSuccess();
// GoodsImage::where('store_id', $storeId)->delete(); }
// GoodsSpecRel::where('store_id', $storeId)->delete();
// GoodsModel::where('store_id', $storeId)->delete(); if ($type == "goods") {
$page = 1; $page = 1;
while (TRUE) { while (TRUE) {
//echo $page.PHP_EOL; //echo $page.PHP_EOL;
@ -426,6 +430,8 @@ class Store extends Controller
} }
//删除商品 //删除商品
GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->delete(); GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->delete();
}
return $this->renderSuccess(); return $this->renderSuccess();
} }

@ -167,6 +167,7 @@ class Goods extends Controller
// print_r($params); // print_r($params);
// print_r($model->toArray()); // print_r($model->toArray());
// exit(); // exit();
$params['data_type'] = $model->data_type;
// 更新记录 // 更新记录
if ($model->edit($params)) { if ($model->edit($params)) {
return $this->renderSuccess('更新成功'); return $this->renderSuccess('更新成功');

@ -114,7 +114,7 @@ class Goods extends GoodsModel
$data = $this->createData($data); $data = $this->createData($data);
// 事务处理 // 事务处理
$this->transaction(function () use ($data) { $this->transaction(function () use ($data) {
$data['data_type'] = $data['data_type'] ?? 1; $data['data_type'] = 1;
// 添加商品 // 添加商品
$this->save($data); $this->save($data);
// 新增商品与分类关联 // 新增商品与分类关联
@ -143,7 +143,6 @@ class Goods extends GoodsModel
public function edit(array $data, $goodsModel = null): bool public function edit(array $data, $goodsModel = null): bool
{ {
// 创建商品数据 // 创建商品数据
$data = $this->createData($data); $data = $this->createData($data);
// echo "<pre>"; // echo "<pre>";
@ -335,7 +334,7 @@ class Goods extends GoodsModel
'line_price' => $data['line_price'] ?? 0, 'line_price' => $data['line_price'] ?? 0,
'content' => $data['content'] ?? '', 'content' => $data['content'] ?? '',
'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) : "",
@ -412,7 +411,9 @@ class Goods extends GoodsModel
} }
$data['imagesIds'] = $images; $data['imagesIds'] = $images;
} }
if ($data['categoryIds']) {
$data['cate_status'] = 1;
}
return $data; return $data;
} }

Loading…
Cancel
Save