From 43315000b2840313a5aff96bf314b3c061e4616d Mon Sep 17 00:00:00 2001
From: zepengdev <lzpsmith@outlook.com>
Date: Mon, 14 Jul 2025 21:00:53 +0800
Subject: [PATCH] feat: 增加店铺和商品审核功能

---
 oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java |   96 +++++++++++++++++++++++++++++------------------
 1 files changed, 59 insertions(+), 37 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java
index 1c19479..4f5f2f0 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java
@@ -2,20 +2,18 @@
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.copier.CopyOptions;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.util.ObjUtil;
 import cn.hutool.core.util.ObjectUtil;
-import com.oying.modules.pc.store.domain.dto.StoreUpdateRequest;
-import com.oying.modules.pc.store.service.StoreQualificationService;
-import com.oying.utils.R;
+import com.oying.exception.BadRequestException;
 import com.oying.modules.pc.store.domain.Store;
-import com.oying.modules.pc.store.domain.dto.StoreCreateRequest;
-import com.oying.modules.pc.store.domain.dto.StoreFieldUpdateRequest;
-import com.oying.modules.pc.store.domain.dto.StoreQueryCriteria;
-import com.oying.modules.pc.store.service.StoreCreateService;
-import com.oying.modules.pc.store.service.StoreService;
+import com.oying.modules.pc.store.domain.dto.*;
+import com.oying.modules.pc.store.domain.enums.StoreStatusEnum;
+import com.oying.modules.pc.store.service.*;
 import com.oying.modules.pc.store.view.StoreMerchantView;
 import com.oying.modules.pc.store.view.StoreSimpleView;
+import com.oying.utils.R;
 import com.oying.utils.SecurityUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -23,12 +21,12 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -46,12 +44,14 @@
     private final StoreService storeService;
     private final StoreCreateService storeCreateService;
     private final StoreQualificationService storeQualificationService;
+    private final StoreQueryService storeQueryService;
+    private final StoreMerchantService storeMerchantService;
 
     @GetMapping(value = "/list")
     @ApiOperation("查询所有店铺")
     //@PreAuthorize("@el.check('merchant:store:list')")
     public ResponseEntity<?> getList() {
-        List<Store> stores = Optional.ofNullable(storeService.queryUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty());
+        List<Store> stores = Optional.ofNullable(storeService.getUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty());
         return ResponseEntity.ok(R.success(stores));
     }
 
