Commit aa10b30a authored by jianghaiming's avatar jianghaiming

updateS:et

parent 2b65ef42
<?php
namespace Validate;
/**
* Class GoodsAuditValidate
*
* @package Validate
*/
class GoodsOnlineSiteValidate extends BaseValidate
{
protected $rule = [
'goods_spu_id' => 'require',
'online_type' => 'require',
];
protected $message = [
"goods_spu_id" => "商品id不能为空",
"online_type" => "设置类型不能为空",
];
}
\ No newline at end of file
...@@ -16,6 +16,7 @@ use \Validate\GoodsOnlineOfflineValidate; ...@@ -16,6 +16,7 @@ use \Validate\GoodsOnlineOfflineValidate;
use \Validate\PaySuccessGoodsCallbackValidate; use \Validate\PaySuccessGoodsCallbackValidate;
use \Validate\GoodsInitShopValidate; use \Validate\GoodsInitShopValidate;
use \Validate\PindanGoodsAddValidate; use \Validate\PindanGoodsAddValidate;
use \Validate\GoodsOnlineSiteValidate;
use \App\Services\goods\ElasticGoodService; use \App\Services\goods\ElasticGoodService;
use \App\Services\goods\MarketingPindanGoodsService; use \App\Services\goods\MarketingPindanGoodsService;
use \App\Models\marketing\mysql\Marketing; use \App\Models\marketing\mysql\Marketing;
...@@ -118,6 +119,20 @@ class GoodsController extends Base ...@@ -118,6 +119,20 @@ class GoodsController extends Base
$this->success(); $this->success();
} }
/**
* 修改商品定点上架设置
* @date 2021-08-25
* @license [license]
* @version [version]
*/
public function online_siteAction()
{
$params = $this->params;
(new GoodsOnlineSiteValidate())->validate();
GoodsService::onlineSite($params);
$this->success();
}
/** /**
* 审核通过/驳回 * 审核通过/驳回
*/ */
......
...@@ -549,6 +549,45 @@ class GoodsService ...@@ -549,6 +549,45 @@ class GoodsService
return true; return true;
} }
/**
* 设置商品上架
* @date 2021-08-25
* @copyright [copyright]
* @license [license]
* @version [version]
* @param $params [description]
* @return array [description]
*/
public static function onlineSite($params)
{
$goodsSpuId = $params["goods_spu_id"];
$onlineType = !empty($params["online_type"]) ? $params["online_type"] : 0;
$onlineStartTime = !empty($params["online_start_time"]) ? $params["online_start_time"] : null;
$onlineEndTime = !empty($params["online_end_time"]) ? $params["online_end_time"] : null;
GoodsSku::beginTransaction();
$goodsSkuList = GoodsSku::select("*", ["goods_spu_id" => $goodsSpuId]);
if (!empty($goodsSkuList)) {
foreach ($goodsSkuList as $sku) {
$goodsSkuId = $sku["goods_sku_id"];
$goodsSkuData = [
"online_type" => $onlineType,
"online_start_time" => $onlineStartTime,
"online_end_time" => $onlineEndTime
];
GoodsSku::save($goodsSkuData, ["goods_sku_id" => $goodsSkuId]);
//上架的话,生成快照
self::addGoodsSnapshot($sku);
self::updateGoodsInfoToEs($goodsSkuId);
}
}
if (!GoodsSku::commit()) {
GoodsSku::rollback();
throw new GoodsException(["cus" => 11]);
}
return true;
}
/** /**
* 生成快照数据 * 生成快照数据
* @param $skuInfo * @param $skuInfo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment