From 6416e025afd6b3d19347610b3e441ac6a12a0f8f Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Thu, 25 Sep 2025 22:59:05 +0800
Subject: [PATCH] 工具:支付配置
---
oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java | 174 +++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 113 insertions(+), 61 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 6e5d928..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
@@ -1,15 +1,19 @@
package com.oying.modules.pc.store.rest;
+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 com.oying.utils.R;
+import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.ObjectUtil;
+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;
@@ -17,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;
/**
@@ -39,21 +43,26 @@
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() {
- StoreQueryCriteria criteria = new StoreQueryCriteria();
- criteria.setMerchantId(SecurityUtils.getCurrentUserId());
- //criteria.setStatus();
- List<Store> storeList = Optional.ofNullable(storeService.queryAll(criteria)).orElse(ListUtil.empty());
- List<StoreSimpleView> storeViewList = storeList.stream().map(s -> {
+ List<Store> stores = Optional.ofNullable(storeService.getUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty());
+ return ResponseEntity.ok(R.success(stores));
+ }
+
+ @GetMapping(value = "/simple-list")
+ @ApiOperation("查询所有店铺")
+ //@PreAuthorize("@el.check('merchant:store:list')")
+ public ResponseEntity<?> getSimpleStores() {
+ List<Store> stores = Optional.ofNullable(storeService.getUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty());
+ List<StoreSimpleView> storeViewList = stores.stream().map(i -> {
StoreSimpleView view = new StoreSimpleView();
- view.setId(s.getStoreId());
- view.setName(s.getStoreName());
- view.setLogoUrl("");
- view.setStatus(s.getStatus());
+ BeanUtil.copyProperties(i, view, CopyOptions.create().setIgnoreNullValue(true));
return view;
}).collect(Collectors.toList());
return ResponseEntity.ok(R.success(storeViewList));
@@ -61,35 +70,50 @@
@GetMapping(value = "/{storeId}")
@ApiOperation("查询店铺")
- //@PreAuthorize("@el.check('merchant:store:getById')" +
- // " and @storeMerchantOwnershipService.check(#storeId)")
- public ResponseEntity<?> getById(@PathVariable Long storeId) {
+ //@PreAuthorize("@el.check('merchant:store:getById')")
+ public ResponseEntity<?> getStoreById(@PathVariable Long storeId) {
Store store = storeService.getById(storeId);
- StoreMerchantView view = new StoreMerchantView();
- BeanUtils.copyProperties(store, view);
- view.setLogoUrl("");
- 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 Store store) {
- store.setStoreId(storeId);
- storeService.updateById(store);
+ public ResponseEntity<?> update(@PathVariable("storeId") Long storeId, @RequestBody StoreUpdateRequest request) {
+ request.setStoreId(ObjectUtil.defaultIfNull(request.getStoreId(), storeId));
+ storeMerchantService.updateStore(request);
return ResponseEntity.noContent().build();
}
@@ -103,7 +127,8 @@
public ResponseEntity<?> updateLogo(@PathVariable("storeId") Long storeId,
@Validated(value = StoreFieldUpdateRequest.UpdateStoreLogoImageGroup.class)
@RequestBody StoreFieldUpdateRequest request) {
- storeService.updateLogo(storeId, request.getLogoImageUploadId());
+ Long logeImageId = Optional.ofNullable(request.getLogoImageId()).orElse(Long.getLong(request.getLogoImageUploadId()));
+ storeService.updateLogo(storeId, logeImageId, request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -117,7 +142,11 @@
public ResponseEntity<?> updateName(@PathVariable("storeId") Long storeId,
@Validated(value = StoreFieldUpdateRequest.UpdateStoreNameGroup.class)
@RequestBody StoreFieldUpdateRequest request) {
- storeService.updateName(storeId, request.getStoreName());
+ StoreUpdateRequest updateRequest = new StoreUpdateRequest();
+ updateRequest.setStoreId(storeId);
+ updateRequest.setStoreName(request.getStoreName());
+ storeMerchantService.updateStore(updateRequest);
+ //storeMerchantService.saveRevisionStore(request, StoreRevisionTypeEnum.NAME_UPDATE);
return ResponseEntity.noContent().build();
}
@@ -131,7 +160,7 @@
public ResponseEntity<?> updateDescription(@PathVariable("storeId") Long storeId,
@Validated(value = StoreFieldUpdateRequest.UpdateStoreDescriptionGroup.class)
@RequestBody StoreFieldUpdateRequest request) {
- storeService.updateDescription(storeId, request.getDescription());
+ storeService.updateDescription(storeId, request.getDescription(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -140,12 +169,12 @@
*/
@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) {
- storeService.updateContactPhone(storeId, request.getContactPhone());
+ storeService.updateContactPhone(storeId, request.getContactPhone(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -154,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());
+ storeService.updateAddress(storeId, request.getAddress(), request.getLongitude(), request.getLatitude(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -168,12 +197,12 @@
*/
@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) {
- storeService.updateLocation(storeId, request.getLongitude(), request.getLatitude());
+ storeService.updateLocation(storeId, request.getLongitude(), request.getLatitude(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -182,12 +211,12 @@
*/
@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) {
- storeService.updateRadius(storeId, request.getRadius());
+ storeService.updateRadius(storeId, request.getRadius(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -196,12 +225,12 @@
*/
@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) {
- storeService.updatePlatformCategory(storeId, request.getPlatformCategoryId());
+ storeService.updatePlatformCategory(storeId, request.getPlatformCategoryId(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -210,12 +239,12 @@
*/
@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) {
- storeService.updateBusinessHours(storeId, request.getOpenTime(), request.getCloseTime());
+ storeService.updateBusinessHours(storeId, request.getOpenTime(), request.getCloseTime(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -224,12 +253,12 @@
*/
@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) {
- storeService.updateDeliveryMinimum(storeId, request.getDeliveryMinimum());
+ storeService.updateDeliveryMinimum(storeId, request.getDeliveryMinimum(), request.getVersion());
return ResponseEntity.noContent().build();
}
@@ -238,12 +267,26 @@
*/
@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) {
- storeService.updateDeliveryFee(storeId, request.getDeliveryFee());
+ storeService.updateDeliveryFee(storeId, request.getDeliveryFee(), request.getVersion());
+ return ResponseEntity.noContent().build();
+ }
+
+ /**
+ * 修改包装费用
+ */
+ @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();
}
@@ -251,13 +294,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());
+ //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