From ab0637e981ab4c85120ccde35ee24ec4abbe3e24 Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Fri, 17 Oct 2025 17:20:15 +0800
Subject: [PATCH] Merge branch 'refs/heads/master' into xin
---
oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java | 131 ++++++++++++++++++++++++++++++-------------
1 files changed, 90 insertions(+), 41 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 e1eee0a..0b9c3b1 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,18 +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.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;
@@ -21,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;
/**
@@ -43,12 +43,15 @@
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));
}
@@ -56,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));
@@ -68,31 +71,49 @@
@GetMapping(value = "/{storeId}")
@ApiOperation("查询店铺")
//@PreAuthorize("@el.check('merchant:store:getById')")
- public ResponseEntity<?> getById(@PathVariable Long storeId) {
+ public ResponseEntity<?> getStoreById(@PathVariable Long storeId) {
Store store = storeService.getById(storeId);
- StoreMerchantView view = new StoreMerchantView();
- BeanUtils.copyProperties(store, view);
- return ResponseEntity.ok(R.success(view));
+ /*StoreMerchantView view = new StoreMerchantView();
+ BeanUtils.copyProperties(store, view);*/
+ return ResponseEntity.ok(R.success(store));
+ }
+
+ @GetMapping(value = "/{storeId}/details")
+ @ApiOperation("查询店铺")
+ //@PreAuthorize("@el.check('merchant:store:getById')")
+ public ResponseEntity<?> getStoreDetailsById(@PathVariable Long storeId) {
+ Store store = storeService.getById(storeId);
+ if (ObjUtil.isNotEmpty(store)) {
+ store.setQualifications(storeQualificationService.getByStoreId(storeId));
+ }
+ return ResponseEntity.ok(R.success(store));
}
@PostMapping
@ApiOperation("创建店铺")
//@PreAuthorize("@el.check('merchant:store:create')")
public ResponseEntity<?> create(@RequestBody StoreCreateRequest request) {
- storeCreateService.create(request);
- return ResponseEntity.status(HttpStatus.CREATED).build();
+ 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();
}
@@ -106,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();
}
@@ -120,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();
}
@@ -143,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) {
@@ -157,12 +183,12 @@
*/
@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) {
- storeService.updateAddress(storeId, request.getAddress(), request.getVersion());
+ storeService.updateAddress(storeId, request.getAddress(), request.getLongitude(), request.getLatitude(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -171,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) {
@@ -185,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) {
@@ -199,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) {
@@ -213,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) {
@@ -227,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) {
@@ -241,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) {
@@ -251,16 +277,39 @@
}
/**
+ * 修改包装费用
+ */
+ @PatchMapping(value = "/{storeId}/packagingFee")
+ @ApiOperation("修改包装费用")
+ /*@PreAuthorize("@el.check('merchant:store:deliveryFee')" +
+ " and @storeMerchantOwnershipService.check(#storeId)")*/
+ public ResponseEntity<?> updatePackagingFee(@PathVariable("storeId") Long storeId,
+ @Validated(value = StoreFieldUpdateRequest.UpdateStorePackagingFeeGroup.class)
+ @RequestBody StoreFieldUpdateRequest request) {
+ storeService.updatePackagingFee(storeId, request.getPackagingFee(), request.getVersion());
+ return ResponseEntity.noContent().build();
+ }
+
+ /**
* 修改状态
*/
@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