PlatformMerchantController.java
2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.diligrp.rider.controller;
import com.diligrp.rider.common.result.Result;
import com.diligrp.rider.dto.MerchantStoreDTO;
import com.diligrp.rider.entity.MerchantStore;
import com.diligrp.rider.service.MerchantService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
/**
* 平台后台:门店管理
* - 外部门店通过开放平台 /api/open/store/sync 同步,统一存入 merchant_store 表
* - 平台管理员也可直接新建门店,选填 outStoreId 与外部系统对账
*/
@RestController
@RequestMapping("/api/platform/merchant")
@RequiredArgsConstructor
public class PlatformMerchantController {
private final MerchantService merchantService;
/** 门店列表(含外部同步的和平台自建的) */
@GetMapping("/store/list")
public Result<List<MerchantStore>> storeList(
@RequestParam(required = false) Long cityId,
@RequestParam(required = false) String keyword,
@RequestParam(defaultValue = "1") int page) {
return Result.success(merchantService.storeList(cityId, keyword, page));
}
/** 新增门店(平台直接建,无需审核) */
@PostMapping("/store/add")
public Result<Long> addStore(@Valid @RequestBody MerchantStoreDTO dto) {
return Result.success(merchantService.addStore(dto));
}
/** 编辑门店 */
@PutMapping("/store/edit")
public Result<Void> editStore(@Valid @RequestBody MerchantStoreDTO dto) {
merchantService.editStore(dto);
return Result.success();
}
/** 门店详情 */
@GetMapping("/store/detail")
public Result<MerchantStore> storeDetail(@RequestParam Long storeId) {
return Result.success(merchantService.getStore(storeId));
}
/** 设置营业/打烊 */
@PostMapping("/store/setOperatingState")
public Result<Void> setOperatingState(@RequestParam Long storeId, @RequestParam int state) {
merchantService.setOperatingState(storeId, state);
return Result.success();
}
/** 更新免运费和起送金额 */
@PostMapping("/store/updateFeeConfig")
public Result<Void> updateFeeConfig(
@RequestParam Long storeId,
@RequestParam(defaultValue = "0") BigDecimal freeShipping,
@RequestParam(defaultValue = "0") BigDecimal upToSend) {
merchantService.updateFeeConfig(storeId, freeShipping, upToSend);
return Result.success();
}
/** 删除门店 */
@DeleteMapping("/store/del")
public Result<Void> delStore(@RequestParam Long storeId) {
merchantService.delStore(storeId);
return Result.success();
}
}