From 035ab1105c77af727a42184292965a3c8a73319c Mon Sep 17 00:00:00 2001 From: lq Date: Tue, 20 May 2025 16:52:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E3=80=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=EF=BC=8C=E4=B8=8B=E4=B8=80=E6=AD=A5=E5=85=88=E6=8A=8A?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=90=9E=E5=AE=8C=E5=86=8D=E6=90=9E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/BaseApp/BaseService.php | 5 + ...r.php => MallClassificationController.php} | 6 +- ...StoreController.php => MallController.php} | 6 +- .../MallMembershipLevelController.php | 18 + .../Api/CodeGeneration/OrderController.php | 18 + .../CodeGeneration/OrderDetailController.php | 18 + .../Api/CodeGeneration/ProductController.php | 4 +- .../ProductLabelRelationsController.php | 18 + .../Api/CodeGeneration/SkuController.php | 18 + .../UserBrowsingHistoryController.php | 18 + .../CodeGeneration/UserCollectController.php | 18 + .../Api/CodeGeneration/UserController.php | 18 + .../UserMembershipController.php | 18 + .../UserReceivingAddressController.php | 18 + ...nModel.php => MallClassificationModel.php} | 4 +- app/Models/MallMembershipLevelModel.php | 26 + app/Models/{StoreModel.php => MallModel.php} | 4 +- app/Models/OrderDetailModel.php | 17 + app/Models/OrderModel.php | 17 + app/Models/ProductLabelRelationsModel.php | 17 + app/Models/ProductModel.php | 26 + app/Models/SkuModel.php | 22 + app/Models/UserBrowsingHistoryModel.php | 27 + app/Models/UserCollectModel.php | 26 + app/Models/UserMembershipModel.php | 17 + app/Models/UserModel.php | 17 + app/Models/UserReceivingAddressModel.php | 22 + ...vice.php => MallClassificationService.php} | 6 +- .../MallMembershipLevelService.php | 87 +++ .../{StoreService.php => MallService.php} | 6 +- .../CodeGeneration/OrderDetailService.php | 87 +++ app/Service/CodeGeneration/OrderService.php | 87 +++ .../ProductLabelRelationsService.php | 87 +++ app/Service/CodeGeneration/ProductService.php | 74 +- app/Service/CodeGeneration/SkuService.php | 90 +++ .../UserBrowsingHistoryService.php | 91 +++ .../CodeGeneration/UserCollectService.php | 91 +++ .../CodeGeneration/UserMembershipService.php | 87 +++ .../UserReceivingAddressService.php | 87 +++ app/Service/CodeGeneration/UserService.php | 88 +++ app/Service/LoginService.php | 1 + app/Service/core/CodeGenerationService.php | 13 +- resources/views/route.blade.php | 2 +- routes/api.php | 29 +- sql/nl_mall-dev.sql | 646 ++++++++++++++---- 45 files changed, 1951 insertions(+), 151 deletions(-) rename app/Http/Controllers/Api/CodeGeneration/{StoreClassificationController.php => MallClassificationController.php} (59%) rename app/Http/Controllers/Api/CodeGeneration/{StoreController.php => MallController.php} (82%) create mode 100644 app/Http/Controllers/Api/CodeGeneration/MallMembershipLevelController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/OrderController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/OrderDetailController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/ProductLabelRelationsController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/SkuController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/UserBrowsingHistoryController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/UserCollectController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/UserController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/UserMembershipController.php create mode 100644 app/Http/Controllers/Api/CodeGeneration/UserReceivingAddressController.php rename app/Models/{StoreClassificationModel.php => MallClassificationModel.php} (66%) create mode 100644 app/Models/MallMembershipLevelModel.php rename app/Models/{StoreModel.php => MallModel.php} (73%) create mode 100644 app/Models/OrderDetailModel.php create mode 100644 app/Models/OrderModel.php create mode 100644 app/Models/ProductLabelRelationsModel.php create mode 100644 app/Models/SkuModel.php create mode 100644 app/Models/UserBrowsingHistoryModel.php create mode 100644 app/Models/UserCollectModel.php create mode 100644 app/Models/UserMembershipModel.php create mode 100644 app/Models/UserModel.php create mode 100644 app/Models/UserReceivingAddressModel.php rename app/Service/CodeGeneration/{StoreClassificationService.php => MallClassificationService.php} (93%) create mode 100644 app/Service/CodeGeneration/MallMembershipLevelService.php rename app/Service/CodeGeneration/{StoreService.php => MallService.php} (95%) create mode 100644 app/Service/CodeGeneration/OrderDetailService.php create mode 100644 app/Service/CodeGeneration/OrderService.php create mode 100644 app/Service/CodeGeneration/ProductLabelRelationsService.php create mode 100644 app/Service/CodeGeneration/SkuService.php create mode 100644 app/Service/CodeGeneration/UserBrowsingHistoryService.php create mode 100644 app/Service/CodeGeneration/UserCollectService.php create mode 100644 app/Service/CodeGeneration/UserMembershipService.php create mode 100644 app/Service/CodeGeneration/UserReceivingAddressService.php create mode 100644 app/Service/CodeGeneration/UserService.php diff --git a/app/BaseApp/BaseService.php b/app/BaseApp/BaseService.php index 6c68d5d8..bba2b041 100755 --- a/app/BaseApp/BaseService.php +++ b/app/BaseApp/BaseService.php @@ -29,6 +29,10 @@ class BaseService * @var int 角色ID,默认值为0,表示未登录状态 */ protected int $roleId = 0; + /** + * @var int 商家ID + */ + protected int $mallId = 0; /** * @var array 用户信息 @@ -95,6 +99,7 @@ class BaseService $this->userInfo = JWTService::getInstance()->getToken()->getUserInfo(); $this->userId = $this->userInfo['id'] ?? 0; $this->roleId = $this->userInfo['role_id'] ?? 0; + $this->mallId = $this->userInfo['mall_id'] ?? 0; $this->utils = UtilsService::getInstance(); } diff --git a/app/Http/Controllers/Api/CodeGeneration/StoreClassificationController.php b/app/Http/Controllers/Api/CodeGeneration/MallClassificationController.php similarity index 59% rename from app/Http/Controllers/Api/CodeGeneration/StoreClassificationController.php rename to app/Http/Controllers/Api/CodeGeneration/MallClassificationController.php index fed48e55..a77732c0 100644 --- a/app/Http/Controllers/Api/CodeGeneration/StoreClassificationController.php +++ b/app/Http/Controllers/Api/CodeGeneration/MallClassificationController.php @@ -3,9 +3,9 @@ namespace App\Http\Controllers\Api\CodeGeneration; use App\BaseApp\BaseController; -use App\Service\CodeGeneration\StoreClassificationService; +use App\Service\CodeGeneration\MallClassificationService; -class StoreClassificationController extends BaseController +class MallClassificationController extends BaseController { // public function __construct() @@ -13,6 +13,6 @@ class StoreClassificationController extends BaseController parent::__construct(); $this->insertField = ["name","pid"]; $this->updateField = ["id","name","pid"]; - $this->service = StoreClassificationService::getInstance(); + $this->service = MallClassificationService::getInstance(); } } diff --git a/app/Http/Controllers/Api/CodeGeneration/StoreController.php b/app/Http/Controllers/Api/CodeGeneration/MallController.php similarity index 82% rename from app/Http/Controllers/Api/CodeGeneration/StoreController.php rename to app/Http/Controllers/Api/CodeGeneration/MallController.php index ded536fd..6532839c 100644 --- a/app/Http/Controllers/Api/CodeGeneration/StoreController.php +++ b/app/Http/Controllers/Api/CodeGeneration/MallController.php @@ -3,9 +3,9 @@ namespace App\Http\Controllers\Api\CodeGeneration; use App\BaseApp\BaseController; -use App\Service\CodeGeneration\StoreService; +use App\Service\CodeGeneration\MallService; -class StoreController extends BaseController +class MallController extends BaseController { // public function __construct() @@ -13,6 +13,6 @@ class StoreController extends BaseController parent::__construct(); $this->insertField = ["name","level","avatar","introduction","description","phone","person", "classification_id","id_card","is_featured","business_license","id_card_portrait_side","id_card_national_emblem_side","chain","business_suspended"]; $this->updateField = ["id","name","level","avatar","introduction","description","phone","person", "classification_id","is_featured","business_license","id_card_portrait_side","id_card_national_emblem_side","chain","business_suspended"]; - $this->service = StoreService::getInstance(); + $this->service = MallService::getInstance(); } } diff --git a/app/Http/Controllers/Api/CodeGeneration/MallMembershipLevelController.php b/app/Http/Controllers/Api/CodeGeneration/MallMembershipLevelController.php new file mode 100644 index 00000000..5e0db4b9 --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/MallMembershipLevelController.php @@ -0,0 +1,18 @@ +insertField = ["name","experience"]; + $this->updateField = ["id","name","experience"]; + $this->service = MallMembershipLevelService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/OrderController.php b/app/Http/Controllers/Api/CodeGeneration/OrderController.php new file mode 100644 index 00000000..71b42d17 --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/OrderController.php @@ -0,0 +1,18 @@ +insertField = ["user_id","order_no","order_status","total_amount"]; + $this->updateField = ["id","user_id","order_no","order_status","total_amount"]; + $this->service = OrderService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/OrderDetailController.php b/app/Http/Controllers/Api/CodeGeneration/OrderDetailController.php new file mode 100644 index 00000000..a11acc85 --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/OrderDetailController.php @@ -0,0 +1,18 @@ +insertField = ["order_id","product_id","quantity","price","subtotal","snapshot"]; + $this->updateField = ["id","order_id","product_id","quantity","price","subtotal","snapshot"]; + $this->service = OrderDetailService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/ProductController.php b/app/Http/Controllers/Api/CodeGeneration/ProductController.php index 8622df35..336ba613 100644 --- a/app/Http/Controllers/Api/CodeGeneration/ProductController.php +++ b/app/Http/Controllers/Api/CodeGeneration/ProductController.php @@ -11,8 +11,8 @@ class ProductController extends BaseController public function __construct() { parent::__construct(); - $this->insertField = ["title","introduction","cover", "images","description","price","classification_id"]; - $this->updateField = ["id","title","introduction","cover", "images","description","price","classification_id"]; + $this->insertField = ["title","introduction","cover", "images", "labels","description","price","classification_id"]; + $this->updateField = ["id","title","introduction","cover", "images", "labels","description","price","classification_id"]; $this->service = ProductService::getInstance(); } } diff --git a/app/Http/Controllers/Api/CodeGeneration/ProductLabelRelationsController.php b/app/Http/Controllers/Api/CodeGeneration/ProductLabelRelationsController.php new file mode 100644 index 00000000..9fd17155 --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/ProductLabelRelationsController.php @@ -0,0 +1,18 @@ +insertField = ["product_id","label_id"]; + $this->updateField = ["id","product_id","label_id"]; + $this->service = ProductLabelRelationsService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/SkuController.php b/app/Http/Controllers/Api/CodeGeneration/SkuController.php new file mode 100644 index 00000000..cca70c26 --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/SkuController.php @@ -0,0 +1,18 @@ +insertField = ["product_id","cover", "name","inventory","price"]; + $this->updateField = ["id","product_id","cover", "name","inventory","price"]; + $this->service = SkuService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/UserBrowsingHistoryController.php b/app/Http/Controllers/Api/CodeGeneration/UserBrowsingHistoryController.php new file mode 100644 index 00000000..b91d850a --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/UserBrowsingHistoryController.php @@ -0,0 +1,18 @@ +insertField = ["user_id","product_id"]; + $this->updateField = ["id","user_id","product_id"]; + $this->service = UserBrowsingHistoryService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/UserCollectController.php b/app/Http/Controllers/Api/CodeGeneration/UserCollectController.php new file mode 100644 index 00000000..b396b85a --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/UserCollectController.php @@ -0,0 +1,18 @@ +insertField = ["user_id","product_id"]; + $this->updateField = ["id","user_id","product_id"]; + $this->service = UserCollectService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/UserController.php b/app/Http/Controllers/Api/CodeGeneration/UserController.php new file mode 100644 index 00000000..069a1ffa --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/UserController.php @@ -0,0 +1,18 @@ +insertField = ["nick_name","phone","email","level","balance","avatar","integral"]; + $this->updateField = ["id","nick_name","phone","email","level","balance","avatar","integral"]; + $this->service = UserService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/UserMembershipController.php b/app/Http/Controllers/Api/CodeGeneration/UserMembershipController.php new file mode 100644 index 00000000..8a51db59 --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/UserMembershipController.php @@ -0,0 +1,18 @@ +insertField = ["name","experience"]; + $this->updateField = ["id","name","experience"]; + $this->service = UserMembershipService::getInstance(); + } +} diff --git a/app/Http/Controllers/Api/CodeGeneration/UserReceivingAddressController.php b/app/Http/Controllers/Api/CodeGeneration/UserReceivingAddressController.php new file mode 100644 index 00000000..e0e122d0 --- /dev/null +++ b/app/Http/Controllers/Api/CodeGeneration/UserReceivingAddressController.php @@ -0,0 +1,18 @@ +insertField = ["user_id","province","city","district","detailed_address","complete_address"]; + $this->updateField = ["id","user_id","province","city","district","detailed_address","complete_address"]; + $this->service = UserReceivingAddressService::getInstance(); + } +} diff --git a/app/Models/StoreClassificationModel.php b/app/Models/MallClassificationModel.php similarity index 66% rename from app/Models/StoreClassificationModel.php rename to app/Models/MallClassificationModel.php index efc3e34b..4763d3ce 100644 --- a/app/Models/StoreClassificationModel.php +++ b/app/Models/MallClassificationModel.php @@ -4,10 +4,10 @@ namespace App\Models; use App\BaseApp\BaseModel; -class StoreClassificationModel extends BaseModel +class MallClassificationModel extends BaseModel { - protected $table = 'store_classification'; + protected $table = 'mall_classification'; /** * The attributes that are mass assignable. * diff --git a/app/Models/MallMembershipLevelModel.php b/app/Models/MallMembershipLevelModel.php new file mode 100644 index 00000000..6ba3fc35 --- /dev/null +++ b/app/Models/MallMembershipLevelModel.php @@ -0,0 +1,26 @@ + + */ + protected $guarded = []; + public function product() + { + return $this->hasOne(ProductModel::class, 'id', 'product_id'); + } + + public function user() + { + return $this->hasOne(UserModel::class, 'id', 'user_id'); + } +} diff --git a/app/Models/StoreModel.php b/app/Models/MallModel.php similarity index 73% rename from app/Models/StoreModel.php rename to app/Models/MallModel.php index 9f5f9100..4a151731 100644 --- a/app/Models/StoreModel.php +++ b/app/Models/MallModel.php @@ -4,10 +4,10 @@ namespace App\Models; use App\BaseApp\BaseModel; -class StoreModel extends BaseModel +class MallModel extends BaseModel { - protected $table = 'store'; + protected $table = 'mall'; /** * The attributes that are mass assignable. * diff --git a/app/Models/OrderDetailModel.php b/app/Models/OrderDetailModel.php new file mode 100644 index 00000000..7f2af8a0 --- /dev/null +++ b/app/Models/OrderDetailModel.php @@ -0,0 +1,17 @@ + + */ + protected $guarded = []; +} diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php new file mode 100644 index 00000000..e56942c6 --- /dev/null +++ b/app/Models/OrderModel.php @@ -0,0 +1,17 @@ + + */ + protected $guarded = []; +} diff --git a/app/Models/ProductLabelRelationsModel.php b/app/Models/ProductLabelRelationsModel.php new file mode 100644 index 00000000..d546a521 --- /dev/null +++ b/app/Models/ProductLabelRelationsModel.php @@ -0,0 +1,17 @@ + + */ + protected $guarded = []; +} diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index 3bc7c153..ccc34d4d 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -20,4 +20,30 @@ class ProductModel extends BaseModel { return $this->hasMany(ProductImageModel::class, 'product_id', 'id'); } + + public function mall() + { + return $this->hasOne(MallModel::class, 'id', 'mall_id'); + } + + public function user() + { + return $this->hasOne(AdminModel::class, 'id', 'user_id'); + } + + public function labels() + { +// return $this->hasMany(ProductLabelRelationsModel::class, 'product_id', 'id'); + return $this->belongsToMany(ProductLabelModel::class, 'product_label_relations', 'product_id', 'label_id'); + } + + public function classification() + { + return $this->hasOne(ProductClassificationModel::class, 'id', 'classification_id'); + } + + public function skus() + { + return $this->hasMany(SkuModel::class, 'product_id', 'id'); + } } diff --git a/app/Models/SkuModel.php b/app/Models/SkuModel.php new file mode 100644 index 00000000..5e199d30 --- /dev/null +++ b/app/Models/SkuModel.php @@ -0,0 +1,22 @@ + + */ + protected $guarded = []; + + public function product() + { + return $this->hasOne(ProductModel::class, 'id', 'product_id'); + } +} diff --git a/app/Models/UserBrowsingHistoryModel.php b/app/Models/UserBrowsingHistoryModel.php new file mode 100644 index 00000000..04f42588 --- /dev/null +++ b/app/Models/UserBrowsingHistoryModel.php @@ -0,0 +1,27 @@ + + */ + protected $guarded = []; + + public function product() + { + return $this->hasOne(ProductModel::class, 'id', 'product_id'); + } + + public function user() + { + return $this->hasOne(UserModel::class, 'id', 'user_id'); + } +} diff --git a/app/Models/UserCollectModel.php b/app/Models/UserCollectModel.php new file mode 100644 index 00000000..f626307f --- /dev/null +++ b/app/Models/UserCollectModel.php @@ -0,0 +1,26 @@ + + */ + protected $guarded = []; + public function product() + { + return $this->hasOne(ProductModel::class, 'id', 'product_id'); + } + + public function user() + { + return $this->hasOne(UserModel::class, 'id', 'user_id'); + } +} diff --git a/app/Models/UserMembershipModel.php b/app/Models/UserMembershipModel.php new file mode 100644 index 00000000..11c3ece8 --- /dev/null +++ b/app/Models/UserMembershipModel.php @@ -0,0 +1,17 @@ + + */ + protected $guarded = []; +} diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php new file mode 100644 index 00000000..2e5c70bb --- /dev/null +++ b/app/Models/UserModel.php @@ -0,0 +1,17 @@ + + */ + protected $guarded = []; +} diff --git a/app/Models/UserReceivingAddressModel.php b/app/Models/UserReceivingAddressModel.php new file mode 100644 index 00000000..f2c766c9 --- /dev/null +++ b/app/Models/UserReceivingAddressModel.php @@ -0,0 +1,22 @@ + + */ + protected $guarded = []; + + public function user() + { + return $this->hasOne(UserModel::class, 'id', 'user_id'); + } +} diff --git a/app/Service/CodeGeneration/StoreClassificationService.php b/app/Service/CodeGeneration/MallClassificationService.php similarity index 93% rename from app/Service/CodeGeneration/StoreClassificationService.php rename to app/Service/CodeGeneration/MallClassificationService.php index fb40a9a5..9793ea68 100644 --- a/app/Service/CodeGeneration/StoreClassificationService.php +++ b/app/Service/CodeGeneration/MallClassificationService.php @@ -3,19 +3,19 @@ namespace App\Service\CodeGeneration; use App\BaseApp\BaseService; -use App\Models\StoreClassificationModel; +use App\Models\MallClassificationModel; use Exception; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; -class StoreClassificationService extends BaseService +class MallClassificationService extends BaseService { public function __construct() { parent::__construct(); $this->selectField = ["id", "name", "pid", "status", "created_at", "updated_at", "deleted_at"]; $this->queryField = ['name' => 'like','pid' => '=,status=']; - $this->model = StoreClassificationModel::class; + $this->model = MallClassificationModel::class; } /** diff --git a/app/Service/CodeGeneration/MallMembershipLevelService.php b/app/Service/CodeGeneration/MallMembershipLevelService.php new file mode 100644 index 00000000..cefe1a6c --- /dev/null +++ b/app/Service/CodeGeneration/MallMembershipLevelService.php @@ -0,0 +1,87 @@ +selectField = ["id", "name", "experience", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['name' => '=,status=']; + $this->model = MallMembershipLevelModel::class; + } + + /** + * 获取店铺会员等级列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取店铺会员等级详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 店铺会员等级下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建店铺会员等级 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑店铺会员等级 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除店铺会员等级 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/StoreService.php b/app/Service/CodeGeneration/MallService.php similarity index 95% rename from app/Service/CodeGeneration/StoreService.php rename to app/Service/CodeGeneration/MallService.php index 896aa0b8..058dcb77 100644 --- a/app/Service/CodeGeneration/StoreService.php +++ b/app/Service/CodeGeneration/MallService.php @@ -3,19 +3,19 @@ namespace App\Service\CodeGeneration; use App\BaseApp\BaseService; -use App\Models\StoreModel; +use App\Models\MallModel; use Exception; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; -class StoreService extends BaseService +class MallService extends BaseService { public function __construct() { parent::__construct(); $this->selectField = ["id", "name", "level", "avatar", "introduction", "classification_id", "description", "phone", "person", "id_card", "qr_code", "is_featured", "business_license", "id_card_portrait_side", "id_card_national_emblem_side", "chain", "business_suspended", "status", "created_at", "updated_at", "deleted_at"]; $this->queryField = ['name' => '=','level' => '=','phone' => 'like','person' => '=','classification_id' => '=','is_featured' => '=','chain' => '=','business_suspended' => '=,status=']; - $this->model = StoreModel::class; + $this->model = MallModel::class; } /** diff --git a/app/Service/CodeGeneration/OrderDetailService.php b/app/Service/CodeGeneration/OrderDetailService.php new file mode 100644 index 00000000..75538d03 --- /dev/null +++ b/app/Service/CodeGeneration/OrderDetailService.php @@ -0,0 +1,87 @@ +selectField = ["id", "order_id", "product_id", "quantity", "price", "subtotal", "snapshot", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['order_id' => '=','product_id' => '=,status=']; + $this->model = OrderDetailModel::class; + } + + /** + * 获取订单详情列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取订单详情详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 订单详情下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建订单详情 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑订单详情 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除订单详情 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/OrderService.php b/app/Service/CodeGeneration/OrderService.php new file mode 100644 index 00000000..5df05722 --- /dev/null +++ b/app/Service/CodeGeneration/OrderService.php @@ -0,0 +1,87 @@ +selectField = ["id", "user_id", "order_no", "order_status", "total_amount", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['user_id' => '=','order_no' => 'like','order_status' => '=,status=']; + $this->model = OrderModel::class; + } + + /** + * 获取订单管理列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取订单管理详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 订单管理下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建订单管理 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑订单管理 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除订单管理 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/ProductLabelRelationsService.php b/app/Service/CodeGeneration/ProductLabelRelationsService.php new file mode 100644 index 00000000..7dc2983f --- /dev/null +++ b/app/Service/CodeGeneration/ProductLabelRelationsService.php @@ -0,0 +1,87 @@ +selectField = ["id", "product_id", "label_id", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['product_id' => '=','label_id' => '=,status=']; + $this->model = ProductLabelRelationsModel::class; + } + + /** + * 获取商品标签关联列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取商品标签关联详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 商品标签关联下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建商品标签关联 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑商品标签关联 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除商品标签关联 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/ProductService.php b/app/Service/CodeGeneration/ProductService.php index 96286724..cc7529c9 100644 --- a/app/Service/CodeGeneration/ProductService.php +++ b/app/Service/CodeGeneration/ProductService.php @@ -4,6 +4,7 @@ namespace App\Service\CodeGeneration; use App\BaseApp\BaseService; use App\Models\ProductImageModel; +use App\Models\ProductLabelRelationsModel; use App\Models\ProductModel; use Exception; use Illuminate\Support\Facades\DB; @@ -19,7 +20,12 @@ class ProductService extends BaseService $this->queryField = ['title' => 'like','mall_id' => '=','classification_id' => '=,status=']; $this->model = ProductModel::class; $this->with = [ - 'images:id,product_id,url' + 'images:id,product_id,url', + 'mall:id,name,avatar', + 'user:id,nick_name,avatar', + 'labels', + 'classification', + 'skus:id,product_id,name,cover,price,inventory', ]; } @@ -34,6 +40,8 @@ class ProductService extends BaseService $result = $this->getPageList(); foreach ($result['items'] as &$v) { $v['images'] = array_column($v['images'], 'url'); + $v['labels_name'] = array_column($v['labels'], 'name'); + $v['labels'] = array_column($v['labels'], 'id'); } return $result; } @@ -46,7 +54,14 @@ class ProductService extends BaseService */ public function detail($id) { - return $this->getDetail($id); + $result = $this->getDetail($id); + $result = $result->toArray(); + $items = []; + foreach ($result['images'] as $v) { + $items[] = $v['url']; + } + $result['images'] = $items; + return $result; } /** @@ -55,7 +70,7 @@ class ProductService extends BaseService */ public function option() { - $this->optionField = ['id', 'name']; + $this->optionField = ['id', 'title']; return $this->getOption(); } @@ -68,8 +83,10 @@ class ProductService extends BaseService public function create($params): mixed { $images = $params['images']; - unset($params['images']); + $labels = $params['labels']; + unset($params['images'], $params['labels']); $params['user_id'] = $this->userId; + $params['mall_id'] = $this->mallId; DB::beginTransaction(); try { @@ -81,7 +98,20 @@ class ProductService extends BaseService 'url' => $v ]; } + $imageModel = ProductImageModel::insert($insertData); + + $labelInsertData = []; + foreach ($labels as $v) { + $labelInsertData[] = [ + 'product_id' => $result, + 'label_id' => $v + ]; + } + $labelModel = ProductLabelRelationsModel::insert($labelInsertData); + if (!$imageModel || !$labelModel) { + $this->utils->errorThrow('操作失败'); + } DB::commit(); } catch (Exception $e) { DB::rollBack(); @@ -102,7 +132,8 @@ class ProductService extends BaseService DB::beginTransaction(); try { $images = $params['images']; - unset($params['images']); + $labels = $params['labels']; + unset($params['images'], $params['labels']); // 1. 更新产品基本信息 $model = $this->save($id, $params); @@ -139,6 +170,39 @@ class ProductService extends BaseService } } + // 3. 处理标签逻辑 + if (isset($images)) { + $newLabels = $labels; + + // 获取当前产品已有的图片URL列表 + $existingLabels = ProductLabelRelationsModel::where('product_id', $id) + ->pluck('label_id') + ->toArray(); + + // 计算新增的图片和被删除的图片 + $addedLabels = array_diff($newLabels, $existingLabels); + $deletedLabels = array_diff($existingLabels, $newLabels); + + // 删除不再需要的图片记录 + if (!empty($deletedLabels)) { + ProductLabelRelationsModel::where('product_id', $id) + ->whereIn('label_id', $deletedLabels) + ->delete(); + } + + // 添加新图片记录 + if (!empty($addedLabels)) { + $insertData = []; + foreach ($addedLabels as $url) { + $insertData[] = [ + 'product_id' => $id, + 'label_id' => $url + ]; + } + ProductLabelRelationsModel::insert($insertData); + } + } + DB::commit(); } catch (Exception $e) { DB::rollBack(); diff --git a/app/Service/CodeGeneration/SkuService.php b/app/Service/CodeGeneration/SkuService.php new file mode 100644 index 00000000..7016ae7e --- /dev/null +++ b/app/Service/CodeGeneration/SkuService.php @@ -0,0 +1,90 @@ +selectField = ["id", "product_id", "name", "cover", "inventory", "price", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['product_id' => '=,status=']; + $this->model = SkuModel::class; + $this->with = [ + 'product:id,title' + ]; + } + + /** + * 获取sku管理列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取sku管理详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * sku管理下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建sku管理 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑sku管理 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除sku管理 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/UserBrowsingHistoryService.php b/app/Service/CodeGeneration/UserBrowsingHistoryService.php new file mode 100644 index 00000000..52d50753 --- /dev/null +++ b/app/Service/CodeGeneration/UserBrowsingHistoryService.php @@ -0,0 +1,91 @@ +selectField = ["id", "user_id", "product_id", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['user_id' => '=','product_id' => '=,status=']; + $this->model = UserBrowsingHistoryModel::class; + } + + /** + * 获取用户浏览记录列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + $this->with = [ + 'user:id,nick_name,avatar', + 'product' + ]; + return $this->getPageList(); + } + + /** + * 获取用户浏览记录详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 用户浏览记录下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建用户浏览记录 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑用户浏览记录 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除用户浏览记录 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/UserCollectService.php b/app/Service/CodeGeneration/UserCollectService.php new file mode 100644 index 00000000..df09bd62 --- /dev/null +++ b/app/Service/CodeGeneration/UserCollectService.php @@ -0,0 +1,91 @@ +selectField = ["id", "user_id", "product_id", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['user_id' => '=','product_id' => '=,status=']; + $this->model = UserCollectModel::class; + } + + /** + * 获取用户收藏列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + $this->with = [ + 'user:id,nick_name,avatar', + 'product' + ]; + return $this->getPageList(); + } + + /** + * 获取用户收藏详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 用户收藏下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建用户收藏 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑用户收藏 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除用户收藏 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/UserMembershipService.php b/app/Service/CodeGeneration/UserMembershipService.php new file mode 100644 index 00000000..280f18fe --- /dev/null +++ b/app/Service/CodeGeneration/UserMembershipService.php @@ -0,0 +1,87 @@ +selectField = ["id", "name", "experience", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['name' => '=,status=']; + $this->model = UserMembershipModel::class; + } + + /** + * 获取用户会员列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取用户会员详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 用户会员下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建用户会员 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑用户会员 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除用户会员 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/UserReceivingAddressService.php b/app/Service/CodeGeneration/UserReceivingAddressService.php new file mode 100644 index 00000000..f117bb5a --- /dev/null +++ b/app/Service/CodeGeneration/UserReceivingAddressService.php @@ -0,0 +1,87 @@ +selectField = ["id", "user_id", "province", "city", "district", "detailed_address", "complete_address", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['user_id' => '=','province' => '=','city' => '=','district' => '=','detailed_address' => '=','complete_address' => '=,status=']; + $this->model = UserReceivingAddressModel::class; + } + + /** + * 获取用户收货地址列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取用户收货地址详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 用户收货地址下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建用户收货地址 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + return $this->insert($params); + } + + /** + * 编辑用户收货地址 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除用户收货地址 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/CodeGeneration/UserService.php b/app/Service/CodeGeneration/UserService.php new file mode 100644 index 00000000..5b194cf6 --- /dev/null +++ b/app/Service/CodeGeneration/UserService.php @@ -0,0 +1,88 @@ +selectField = ["id", "open_id", "nick_name", "phone", "email", "level", "balance", "avatar", "integral", "wx_open_id", "zfb_open_id", "status", "created_at", "updated_at", "deleted_at"]; + $this->queryField = ['open_id' => '=','nick_name' => 'like','phone' => '=','email' => '=','level' => '=,status=']; + $this->model = UserModel::class; + } + + /** + * 获取用户列表 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function list(): array + { + return $this->getPageList(); + } + + /** + * 获取用户详情 + * @param $id + * @return mixed + * @throws Exception + */ + public function detail($id) + { + return $this->getDetail($id); + } + + /** + * 用户下拉列表 + * @return mixed + */ + public function option() + { + $this->optionField = ['id', 'name']; + return $this->getOption(); + } + + /** + * 创建用户 + * @param $params + * @return mixed + * @throws Exception + */ + public function create($params): mixed + { + $params['open_id'] = $this->utils->genOpenId(); + return $this->insert($params); + } + + /** + * 编辑用户 + * @param $id + * @param $params + * @return mixed + * @throws Exception + */ + public function update($id, $params): mixed + { + return $this->save($id, $params); + } + + /** + * 删除用户 + * @param $ids + * @return mixed|true + * @throws Exception + */ + public function delete($ids): mixed + { + return $this->del($ids); + } + +} diff --git a/app/Service/LoginService.php b/app/Service/LoginService.php index da7c18ca..24c246f4 100644 --- a/app/Service/LoginService.php +++ b/app/Service/LoginService.php @@ -55,6 +55,7 @@ class LoginService extends BaseNotAuthService 'avatar' => $userModel->avatar, 'email' => $userModel->email, 'role_id' => $userModel->role_id, + 'mall_id' => $userModel->mall_id, 'role_name' => $userModel->role->name, 'role_value' => $userModel->role->value, 'ip' => $userModel->ip, diff --git a/app/Service/core/CodeGenerationService.php b/app/Service/core/CodeGenerationService.php index fbe44639..90e28b8b 100644 --- a/app/Service/core/CodeGenerationService.php +++ b/app/Service/core/CodeGenerationService.php @@ -15,7 +15,9 @@ class CodeGenerationService { const TEXT_TYPE = [ 'LONGTEXT', - 'TEXT' + 'TEXT', + 'longtext', + 'text', ]; const INT_TYPE = [ 'INT', @@ -23,6 +25,13 @@ class CodeGenerationService 'BIGINT', 'SMALLINT', 'FLOAT', + 'DECIMAL', + 'int', + 'tinyint', + 'bigint', + 'smallint', + 'float', + 'decimal', ]; private static mixed $_instance; @@ -140,6 +149,8 @@ class CodeGenerationService 'created_at' => time(), 'updated_at' => time(), ]); + // 删除Store/app/www + Storage::deleteDirectory('www'); return [ 'id' => $insertModel->id, 'file_name' => $insertModel->file_name diff --git a/resources/views/route.blade.php b/resources/views/route.blade.php index becc05df..c05233a1 100755 --- a/resources/views/route.blade.php +++ b/resources/views/route.blade.php @@ -14,7 +14,7 @@