From 47cceb8bb2d80e3dabe2baa33c20e53561774f3a Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Thu, 7 Mar 2024 17:05:01 +0800 Subject: [PATCH 1/3] 1 --- app/api/model/Goods.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 2e0525af..95a54449 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -708,8 +708,9 @@ class Goods extends GoodsModel return false; } //批量修改秒杀价格 - $sku_ids = explode(',', $data['sku_id']); - foreach ($sku_ids as $sku_id) { +// var_dump($data['sku_id']); + $sku_id = $data['sku_id']; +// foreach ($sku_ids as $sku_id) { $skuData = GoodsSkuModel::get(['id' => $sku_id,'goods_id' => $data['goods_id']]); if ($skuData) { $up_data = [ @@ -721,7 +722,7 @@ class Goods extends GoodsModel ]; $skuData->save($up_data); } - } +// } return true; } } From 30551faa67a924305c191cee9a1d420109ac1c6a Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Fri, 8 Mar 2024 08:54:30 +0800 Subject: [PATCH 2/3] 1 --- app/common/model/PreSale.php | 8 ++++++++ app/store/controller/Presale.php | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/common/model/PreSale.php b/app/common/model/PreSale.php index 24bfbfbb..d24d48bd 100644 --- a/app/common/model/PreSale.php +++ b/app/common/model/PreSale.php @@ -28,4 +28,12 @@ class PreSale extends BaseModel protected $pk = 'id'; protected $updateTime = false; + + public function getCtimeAttr($value) { + if(!empty($value)) return format_time($value); + } + + public function getPTimeAttr($value) { + if(!empty($value)) return format_time($value); + } } diff --git a/app/store/controller/Presale.php b/app/store/controller/Presale.php index 4151dec4..3d62b0e0 100644 --- a/app/store/controller/Presale.php +++ b/app/store/controller/Presale.php @@ -75,7 +75,12 @@ class Presale extends Controller { // 新增记录 $model = new PreSaleModel; - if ($model->save($this->postForm())) { + $data = $this->postForm(); + $data['store_id'] = $this->storeId; + $data['ctime'] = time(); + $data['p_time'] = time(); + $data['goods_list'] = implode(',', $data['goods_list']); + if ($model->save($data)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); @@ -90,8 +95,10 @@ class Presale extends Controller { // 评论详情 $model = PreSaleModel::get($id); + $data = $this->postForm(); + $data['p_time'] = time(); // 更新记录 - if ($model->save($this->postForm())) { + if ($model->save($data)) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); From 312fc9ee8d81a5e26f4b0df7e051caa192a9bd26 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Fri, 8 Mar 2024 09:34:13 +0800 Subject: [PATCH 3/3] 1 --- app/common/model/PreSale.php | 7 ------- app/store/controller/Presale.php | 11 +++++------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/common/model/PreSale.php b/app/common/model/PreSale.php index d24d48bd..e86a6cfa 100644 --- a/app/common/model/PreSale.php +++ b/app/common/model/PreSale.php @@ -29,11 +29,4 @@ class PreSale extends BaseModel protected $updateTime = false; - public function getCtimeAttr($value) { - if(!empty($value)) return format_time($value); - } - - public function getPTimeAttr($value) { - if(!empty($value)) return format_time($value); - } } diff --git a/app/store/controller/Presale.php b/app/store/controller/Presale.php index 3d62b0e0..be168b4a 100644 --- a/app/store/controller/Presale.php +++ b/app/store/controller/Presale.php @@ -36,7 +36,7 @@ class Presale extends Controller $model = new PreSaleModel; $goodsModel = new \app\common\model\Goods(); $detail = $model->get($id); - $detail['goods_list'] = $goodsModel->whereIn('goods_id', explode(',', $detail['goods_list']))->select()->toArray(); + $detail['goods_list'] = $goodsModel->with(['images.file'])->whereIn('goods_id', explode(',', $detail['goods_list']))->select()->toArray(); return $this->renderSuccess(compact('detail')); } @@ -45,7 +45,7 @@ class Presale extends Controller */ public function log(int $pre_id): Json { $model = new PreSaleLogModel(); - $list = $model->with(['goods']) + $list = $model->with(['goods.images.file']) ->where('store_id', $this->storeId) ->where('pre_id', $pre_id) ->paginate(15); @@ -77,9 +77,8 @@ class Presale extends Controller $model = new PreSaleModel; $data = $this->postForm(); $data['store_id'] = $this->storeId; - $data['ctime'] = time(); - $data['p_time'] = time(); - $data['goods_list'] = implode(',', $data['goods_list']); + $data['ctime'] = format_time(time()); + $data['p_time'] = format_time(time()); if ($model->save($data)) { return $this->renderSuccess('添加成功'); } @@ -96,7 +95,7 @@ class Presale extends Controller // 评论详情 $model = PreSaleModel::get($id); $data = $this->postForm(); - $data['p_time'] = time(); + $data['p_time'] = format_time(time()); // 更新记录 if ($model->save($data)) { return $this->renderSuccess('更新成功');