1748153932 11 months ago
parent e121e4d5d1
commit 9026097570
  1. 13
      app/common/repositories/store/product/ProductRepository.php
  2. 1
      app/controller/admin/store/StoreProductAssist.php
  3. 9
      app/controller/merchant/store/product/Product.php

@ -13,6 +13,8 @@
namespace app\common\repositories\store\product;
use app\common\model\store\product\Product;
use app\common\model\store\product\Spu;
use app\common\model\store\product\ProductLabel;
use app\common\model\user\User;
use app\common\repositories\community\CommunityRepository;
@ -60,7 +62,7 @@ class ProductRepository extends BaseRepository
protected $dao;
const CREATE_PARAMS = [
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend',
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code",'is_pre', "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend',
["brand_id",0],
['once_max_count',0],
['once_min_count',0],
@ -258,6 +260,7 @@ class ProductRepository extends BaseRepository
$data['attr'] = [];
if (count($data['attrValue']) > 1) throw new ValidateException('单规格商品属性错误');
}
event('product.update.before', compact('id','data','merId','productType','conType'));
$spuData = $product = $this->setProduct($data);
$settleParams = $this->setAttrValue($data, $id, $productType, 1);
@ -270,7 +273,7 @@ class ProductRepository extends BaseRepository
$spuData['price'] = $settleParams['data']['price'];
$spuData['mer_id'] = $merId;
$spuData['mer_labels'] = $data['mer_labels'];
$spuData['is_pre'] = $data['is_pre'];
Db::transaction(function () use ($id, $data, $productType, $settleParams,$content,$product,$spuData,$merId) {
$this->save($id, $settleParams, $content, $product, $productType);
if ($productType == 1) { //秒杀商品
@ -593,6 +596,7 @@ class ProductRepository extends BaseRepository
"extension_two" => $extension_status ? ($value['extension_two'] ?? 0) : 0,
"product_id" => $productId,
"type" => 0,
"sku" => $sku,
"unique" => $unique,
'sales' => $isUpdate ? ($oldSku[$sku]['sales'] ?? 0) : 0,
@ -734,6 +738,11 @@ class ProductRepository extends BaseRepository
if ($conType) $content = json_decode($content);
unset($data['content']);
$data['content'] = $content;
$info = Spu::getDB()
->where('product_id', $id)->find()->toArray();
$data['mer_labels'] = (int)$info['mer_labels'][0];
return $data;
}

@ -97,6 +97,7 @@ class StoreProductAssist extends BaseController
*/
public function update($id, validate $validate)
{
$data = $this->checkParams($validate);
if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
return app('json')->fail('数据不存在');

@ -12,6 +12,8 @@
namespace app\controller\merchant\store\product;
use app\common\model\store\product\StoreDiscountProduct;
use app\common\model\store\product\Product as smodel;
use app\common\repositories\store\order\StoreCartRepository;
use app\common\repositories\store\product\ProductAttrValueRepository;
use app\common\repositories\store\product\SpuRepository;
@ -94,8 +96,11 @@ class Product extends BaseController
*/
public function update($id)
{
$params = $this->request->params($this->repository::CREATE_PARAMS);
$data = $this->repository->checkParams($params,$this->request->merId(), $id);
if (!$this->repository->merExists($this->request->merId(), $id))
return app('json')->fail('数据不存在');
$pro = $this->repository->getWhere(['product_id' => $id]);
@ -106,7 +111,11 @@ class Product extends BaseController
}
$data['mer_status'] = ($this->request->merchant()->is_del || !$this->request->merchant()->mer_state || !$this->request->merchant()->status) ? 0 : 1;
$data['mer_id'] = $this->request->merId();
$this->repository->edit($id, $data, $this->request->merId(), 0);
$a = new smodel();
$a::getDB()->where('product_id',$id)->update(['is_pre'=>$data['is_pre']]);
return app('json')->success('编辑成功');
}

Loading…
Cancel
Save