@@ -59,7 +59,7 @@
     @ApiOperation("查询所有店铺")
     //@PreAuthorize("@el.check('merchant:store:list')")
     public ResponseEntity<?> getSimpleStores() {
-        List<Store> stores = Optional.ofNullable(storeService.queryUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty());
+        List<Store> stores = Optional.ofNullable(storeService.getUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty());
         List<StoreSimpleView> storeViewList = stores.stream().map(i -> {
             StoreSimpleView view = new StoreSimpleView();
             BeanUtil.copyProperties(i, view, CopyOptions.create().setIgnoreNullValue(true));
@@ -84,7 +84,7 @@
     public ResponseEntity<?> getStoreDetailsById(@PathVariable Long storeId) {
         Store store = storeService.getById(storeId);
         if (ObjUtil.isNotEmpty(store)) {
-            store.setQualifications(storeQualificationService.queryByStoreId(storeId));
+            store.setQualifications(storeQualificationService.getByStoreId(storeId));
         }
         return ResponseEntity.ok(R.success(store));
     }
@@ -93,19 +93,27 @@
     @ApiOperation("创建店铺")
     //@PreAuthorize("@el.check('merchant:store:create')")
     public ResponseEntity<?> create(@RequestBody StoreCreateRequest request) {
-        return ResponseEntity.status(HttpStatus.CREATED).body(storeCreateService.create(request));
+        return ResponseEntity.status(HttpStatus.CREATED).body(storeMerchantService.createStore(request));
+    }
+
+    @PostMapping(value = "/{storeId}/audit/submit")
+    @ApiOperation("提交审核")
+    //@PreAuthorize("@el.check('merchant:store:create')")
+    public ResponseEntity<?> submitAudit(@PathVariable Long storeId) {
+        storeMerchantService.submitStoreAudit(storeId);
+        return ResponseEntity.noContent().build();
     }
 
     /**
      * 修改店铺信息
      */
-    @PostMapping(value = "/{storeId}")
+    @PutMapping(value = "/{storeId}")
     @ApiOperation("修改店铺")
     //@PreAuthorize("@el.check('merchant:store:update')" +
     //        " and @storeMerchantOwnershipService.check(#storeId)")
     public ResponseEntity<?> update(@PathVariable("storeId") Long storeId, @RequestBody StoreUpdateRequest request) {
         request.setStoreId(ObjectUtil.defaultIfNull(request.getStoreId(), storeId));
-        storeService.update(request);
+        storeMerchantService.updateStore(request);
         return ResponseEntity.noContent().build();
     }
 
@@ -119,7 +127,8 @@
     public ResponseEntity<?> updateLogo(@PathVariable("storeId") Long storeId,
                            @Validated(value = StoreFieldUpdateRequest.UpdateStoreLogoImageGroup.class)
                            @RequestBody StoreFieldUpdateRequest request) {
-        storeService.updateLogo(storeId, request.getLogoImageUploadId(), request.getVersion());
+        Long logeImageId = Optional.ofNullable(request.getLogoImageId()).orElse(Long.getLong(request.getLogoImageUploadId()));
+        storeService.updateLogo(storeId, logeImageId, request.getVersion());
         return ResponseEntity.noContent().build();
     }
 
@@ -133,7 +142,11 @@
     public ResponseEntity<?> updateName(@PathVariable("storeId") Long storeId,
                            @Validated(value = StoreFieldUpdateRequest.UpdateStoreNameGroup.class)
                            @RequestBody StoreFieldUpdateRequest request) {
-        storeService.updateName(storeId, request.getStoreName(), request.getVersion());
+        StoreUpdateRequest updateRequest = new StoreUpdateRequest();
+        updateRequest.setStoreId(storeId);
+        updateRequest.setStoreName(request.getStoreName());
+        storeMerchantService.updateStore(updateRequest);
+        //storeMerchantService.saveRevisionStore(request, StoreRevisionTypeEnum.NAME_UPDATE);
         return ResponseEntity.noContent().build();
     }
 
@@ -156,8 +169,8 @@
      */
     @PatchMapping(value = "/{storeId}/contactPhone")
     @ApiOperation("修改店铺联系电话")
-    @PreAuthorize("@el.check('merchant:store:list')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:list')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updateContactPhone(@PathVariable("storeId") Long storeId,
                                    @Validated(value = StoreFieldUpdateRequest.UpdateStoreContactPhoneGroup.class)
                                    @RequestBody StoreFieldUpdateRequest request) {
@@ -170,8 +183,8 @@
      */
     @PatchMapping(value = "/{storeId}/address")
     @ApiOperation("修改店铺地址")
-    @PreAuthorize("@el.check('merchant:store:address')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:address')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updateAddress(@PathVariable("storeId") Long storeId,
                               @Validated(value = StoreFieldUpdateRequest.UpdateStoreAddressGroup.class)
                               @RequestBody StoreFieldUpdateRequest request) {
@@ -184,8 +197,8 @@
      */
     @PatchMapping(value = "/{storeId}/location")
     @ApiOperation("修改店铺坐标")
-    @PreAuthorize("@el.check('merchant:store:location')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:location')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updateLocation(@PathVariable("storeId") Long storeId,
                                @Validated(value = StoreFieldUpdateRequest.UpdateStoreLocationGroup.class)
                                @RequestBody StoreFieldUpdateRequest request) {
@@ -198,8 +211,8 @@
      */
     @PatchMapping(value = "/{storeId}/radius")
     @ApiOperation("修改店铺配送范围")
-    @PreAuthorize("@el.check('merchant:store:radius')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:radius')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updateRadius(@PathVariable("storeId") Long storeId,
                              @Validated(value = StoreFieldUpdateRequest.UpdateStoreRadiusGroup.class)
                              @RequestBody StoreFieldUpdateRequest request) {
@@ -212,8 +225,8 @@
      */
     @PatchMapping(value = "/{storeId}/platformCategory")
     @ApiOperation("修改店铺绑定的经营类目")
-    @PreAuthorize("@el.check('merchant:store:platformCategory')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:platformCategory')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updatePlatformCategory(@PathVariable("storeId") Long storeId,
                                        @Validated(value = StoreFieldUpdateRequest.UpdateStorePlatformCategoryGroup.class)
                                        @RequestBody StoreFieldUpdateRequest request) {
@@ -226,8 +239,8 @@
      */
     @PatchMapping(value = "/{storeId}/businessHours")
     @ApiOperation("修改店铺营业时间")
-    @PreAuthorize("@el.check('merchant:store:businessHours')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:businessHours')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updateBusinessHours(@PathVariable("storeId") Long storeId,
                                     @Validated(value = StoreFieldUpdateRequest.UpdateStoreBusinessHoursGroup.class)
                                     @RequestBody StoreFieldUpdateRequest request) {
@@ -240,8 +253,8 @@
      */
     @PatchMapping(value = "/{storeId}/deliveryMinimum")
     @ApiOperation("修改起送金额")
-    @PreAuthorize("@el.check('merchant:store:deliveryMinimum')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:deliveryMinimum')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updateDeliveryMinimum(@PathVariable("storeId") Long storeId,
                                       @Validated(value = StoreFieldUpdateRequest.UpdateStoreDeliveryMinimumGroup.class)
                                       @RequestBody StoreFieldUpdateRequest request) {
@@ -254,8 +267,8 @@
      */
     @PatchMapping(value = "/{storeId}/deliveryFee")
     @ApiOperation("修改配送费用")
-    @PreAuthorize("@el.check('merchant:store:deliveryFee')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    /*@PreAuthorize("@el.check('merchant:store:deliveryFee')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> updateDeliveryFee(@PathVariable("storeId") Long storeId,
                                   @Validated(value = StoreFieldUpdateRequest.UpdateStoreDeliveryFeeGroup.class)
                                   @RequestBody StoreFieldUpdateRequest request) {
@@ -267,13 +280,22 @@
      * 修改状态
      */
     @PatchMapping(value = "/{storeId}/businessStatus")
-    @ApiOperation("修改状态")
-    @PreAuthorize("@el.check('merchant:store:businessStatus')" +
-            " and @storeMerchantOwnershipService.check(#storeId)")
+    @ApiOperation("修改营业状态")
+    /*@PreAuthorize("@el.check('merchant:store:businessStatus')" +
+            " and @storeMerchantOwnershipService.check(#storeId)")*/
     public ResponseEntity<?> businessStatus(@PathVariable("storeId") Long storeId,
                                @Validated(value = StoreFieldUpdateRequest.UpdateStoreBusinessStatusGroup.class)
                                @RequestBody StoreFieldUpdateRequest request) {
-        storeService.updateStatus(storeId, request.getBusinessStatus(), request.getVersion());
+        //storeService.updateStatus(storeId, request.getBusinessStatus(), request.getVersion());
+        Store store = new Store();
+        store.setStoreId(storeId);
+        store.setStatus(request.getBusinessStatus());
+        store.setBusinessStatus(request.getBusinessStatus());
+        Set<Integer> statusEnumSet = CollectionUtil.newHashSet(StoreStatusEnum.OPEN.getValue(), StoreStatusEnum.CLOSED.getValue());
+        if (!statusEnumSet.contains(request.getBusinessStatus())) {
+            throw new BadRequestException("状态错误");
+        }
+        storeMerchantService.updateBusinessStatus(store);
         return ResponseEntity.noContent().build();
     }
 }

--
Gitblit v1.9.3