mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
feat: #10000 优化修改
This commit is contained in:
parent
60ee98a6b4
commit
4e872a2d50
@ -19,6 +19,7 @@ class BusinessOrdersUpdate
|
|||||||
public $num;
|
public $num;
|
||||||
public $businessGoods;
|
public $businessGoods;
|
||||||
public $goodsSku;
|
public $goodsSku;
|
||||||
|
public $goodsSkus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
|
|||||||
@ -59,6 +59,7 @@ class GoodsSkusExport implements FromCollection, ShouldAutoSize
|
|||||||
->when($ids, function ($query, $ids) {
|
->when($ids, function ($query, $ids) {
|
||||||
return $query->whereIn('id', $ids);
|
return $query->whereIn('id', $ids);
|
||||||
})
|
})
|
||||||
|
->where('is_combination', 0)
|
||||||
->with(['goods' => function ($query) {
|
->with(['goods' => function ($query) {
|
||||||
$query->with(['type:id,name', 'brand:id,name'])
|
$query->with(['type:id,name', 'brand:id,name'])
|
||||||
->orderBy('type_id')
|
->orderBy('type_id')
|
||||||
|
|||||||
@ -28,11 +28,7 @@ class GoodsSkuLocationFilter extends Filters
|
|||||||
|
|
||||||
public function externalSkuId($value)
|
public function externalSkuId($value)
|
||||||
{
|
{
|
||||||
[$goodsCode, $skuCode] = explode('_', $value);
|
return $this->builder->where('external_sku_id', $value);
|
||||||
$goodsId = Goods::query()->where('goods_code', $goodsCode)->value('id');
|
|
||||||
$skuId = GoodsSku::query()->where('sku_code', $skuCode)->value('id');
|
|
||||||
|
|
||||||
return $this->builder->where('goods_sku_id', $skuId)->where('goods_id', $goodsId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function location($value)
|
public function location($value)
|
||||||
|
|||||||
40
app/Http/Controllers/Goods/GoodsCombinationController.php
Normal file
40
app/Http/Controllers/Goods/GoodsCombinationController.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Goods;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\GoodsSkuResource;
|
||||||
|
use App\Models\GoodsSku;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class GoodsCombinationController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$skus = GoodsSku::query()
|
||||||
|
->where('is_combination', 1)
|
||||||
|
->with([
|
||||||
|
'combinationItems:goods_sku_id,item_id,item_num',
|
||||||
|
'combinationItems.goodsSkuItem:id,goods_id,title,stock,external_sku_id',
|
||||||
|
'combinationItems.goodsSkuItem.goods:id,title',
|
||||||
|
])
|
||||||
|
->paginate($request->get('per_page'));
|
||||||
|
|
||||||
|
return GoodsSkuResource::collection($skus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request, $id)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,6 +51,7 @@ class GoodsSkusController extends Controller
|
|||||||
->with(['daily' => function ($query) use ($day) {
|
->with(['daily' => function ($query) use ($day) {
|
||||||
$query->where('day', $day);
|
$query->where('day', $day);
|
||||||
}])
|
}])
|
||||||
|
->where('is_combination', 0)
|
||||||
->orderByDesc('updated_at')
|
->orderByDesc('updated_at')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
$fields = implode(',', [
|
$fields = implode(',', [
|
||||||
@ -509,9 +510,11 @@ class GoodsSkusController extends Controller
|
|||||||
{
|
{
|
||||||
$roseTypeId = GoodsType::query()->where('name', '玫瑰')->value('id');
|
$roseTypeId = GoodsType::query()->where('name', '玫瑰')->value('id');
|
||||||
$totalNum = GoodsSku::query()
|
$totalNum = GoodsSku::query()
|
||||||
|
->where('is_combination', 0)
|
||||||
->where('status', '>', 0)
|
->where('status', '>', 0)
|
||||||
->sum('stock');
|
->sum('stock');
|
||||||
$roseNum = GoodsSku::query()
|
$roseNum = GoodsSku::query()
|
||||||
|
->where('is_combination', 0)
|
||||||
->whereHas('goods', function (Builder $query) use ($roseTypeId) {
|
->whereHas('goods', function (Builder $query) use ($roseTypeId) {
|
||||||
$query->where('type_id', $roseTypeId);
|
$query->where('type_id', $roseTypeId);
|
||||||
})
|
})
|
||||||
|
|||||||
@ -191,6 +191,7 @@ class ShopsController extends Controller
|
|||||||
{
|
{
|
||||||
$shopId = $request->get('shop_id');
|
$shopId = $request->get('shop_id');
|
||||||
$skus = GoodsSku::query()
|
$skus = GoodsSku::query()
|
||||||
|
->where('is_combination', 0)
|
||||||
->where('status', '>', 0)
|
->where('status', '>', 0)
|
||||||
->whereNotNull('external_sku_id')
|
->whereNotNull('external_sku_id')
|
||||||
->pluck('stock', 'external_sku_id')
|
->pluck('stock', 'external_sku_id')
|
||||||
|
|||||||
@ -78,6 +78,7 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
|||||||
}
|
}
|
||||||
sleep(2);
|
sleep(2);
|
||||||
$onSkuIds = GoodsSku::query()
|
$onSkuIds = GoodsSku::query()
|
||||||
|
->where('is_combination', 0)
|
||||||
->where('status', '>', 0)
|
->where('status', '>', 0)
|
||||||
->pluck('id')
|
->pluck('id')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
|||||||
$log->message = '未找到' . json_encode($event->businessGoods, 256);
|
$log->message = '未找到' . json_encode($event->businessGoods, 256);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$builder = Shop::query()->whereNotIn('status', [Shop::$STATUS_UNAUTHORIZED, Shop::$STATUS_STOP]);
|
$builder = Shop::query()->whereNotIn('status', [Shop::$STATUS_UNAUTHORIZED, Shop::$STATUS_STOP]);
|
||||||
// 非订单影响库存变更,只更新本店铺下商品
|
// 非订单影响库存变更,只更新本店铺下商品
|
||||||
@ -54,7 +54,7 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
|||||||
$shops = $builder->get(['id', 'plat_id']);
|
$shops = $builder->get(['id', 'plat_id']);
|
||||||
if (empty($shops)) {
|
if (empty($shops)) {
|
||||||
LogFile::info('可操作店铺为空');
|
LogFile::info('可操作店铺为空');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($shops as $shop) {
|
foreach ($shops as $shop) {
|
||||||
|
|||||||
13
app/Models/CombinationGood.php
Normal file
13
app/Models/CombinationGood.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CombinationGood extends Model
|
||||||
|
{
|
||||||
|
public function goodsSkuItem()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(GoodsSku::class, 'id', 'item_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -76,4 +76,9 @@ class GoodsSku extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasOne(DailyStockRecord::class, 'sku_id', 'id');
|
return $this->hasOne(DailyStockRecord::class, 'sku_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function combinationItems()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CombinationGood::class, 'goods_sku_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,9 +19,9 @@ class CreateGoodsSkusTable extends Migration
|
|||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
Schema::create('goods_skus', function (Blueprint $table) {
|
Schema::create('goods_skus', function (Blueprint $table) {
|
||||||
$table->bigIncrements('id');
|
$table->bigIncrements('id');
|
||||||
$table->unsignedBigInteger('goods_id')->comment('商品id');
|
$table->unsignedBigInteger('goods_id')->default(0)->comment('商品id');
|
||||||
$table->string('title')->comment('商品规格');
|
$table->string('title')->default('')->comment('商品规格');
|
||||||
$table->string('sku_code', 32)->comment('规格编码');
|
$table->string('sku_code', 32)->default('')->comment('规格编码');
|
||||||
$table->unsignedTinyInteger('status')->default(0)->comment('规格状态(0-下架,1在售,2预警)');
|
$table->unsignedTinyInteger('status')->default(0)->comment('规格状态(0-下架,1在售,2预警)');
|
||||||
$table->unsignedInteger('num')->default(0)->comment('总量');
|
$table->unsignedInteger('num')->default(0)->comment('总量');
|
||||||
$table->integer('stock')->default(0)->comment('库存');
|
$table->integer('stock')->default(0)->comment('库存');
|
||||||
|
|||||||
@ -23,8 +23,6 @@ class CreateMenusTable extends Migration
|
|||||||
$table->string('name', 32)->comment('菜单名称');
|
$table->string('name', 32)->comment('菜单名称');
|
||||||
$table->unsignedBigInteger('parent_id')->default(0);
|
$table->unsignedBigInteger('parent_id')->default(0);
|
||||||
$table->unsignedInteger('seq')->default(0)->comment('排序序号');
|
$table->unsignedInteger('seq')->default(0)->comment('排序序号');
|
||||||
$table->softDeletes();
|
|
||||||
$table->timestamps();
|
|
||||||
// 索引
|
// 索引
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class CreateBusinessOrderItemsTable extends Migration
|
|||||||
$table->integer('verification_number')->nullable();
|
$table->integer('verification_number')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
// 索引
|
// 索引
|
||||||
$table->index(['shop_id', 'business_order_id', 'goods_id', 'sku_id']);
|
// $table->index(['shop_id', 'business_order_id', 'goods_id', 'sku_id']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,10 @@ class AddExternalSkuIdToGoodsSkusTable extends Migration
|
|||||||
}
|
}
|
||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
Schema::table('goods_skus', function (Blueprint $table) {
|
Schema::table('goods_skus', function (Blueprint $table) {
|
||||||
$table->string('external_sku_id')->nullable();
|
$table->string('external_sku_id')->default('')->nullable();
|
||||||
|
$table->tinyInteger('is_combination')->default(0);
|
||||||
$table->index('external_sku_id');
|
$table->index('external_sku_id');
|
||||||
|
$table->index('is_combination');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateCombinationGoodsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if (Schema::hasTable('combination_goods')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Schema::create('combination_goods', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->unsignedBigInteger('goods_sku_id');
|
||||||
|
$table->unsignedBigInteger('item_id');
|
||||||
|
$table->unsignedInteger('item_num');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('combination_goods');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Models\Menu;
|
||||||
|
|
||||||
class MenusTableSeeder extends Seeder
|
class MenusTableSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -12,6 +13,7 @@ class MenusTableSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
return $this->update();
|
||||||
// 商品管理-(商品列表,商品种类,商品品牌)
|
// 商品管理-(商品列表,商品种类,商品品牌)
|
||||||
$id = DB::table('menus')->insertGetId(['parent_id' => 0, 'code' => 'GOODS_MANAGE', 'name' => '商品管理', 'seq' => 0]);
|
$id = DB::table('menus')->insertGetId(['parent_id' => 0, 'code' => 'GOODS_MANAGE', 'name' => '商品管理', 'seq' => 0]);
|
||||||
DB::table('menus')->insert([
|
DB::table('menus')->insert([
|
||||||
@ -19,6 +21,7 @@ class MenusTableSeeder extends Seeder
|
|||||||
['parent_id' => $id, 'code' => 'GOODS_TYPE', 'name' => '商品种类', 'seq' => 1],
|
['parent_id' => $id, 'code' => 'GOODS_TYPE', 'name' => '商品种类', 'seq' => 1],
|
||||||
['parent_id' => $id, 'code' => 'GOODS_BRAND', 'name' => '商品品牌', 'seq' => 2],
|
['parent_id' => $id, 'code' => 'GOODS_BRAND', 'name' => '商品品牌', 'seq' => 2],
|
||||||
['parent_id' => $id, 'code' => 'GOODS_SKU_LOCATION', 'name' => '商品货架', 'seq' => 3],
|
['parent_id' => $id, 'code' => 'GOODS_SKU_LOCATION', 'name' => '商品货架', 'seq' => 3],
|
||||||
|
['parent_id' => $id, 'code' => 'GOODS_COMBINATION', 'name' => '组合商品', 'seq' => 4],
|
||||||
]);
|
]);
|
||||||
// 店铺管理
|
// 店铺管理
|
||||||
DB::table('menus')->insertGetId(['parent_id' => 0, 'code' => 'SHOP_MANAGE', 'name' => '店铺管理', 'seq' => 10]);
|
DB::table('menus')->insertGetId(['parent_id' => 0, 'code' => 'SHOP_MANAGE', 'name' => '店铺管理', 'seq' => 10]);
|
||||||
@ -40,4 +43,17 @@ class MenusTableSeeder extends Seeder
|
|||||||
// 团购
|
// 团购
|
||||||
DB::table('menus')->insertGetId(['parent_id' => 0, 'code' => 'GROUP_MANAGEMENT', 'name' => '团购管理', 'seq' => 1]);
|
DB::table('menus')->insertGetId(['parent_id' => 0, 'code' => 'GROUP_MANAGEMENT', 'name' => '团购管理', 'seq' => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update()
|
||||||
|
{
|
||||||
|
$routes = include(resource_path('lang/zh-CN/permission.php'));
|
||||||
|
foreach ($routes as $code => $route) {
|
||||||
|
if (false === strpos($code, '.')) {
|
||||||
|
DB::table('menus')->updateOrInsert(
|
||||||
|
['id' => $route['id'], 'parent_id' => $route['parent_id'], 'code' => $code],
|
||||||
|
['name' => $route['name']]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,8 @@ class PermissionsTableSeeder extends Seeder
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$routes = include(resource_path('lang/zh-CN/permission.php'));
|
$routes = include(resource_path('lang/zh-CN/permission.php'));
|
||||||
foreach ($routes as $key => $route) {
|
foreach ($routes as $code => $route) {
|
||||||
$data = ['id' => $route['id'], 'name' => $key, 'guard_name' => 'api'];
|
$data = ['id' => $route['id'], 'name' => $code, 'guard_name' => 'api'];
|
||||||
Permission::firstOrCreate($data);
|
Permission::firstOrCreate($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,6 +147,36 @@ return [
|
|||||||
'name' => '删除',
|
'name' => '删除',
|
||||||
'parent_id' => 15,
|
'parent_id' => 15,
|
||||||
],
|
],
|
||||||
|
'GOODS_COMBINATION' => [
|
||||||
|
'id' => 16,
|
||||||
|
'name' => '组合商品',
|
||||||
|
'parent_id' => 1,
|
||||||
|
],
|
||||||
|
'goods_combination.index' => [
|
||||||
|
'id' => 160,
|
||||||
|
'name' => '列表',
|
||||||
|
'parent_id' => 16,
|
||||||
|
],
|
||||||
|
'goods_combination.store' => [
|
||||||
|
'id' => 161,
|
||||||
|
'name' => '新增',
|
||||||
|
'parent_id' => 16,
|
||||||
|
],
|
||||||
|
'goods_combination.show' => [
|
||||||
|
'id' => 162,
|
||||||
|
'name' => '查看',
|
||||||
|
'parent_id' => 16,
|
||||||
|
],
|
||||||
|
'goods_combination.update' => [
|
||||||
|
'id' => 163,
|
||||||
|
'name' => '更新',
|
||||||
|
'parent_id' => 16,
|
||||||
|
],
|
||||||
|
'goods_combination.destroy' => [
|
||||||
|
'id' => 164,
|
||||||
|
'name' => '删除',
|
||||||
|
'parent_id' => 16,
|
||||||
|
],
|
||||||
// 店铺管理
|
// 店铺管理
|
||||||
'SHOP_MANAGE' => [
|
'SHOP_MANAGE' => [
|
||||||
'id' => 5,
|
'id' => 5,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user