鲜花2.0-sku命名规则变更
This commit is contained in:
parent
20ae896e0c
commit
ea65bcee66
@ -66,6 +66,8 @@ class GoodsCombinationController extends Controller
|
||||
->sum('already_cancel_number');
|
||||
$item['total_orders_num'] = $number - $cancelNumber;
|
||||
foreach ($item['combinationGoods'] as $combinationItem) {
|
||||
$title = !empty($combinationItem['goodsSkuItem']['goods']['name'])?$combinationItem['goodsSkuItem']['goods']['name']:
|
||||
$combinationItem['goodsSkuItem']['goods']['title'] . " " . $combinationItem['goodsSkuItem']['title'];
|
||||
$items[] = [
|
||||
'cost' => 0,
|
||||
'external_sku_id' => $combinationItem['goodsSkuItem']['external_sku_id'],
|
||||
@ -79,7 +81,7 @@ class GoodsCombinationController extends Controller
|
||||
'sale_stock' => $combinationItem['goodsSkuItem']['sale_stock'],
|
||||
'thumb_url' => $combinationItem['goodsSkuItem']['goods']['img_url'],
|
||||
'img_url' => $combinationItem['goodsSkuItem']['goods']['img_url'],
|
||||
'title' => $combinationItem['goodsSkuItem']['goods']['title'] ." ". $combinationItem['goodsSkuItem']['title'],
|
||||
'title' => $title,
|
||||
'updated_at' => $combinationItem['goodsSkuItem']['updated_at'],
|
||||
'yesterday_num' => $combinationItem['goodsSkuItem']['yesterday_num'],
|
||||
'order_goods_num' => '请在商品列表查看',
|
||||
@ -198,9 +200,13 @@ class GoodsCombinationController extends Controller
|
||||
->where('name', 'like', '%' . $title . '%')
|
||||
->where('is_combination', 0)
|
||||
->with('goods:id,title')
|
||||
->get(['id', 'title', 'goods_id']);
|
||||
->get(['id', 'title', 'goods_id', "name"]);
|
||||
foreach ($skus as &$sku) {
|
||||
$sku['title'] = ($sku['goods']['title'] ?? "") . $sku['title'];
|
||||
if (!empty($sku['name'])) {
|
||||
$sku['title'] = $sku['name'];
|
||||
} else {
|
||||
$sku['title'] = ($sku['goods']['title'] ?? "") . $sku['title'];
|
||||
}
|
||||
}
|
||||
|
||||
return GoodsSkuResource::collection($skus);
|
||||
|
||||
@ -58,7 +58,7 @@ class GoodsController extends Controller
|
||||
$item['reference_price'] = $item['cost'] * 1.5;
|
||||
$item['sku_code'] = !empty($item['external_sku_id']) ? $item['external_sku_id'] : $goodService->getRandomCode();
|
||||
$item['external_sku_id'] = !empty($item['external_sku_id']) ? $item['external_sku_id'] : ($goods->goods_code . '_' . $item['sku_code']);
|
||||
$item['name'] = $goods->title . " " . $item['title'];
|
||||
$item['name'] = $goodService->getSkuName($request->type_id,$item);
|
||||
$goodsSkus[] = $item;
|
||||
}
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ class GoodsSkusController extends Controller
|
||||
|
||||
$goodsSkus = (clone $builder)->with(['goods' => function ($query) {
|
||||
$query->with(['type' => function ($query) {
|
||||
$query->with("parentType:id,name")->select(["id","name","parent_id"]);
|
||||
$query->with("parentType:id,name")->select(["id", "name", "parent_id"]);
|
||||
}]);
|
||||
}])
|
||||
->with(['daily' => function ($query) use ($day) {
|
||||
@ -202,7 +202,7 @@ class GoodsSkusController extends Controller
|
||||
$goodService = new GoodService();
|
||||
$goods = $goodService->saveDefaultGoodsByGoodType($request->goods['type_id']);
|
||||
$skuInfo['goods_id'] = $goods->id;
|
||||
$skuInfo['name'] =$goods->title." ". $request->sku['title'];
|
||||
$skuInfo['name'] = $goodService->getSkuName($request->goods['type_id'], $skuInfo);
|
||||
$sku->update($skuInfo);
|
||||
$this->setAfterUpdateForLog($sku->toArray());
|
||||
$this->addLog($id, 'update');
|
||||
@ -275,7 +275,7 @@ class GoodsSkusController extends Controller
|
||||
$log = new LogModel();
|
||||
$log->batchInsert($logs);
|
||||
DB::commit();
|
||||
if(!empty($updateIds)){
|
||||
if (!empty($updateIds)) {
|
||||
event(new BatchStockUpdateEvent($updateIds));
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
|
||||
@ -31,6 +31,7 @@ class GoodsSkuRequest extends FormRequest
|
||||
'status' => ['sometimes', 'required', 'integer', Rule::in([0, 1, 2])],
|
||||
'num' => ['sometimes', 'required', 'integer'],
|
||||
'cost' => ['sometimes', 'required', 'numeric'],
|
||||
'attribute' => ['sometimes', 'required', 'string'],
|
||||
'reference_price' => [
|
||||
'sometimes',
|
||||
'numeric',
|
||||
|
||||
@ -34,6 +34,7 @@ class GoodsSku extends Model
|
||||
'is_combination',
|
||||
'name',
|
||||
'sale_stock',
|
||||
'attribute'
|
||||
];
|
||||
|
||||
protected $hidden = ['created_at'];
|
||||
|
||||
@ -44,6 +44,20 @@ class GoodService
|
||||
return $goodsType['name'] . " " .$parentName;
|
||||
}
|
||||
|
||||
public function getSkuName($typeId,$sku)
|
||||
{
|
||||
$goodsType = GoodsType::query()->with("parentType")->where('id', "=", $typeId)
|
||||
->first()->toArray();
|
||||
$skuName = $goodsType['name'];
|
||||
if(!empty($sku['attribute'])){
|
||||
$skuName.=" ".$sku['attribute'];
|
||||
}
|
||||
if (!empty($goodsType['parent_type']['name'])) {
|
||||
$skuName.= " ".$goodsType['parent_type']['name'] ?? '';
|
||||
}
|
||||
return $skuName." ".$sku['title'];
|
||||
}
|
||||
|
||||
public function getRandomCode()
|
||||
{
|
||||
$time = time();
|
||||
|
||||
@ -130,7 +130,7 @@ class SaleDataService
|
||||
return $v;
|
||||
})->pluck(null, "external_sku_id")->toArray();
|
||||
Log::info("combineGoodsSkus", $combineGoodsSkus);
|
||||
$orderItems->getCollection()->map(function ($v) use ($combineGoodsSkus) {
|
||||
$orderItems->getCollection()· use ($combineGoodsSkus) {
|
||||
if (!empty($combineGoodsSkus[$v['external_sku_id']])) {
|
||||
foreach ($combineGoodsSkus[$v['external_sku_id']] as $key => $val) {
|
||||
$v->$key = $val;
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RemoveIndexToGoodsTypes extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
Schema::table('goods_types', function (Blueprint $table) {
|
||||
$table->dropUnique('goods_types_name_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('goods_types', function (Blueprint $table) {
|
||||
//
|
||||
$table->unique('name');
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddAttributeToGoodsSkus extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('goods_skus', "attribute")) {
|
||||
return;
|
||||
}
|
||||
Schema::table('goods_skus', function (Blueprint $table) {
|
||||
|
||||
$table->string('attribute',100)->default("")->comment('属性名称');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
Schema::table('goods_skus', function (Blueprint $table) {
|
||||
$table->dropColumn("attribute");
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddFieldToPurchaseRecordsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumns('purchase_records', ["arrived_time", "status"])) {
|
||||
return;
|
||||
}
|
||||
Schema::table('purchase_records', function (Blueprint $table) {
|
||||
$table->dateTime('arrived_time')->nullable()->comment('到货时间');
|
||||
$table->integer('status')->default(0)->comment('采购单状态 0待审核 1已审核');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('purchase_records', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('arrived_time');
|
||||
$table->dropColumn('status');
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user