功能:新增下一阶段运营能力和生产部署
This commit is contained in:
@@ -59,6 +59,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
"/nail-artist/*/reviews",
|
||||
"/shop/get/**",
|
||||
"/shop/trust-profile/**",
|
||||
"/shop/list",
|
||||
"/shop/list/public",
|
||||
"/shop/list/simple",
|
||||
"/tag/list/all",
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleAuditDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.AfterSaleService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/after-sale")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminAfterSaleController {
|
||||
|
||||
private final AfterSaleService afterSaleService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final SecurityAuditSupport securityAuditSupport;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("after_sale:view")
|
||||
public Result<PageResultVO<AfterSaleVO>> list(HttpServletRequest request,
|
||||
@RequestParam(required = false) String status,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
return Result.success(afterSaleService.listAdmin(shopId, status, page, size));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/approve")
|
||||
@RequirePermission("after_sale:audit")
|
||||
public Result<AfterSaleVO> approve(HttpServletRequest request, @PathVariable Long id, @RequestBody(required = false) AfterSaleAuditDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
try {
|
||||
AfterSaleVO result = afterSaleService.approve(currentUser.getId(), id, dto);
|
||||
securityAuditSupport.success(request, SecurityAuditActions.AFTER_SALE_APPROVE, "afterSaleId=" + id);
|
||||
return Result.success(result);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditSupport.fail(request, SecurityAuditActions.AFTER_SALE_APPROVE, "afterSaleId=" + id + ",reason=" + exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/reject")
|
||||
@RequirePermission("after_sale:audit")
|
||||
public Result<AfterSaleVO> reject(HttpServletRequest request, @PathVariable Long id, @RequestBody(required = false) AfterSaleAuditDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
try {
|
||||
AfterSaleVO result = afterSaleService.reject(currentUser.getId(), id, dto);
|
||||
securityAuditSupport.success(request, SecurityAuditActions.AFTER_SALE_REJECT, "afterSaleId=" + id);
|
||||
return Result.success(result);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditSupport.fail(request, SecurityAuditActions.AFTER_SALE_REJECT, "afterSaleId=" + id + ",reason=" + exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.ArtistScheduleDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.ArtistScheduleService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||
import com.xiaowang.yuminailcore.vo.ArtistScheduleVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/artist-schedule")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminArtistScheduleController {
|
||||
|
||||
private final ArtistScheduleService artistScheduleService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final SecurityAuditSupport securityAuditSupport;
|
||||
|
||||
@PostMapping("/save")
|
||||
@RequirePermission("schedule:edit")
|
||||
public Result<ArtistScheduleVO> save(HttpServletRequest request, @RequestBody ArtistScheduleDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
dto.setShopId(adminScopeHelper.resolveShopScope(currentUser, dto.getShopId()));
|
||||
try {
|
||||
ArtistScheduleVO result = artistScheduleService.saveSchedule(dto);
|
||||
securityAuditSupport.success(request, SecurityAuditActions.SCHEDULE_UPDATE, "artistId=" + dto.getArtistId() + ",date=" + dto.getWorkDate());
|
||||
return Result.success(result);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditSupport.fail(request, SecurityAuditActions.SCHEDULE_UPDATE, "artistId=" + dto.getArtistId() + ",reason=" + exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("schedule:view")
|
||||
public Result<List<ArtistScheduleVO>> list(HttpServletRequest request,
|
||||
@RequestParam(required = false) Long artistId,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
return Result.success(artistScheduleService.listSchedules(shopId, artistId, startDate, endDate));
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.CampaignDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.CampaignService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||
import com.xiaowang.yuminailcore.vo.CampaignVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/campaign")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminCampaignController {
|
||||
|
||||
private final CampaignService campaignService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final SecurityAuditSupport securityAuditSupport;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("campaign:view")
|
||||
public Result<PageResultVO<CampaignVO>> list(HttpServletRequest request,
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
return Result.success(campaignService.listCampaigns(shopId, status, page, size));
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
@RequirePermission("campaign:manage")
|
||||
public Result<CampaignVO> save(HttpServletRequest request, @RequestBody CampaignDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
dto.setShopId(adminScopeHelper.resolveShopScope(currentUser, dto.getShopId()));
|
||||
try {
|
||||
CampaignVO result = campaignService.saveCampaign(dto);
|
||||
securityAuditSupport.success(request, SecurityAuditActions.CAMPAIGN_PUBLISH, "campaignId=" + result.getId());
|
||||
return Result.success(result);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditSupport.fail(request, SecurityAuditActions.CAMPAIGN_PUBLISH, "reason=" + exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.InventoryAdjustDTO;
|
||||
import com.xiaowang.yuminailcore.dto.InventoryItemDTO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.InventoryService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||
import com.xiaowang.yuminailcore.vo.InventoryItemVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/inventory")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminInventoryController {
|
||||
|
||||
private final InventoryService inventoryService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final SecurityAuditSupport securityAuditSupport;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequirePermission("inventory:view")
|
||||
public Result<PageResultVO<InventoryItemVO>> list(HttpServletRequest request,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
return Result.success(inventoryService.listItems(shopId, page, size));
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
@RequirePermission("inventory:manage")
|
||||
public Result<InventoryItemVO> save(HttpServletRequest request, @RequestBody InventoryItemDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
dto.setShopId(adminScopeHelper.resolveShopScope(currentUser, dto.getShopId()));
|
||||
return Result.success(inventoryService.saveItem(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/adjust")
|
||||
@RequirePermission("inventory:manage")
|
||||
public Result<InventoryItemVO> adjust(HttpServletRequest request, @PathVariable Long id, @RequestBody InventoryAdjustDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
try {
|
||||
InventoryItemVO result = inventoryService.adjustStock(currentUser.getId(), id, dto);
|
||||
securityAuditSupport.success(request, SecurityAuditActions.INVENTORY_ADJUST, "itemId=" + id);
|
||||
return Result.success(result);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditSupport.fail(request, SecurityAuditActions.INVENTORY_ADJUST, "itemId=" + id + ",reason=" + exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.PaymentService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||
import com.xiaowang.yuminailcore.vo.RefundOrderVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/payment")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminPaymentController {
|
||||
|
||||
private final PaymentService paymentService;
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final SecurityAuditSupport securityAuditSupport;
|
||||
|
||||
@PostMapping("/order/{orderId}/manual-confirm")
|
||||
@RequirePermission("payment:manage")
|
||||
public Result<PaymentOrderVO> manualConfirm(HttpServletRequest request,
|
||||
@PathVariable Long orderId,
|
||||
@RequestParam(required = false) String remark) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
try {
|
||||
PaymentOrderVO result = paymentService.manualConfirmOrderPaid(currentUser.getId(), orderId, remark);
|
||||
securityAuditSupport.success(request, SecurityAuditActions.PAYMENT_MANUAL_CONFIRM, "orderId=" + orderId);
|
||||
return Result.success(result);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditSupport.fail(request, SecurityAuditActions.PAYMENT_MANUAL_CONFIRM, "orderId=" + orderId + ",reason=" + exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/order/{orderId}/manual-refund")
|
||||
@RequirePermission("refund:manage")
|
||||
public Result<RefundOrderVO> manualRefund(HttpServletRequest request,
|
||||
@PathVariable Long orderId,
|
||||
@RequestParam(required = false) Long afterSaleId,
|
||||
@RequestParam(required = false) String remark) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
try {
|
||||
RefundOrderVO result = paymentService.manualRefundOrder(currentUser.getId(), orderId, afterSaleId, remark);
|
||||
securityAuditSupport.success(request, SecurityAuditActions.REFUND_MANUAL_CONFIRM, "orderId=" + orderId);
|
||||
return Result.success(result);
|
||||
} catch (RuntimeException exception) {
|
||||
securityAuditSupport.fail(request, SecurityAuditActions.REFUND_MANUAL_CONFIRM, "orderId=" + orderId + ",reason=" + exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.service.WorkbenchService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.vo.StoreWorkbenchVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/workbench")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminWorkbenchController {
|
||||
|
||||
private final AdminScopeHelper adminScopeHelper;
|
||||
private final WorkbenchService workbenchService;
|
||||
|
||||
@GetMapping("/summary")
|
||||
@RequirePermission("workbench:view")
|
||||
public Result<StoreWorkbenchVO> summary(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
Long artistId = currentUser != null && Integer.valueOf(3).equals(currentUser.getType()) ? currentUser.getId() : null;
|
||||
return Result.success(workbenchService.getWorkbench(shopId, artistId));
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleApplyDTO;
|
||||
import com.xiaowang.yuminailcore.service.AfterSaleService;
|
||||
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/after-sale")
|
||||
@RequiredArgsConstructor
|
||||
public class AfterSaleController {
|
||||
|
||||
private final AfterSaleService afterSaleService;
|
||||
|
||||
@PostMapping("/apply")
|
||||
public Result<AfterSaleVO> apply(HttpServletRequest request, @RequestBody AfterSaleApplyDTO dto) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(afterSaleService.apply(userId, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/my")
|
||||
public Result<PageResultVO<AfterSaleVO>> listMy(HttpServletRequest request,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(afterSaleService.listMy(userId, page, size));
|
||||
}
|
||||
}
|
||||
+12
@@ -16,11 +16,13 @@ import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||
import com.xiaowang.yuminailcore.service.OperationsAnalyticsService;
|
||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||
import com.xiaowang.yuminailcore.support.UserShopBindingSupport;
|
||||
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
||||
import com.xiaowang.yuminailcore.vo.DashboardStatsVO;
|
||||
import com.xiaowang.yuminailcore.vo.HotProductVO;
|
||||
import com.xiaowang.yuminailcore.vo.OperationsAnalyticsVO;
|
||||
import com.xiaowang.yuminailcore.vo.RecentActivityVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -87,6 +89,7 @@ public class DashboardController {
|
||||
* Variable `appCacheProperties`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final AppCacheProperties appCacheProperties;
|
||||
private final OperationsAnalyticsService operationsAnalyticsService;
|
||||
|
||||
@GetMapping("/stats")
|
||||
@RequirePermission("dashboard:view")
|
||||
@@ -112,6 +115,15 @@ public class DashboardController {
|
||||
return Result.success(stats);
|
||||
}
|
||||
|
||||
@GetMapping("/analytics")
|
||||
@RequirePermission("analytics:view")
|
||||
public Result<OperationsAnalyticsVO> getAnalytics(HttpServletRequest request) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
Long shopIdScope = resolveShopScope(currentUser);
|
||||
Long artistScope = currentUser != null && Integer.valueOf(3).equals(currentUser.getType()) ? currentUser.getId() : null;
|
||||
return Result.success(operationsAnalyticsService.getDashboardAnalytics(shopIdScope, artistScope));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `buildDashboardStats`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
|
||||
+9
-32
@@ -16,46 +16,23 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 前台文件控制器,提供前台用户可访问的文件相关接口。
|
||||
* Purpose: FrontendFileController exposes signed-file access only for public frontend references.
|
||||
* Usage: anonymous clients call /file/get-signed-url/{fileId}; the controller verifies the file is referenced by public content before returning a URL.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/file")
|
||||
@RequiredArgsConstructor
|
||||
public class FrontendFileController {
|
||||
/**
|
||||
* Variable `objectStorageFileService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
/**
|
||||
* Variable `minioService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final MinioService minioService;
|
||||
/**
|
||||
* Variable `objectStorageUrlSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
/**
|
||||
* Purpose: productMapper supports FrontendFileController.java by holding or executing the product mapper business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private final ProductMapper productMapper;
|
||||
/**
|
||||
* Purpose: shopMapper supports FrontendFileController.java by holding or executing the shop mapper business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private final ShopMapper shopMapper;
|
||||
/**
|
||||
* Purpose: effectDiagramMapper supports FrontendFileController.java by holding or executing the effect diagram mapper business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private final EffectDiagramMapper effectDiagramMapper;
|
||||
|
||||
/**
|
||||
* 获取带签名的图片链接。
|
||||
*
|
||||
* @param fileId 文件 ID
|
||||
* @param expiryTimeInMinutes 有效期,默认 60 分钟
|
||||
* @return 临时可访问的签名地址
|
||||
* Purpose: getSignedUrl returns a short-lived URL for public image references, or the original external URL when it is already public.
|
||||
* Usage: pass a public file id and optional expiry minutes; private or unreferenced files are rejected.
|
||||
*/
|
||||
@GetMapping("/get-signed-url/{fileId}")
|
||||
public Result<String> getSignedUrl(@PathVariable Long fileId,
|
||||
@@ -71,7 +48,7 @@ public class FrontendFileController {
|
||||
|
||||
String objectName = objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl());
|
||||
if (objectName == null || objectName.isEmpty()) {
|
||||
return Result.error("文件 URL 格式错误");
|
||||
return Result.success(fileVO.getFileUrl());
|
||||
}
|
||||
|
||||
String signedUrl = minioService.getPresignedUrl(objectName, expiryTimeInMinutes);
|
||||
@@ -83,8 +60,8 @@ public class FrontendFileController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isPublicFileReference supports FrontendFileController.java by holding or executing the is public file reference business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
* Purpose: isPublicFileReference prevents arbitrary uploaded files from being exposed through the public signing endpoint.
|
||||
* Usage: call with a file id and keep mapper checks in sync with public content tables.
|
||||
*/
|
||||
private boolean isPublicFileReference(Long fileId) {
|
||||
if (fileId == null) {
|
||||
@@ -96,8 +73,8 @@ public class FrontendFileController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: positive supports FrontendFileController.java by holding or executing the positive business role.
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
* Purpose: positive normalizes nullable mapper counts.
|
||||
* Usage: use for COUNT(*) results where null should behave like zero.
|
||||
*/
|
||||
private boolean positive(Long count) {
|
||||
return count != null && count > 0;
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.service.GrowthService;
|
||||
import com.xiaowang.yuminailcore.vo.GrowthSummaryVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/growth")
|
||||
@RequiredArgsConstructor
|
||||
public class GrowthController {
|
||||
|
||||
private final GrowthService growthService;
|
||||
|
||||
@GetMapping("/summary")
|
||||
public Result<GrowthSummaryVO> summary(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(growthService.getSummary(userId));
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.service.PaymentService;
|
||||
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/payment")
|
||||
@RequiredArgsConstructor
|
||||
public class PaymentController {
|
||||
|
||||
private final PaymentService paymentService;
|
||||
|
||||
@PostMapping("/order/{orderId}/prepare")
|
||||
public Result<PaymentOrderVO> prepareOrderPayment(HttpServletRequest request, @PathVariable Long orderId) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(paymentService.prepareOrderPayment(userId, orderId));
|
||||
}
|
||||
|
||||
@PostMapping("/order/{orderId}/mock-success")
|
||||
public Result<PaymentOrderVO> mockSuccess(HttpServletRequest request, @PathVariable Long orderId) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
return Result.success(paymentService.manualConfirmOrderPaid(userId, orderId, "mock-success"));
|
||||
}
|
||||
}
|
||||
@@ -176,6 +176,16 @@ public class ShopController {
|
||||
return Result.success(simpleVOs);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
/**
|
||||
* Purpose: listPublicShopsCompat keeps the legacy /shop/list public catalog URL usable for anonymous clients.
|
||||
* Usage: call from old Web or mini-program builds that still request /api/shop/list; new code may prefer /shop/list/public.
|
||||
* @return Result<List<ShopVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ShopVO>> listPublicShopsCompat() {
|
||||
return Result.success(shopService.listAllShops());
|
||||
}
|
||||
|
||||
@GetMapping("/list/public")
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class AfterSaleApplyDTO {
|
||||
private Long orderId;
|
||||
private Long orderItemId;
|
||||
private String type;
|
||||
private String reason;
|
||||
private BigDecimal refundAmount;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AfterSaleAuditDTO {
|
||||
private String auditReason;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@Data
|
||||
public class ArtistScheduleDTO {
|
||||
private Long shopId;
|
||||
private Long artistId;
|
||||
private LocalDate workDate;
|
||||
private LocalTime startTime;
|
||||
private LocalTime endTime;
|
||||
private Integer slotMinutes;
|
||||
private Integer capacity;
|
||||
private Integer status;
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CampaignDTO {
|
||||
private Long shopId;
|
||||
private String title;
|
||||
private String description;
|
||||
private String scene;
|
||||
private String productIds;
|
||||
private String couponIds;
|
||||
private Integer status;
|
||||
private LocalDateTime startTime;
|
||||
private LocalDateTime endTime;
|
||||
private Integer sortOrder;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class InventoryAdjustDTO {
|
||||
private String changeType;
|
||||
private BigDecimal changeQuantity;
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class InventoryItemDTO {
|
||||
private Long shopId;
|
||||
private String category;
|
||||
private String itemName;
|
||||
private String unit;
|
||||
private BigDecimal stockQuantity;
|
||||
private BigDecimal warningThreshold;
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_after_sale")
|
||||
public class AfterSaleDO extends BaseEntity {
|
||||
@TableField("after_sale_no")
|
||||
private String afterSaleNo;
|
||||
@TableField("order_id")
|
||||
private Long orderId;
|
||||
@TableField("order_item_id")
|
||||
private Long orderItemId;
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
@TableField("type")
|
||||
private String type;
|
||||
@TableField("reason")
|
||||
private String reason;
|
||||
@TableField("refund_amount")
|
||||
private BigDecimal refundAmount;
|
||||
@TableField("status")
|
||||
private String status;
|
||||
@TableField("audit_user_id")
|
||||
private Long auditUserId;
|
||||
@TableField("audit_reason")
|
||||
private String auditReason;
|
||||
@TableField("audit_time")
|
||||
private LocalDateTime auditTime;
|
||||
@TableField("refund_order_id")
|
||||
private Long refundOrderId;
|
||||
@TableField("is_delete")
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_after_sale_log")
|
||||
public class AfterSaleLogDO extends BaseEntity {
|
||||
@TableField("after_sale_id")
|
||||
private Long afterSaleId;
|
||||
@TableField("action")
|
||||
private String action;
|
||||
@TableField("from_status")
|
||||
private String fromStatus;
|
||||
@TableField("to_status")
|
||||
private String toStatus;
|
||||
@TableField("operator_id")
|
||||
private Long operatorId;
|
||||
@TableField("operator_type")
|
||||
private String operatorType;
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_appointment_reservation")
|
||||
public class AppointmentReservationDO extends BaseEntity {
|
||||
@TableField("order_id")
|
||||
private Long orderId;
|
||||
@TableField("order_item_id")
|
||||
private Long orderItemId;
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
@TableField("artist_id")
|
||||
private Long artistId;
|
||||
@TableField("product_title")
|
||||
private String productTitle;
|
||||
@TableField("appointment_start_time")
|
||||
private LocalDateTime appointmentStartTime;
|
||||
@TableField("appointment_end_time")
|
||||
private LocalDateTime appointmentEndTime;
|
||||
@TableField("status")
|
||||
private String status;
|
||||
@TableField("is_delete")
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_artist_schedule")
|
||||
public class ArtistScheduleDO extends BaseEntity {
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
@TableField("artist_id")
|
||||
private Long artistId;
|
||||
@TableField("work_date")
|
||||
private LocalDate workDate;
|
||||
@TableField("start_time")
|
||||
private LocalTime startTime;
|
||||
@TableField("end_time")
|
||||
private LocalTime endTime;
|
||||
@TableField("slot_minutes")
|
||||
private Integer slotMinutes;
|
||||
@TableField("capacity")
|
||||
private Integer capacity;
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
@TableField("is_delete")
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_campaign")
|
||||
public class CampaignDO extends BaseEntity {
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
@TableField("title")
|
||||
private String title;
|
||||
@TableField("description")
|
||||
private String description;
|
||||
@TableField("scene")
|
||||
private String scene;
|
||||
@TableField("product_ids")
|
||||
private String productIds;
|
||||
@TableField("coupon_ids")
|
||||
private String couponIds;
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
@TableField("start_time")
|
||||
private LocalDateTime startTime;
|
||||
@TableField("end_time")
|
||||
private LocalDateTime endTime;
|
||||
@TableField("sort_order")
|
||||
private Integer sortOrder;
|
||||
@TableField("is_delete")
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_inventory_item")
|
||||
public class InventoryItemDO extends BaseEntity {
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
@TableField("category")
|
||||
private String category;
|
||||
@TableField("item_name")
|
||||
private String itemName;
|
||||
@TableField("unit")
|
||||
private String unit;
|
||||
@TableField("stock_quantity")
|
||||
private BigDecimal stockQuantity;
|
||||
@TableField("warning_threshold")
|
||||
private BigDecimal warningThreshold;
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
@TableField("is_delete")
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_inventory_record")
|
||||
public class InventoryRecordDO extends BaseEntity {
|
||||
@TableField("inventory_item_id")
|
||||
private Long inventoryItemId;
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
@TableField("change_type")
|
||||
private String changeType;
|
||||
@TableField("change_quantity")
|
||||
private BigDecimal changeQuantity;
|
||||
@TableField("before_quantity")
|
||||
private BigDecimal beforeQuantity;
|
||||
@TableField("after_quantity")
|
||||
private BigDecimal afterQuantity;
|
||||
@TableField("operator_id")
|
||||
private Long operatorId;
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
}
|
||||
@@ -45,6 +45,13 @@ public class OrderDO extends BaseEntity {
|
||||
* Field `couponSourceType` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private String couponSourceType;
|
||||
private String paymentStatus;
|
||||
private BigDecimal payAmount;
|
||||
private BigDecimal paidAmount;
|
||||
private LocalDateTime payTime;
|
||||
private String paymentMethod;
|
||||
private String paymentOrderNo;
|
||||
private String refundStatus;
|
||||
/**
|
||||
* Field `status` (Integer): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_payment_order")
|
||||
public class PaymentOrderDO extends BaseEntity {
|
||||
@TableField("pay_no")
|
||||
private String payNo;
|
||||
@TableField("order_id")
|
||||
private Long orderId;
|
||||
@TableField("order_no")
|
||||
private String orderNo;
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
@TableField("channel")
|
||||
private String channel;
|
||||
@TableField("status")
|
||||
private String status;
|
||||
@TableField("pay_amount")
|
||||
private BigDecimal payAmount;
|
||||
@TableField("paid_amount")
|
||||
private BigDecimal paidAmount;
|
||||
@TableField("pay_time")
|
||||
private LocalDateTime payTime;
|
||||
@TableField("expire_time")
|
||||
private LocalDateTime expireTime;
|
||||
@TableField("operator_id")
|
||||
private Long operatorId;
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
@TableField("idempotency_key")
|
||||
private String idempotencyKey;
|
||||
@TableField("raw_payload")
|
||||
private String rawPayload;
|
||||
@TableField("is_delete")
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_refund_order")
|
||||
public class RefundOrderDO extends BaseEntity {
|
||||
@TableField("refund_no")
|
||||
private String refundNo;
|
||||
@TableField("after_sale_id")
|
||||
private Long afterSaleId;
|
||||
@TableField("payment_order_id")
|
||||
private Long paymentOrderId;
|
||||
@TableField("order_id")
|
||||
private Long orderId;
|
||||
@TableField("status")
|
||||
private String status;
|
||||
@TableField("refund_amount")
|
||||
private BigDecimal refundAmount;
|
||||
@TableField("refund_time")
|
||||
private LocalDateTime refundTime;
|
||||
@TableField("channel")
|
||||
private String channel;
|
||||
@TableField("external_refund_no")
|
||||
private String externalRefundNo;
|
||||
@TableField("fail_reason")
|
||||
private String failReason;
|
||||
@TableField("idempotency_key")
|
||||
private String idempotencyKey;
|
||||
@TableField("is_delete")
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xiaowang.yuminailcore.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_user_growth_record")
|
||||
public class UserGrowthRecordDO extends BaseEntity {
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
@TableField("source_type")
|
||||
private String sourceType;
|
||||
@TableField("source_id")
|
||||
private Long sourceId;
|
||||
@TableField("growth_value")
|
||||
private Integer growthValue;
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.AfterSaleLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AfterSaleLogMapper extends BaseMapper<AfterSaleLogDO> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.AfterSaleDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AfterSaleMapper extends BaseMapper<AfterSaleDO> {
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.AppointmentReservationDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Mapper
|
||||
public interface AppointmentReservationMapper extends BaseMapper<AppointmentReservationDO> {
|
||||
@Select("SELECT COUNT(*) FROM t_appointment_reservation WHERE artist_id = #{artistId} " +
|
||||
"AND status IN ('LOCKED','CONFIRMED') AND is_delete = 0 " +
|
||||
"AND appointment_start_time < #{endTime} AND appointment_end_time > #{startTime} FOR UPDATE")
|
||||
int countOverlappingActiveForUpdate(@Param("artistId") Long artistId,
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM t_appointment_reservation WHERE artist_id = #{artistId} " +
|
||||
"AND order_item_id <> #{orderItemId} AND status IN ('LOCKED','CONFIRMED') AND is_delete = 0 " +
|
||||
"AND appointment_start_time < #{endTime} AND appointment_end_time > #{startTime} FOR UPDATE")
|
||||
int countOverlappingActiveForUpdateExcludingOrderItem(@Param("artistId") Long artistId,
|
||||
@Param("orderItemId") Long orderItemId,
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM t_appointment_reservation WHERE artist_id = #{artistId} " +
|
||||
"AND status IN ('LOCKED','CONFIRMED') AND is_delete = 0 " +
|
||||
"AND appointment_start_time < #{endTime} AND appointment_end_time > #{startTime}")
|
||||
int countOverlappingActive(@Param("artistId") Long artistId,
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
@Update("UPDATE t_appointment_reservation SET status = #{status}, is_delete = 1, update_time = NOW() " +
|
||||
"WHERE order_id = #{orderId} AND is_delete = 0")
|
||||
int releaseByOrderId(@Param("orderId") Long orderId, @Param("status") String status);
|
||||
|
||||
@Update("UPDATE t_appointment_reservation SET status = #{status}, is_delete = 1, update_time = NOW() " +
|
||||
"WHERE order_item_id = #{orderItemId} AND is_delete = 0")
|
||||
int releaseByOrderItem(@Param("orderItemId") Long orderItemId, @Param("status") String status);
|
||||
|
||||
@Update("UPDATE t_appointment_reservation SET order_id = #{orderId}, shop_id = #{shopId}, " +
|
||||
"artist_id = #{artistId}, product_title = #{productTitle}, " +
|
||||
"appointment_start_time = #{startTime}, appointment_end_time = #{endTime}, " +
|
||||
"status = #{status}, is_delete = 0, update_time = NOW() " +
|
||||
"WHERE order_item_id = #{orderItemId} AND is_delete = 0")
|
||||
int updateActiveReservationForOrderItem(@Param("orderItemId") Long orderItemId,
|
||||
@Param("orderId") Long orderId,
|
||||
@Param("shopId") Long shopId,
|
||||
@Param("artistId") Long artistId,
|
||||
@Param("productTitle") String productTitle,
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime,
|
||||
@Param("status") String status);
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@Mapper
|
||||
public interface ArtistScheduleMapper extends BaseMapper<ArtistScheduleDO> {
|
||||
@Select("SELECT * FROM t_artist_schedule WHERE shop_id = #{shopId} AND artist_id = #{artistId} " +
|
||||
"AND work_date = #{workDate} AND start_time <= #{startTime} AND end_time >= #{endTime} " +
|
||||
"AND is_delete = 0 ORDER BY CASE WHEN status = 1 THEN 0 ELSE 1 END, start_time ASC LIMIT 1 FOR UPDATE")
|
||||
ArtistScheduleDO selectCoveringSchedule(@Param("shopId") Long shopId,
|
||||
@Param("artistId") Long artistId,
|
||||
@Param("workDate") LocalDate workDate,
|
||||
@Param("startTime") LocalTime startTime,
|
||||
@Param("endTime") LocalTime endTime);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.CampaignDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CampaignMapper extends BaseMapper<CampaignDO> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.InventoryItemDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InventoryItemMapper extends BaseMapper<InventoryItemDO> {
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.InventoryRecordDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InventoryRecordMapper extends BaseMapper<InventoryRecordDO> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.PaymentOrderDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface PaymentOrderMapper extends BaseMapper<PaymentOrderDO> {
|
||||
@Select("SELECT * FROM t_payment_order WHERE order_id = #{orderId} AND is_delete = 0 ORDER BY create_time DESC, id DESC LIMIT 1")
|
||||
PaymentOrderDO selectLatestByOrderId(@Param("orderId") Long orderId);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.RefundOrderDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RefundOrderMapper extends BaseMapper<RefundOrderDO> {
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.xiaowang.yuminailcore.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.yuminailcore.entity.UserGrowthRecordDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserGrowthRecordMapper extends BaseMapper<UserGrowthRecordDO> {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleApplyDTO;
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleAuditDTO;
|
||||
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
|
||||
public interface AfterSaleService {
|
||||
AfterSaleVO apply(Long userId, AfterSaleApplyDTO dto);
|
||||
|
||||
PageResultVO<AfterSaleVO> listMy(Long userId, Integer page, Integer size);
|
||||
|
||||
PageResultVO<AfterSaleVO> listAdmin(Long shopId, String status, Integer page, Integer size);
|
||||
|
||||
AfterSaleVO approve(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto);
|
||||
|
||||
AfterSaleVO reject(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto);
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public interface AppointmentCapacityService {
|
||||
void reserveOrThrow(Long orderId, Long orderItemId, Long shopId, Long artistId, String productTitle,
|
||||
LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
void releaseByOrder(Long orderId);
|
||||
|
||||
void moveReservationForArtistChange(Long orderId, Long orderItemId, Long shopId, Long fromArtistId,
|
||||
Long toArtistId, String productTitle,
|
||||
LocalDateTime startTime, LocalDateTime endTime);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.dto.ArtistScheduleDTO;
|
||||
import com.xiaowang.yuminailcore.vo.ArtistScheduleVO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public interface ArtistScheduleService {
|
||||
ArtistScheduleVO saveSchedule(ArtistScheduleDTO dto);
|
||||
|
||||
List<ArtistScheduleVO> listSchedules(Long shopId, Long artistId, LocalDate startDate, LocalDate endDate);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.dto.CampaignDTO;
|
||||
import com.xiaowang.yuminailcore.vo.CampaignVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
|
||||
public interface CampaignService {
|
||||
CampaignVO saveCampaign(CampaignDTO dto);
|
||||
|
||||
PageResultVO<CampaignVO> listCampaigns(Long shopId, Integer status, Integer page, Integer size);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.vo.GrowthSummaryVO;
|
||||
|
||||
public interface GrowthService {
|
||||
GrowthSummaryVO getSummary(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.dto.InventoryAdjustDTO;
|
||||
import com.xiaowang.yuminailcore.dto.InventoryItemDTO;
|
||||
import com.xiaowang.yuminailcore.vo.InventoryItemVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
|
||||
public interface InventoryService {
|
||||
InventoryItemVO saveItem(InventoryItemDTO dto);
|
||||
|
||||
InventoryItemVO adjustStock(Long operatorId, Long itemId, InventoryAdjustDTO dto);
|
||||
|
||||
PageResultVO<InventoryItemVO> listItems(Long shopId, Integer page, Integer size);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.vo.OperationsAnalyticsVO;
|
||||
|
||||
public interface OperationsAnalyticsService {
|
||||
OperationsAnalyticsVO getDashboardAnalytics(Long shopId, Long artistId);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||
import com.xiaowang.yuminailcore.vo.RefundOrderVO;
|
||||
|
||||
public interface PaymentService {
|
||||
PaymentOrderVO prepareOrderPayment(Long userId, Long orderId);
|
||||
|
||||
PaymentOrderVO manualConfirmOrderPaid(Long operatorId, Long orderId, String remark);
|
||||
|
||||
RefundOrderVO manualRefundOrder(Long operatorId, Long orderId, Long afterSaleId, String remark);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.xiaowang.yuminailcore.service;
|
||||
|
||||
import com.xiaowang.yuminailcore.vo.StoreWorkbenchVO;
|
||||
|
||||
public interface WorkbenchService {
|
||||
StoreWorkbenchVO getWorkbench(Long shopId, Long artistId);
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleApplyDTO;
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleAuditDTO;
|
||||
import com.xiaowang.yuminailcore.entity.AfterSaleDO;
|
||||
import com.xiaowang.yuminailcore.entity.AfterSaleLogDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.SystemMessageDO;
|
||||
import com.xiaowang.yuminailcore.mapper.AfterSaleLogMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.AfterSaleMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.SystemMessageMapper;
|
||||
import com.xiaowang.yuminailcore.service.AfterSaleService;
|
||||
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AfterSaleServiceImpl implements AfterSaleService {
|
||||
|
||||
private static final String STATUS_PENDING = "PENDING";
|
||||
private static final String STATUS_APPROVED = "APPROVED";
|
||||
private static final String STATUS_REJECTED = "REJECTED";
|
||||
|
||||
private final AfterSaleMapper afterSaleMapper;
|
||||
private final AfterSaleLogMapper afterSaleLogMapper;
|
||||
private final OrderMapper orderMapper;
|
||||
private final SystemMessageMapper systemMessageMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AfterSaleVO apply(Long userId, AfterSaleApplyDTO dto) {
|
||||
if (dto == null || dto.getOrderId() == null) {
|
||||
throw new RuntimeException("售后订单信息不完整");
|
||||
}
|
||||
OrderDO order = orderMapper.selectById(dto.getOrderId());
|
||||
if (order == null || Integer.valueOf(1).equals(order.getIsDelete())) {
|
||||
throw new RuntimeException("订单不存在");
|
||||
}
|
||||
if (!order.getUserId().equals(userId)) {
|
||||
throw new RuntimeException("无权申请该订单售后");
|
||||
}
|
||||
AfterSaleDO afterSale = new AfterSaleDO();
|
||||
afterSale.setAfterSaleNo("AS" + System.currentTimeMillis() + dto.getOrderId());
|
||||
afterSale.setOrderId(order.getId());
|
||||
afterSale.setOrderItemId(dto.getOrderItemId());
|
||||
afterSale.setUserId(userId);
|
||||
afterSale.setShopId(order.getShopId());
|
||||
afterSale.setType(dto.getType());
|
||||
afterSale.setReason(dto.getReason());
|
||||
afterSale.setRefundAmount(dto.getRefundAmount());
|
||||
afterSale.setStatus(STATUS_PENDING);
|
||||
afterSale.setIsDelete(0);
|
||||
afterSaleMapper.insert(afterSale);
|
||||
writeLog(afterSale.getId(), "CREATE", null, STATUS_PENDING, userId, "USER", dto.getReason());
|
||||
return toVO(afterSale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<AfterSaleVO> listMy(Long userId, Integer page, Integer size) {
|
||||
return pageByWrapper(new LambdaQueryWrapper<AfterSaleDO>()
|
||||
.eq(AfterSaleDO::getUserId, userId)
|
||||
.eq(AfterSaleDO::getIsDelete, 0)
|
||||
.orderByDesc(AfterSaleDO::getCreateTime), page, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<AfterSaleVO> listAdmin(Long shopId, String status, Integer page, Integer size) {
|
||||
LambdaQueryWrapper<AfterSaleDO> wrapper = new LambdaQueryWrapper<AfterSaleDO>()
|
||||
.eq(AfterSaleDO::getIsDelete, 0)
|
||||
.orderByDesc(AfterSaleDO::getCreateTime);
|
||||
if (shopId != null) {
|
||||
wrapper.eq(AfterSaleDO::getShopId, shopId);
|
||||
}
|
||||
if (status != null && !status.isBlank()) {
|
||||
wrapper.eq(AfterSaleDO::getStatus, status);
|
||||
}
|
||||
return pageByWrapper(wrapper, page, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AfterSaleVO approve(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto) {
|
||||
return audit(operatorId, afterSaleId, dto, STATUS_APPROVED, "APPROVE");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AfterSaleVO reject(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto) {
|
||||
return audit(operatorId, afterSaleId, dto, STATUS_REJECTED, "REJECT");
|
||||
}
|
||||
|
||||
private AfterSaleVO audit(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto, String targetStatus, String action) {
|
||||
AfterSaleDO afterSale = afterSaleMapper.selectById(afterSaleId);
|
||||
if (afterSale == null || Integer.valueOf(1).equals(afterSale.getIsDelete())) {
|
||||
throw new RuntimeException("售后单不存在");
|
||||
}
|
||||
if (!STATUS_PENDING.equals(afterSale.getStatus())) {
|
||||
throw new RuntimeException("售后单已处理");
|
||||
}
|
||||
String fromStatus = afterSale.getStatus();
|
||||
afterSale.setStatus(targetStatus);
|
||||
afterSale.setAuditUserId(operatorId);
|
||||
afterSale.setAuditReason(dto == null ? null : dto.getAuditReason());
|
||||
afterSale.setAuditTime(LocalDateTime.now());
|
||||
afterSaleMapper.updateById(afterSale);
|
||||
writeLog(afterSale.getId(), action, fromStatus, targetStatus, operatorId, "ADMIN", afterSale.getAuditReason());
|
||||
notifyCustomer(afterSale, targetStatus);
|
||||
return toVO(afterSale);
|
||||
}
|
||||
|
||||
private void writeLog(Long afterSaleId, String action, String fromStatus, String toStatus,
|
||||
Long operatorId, String operatorType, String remark) {
|
||||
AfterSaleLogDO log = new AfterSaleLogDO();
|
||||
log.setAfterSaleId(afterSaleId);
|
||||
log.setAction(action);
|
||||
log.setFromStatus(fromStatus);
|
||||
log.setToStatus(toStatus);
|
||||
log.setOperatorId(operatorId);
|
||||
log.setOperatorType(operatorType);
|
||||
log.setRemark(remark);
|
||||
afterSaleLogMapper.insert(log);
|
||||
}
|
||||
|
||||
private void notifyCustomer(AfterSaleDO afterSale, String status) {
|
||||
SystemMessageDO message = new SystemMessageDO();
|
||||
message.setTitle("售后处理进度更新");
|
||||
message.setContent("您的售后申请已更新为:" + status);
|
||||
message.setTargetType("SELECTED_USERS");
|
||||
message.setTargetIds(String.valueOf(afterSale.getUserId()));
|
||||
message.setBusinessType("AFTER_SALE_" + status);
|
||||
message.setBusinessId(afterSale.getId());
|
||||
message.setActionPath("/after-sales?afterSaleId=" + afterSale.getId());
|
||||
message.setPopupEnabled(1);
|
||||
message.setStatus(1);
|
||||
message.setPublishTime(LocalDateTime.now());
|
||||
message.setIsDelete(0);
|
||||
systemMessageMapper.insert(message);
|
||||
}
|
||||
|
||||
private PageResultVO<AfterSaleVO> pageByWrapper(LambdaQueryWrapper<AfterSaleDO> wrapper, Integer page, Integer size) {
|
||||
int current = page == null || page < 1 ? 1 : page;
|
||||
int pageSize = size == null || size < 1 ? 10 : size;
|
||||
Page<AfterSaleDO> result = afterSaleMapper.selectPage(new Page<>(current, pageSize), wrapper);
|
||||
PageResultVO<AfterSaleVO> vo = new PageResultVO<>();
|
||||
List<AfterSaleVO> list = result.getRecords().stream().map(this::toVO).toList();
|
||||
vo.setList(list);
|
||||
vo.setTotal(result.getTotal());
|
||||
vo.setPage(current);
|
||||
vo.setSize(pageSize);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private AfterSaleVO toVO(AfterSaleDO afterSale) {
|
||||
AfterSaleVO vo = new AfterSaleVO();
|
||||
BeanUtils.copyProperties(afterSale, vo);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.entity.AppointmentReservationDO;
|
||||
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.yuminailcore.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.yuminailcore.service.AppointmentCapacityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AppointmentCapacityServiceImpl implements AppointmentCapacityService {
|
||||
|
||||
private static final int MIN_CAPACITY = 1;
|
||||
private static final String STATUS_CONFIRMED = "CONFIRMED";
|
||||
private static final String STATUS_RELEASED = "RELEASED";
|
||||
private static final String UNAVAILABLE_MESSAGE = "涓嶅彲棰勭害";
|
||||
private static final String FULL_MESSAGE = "褰撳墠缇庣敳甯堣鏃堕棿娈靛凡绾︽弧锛岃閲嶆柊閫夋嫨棰勭害鏃堕棿";
|
||||
|
||||
private final AppointmentReservationMapper reservationMapper;
|
||||
private final ArtistScheduleMapper scheduleMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void reserveOrThrow(Long orderId, Long orderItemId, Long shopId, Long artistId, String productTitle,
|
||||
LocalDateTime startTime, LocalDateTime endTime) {
|
||||
if (orderId == null || orderItemId == null || shopId == null || artistId == null || startTime == null || endTime == null) {
|
||||
return;
|
||||
}
|
||||
assertCapacityAvailable(shopId, artistId, null, startTime, endTime);
|
||||
AppointmentReservationDO reservation = new AppointmentReservationDO();
|
||||
reservation.setOrderId(orderId);
|
||||
reservation.setOrderItemId(orderItemId);
|
||||
reservation.setShopId(shopId);
|
||||
reservation.setArtistId(artistId);
|
||||
reservation.setProductTitle(productTitle);
|
||||
reservation.setAppointmentStartTime(startTime);
|
||||
reservation.setAppointmentEndTime(endTime);
|
||||
reservation.setStatus(STATUS_CONFIRMED);
|
||||
reservation.setIsDelete(0);
|
||||
reservationMapper.insert(reservation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void releaseByOrder(Long orderId) {
|
||||
if (orderId != null) {
|
||||
reservationMapper.releaseByOrderId(orderId, STATUS_RELEASED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void moveReservationForArtistChange(Long orderId, Long orderItemId, Long shopId, Long fromArtistId,
|
||||
Long toArtistId, String productTitle,
|
||||
LocalDateTime startTime, LocalDateTime endTime) {
|
||||
if (orderItemId == null || orderId == null || shopId == null || toArtistId == null || startTime == null || endTime == null) {
|
||||
return;
|
||||
}
|
||||
assertCapacityAvailable(shopId, toArtistId, orderItemId, startTime, endTime);
|
||||
int updated = reservationMapper.updateActiveReservationForOrderItem(
|
||||
orderItemId,
|
||||
orderId,
|
||||
shopId,
|
||||
toArtistId,
|
||||
productTitle,
|
||||
startTime,
|
||||
endTime,
|
||||
STATUS_CONFIRMED
|
||||
);
|
||||
if (updated == 0) {
|
||||
reserveOrThrow(orderId, orderItemId, shopId, toArtistId, productTitle, startTime, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertCapacityAvailable(Long shopId, Long artistId, Long excludedOrderItemId,
|
||||
LocalDateTime startTime, LocalDateTime endTime) {
|
||||
int capacity = resolveCapacity(shopId, artistId, startTime, endTime);
|
||||
int used = excludedOrderItemId == null
|
||||
? reservationMapper.countOverlappingActiveForUpdate(artistId, startTime, endTime)
|
||||
: reservationMapper.countOverlappingActiveForUpdateExcludingOrderItem(artistId, excludedOrderItemId, startTime, endTime);
|
||||
if (used >= capacity) {
|
||||
throw new RuntimeException(FULL_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
private int resolveCapacity(Long shopId, Long artistId, LocalDateTime startTime, LocalDateTime endTime) {
|
||||
ArtistScheduleDO schedule = scheduleMapper.selectCoveringSchedule(
|
||||
shopId,
|
||||
artistId,
|
||||
startTime.toLocalDate(),
|
||||
startTime.toLocalTime(),
|
||||
endTime.toLocalTime()
|
||||
);
|
||||
if (schedule == null || Integer.valueOf(1).equals(schedule.getIsDelete())
|
||||
|| !Integer.valueOf(1).equals(schedule.getStatus())
|
||||
|| schedule.getCapacity() == null || schedule.getCapacity() < MIN_CAPACITY) {
|
||||
throw new RuntimeException(UNAVAILABLE_MESSAGE);
|
||||
}
|
||||
return schedule.getCapacity();
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.xiaowang.yuminailcore.dto.ArtistScheduleDTO;
|
||||
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.yuminailcore.service.ArtistScheduleService;
|
||||
import com.xiaowang.yuminailcore.vo.ArtistScheduleVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ArtistScheduleServiceImpl implements ArtistScheduleService {
|
||||
|
||||
private final ArtistScheduleMapper artistScheduleMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ArtistScheduleVO saveSchedule(ArtistScheduleDTO dto) {
|
||||
if (dto == null || dto.getShopId() == null || dto.getArtistId() == null || dto.getWorkDate() == null
|
||||
|| dto.getStartTime() == null || dto.getEndTime() == null) {
|
||||
throw new RuntimeException("排班信息不完整");
|
||||
}
|
||||
ArtistScheduleDO schedule = new ArtistScheduleDO();
|
||||
BeanUtils.copyProperties(dto, schedule);
|
||||
schedule.setSlotMinutes(dto.getSlotMinutes() == null ? 60 : dto.getSlotMinutes());
|
||||
schedule.setCapacity(dto.getCapacity() == null || dto.getCapacity() < 1 ? 1 : dto.getCapacity());
|
||||
schedule.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
||||
schedule.setIsDelete(0);
|
||||
artistScheduleMapper.insert(schedule);
|
||||
return toVO(schedule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtistScheduleVO> listSchedules(Long shopId, Long artistId, LocalDate startDate, LocalDate endDate) {
|
||||
LambdaQueryWrapper<ArtistScheduleDO> wrapper = new LambdaQueryWrapper<ArtistScheduleDO>()
|
||||
.eq(ArtistScheduleDO::getIsDelete, 0)
|
||||
.orderByAsc(ArtistScheduleDO::getWorkDate)
|
||||
.orderByAsc(ArtistScheduleDO::getStartTime);
|
||||
if (shopId != null) {
|
||||
wrapper.eq(ArtistScheduleDO::getShopId, shopId);
|
||||
}
|
||||
if (artistId != null) {
|
||||
wrapper.eq(ArtistScheduleDO::getArtistId, artistId);
|
||||
}
|
||||
if (startDate != null) {
|
||||
wrapper.ge(ArtistScheduleDO::getWorkDate, startDate);
|
||||
}
|
||||
if (endDate != null) {
|
||||
wrapper.le(ArtistScheduleDO::getWorkDate, endDate);
|
||||
}
|
||||
return artistScheduleMapper.selectList(wrapper).stream().map(this::toVO).toList();
|
||||
}
|
||||
|
||||
private ArtistScheduleVO toVO(ArtistScheduleDO schedule) {
|
||||
ArtistScheduleVO vo = new ArtistScheduleVO();
|
||||
BeanUtils.copyProperties(schedule, vo);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class BusinessEventOutboxProcessor {
|
||||
*/
|
||||
private final OrderServiceImpl orderService;
|
||||
|
||||
@Scheduled(fixedDelay = 10000L)
|
||||
@Scheduled(fixedDelay = 2000L)
|
||||
@Transactional
|
||||
/**
|
||||
* Purpose: processDueEvents supports BusinessEventOutboxProcessor.java by holding or executing the process due events business role.
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xiaowang.yuminailcore.dto.CampaignDTO;
|
||||
import com.xiaowang.yuminailcore.entity.CampaignDO;
|
||||
import com.xiaowang.yuminailcore.mapper.CampaignMapper;
|
||||
import com.xiaowang.yuminailcore.service.CampaignService;
|
||||
import com.xiaowang.yuminailcore.vo.CampaignVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CampaignServiceImpl implements CampaignService {
|
||||
|
||||
private final CampaignMapper campaignMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CampaignVO saveCampaign(CampaignDTO dto) {
|
||||
if (dto == null || dto.getTitle() == null || dto.getTitle().isBlank()) {
|
||||
throw new RuntimeException("活动标题不能为空");
|
||||
}
|
||||
CampaignDO campaign = new CampaignDO();
|
||||
BeanUtils.copyProperties(dto, campaign);
|
||||
campaign.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
||||
campaign.setSortOrder(dto.getSortOrder() == null ? 0 : dto.getSortOrder());
|
||||
campaign.setIsDelete(0);
|
||||
campaignMapper.insert(campaign);
|
||||
return toVO(campaign);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<CampaignVO> listCampaigns(Long shopId, Integer status, Integer page, Integer size) {
|
||||
int current = page == null || page < 1 ? 1 : page;
|
||||
int pageSize = size == null || size < 1 ? 10 : size;
|
||||
LambdaQueryWrapper<CampaignDO> wrapper = new LambdaQueryWrapper<CampaignDO>()
|
||||
.eq(CampaignDO::getIsDelete, 0)
|
||||
.orderByAsc(CampaignDO::getSortOrder)
|
||||
.orderByDesc(CampaignDO::getCreateTime);
|
||||
if (shopId != null) {
|
||||
wrapper.eq(CampaignDO::getShopId, shopId);
|
||||
}
|
||||
if (status != null) {
|
||||
wrapper.eq(CampaignDO::getStatus, status);
|
||||
}
|
||||
Page<CampaignDO> result = campaignMapper.selectPage(new Page<>(current, pageSize), wrapper);
|
||||
PageResultVO<CampaignVO> vo = new PageResultVO<>();
|
||||
vo.setList(result.getRecords().stream().map(this::toVO).toList());
|
||||
vo.setTotal(result.getTotal());
|
||||
vo.setPage(current);
|
||||
vo.setSize(pageSize);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private CampaignVO toVO(CampaignDO campaign) {
|
||||
CampaignVO vo = new CampaignVO();
|
||||
BeanUtils.copyProperties(campaign, vo);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.xiaowang.yuminailcore.entity.UserGrowthRecordDO;
|
||||
import com.xiaowang.yuminailcore.mapper.UserGrowthRecordMapper;
|
||||
import com.xiaowang.yuminailcore.service.GrowthService;
|
||||
import com.xiaowang.yuminailcore.vo.GrowthSummaryVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GrowthServiceImpl implements GrowthService {
|
||||
|
||||
private final UserGrowthRecordMapper userGrowthRecordMapper;
|
||||
|
||||
@Override
|
||||
public GrowthSummaryVO getSummary(Long userId) {
|
||||
Integer growthValue = userGrowthRecordMapper.selectList(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
||||
.eq(UserGrowthRecordDO::getUserId, userId))
|
||||
.stream()
|
||||
.map(UserGrowthRecordDO::getGrowthValue)
|
||||
.filter(value -> value != null)
|
||||
.reduce(0, Integer::sum);
|
||||
GrowthSummaryVO vo = new GrowthSummaryVO();
|
||||
vo.setUserId(userId);
|
||||
vo.setGrowthValue(growthValue);
|
||||
vo.setLevelName(growthValue >= 1000 ? "黄金会员" : growthValue >= 300 ? "白银会员" : "成长新客");
|
||||
vo.setAppointmentCount(0);
|
||||
vo.setReviewCount(0);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xiaowang.yuminailcore.dto.InventoryAdjustDTO;
|
||||
import com.xiaowang.yuminailcore.dto.InventoryItemDTO;
|
||||
import com.xiaowang.yuminailcore.entity.InventoryItemDO;
|
||||
import com.xiaowang.yuminailcore.entity.InventoryRecordDO;
|
||||
import com.xiaowang.yuminailcore.mapper.InventoryItemMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.InventoryRecordMapper;
|
||||
import com.xiaowang.yuminailcore.service.InventoryService;
|
||||
import com.xiaowang.yuminailcore.vo.InventoryItemVO;
|
||||
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class InventoryServiceImpl implements InventoryService {
|
||||
|
||||
private final InventoryItemMapper inventoryItemMapper;
|
||||
private final InventoryRecordMapper inventoryRecordMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public InventoryItemVO saveItem(InventoryItemDTO dto) {
|
||||
if (dto == null || dto.getShopId() == null || dto.getItemName() == null || dto.getItemName().isBlank()) {
|
||||
throw new RuntimeException("库存物料信息不完整");
|
||||
}
|
||||
InventoryItemDO item = new InventoryItemDO();
|
||||
BeanUtils.copyProperties(dto, item);
|
||||
item.setStockQuantity(dto.getStockQuantity() == null ? BigDecimal.ZERO : dto.getStockQuantity());
|
||||
item.setWarningThreshold(dto.getWarningThreshold() == null ? BigDecimal.ZERO : dto.getWarningThreshold());
|
||||
item.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
||||
item.setIsDelete(0);
|
||||
inventoryItemMapper.insert(item);
|
||||
return toVO(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public InventoryItemVO adjustStock(Long operatorId, Long itemId, InventoryAdjustDTO dto) {
|
||||
InventoryItemDO item = inventoryItemMapper.selectById(itemId);
|
||||
if (item == null || Integer.valueOf(1).equals(item.getIsDelete())) {
|
||||
throw new RuntimeException("库存物料不存在");
|
||||
}
|
||||
BigDecimal before = item.getStockQuantity() == null ? BigDecimal.ZERO : item.getStockQuantity();
|
||||
BigDecimal delta = dto == null || dto.getChangeQuantity() == null ? BigDecimal.ZERO : dto.getChangeQuantity();
|
||||
BigDecimal after = before.add(delta);
|
||||
if (after.compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new RuntimeException("库存不能小于 0");
|
||||
}
|
||||
item.setStockQuantity(after);
|
||||
inventoryItemMapper.updateById(item);
|
||||
InventoryRecordDO record = new InventoryRecordDO();
|
||||
record.setInventoryItemId(item.getId());
|
||||
record.setShopId(item.getShopId());
|
||||
record.setChangeType(dto == null ? null : dto.getChangeType());
|
||||
record.setChangeQuantity(delta);
|
||||
record.setBeforeQuantity(before);
|
||||
record.setAfterQuantity(after);
|
||||
record.setOperatorId(operatorId);
|
||||
record.setRemark(dto == null ? null : dto.getRemark());
|
||||
inventoryRecordMapper.insert(record);
|
||||
return toVO(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<InventoryItemVO> listItems(Long shopId, Integer page, Integer size) {
|
||||
int current = page == null || page < 1 ? 1 : page;
|
||||
int pageSize = size == null || size < 1 ? 10 : size;
|
||||
LambdaQueryWrapper<InventoryItemDO> wrapper = new LambdaQueryWrapper<InventoryItemDO>()
|
||||
.eq(InventoryItemDO::getIsDelete, 0)
|
||||
.orderByDesc(InventoryItemDO::getCreateTime);
|
||||
if (shopId != null) {
|
||||
wrapper.eq(InventoryItemDO::getShopId, shopId);
|
||||
}
|
||||
Page<InventoryItemDO> result = inventoryItemMapper.selectPage(new Page<>(current, pageSize), wrapper);
|
||||
PageResultVO<InventoryItemVO> vo = new PageResultVO<>();
|
||||
vo.setList(result.getRecords().stream().map(this::toVO).toList());
|
||||
vo.setTotal(result.getTotal());
|
||||
vo.setPage(current);
|
||||
vo.setSize(pageSize);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private InventoryItemVO toVO(InventoryItemDO item) {
|
||||
InventoryItemVO vo = new InventoryItemVO();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
BigDecimal stock = item.getStockQuantity() == null ? BigDecimal.ZERO : item.getStockQuantity();
|
||||
BigDecimal warning = item.getWarningThreshold() == null ? BigDecimal.ZERO : item.getWarningThreshold();
|
||||
vo.setWarning(stock.compareTo(warning) <= 0);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+56
@@ -3,6 +3,7 @@ package com.xiaowang.yuminailcore.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiaowang.yuminailcore.dto.NailArtistInfoDTO;
|
||||
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.yuminailcore.entity.NailArtistInfoDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderArtistReviewDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
@@ -11,6 +12,8 @@ import com.xiaowang.yuminailcore.entity.ProductDO;
|
||||
import com.xiaowang.yuminailcore.entity.ShopDO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderArtistReviewMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderItemMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
@@ -98,6 +101,12 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
@Autowired
|
||||
private ObjectStorageFileService objectStorageFileService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ArtistScheduleMapper artistScheduleMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AppointmentReservationMapper appointmentReservationMapper;
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Load data by the supplied parameter.
|
||||
@@ -262,6 +271,11 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<NailArtistAvailabilityVO> scheduleSlots = buildScheduleAvailabilitySlots(artistId, artistInfo);
|
||||
if (!scheduleSlots.isEmpty()) {
|
||||
return scheduleSlots;
|
||||
}
|
||||
|
||||
LocalTime workStart = artistInfo.getWorkStartTime() == null ? LocalTime.of(10, 0) : artistInfo.getWorkStartTime();
|
||||
LocalTime workEnd = artistInfo.getWorkEndTime() == null ? LocalTime.of(20, 0) : artistInfo.getWorkEndTime();
|
||||
if (!workEnd.isAfter(workStart)) {
|
||||
@@ -291,6 +305,48 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return slots;
|
||||
}
|
||||
|
||||
private List<NailArtistAvailabilityVO> buildScheduleAvailabilitySlots(Long artistId, NailArtistInfoDTO artistInfo) {
|
||||
if (artistScheduleMapper == null || artistInfo.getShopId() == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
LocalDate today = LocalDate.now();
|
||||
List<ArtistScheduleDO> schedules = artistScheduleMapper.selectList(new LambdaQueryWrapper<ArtistScheduleDO>()
|
||||
.eq(ArtistScheduleDO::getShopId, artistInfo.getShopId())
|
||||
.eq(ArtistScheduleDO::getArtistId, artistId)
|
||||
.eq(ArtistScheduleDO::getStatus, 1)
|
||||
.eq(ArtistScheduleDO::getIsDelete, 0)
|
||||
.ge(ArtistScheduleDO::getWorkDate, today)
|
||||
.lt(ArtistScheduleDO::getWorkDate, today.plusDays(AVAILABILITY_DAYS))
|
||||
.orderByAsc(ArtistScheduleDO::getWorkDate)
|
||||
.orderByAsc(ArtistScheduleDO::getStartTime));
|
||||
if (schedules == null || schedules.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
LocalDateTime minStart = LocalDateTime.now().plusMinutes(30);
|
||||
List<NailArtistAvailabilityVO> slots = new ArrayList<>();
|
||||
for (ArtistScheduleDO schedule : schedules) {
|
||||
int slotMinutes = schedule.getSlotMinutes() == null || schedule.getSlotMinutes() < 15 ? SLOT_MINUTES : schedule.getSlotMinutes();
|
||||
int capacity = schedule.getCapacity() == null || schedule.getCapacity() < 1 ? 1 : schedule.getCapacity();
|
||||
LocalTime cursor = schedule.getStartTime();
|
||||
while (cursor != null && schedule.getEndTime() != null
|
||||
&& !cursor.plusMinutes(slotMinutes).isAfter(schedule.getEndTime())
|
||||
&& slots.size() < MAX_AVAILABILITY_SLOTS) {
|
||||
LocalDateTime slotStart = schedule.getWorkDate().atTime(cursor);
|
||||
LocalDateTime slotEnd = slotStart.plusMinutes(slotMinutes);
|
||||
int used = appointmentReservationMapper == null ? 0
|
||||
: appointmentReservationMapper.countOverlappingActive(artistId, slotStart, slotEnd);
|
||||
if (slotStart.isAfter(minStart) && used < capacity) {
|
||||
slots.add(buildAvailabilitySlot(slotStart, slotEnd));
|
||||
}
|
||||
cursor = cursor.plusMinutes(slotMinutes);
|
||||
}
|
||||
if (slots.size() >= MAX_AVAILABILITY_SLOTS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NailArtistReviewVO> listPublicReviews(Long artistId) {
|
||||
if (artistId == null) {
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderItemDO;
|
||||
import com.xiaowang.yuminailcore.entity.ProductDO;
|
||||
import com.xiaowang.yuminailcore.entity.UserGrowthRecordDO;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderItemMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserGrowthRecordMapper;
|
||||
import com.xiaowang.yuminailcore.service.OperationsAnalyticsService;
|
||||
import com.xiaowang.yuminailcore.vo.OperationsAnalyticsVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OperationsAnalyticsServiceImpl implements OperationsAnalyticsService {
|
||||
|
||||
private final OrderMapper orderMapper;
|
||||
private final OrderItemMapper orderItemMapper;
|
||||
private final ProductMapper productMapper;
|
||||
private final UserGrowthRecordMapper userGrowthRecordMapper;
|
||||
|
||||
@Override
|
||||
public OperationsAnalyticsVO getDashboardAnalytics(Long shopId, Long artistId) {
|
||||
List<OrderDO> orders = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(shopId != null, OrderDO::getShopId, shopId)
|
||||
.eq(OrderDO::getIsDelete, 0));
|
||||
if (artistId != null) {
|
||||
Set<Long> orderIds = new HashSet<>();
|
||||
orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getArtistId, artistId)
|
||||
.eq(OrderItemDO::getIsDelete, 0))
|
||||
.forEach(item -> orderIds.add(item.getOrderId()));
|
||||
orders = orders.stream().filter(order -> orderIds.contains(order.getId())).toList();
|
||||
}
|
||||
OperationsAnalyticsVO vo = new OperationsAnalyticsVO();
|
||||
vo.setViewCount(productMapper.selectList(new LambdaQueryWrapper<ProductDO>()
|
||||
.eq(shopId != null, ProductDO::getShopId, shopId)
|
||||
.eq(ProductDO::getIsDelete, 0))
|
||||
.stream().map(ProductDO::getLikeCount).filter(v -> v != null).mapToLong(Integer::longValue).sum());
|
||||
vo.setFavoriteCount(productMapper.selectList(new LambdaQueryWrapper<ProductDO>()
|
||||
.eq(shopId != null, ProductDO::getShopId, shopId)
|
||||
.eq(ProductDO::getIsDelete, 0))
|
||||
.stream().map(ProductDO::getCollectCount).filter(v -> v != null).mapToLong(Integer::longValue).sum());
|
||||
vo.setCartCount(0L);
|
||||
vo.setOrderCount((long) orders.size());
|
||||
vo.setPaidOrderCount(orders.stream().filter(order -> "PAID".equals(order.getPaymentStatus())).count());
|
||||
vo.setCompletedOrderCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
|
||||
vo.setReviewCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
||||
.eq(UserGrowthRecordDO::getSourceType, "REVIEW")));
|
||||
vo.setRebookCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
||||
.eq(UserGrowthRecordDO::getSourceType, "REBOOK")));
|
||||
vo.setTotalAmount(orders.stream()
|
||||
.map(order -> order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount())
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+38
@@ -32,6 +32,7 @@ import com.xiaowang.yuminailcore.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.SystemMessageMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserCouponMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||
import com.xiaowang.yuminailcore.service.AppointmentCapacityService;
|
||||
import com.xiaowang.yuminailcore.service.BusinessEventOutboxService;
|
||||
import com.xiaowang.yuminailcore.service.CouponService;
|
||||
import com.xiaowang.yuminailcore.service.OrderService;
|
||||
@@ -372,6 +373,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
*/
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Resource
|
||||
private AppointmentCapacityService appointmentCapacityService;
|
||||
|
||||
@PreDestroy
|
||||
/**
|
||||
* Run business method `shutdownOrderLockRenewExecutor`.
|
||||
@@ -726,6 +730,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
order.setCouponId(couponId);
|
||||
order.setUserCouponId(userCouponId);
|
||||
order.setCouponSourceType(couponSourceType);
|
||||
order.setPaymentStatus(actualAmount.compareTo(BigDecimal.ZERO) <= 0 ? "PAID" : "UNPAID");
|
||||
order.setPayAmount(actualAmount);
|
||||
order.setPaidAmount(actualAmount.compareTo(BigDecimal.ZERO) <= 0 ? actualAmount : BigDecimal.ZERO);
|
||||
order.setStatus(1);
|
||||
order.setIsDelete(0);
|
||||
orderMapper.insert(order);
|
||||
@@ -734,6 +741,17 @@ public class OrderServiceImpl implements OrderService {
|
||||
item.setOrderId(order.getId());
|
||||
item.setIsDelete(0);
|
||||
orderItemMapper.insert(item);
|
||||
ProductDO product = productCache.get(item.getProductId());
|
||||
long durationMinutes = resolveServiceDurationMinutes(product) * Math.max(1, item.getQuantity() == null ? 1 : item.getQuantity());
|
||||
appointmentCapacityService.reserveOrThrow(
|
||||
order.getId(),
|
||||
item.getId(),
|
||||
shopId,
|
||||
item.getArtistId(),
|
||||
product == null ? null : product.getTitle(),
|
||||
item.getAppointmentTime(),
|
||||
item.getAppointmentTime() == null ? null : item.getAppointmentTime().plusMinutes(durationMinutes)
|
||||
);
|
||||
}
|
||||
|
||||
QueryWrapper<CartDO> cartWrapper = new QueryWrapper<>();
|
||||
@@ -1147,6 +1165,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
order.setStatus(3);
|
||||
orderMapper.updateById(order);
|
||||
appointmentCapacityService.releaseByOrder(orderId);
|
||||
/**
|
||||
* Run business method `restoreUserCoupon`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
@@ -1202,6 +1221,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
businessEventOutboxService.enqueueOrderCompleted(order.getId());
|
||||
}
|
||||
if (targetStatus == OrderStatus.CANCELLED) {
|
||||
appointmentCapacityService.releaseByOrder(order.getId());
|
||||
restoreUserCoupon(order, order.getUserId());
|
||||
}
|
||||
}
|
||||
@@ -1590,6 +1610,17 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
ProductDO product = requireActiveProduct(item.getProductId());
|
||||
validateRequestedArtistForItem(order.getShopId(), request.getToArtistId(), item, product);
|
||||
long durationMinutes = resolveServiceDurationMinutes(product) * Math.max(1, item.getQuantity() == null ? 1 : item.getQuantity());
|
||||
appointmentCapacityService.moveReservationForArtistChange(
|
||||
order.getId(),
|
||||
item.getId(),
|
||||
order.getShopId(),
|
||||
request.getFromArtistId(),
|
||||
request.getToArtistId(),
|
||||
product.getTitle(),
|
||||
item.getAppointmentTime(),
|
||||
item.getAppointmentTime() == null ? null : item.getAppointmentTime().plusMinutes(durationMinutes)
|
||||
);
|
||||
|
||||
LocalDateTime approvedTime = LocalDateTime.now();
|
||||
if (orderArtistChangeRequestMapper.approvePending(request.getId(), approvedTime) == 0) {
|
||||
@@ -2428,6 +2459,13 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderVO.setCouponId(order.getCouponId());
|
||||
orderVO.setUserCouponId(order.getUserCouponId());
|
||||
orderVO.setCouponSourceType(order.getCouponSourceType());
|
||||
orderVO.setPaymentStatus(order.getPaymentStatus());
|
||||
orderVO.setPayAmount(order.getPayAmount());
|
||||
orderVO.setPaidAmount(order.getPaidAmount());
|
||||
orderVO.setPayTime(order.getPayTime());
|
||||
orderVO.setPaymentMethod(order.getPaymentMethod());
|
||||
orderVO.setPaymentOrderNo(order.getPaymentOrderNo());
|
||||
orderVO.setRefundStatus(order.getRefundStatus());
|
||||
UserDO customer = getUserFromCache(order.getUserId(), userCache);
|
||||
orderVO.setCustomerNickname(resolveCustomerNickname(customer));
|
||||
orderVO.setCustomerPhoneMasked(maskPhone(customer == null ? null : customer.getPhone()));
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.PaymentOrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.RefundOrderDO;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.PaymentOrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.RefundOrderMapper;
|
||||
import com.xiaowang.yuminailcore.service.PaymentService;
|
||||
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||
import com.xiaowang.yuminailcore.vo.RefundOrderVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
private static final String CHANNEL_MANUAL = "MANUAL";
|
||||
private static final String STATUS_UNPAID = "UNPAID";
|
||||
private static final String STATUS_PAYING = "PAYING";
|
||||
private static final String STATUS_PAID = "PAID";
|
||||
private static final String STATUS_REFUNDED = "REFUNDED";
|
||||
|
||||
private final OrderMapper orderMapper;
|
||||
private final PaymentOrderMapper paymentOrderMapper;
|
||||
private final RefundOrderMapper refundOrderMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public PaymentOrderVO prepareOrderPayment(Long userId, Long orderId) {
|
||||
OrderDO order = requirePayableOrder(userId, orderId);
|
||||
PaymentOrderDO latest = paymentOrderMapper.selectLatestByOrderId(orderId);
|
||||
if (latest != null && (STATUS_PAYING.equals(latest.getStatus()) || STATUS_PAID.equals(latest.getStatus()))) {
|
||||
return toVO(latest);
|
||||
}
|
||||
PaymentOrderDO payment = new PaymentOrderDO();
|
||||
payment.setPayNo("PAY" + System.currentTimeMillis() + orderId);
|
||||
payment.setOrderId(order.getId());
|
||||
payment.setOrderNo(order.getOrderNo());
|
||||
payment.setUserId(order.getUserId());
|
||||
payment.setShopId(order.getShopId());
|
||||
payment.setChannel(CHANNEL_MANUAL);
|
||||
payment.setStatus(STATUS_PAYING);
|
||||
payment.setPayAmount(order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount());
|
||||
payment.setPaidAmount(BigDecimal.ZERO);
|
||||
payment.setExpireTime(LocalDateTime.now().plusMinutes(30));
|
||||
payment.setIdempotencyKey("PAY:" + order.getId());
|
||||
payment.setIsDelete(0);
|
||||
paymentOrderMapper.insert(payment);
|
||||
order.setPaymentStatus(STATUS_PAYING);
|
||||
order.setPaymentOrderNo(payment.getPayNo());
|
||||
order.setPayAmount(payment.getPayAmount());
|
||||
orderMapper.updateById(order);
|
||||
return toVO(payment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public PaymentOrderVO manualConfirmOrderPaid(Long operatorId, Long orderId, String remark) {
|
||||
OrderDO order = requirePayableOrder(null, orderId);
|
||||
PaymentOrderDO payment = paymentOrderMapper.selectLatestByOrderId(orderId);
|
||||
if (payment == null) {
|
||||
prepareOrderPayment(order.getUserId(), orderId);
|
||||
payment = paymentOrderMapper.selectLatestByOrderId(orderId);
|
||||
}
|
||||
if (payment == null) {
|
||||
throw new RuntimeException("支付单创建失败");
|
||||
}
|
||||
payment.setStatus(STATUS_PAID);
|
||||
payment.setPaidAmount(payment.getPayAmount());
|
||||
payment.setPayTime(LocalDateTime.now());
|
||||
payment.setOperatorId(operatorId);
|
||||
payment.setRemark(remark);
|
||||
paymentOrderMapper.updateById(payment);
|
||||
|
||||
order.setPaymentStatus(STATUS_PAID);
|
||||
order.setPaidAmount(payment.getPayAmount());
|
||||
order.setPayTime(payment.getPayTime());
|
||||
order.setPaymentMethod(payment.getChannel());
|
||||
order.setPaymentOrderNo(payment.getPayNo());
|
||||
orderMapper.updateById(order);
|
||||
return toVO(payment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public RefundOrderVO manualRefundOrder(Long operatorId, Long orderId, Long afterSaleId, String remark) {
|
||||
OrderDO order = orderMapper.selectById(orderId);
|
||||
if (order == null || Integer.valueOf(1).equals(order.getIsDelete())) {
|
||||
throw new RuntimeException("璁㈠崟涓嶅瓨鍦?");
|
||||
}
|
||||
if (!STATUS_PAID.equals(order.getPaymentStatus())) {
|
||||
throw new RuntimeException("鏈敮浠樿鍗曚笉鍏佽閫€娆?");
|
||||
}
|
||||
PaymentOrderDO payment = paymentOrderMapper.selectLatestByOrderId(orderId);
|
||||
if (payment == null || !STATUS_PAID.equals(payment.getStatus())) {
|
||||
throw new RuntimeException("鏈壘鍒板凡鏀粯鏀粯鍗?");
|
||||
}
|
||||
RefundOrderDO refund = new RefundOrderDO();
|
||||
refund.setRefundNo("RF" + System.currentTimeMillis() + orderId);
|
||||
refund.setAfterSaleId(afterSaleId);
|
||||
refund.setPaymentOrderId(payment.getId());
|
||||
refund.setOrderId(order.getId());
|
||||
refund.setStatus(STATUS_REFUNDED);
|
||||
refund.setRefundAmount(payment.getPaidAmount() == null ? payment.getPayAmount() : payment.getPaidAmount());
|
||||
refund.setRefundTime(LocalDateTime.now());
|
||||
refund.setChannel(payment.getChannel());
|
||||
refund.setExternalRefundNo(refund.getRefundNo());
|
||||
refund.setFailReason(remark);
|
||||
refund.setIdempotencyKey("REFUND:" + order.getId() + ":" + (afterSaleId == null ? 0 : afterSaleId));
|
||||
refund.setIsDelete(0);
|
||||
refundOrderMapper.insert(refund);
|
||||
|
||||
order.setRefundStatus(STATUS_REFUNDED);
|
||||
order.setPaymentStatus(STATUS_REFUNDED);
|
||||
orderMapper.updateById(order);
|
||||
return toVO(refund);
|
||||
}
|
||||
|
||||
private OrderDO requirePayableOrder(Long userId, Long orderId) {
|
||||
OrderDO order = orderMapper.selectById(orderId);
|
||||
if (order == null || Integer.valueOf(1).equals(order.getIsDelete())) {
|
||||
throw new RuntimeException("订单不存在");
|
||||
}
|
||||
if (userId != null && !userId.equals(order.getUserId())) {
|
||||
throw new RuntimeException("无权支付该订单");
|
||||
}
|
||||
if (STATUS_PAID.equals(order.getPaymentStatus())) {
|
||||
throw new RuntimeException("订单已支付");
|
||||
}
|
||||
if (order.getPaymentStatus() == null) {
|
||||
order.setPaymentStatus(STATUS_UNPAID);
|
||||
}
|
||||
return order;
|
||||
}
|
||||
|
||||
private PaymentOrderVO toVO(PaymentOrderDO payment) {
|
||||
PaymentOrderVO vo = new PaymentOrderVO();
|
||||
BeanUtils.copyProperties(payment, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private RefundOrderVO toVO(RefundOrderDO refund) {
|
||||
RefundOrderVO vo = new RefundOrderVO();
|
||||
BeanUtils.copyProperties(refund, vo);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -15,6 +15,7 @@ import com.xiaowang.yuminailcore.mapper.UserPermissionMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ShopRolePermissionMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserShopRoleMapper;
|
||||
import com.xiaowang.yuminailcore.service.PermissionService;
|
||||
import com.xiaowang.yuminailcore.support.PermissionCatalog;
|
||||
import com.xiaowang.yuminailcore.support.PermissionPolicy;
|
||||
import com.xiaowang.yuminailcore.support.RequestShopContext;
|
||||
import com.xiaowang.yuminailcore.support.UserShopBindingSupport;
|
||||
@@ -196,6 +197,11 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
||||
if (userDO == null || Integer.valueOf(1).equals(userDO.getIsDelete())) {
|
||||
return List.of();
|
||||
}
|
||||
if (isShopBootstrapAdmin(userDO)) {
|
||||
return listAllPermissions().stream()
|
||||
.filter(permission -> PermissionCatalog.isAllowedForPlatformOverview(permission.getPermissionCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<UserShopRoleDO> activeShopRoles = listActiveShopRoles(userId);
|
||||
if (usesShopRoleEffectivePermissions(userDO, activeShopRoles)) {
|
||||
@@ -229,12 +235,6 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (isShopBootstrapAdmin(userDO)) {
|
||||
return permissionVOs.stream()
|
||||
.filter(permission -> SHOP_BOOTSTRAP_PERMISSION_CODES.contains(permission.getPermissionCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return permissionVOs.stream()
|
||||
.filter(permission -> isPermissionAllowedForUserType(userDO, permission.getPermissionCode()))
|
||||
.collect(Collectors.toList());
|
||||
@@ -457,7 +457,7 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
||||
return false;
|
||||
}
|
||||
if (isShopBootstrapAdmin(userDO)) {
|
||||
return SHOP_BOOTSTRAP_PERMISSION_CODES.contains(permissionCode);
|
||||
return PermissionCatalog.isAllowedForPlatformOverview(permissionCode);
|
||||
}
|
||||
if (!isPermissionAllowedForUserType(userDO, permissionCode)) {
|
||||
return false;
|
||||
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.xiaowang.yuminailcore.entity.AfterSaleDO;
|
||||
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.yuminailcore.entity.InventoryItemDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderArtistChangeRequestDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderArtistReviewDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderItemDO;
|
||||
import com.xiaowang.yuminailcore.mapper.AfterSaleMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.InventoryItemMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderArtistChangeRequestMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderArtistReviewMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderItemMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.service.WorkbenchService;
|
||||
import com.xiaowang.yuminailcore.vo.StoreWorkbenchVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WorkbenchServiceImpl implements WorkbenchService {
|
||||
|
||||
private final OrderMapper orderMapper;
|
||||
private final OrderItemMapper orderItemMapper;
|
||||
private final AfterSaleMapper afterSaleMapper;
|
||||
private final OrderArtistChangeRequestMapper orderArtistChangeRequestMapper;
|
||||
private final InventoryItemMapper inventoryItemMapper;
|
||||
private final ArtistScheduleMapper artistScheduleMapper;
|
||||
private final OrderArtistReviewMapper orderArtistReviewMapper;
|
||||
|
||||
@Override
|
||||
public StoreWorkbenchVO getWorkbench(Long shopId, Long artistId) {
|
||||
LocalDateTime todayStart = LocalDate.now().atStartOfDay();
|
||||
LocalDateTime tomorrowStart = todayStart.plusDays(1);
|
||||
List<OrderDO> orders = scopedOrders(shopId, artistId);
|
||||
StoreWorkbenchVO vo = new StoreWorkbenchVO();
|
||||
vo.setTodayOrderCount(orders.stream().filter(order -> between(order.getCreateTime(), todayStart, tomorrowStart)).count());
|
||||
vo.setPendingOrderCount(orders.stream().filter(order -> Integer.valueOf(1).equals(order.getStatus())).count());
|
||||
vo.setPendingAfterSaleCount(countAfterSales(shopId));
|
||||
vo.setPendingArtistChangeCount(countArtistChanges(shopId, artistId));
|
||||
vo.setLowStockItemCount(countLowStock(shopId));
|
||||
vo.setScheduleReminderCount(countMissingSchedules(shopId, artistId, todayStart.toLocalDate()));
|
||||
vo.setTodayServiceCount(countTodayServices(artistId, todayStart, tomorrowStart));
|
||||
vo.setCompletedServiceCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
|
||||
vo.setServiceAmount(orders.stream()
|
||||
.map(order -> order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount())
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setAverageRating(resolveRating(artistId));
|
||||
return vo;
|
||||
}
|
||||
|
||||
private List<OrderDO> scopedOrders(Long shopId, Long artistId) {
|
||||
List<OrderDO> orders = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(shopId != null, OrderDO::getShopId, shopId)
|
||||
.eq(OrderDO::getIsDelete, 0));
|
||||
if (artistId == null) {
|
||||
return orders;
|
||||
}
|
||||
Set<Long> orderIds = new HashSet<>();
|
||||
orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getArtistId, artistId)
|
||||
.eq(OrderItemDO::getIsDelete, 0))
|
||||
.forEach(item -> orderIds.add(item.getOrderId()));
|
||||
return orders.stream().filter(order -> orderIds.contains(order.getId())).toList();
|
||||
}
|
||||
|
||||
private long countAfterSales(Long shopId) {
|
||||
return afterSaleMapper.selectCount(new LambdaQueryWrapper<AfterSaleDO>()
|
||||
.eq(shopId != null, AfterSaleDO::getShopId, shopId)
|
||||
.eq(AfterSaleDO::getStatus, "PENDING")
|
||||
.eq(AfterSaleDO::getIsDelete, 0));
|
||||
}
|
||||
|
||||
private long countArtistChanges(Long shopId, Long artistId) {
|
||||
return orderArtistChangeRequestMapper.selectCount(new LambdaQueryWrapper<OrderArtistChangeRequestDO>()
|
||||
.eq(shopId != null, OrderArtistChangeRequestDO::getShopId, shopId)
|
||||
.eq(artistId != null, OrderArtistChangeRequestDO::getRequesterId, artistId)
|
||||
.eq(OrderArtistChangeRequestDO::getStatus, "PENDING")
|
||||
.eq(OrderArtistChangeRequestDO::getIsDelete, 0));
|
||||
}
|
||||
|
||||
private long countLowStock(Long shopId) {
|
||||
return inventoryItemMapper.selectList(new LambdaQueryWrapper<InventoryItemDO>()
|
||||
.eq(shopId != null, InventoryItemDO::getShopId, shopId)
|
||||
.eq(InventoryItemDO::getIsDelete, 0))
|
||||
.stream()
|
||||
.filter(item -> item.getStockQuantity() != null
|
||||
&& item.getWarningThreshold() != null
|
||||
&& item.getStockQuantity().compareTo(item.getWarningThreshold()) <= 0)
|
||||
.count();
|
||||
}
|
||||
|
||||
private long countMissingSchedules(Long shopId, Long artistId, LocalDate today) {
|
||||
return artistScheduleMapper.selectCount(new LambdaQueryWrapper<ArtistScheduleDO>()
|
||||
.eq(shopId != null, ArtistScheduleDO::getShopId, shopId)
|
||||
.eq(artistId != null, ArtistScheduleDO::getArtistId, artistId)
|
||||
.ge(ArtistScheduleDO::getWorkDate, today)
|
||||
.lt(ArtistScheduleDO::getWorkDate, today.plusDays(3))
|
||||
.eq(ArtistScheduleDO::getIsDelete, 0));
|
||||
}
|
||||
|
||||
private long countTodayServices(Long artistId, LocalDateTime todayStart, LocalDateTime tomorrowStart) {
|
||||
if (artistId == null) {
|
||||
return 0L;
|
||||
}
|
||||
return orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getArtistId, artistId)
|
||||
.ge(OrderItemDO::getAppointmentTime, todayStart)
|
||||
.lt(OrderItemDO::getAppointmentTime, tomorrowStart)
|
||||
.eq(OrderItemDO::getIsDelete, 0))
|
||||
.size();
|
||||
}
|
||||
|
||||
private BigDecimal resolveRating(Long artistId) {
|
||||
if (artistId == null) {
|
||||
return BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP);
|
||||
}
|
||||
BigDecimal rating = orderArtistReviewMapper.selectAverageSubmittedRatingByArtistId(artistId);
|
||||
return (rating == null ? BigDecimal.ZERO : rating).setScale(1, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
private boolean between(LocalDateTime value, LocalDateTime start, LocalDateTime end) {
|
||||
return value != null && !value.isBefore(start) && value.isBefore(end);
|
||||
}
|
||||
}
|
||||
+35
-3
@@ -17,6 +17,7 @@ public final class PermissionCatalog {
|
||||
private static final List<String> ADMIN_DEFAULT_PERMISSION_CODES = List.of(
|
||||
"home:view",
|
||||
"dashboard:view",
|
||||
"workbench:view",
|
||||
"user:view", "user:create", "user:edit", "user:disable", "user:unbind", "user:reset_password", "user:delete",
|
||||
"user:balance:view", "user:balance:manage", "user:vip:manage",
|
||||
"role:view", "role:create", "role:edit", "role:delete", "user:relation:view", "user:relation:edit",
|
||||
@@ -32,12 +33,19 @@ public final class PermissionCatalog {
|
||||
"announcement:view", "announcement:create", "announcement:delete",
|
||||
"messagehub:config:manage",
|
||||
"security:audit:view",
|
||||
"legal_agreement:manage"
|
||||
"legal_agreement:manage",
|
||||
"schedule:view", "schedule:edit",
|
||||
"payment:view", "payment:manage", "refund:view", "refund:manage",
|
||||
"after_sale:view", "after_sale:audit",
|
||||
"inventory:view", "inventory:manage",
|
||||
"campaign:view", "campaign:manage",
|
||||
"growth:view", "analytics:view", "performance:view"
|
||||
);
|
||||
|
||||
private static final List<String> SHOP_MANAGER_DEFAULT_PERMISSION_CODES = List.of(
|
||||
"home:view",
|
||||
"dashboard:view",
|
||||
"workbench:view",
|
||||
"user:view", "user:create", "user:edit", "user:unbind", "user:reset_password",
|
||||
"user:balance:view", "user:balance:manage", "user:vip:manage",
|
||||
"role:view", "role:create", "role:edit", "role:delete", "user:relation:view", "user:relation:edit",
|
||||
@@ -50,11 +58,18 @@ public final class PermissionCatalog {
|
||||
"order:view", "order:process", "order:edit", "order:delete", "order:artist-change",
|
||||
"nail_artist:view", "nail_artist:edit",
|
||||
"message:view", "message:create",
|
||||
"announcement:view", "announcement:create"
|
||||
"announcement:view", "announcement:create",
|
||||
"schedule:view", "schedule:edit",
|
||||
"payment:view", "refund:view",
|
||||
"after_sale:view", "after_sale:audit",
|
||||
"inventory:view", "inventory:manage",
|
||||
"campaign:view", "campaign:manage",
|
||||
"analytics:view", "performance:view"
|
||||
);
|
||||
|
||||
private static final List<String> NAIL_ARTIST_DEFAULT_PERMISSION_CODES = List.of(
|
||||
"home:view",
|
||||
"workbench:view",
|
||||
"user:view",
|
||||
"user:balance:view",
|
||||
"product:view",
|
||||
@@ -62,7 +77,8 @@ public final class PermissionCatalog {
|
||||
"tag:view",
|
||||
"coupon:view",
|
||||
"comment:view",
|
||||
"order:view", "order:process", "order:artist-change"
|
||||
"order:view", "order:process", "order:artist-change",
|
||||
"schedule:view", "after_sale:view", "performance:view"
|
||||
);
|
||||
|
||||
private static final Set<String> PLATFORM_OVERVIEW_PREFIXES = Set.of(
|
||||
@@ -256,6 +272,22 @@ public final class PermissionCatalog {
|
||||
put(definitions, "messagehub:config:manage", "管理消息参数", "参数管理", "管理地图 Key、短信 MessageHub 等平台参数");
|
||||
put(definitions, "security:audit:view", "查看安全审计", "安全审计", "查看高危操作和登录安全审计日志");
|
||||
put(definitions, "legal_agreement:manage", "管理协议", "协议管理", "管理用户协议和隐私政策版本");
|
||||
put(definitions, "schedule:view", "查看排班", "排班管理", "查看美甲师排班和可约时段");
|
||||
put(definitions, "schedule:edit", "编辑排班", "排班管理", "维护美甲师班次、休息日和预约容量");
|
||||
put(definitions, "payment:view", "查看支付", "支付退款", "查看订单支付状态和支付单");
|
||||
put(definitions, "payment:manage", "确认支付", "支付退款", "手工确认支付或处理支付异常");
|
||||
put(definitions, "refund:view", "查看退款", "支付退款", "查看退款申请和退款单");
|
||||
put(definitions, "refund:manage", "处理退款", "支付退款", "手工确认退款或处理退款异常");
|
||||
put(definitions, "after_sale:view", "查看售后", "售后管理", "查看订单售后和客户反馈");
|
||||
put(definitions, "after_sale:audit", "处理售后", "售后管理", "审批或驳回售后申请");
|
||||
put(definitions, "inventory:view", "查看库存", "库存管理", "查看门店耗材库存和预警");
|
||||
put(definitions, "inventory:manage", "调整库存", "库存管理", "维护耗材、入库和库存调整");
|
||||
put(definitions, "campaign:view", "查看活动", "活动管理", "查看营销活动和推荐位");
|
||||
put(definitions, "campaign:manage", "管理活动", "活动管理", "创建、编辑和发布营销活动");
|
||||
put(definitions, "growth:view", "查看成长", "用户成长", "查看用户成长值和会员权益进度");
|
||||
put(definitions, "analytics:view", "查看经营分析", "经营分析", "查看订单漏斗和经营指标");
|
||||
put(definitions, "performance:view", "查看绩效", "绩效统计", "查看门店和美甲师服务绩效");
|
||||
put(definitions, "workbench:view", "查看工作台", "门店工作台", "查看今日订单、售后待办、排班和绩效摘要");
|
||||
return Map.copyOf(definitions);
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -97,6 +97,16 @@ public final class SecurityAuditActions {
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public static final String USER_VIP_RECALCULATE = "USER_VIP_RECALCULATE";
|
||||
public static final String SCHEDULE_UPDATE = "SCHEDULE_UPDATE";
|
||||
public static final String PAYMENT_MANUAL_CONFIRM = "PAYMENT_MANUAL_CONFIRM";
|
||||
public static final String REFUND_MANUAL_CONFIRM = "REFUND_MANUAL_CONFIRM";
|
||||
public static final String AFTER_SALE_CREATE = "AFTER_SALE_CREATE";
|
||||
public static final String AFTER_SALE_APPROVE = "AFTER_SALE_APPROVE";
|
||||
public static final String AFTER_SALE_REJECT = "AFTER_SALE_REJECT";
|
||||
public static final String INVENTORY_ADJUST = "INVENTORY_ADJUST";
|
||||
public static final String CAMPAIGN_PUBLISH = "CAMPAIGN_PUBLISH";
|
||||
public static final String ANALYTICS_VIEW = "ANALYTICS_VIEW";
|
||||
public static final String PERFORMANCE_VIEW = "PERFORMANCE_VIEW";
|
||||
|
||||
private SecurityAuditActions() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AfterSaleVO {
|
||||
private Long id;
|
||||
private String afterSaleNo;
|
||||
private Long orderId;
|
||||
private Long orderItemId;
|
||||
private Long userId;
|
||||
private Long shopId;
|
||||
private String type;
|
||||
private String reason;
|
||||
private BigDecimal refundAmount;
|
||||
private String status;
|
||||
private Long auditUserId;
|
||||
private String auditReason;
|
||||
private LocalDateTime auditTime;
|
||||
private Long refundOrderId;
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@Data
|
||||
public class ArtistScheduleVO {
|
||||
private Long id;
|
||||
private Long shopId;
|
||||
private Long artistId;
|
||||
private LocalDate workDate;
|
||||
private LocalTime startTime;
|
||||
private LocalTime endTime;
|
||||
private Integer slotMinutes;
|
||||
private Integer capacity;
|
||||
private Integer status;
|
||||
private String remark;
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CampaignVO {
|
||||
private Long id;
|
||||
private Long shopId;
|
||||
private String title;
|
||||
private String description;
|
||||
private String scene;
|
||||
private String productIds;
|
||||
private String couponIds;
|
||||
private Integer status;
|
||||
private LocalDateTime startTime;
|
||||
private LocalDateTime endTime;
|
||||
private Integer sortOrder;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GrowthSummaryVO {
|
||||
private Long userId;
|
||||
private Integer growthValue;
|
||||
private String levelName;
|
||||
private Integer appointmentCount;
|
||||
private Integer reviewCount;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class InventoryItemVO {
|
||||
private Long id;
|
||||
private Long shopId;
|
||||
private String category;
|
||||
private String itemName;
|
||||
private String unit;
|
||||
private BigDecimal stockQuantity;
|
||||
private BigDecimal warningThreshold;
|
||||
private Boolean warning;
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class OperationsAnalyticsVO {
|
||||
private Long viewCount;
|
||||
private Long favoriteCount;
|
||||
private Long cartCount;
|
||||
private Long orderCount;
|
||||
private Long paidOrderCount;
|
||||
private Long completedOrderCount;
|
||||
private Long reviewCount;
|
||||
private Long rebookCount;
|
||||
private BigDecimal totalAmount;
|
||||
}
|
||||
@@ -57,6 +57,13 @@ public class OrderVO {
|
||||
* Field `couponName` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private String couponName;
|
||||
private String paymentStatus;
|
||||
private BigDecimal payAmount;
|
||||
private BigDecimal paidAmount;
|
||||
private LocalDateTime payTime;
|
||||
private String paymentMethod;
|
||||
private String paymentOrderNo;
|
||||
private String refundStatus;
|
||||
/**
|
||||
* Field `customerNickname` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class PaymentOrderVO {
|
||||
private Long id;
|
||||
private String payNo;
|
||||
private Long orderId;
|
||||
private String orderNo;
|
||||
private Long userId;
|
||||
private Long shopId;
|
||||
private String channel;
|
||||
private String status;
|
||||
private BigDecimal payAmount;
|
||||
private BigDecimal paidAmount;
|
||||
private LocalDateTime payTime;
|
||||
private LocalDateTime expireTime;
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RefundOrderVO {
|
||||
private Long id;
|
||||
private String refundNo;
|
||||
private Long afterSaleId;
|
||||
private Long paymentOrderId;
|
||||
private Long orderId;
|
||||
private String status;
|
||||
private BigDecimal refundAmount;
|
||||
private LocalDateTime refundTime;
|
||||
private String channel;
|
||||
private String externalRefundNo;
|
||||
private String failReason;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xiaowang.yuminailcore.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class StoreWorkbenchVO {
|
||||
private Long todayOrderCount;
|
||||
private Long pendingOrderCount;
|
||||
private Long pendingAfterSaleCount;
|
||||
private Long pendingArtistChangeCount;
|
||||
private Long lowStockItemCount;
|
||||
private Long scheduleReminderCount;
|
||||
private Long todayServiceCount;
|
||||
private Long completedServiceCount;
|
||||
private BigDecimal serviceAmount;
|
||||
private BigDecimal averageRating;
|
||||
}
|
||||
@@ -1409,6 +1409,270 @@ CALL sp_add_index_if_not_exists('t_business_event_outbox', 'idx_business_event_o
|
||||
-- Artist change requests can be expired asynchronously; expired rows release pending_key for a new request.
|
||||
-- EXPIRED
|
||||
|
||||
-- ========================================
|
||||
-- vNext operations schema: schedule / reservation / payment / after sale / inventory / campaign / growth
|
||||
-- ========================================
|
||||
|
||||
CALL sp_add_column_if_not_exists('t_order', 'payment_status', 'varchar(20) NOT NULL DEFAULT ''UNPAID'' COMMENT ''支付状态:UNPAID/PAYING/PAID/REFUNDED''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'pay_amount', 'decimal(10,2) NULL COMMENT ''应支付金额快照''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'paid_amount', 'decimal(10,2) NULL COMMENT ''实付金额快照''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'pay_time', 'datetime NULL COMMENT ''支付完成时间''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'payment_method', 'varchar(32) NULL COMMENT ''支付方式/渠道''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'payment_order_no', 'varchar(64) NULL COMMENT ''最近一次支付单号''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'refund_status', 'varchar(20) NOT NULL DEFAULT ''NONE'' COMMENT ''退款状态:NONE/REFUNDED''');
|
||||
CALL sp_add_index_if_not_exists('t_order', 'idx_t_order_payment_status', '(`payment_status`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_order', 'idx_t_order_payment_order_no', '(`payment_order_no`)');
|
||||
CALL sp_add_index_if_not_exists('t_order', 'idx_t_order_refund_status', '(`refund_status`, `is_delete`)');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_artist_schedule
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '排班ID',
|
||||
shop_id bigint unsigned NOT NULL COMMENT '店铺ID',
|
||||
artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID',
|
||||
work_date date NOT NULL COMMENT '工作日期',
|
||||
start_time time NOT NULL COMMENT '班次开始时间',
|
||||
end_time time NOT NULL COMMENT '班次结束时间',
|
||||
slot_minutes int NOT NULL DEFAULT 30 COMMENT '预约粒度分钟数',
|
||||
capacity int NOT NULL DEFAULT 1 COMMENT '同一时段可预约容量',
|
||||
status tinyint NOT NULL DEFAULT 1 COMMENT '状态:1-可预约,0-停用',
|
||||
remark varchar(255) NULL COMMENT '排班备注',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint unsigned DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '美甲师排班表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_appointment_reservation
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '预约占用ID',
|
||||
order_id bigint unsigned NOT NULL COMMENT '订单ID',
|
||||
order_item_id bigint unsigned NOT NULL COMMENT '订单项ID',
|
||||
shop_id bigint unsigned NOT NULL COMMENT '店铺ID',
|
||||
artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID',
|
||||
product_title varchar(200) NULL COMMENT '预约作品标题快照',
|
||||
appointment_start_time datetime NOT NULL COMMENT '预约开始时间',
|
||||
appointment_end_time datetime NOT NULL COMMENT '预约结束时间',
|
||||
status varchar(20) NOT NULL DEFAULT 'LOCKED' COMMENT '状态:LOCKED/CONFIRMED/RELEASED/CANCELLED',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint unsigned DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '订单预约时段占用表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_payment_order
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '支付单ID',
|
||||
pay_no varchar(64) NOT NULL COMMENT '支付单号',
|
||||
order_id bigint unsigned NOT NULL COMMENT '订单ID',
|
||||
order_no varchar(64) NOT NULL COMMENT '订单号快照',
|
||||
user_id bigint unsigned NOT NULL COMMENT '支付用户ID',
|
||||
shop_id bigint unsigned NULL COMMENT '店铺ID',
|
||||
channel varchar(32) NOT NULL DEFAULT 'MANUAL' COMMENT '支付渠道',
|
||||
status varchar(20) NOT NULL DEFAULT 'PAYING' COMMENT '状态:PAYING/PAID/CLOSED',
|
||||
pay_amount decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '应支付金额',
|
||||
paid_amount decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '实付金额',
|
||||
pay_time datetime NULL COMMENT '支付完成时间',
|
||||
expire_time datetime NULL COMMENT '支付单过期时间',
|
||||
operator_id bigint unsigned NULL COMMENT '手工确认操作人ID',
|
||||
remark varchar(255) NULL COMMENT '支付备注',
|
||||
idempotency_key varchar(160) NULL COMMENT '支付幂等键',
|
||||
raw_payload text NULL COMMENT '支付渠道原始载荷',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint unsigned DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '订单支付单表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_refund_order
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '退款单ID',
|
||||
refund_no varchar(64) NOT NULL COMMENT '退款单号',
|
||||
after_sale_id bigint unsigned NULL COMMENT '售后单ID',
|
||||
payment_order_id bigint unsigned NOT NULL COMMENT '支付单ID',
|
||||
order_id bigint unsigned NOT NULL COMMENT '订单ID',
|
||||
status varchar(20) NOT NULL DEFAULT 'REFUNDED' COMMENT '状态:PROCESSING/REFUNDED/FAILED',
|
||||
refund_amount decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '退款金额',
|
||||
refund_time datetime NULL COMMENT '退款完成时间',
|
||||
channel varchar(32) NULL COMMENT '退款渠道',
|
||||
external_refund_no varchar(64) NULL COMMENT '外部退款单号',
|
||||
fail_reason varchar(255) NULL COMMENT '失败原因或备注',
|
||||
idempotency_key varchar(160) NULL COMMENT '退款幂等键',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint unsigned DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '订单退款单表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_after_sale
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '售后单ID',
|
||||
after_sale_no varchar(64) NOT NULL COMMENT '售后单号',
|
||||
order_id bigint unsigned NOT NULL COMMENT '订单ID',
|
||||
order_item_id bigint unsigned NULL COMMENT '订单项ID',
|
||||
user_id bigint unsigned NOT NULL COMMENT '申请用户ID',
|
||||
shop_id bigint unsigned NULL COMMENT '店铺ID',
|
||||
type varchar(32) NOT NULL COMMENT '售后类型',
|
||||
reason varchar(1000) NULL COMMENT '申请原因',
|
||||
refund_amount decimal(10, 2) NULL COMMENT '申请退款金额',
|
||||
status varchar(20) NOT NULL DEFAULT 'PENDING' COMMENT '状态:PENDING/APPROVED/REJECTED',
|
||||
audit_user_id bigint unsigned NULL COMMENT '审核人ID',
|
||||
audit_reason varchar(500) NULL COMMENT '审核说明',
|
||||
audit_time datetime NULL COMMENT '审核时间',
|
||||
refund_order_id bigint unsigned NULL COMMENT '关联退款单ID',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint unsigned DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '订单售后申请表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_after_sale_log
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '售后日志ID',
|
||||
after_sale_id bigint unsigned NOT NULL COMMENT '售后单ID',
|
||||
action varchar(32) NOT NULL COMMENT '动作:CREATE/APPROVE/REJECT',
|
||||
from_status varchar(20) NULL COMMENT '变更前状态',
|
||||
to_status varchar(20) NULL COMMENT '变更后状态',
|
||||
operator_id bigint unsigned NULL COMMENT '操作人ID',
|
||||
operator_type varchar(20) NULL COMMENT '操作人类型:USER/ADMIN',
|
||||
remark varchar(500) NULL COMMENT '备注',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '订单售后流转日志表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_inventory_item
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '库存物料ID',
|
||||
shop_id bigint unsigned NOT NULL COMMENT '店铺ID',
|
||||
category varchar(50) NULL COMMENT '物料分类',
|
||||
item_name varchar(100) NOT NULL COMMENT '物料名称',
|
||||
unit varchar(20) NOT NULL DEFAULT '件' COMMENT '计量单位',
|
||||
stock_quantity decimal(12, 3) NOT NULL DEFAULT 0.000 COMMENT '当前库存数量',
|
||||
warning_threshold decimal(12, 3) NOT NULL DEFAULT 0.000 COMMENT '库存预警阈值',
|
||||
status tinyint NOT NULL DEFAULT 1 COMMENT '状态:1-启用,0-停用',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint unsigned DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '门店库存物料表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_inventory_record
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '库存流水ID',
|
||||
inventory_item_id bigint unsigned NOT NULL COMMENT '库存物料ID',
|
||||
shop_id bigint unsigned NOT NULL COMMENT '店铺ID',
|
||||
change_type varchar(32) NOT NULL COMMENT '变动类型:IN/OUT/ADJUST',
|
||||
change_quantity decimal(12, 3) NOT NULL COMMENT '变动数量',
|
||||
before_quantity decimal(12, 3) NOT NULL COMMENT '变动前数量',
|
||||
after_quantity decimal(12, 3) NOT NULL COMMENT '变动后数量',
|
||||
operator_id bigint unsigned NULL COMMENT '操作人ID',
|
||||
remark varchar(255) NULL COMMENT '备注',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '门店库存变动流水表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_campaign
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '营销活动ID',
|
||||
shop_id bigint unsigned NULL COMMENT '店铺ID,空表示平台活动',
|
||||
title varchar(120) NOT NULL COMMENT '活动标题',
|
||||
description varchar(1000) NULL COMMENT '活动说明',
|
||||
scene varchar(32) NOT NULL DEFAULT 'HOME' COMMENT '活动场景',
|
||||
product_ids text NULL COMMENT '关联作品ID集合',
|
||||
coupon_ids text NULL COMMENT '关联优惠券ID集合',
|
||||
status tinyint NOT NULL DEFAULT 0 COMMENT '状态:0-草稿,1-启用,2-停用',
|
||||
start_time datetime NULL COMMENT '开始时间',
|
||||
end_time datetime NULL COMMENT '结束时间',
|
||||
sort_order int NOT NULL DEFAULT 100 COMMENT '排序',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint unsigned DEFAULT 0 NULL COMMENT '逻辑删除:0-未删,1-已删',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '营销活动配置表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_user_growth_record
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '成长值记录ID',
|
||||
user_id bigint unsigned NOT NULL COMMENT '用户ID',
|
||||
source_type varchar(32) NOT NULL COMMENT '成长来源:REVIEW/REBOOK/ORDER',
|
||||
source_id bigint unsigned NULL COMMENT '来源业务ID',
|
||||
growth_value int NOT NULL DEFAULT 0 COMMENT '成长值变化',
|
||||
remark varchar(255) NULL COMMENT '备注',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
COMMENT '用户成长值流水表';
|
||||
|
||||
CALL sp_add_unique_index_if_not_exists('t_artist_schedule', 'uk_t_artist_schedule_slot', '(`shop_id`, `artist_id`, `work_date`, `start_time`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_artist_schedule', 'idx_t_artist_schedule_artist_date', '(`artist_id`, `work_date`, `status`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_artist_schedule', 'idx_t_artist_schedule_shop_date', '(`shop_id`, `work_date`, `status`, `is_delete`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_appointment_reservation', 'uk_t_appointment_reservation_item', '(`order_item_id`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_appointment_reservation', 'idx_t_appointment_reservation_artist_time', '(`artist_id`, `status`, `appointment_start_time`, `appointment_end_time`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_appointment_reservation', 'idx_t_appointment_reservation_order', '(`order_id`, `status`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_appointment_reservation', 'idx_t_appointment_reservation_shop_time', '(`shop_id`, `appointment_start_time`, `status`, `is_delete`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_payment_order', 'uk_t_payment_order_pay_no', '(`pay_no`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_payment_order', 'uk_t_payment_order_idempotency', '(`idempotency_key`)');
|
||||
CALL sp_add_index_if_not_exists('t_payment_order', 'idx_t_payment_order_order_latest', '(`order_id`, `is_delete`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_payment_order', 'idx_t_payment_order_user_status', '(`user_id`, `status`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_payment_order', 'idx_t_payment_order_shop_status', '(`shop_id`, `status`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_payment_order', 'idx_t_payment_order_expire', '(`status`, `expire_time`, `is_delete`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_refund_order', 'uk_t_refund_order_refund_no', '(`refund_no`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_refund_order', 'uk_t_refund_order_idempotency', '(`idempotency_key`)');
|
||||
CALL sp_add_index_if_not_exists('t_refund_order', 'idx_t_refund_order_after_sale', '(`after_sale_id`)');
|
||||
CALL sp_add_index_if_not_exists('t_refund_order', 'idx_t_refund_order_order_status', '(`order_id`, `status`, `create_time`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_after_sale', 'uk_t_after_sale_no', '(`after_sale_no`)');
|
||||
CALL sp_add_index_if_not_exists('t_after_sale', 'idx_t_after_sale_user_status', '(`user_id`, `status`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_after_sale', 'idx_t_after_sale_shop_status', '(`shop_id`, `status`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_after_sale', 'idx_t_after_sale_order', '(`order_id`, `order_item_id`)');
|
||||
CALL sp_add_index_if_not_exists('t_after_sale_log', 'idx_t_after_sale_log_after_sale', '(`after_sale_id`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_after_sale_log', 'idx_t_after_sale_log_operator', '(`operator_id`, `create_time`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_inventory_item', 'uk_t_inventory_item_shop_name', '(`shop_id`, `item_name`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_inventory_item', 'idx_t_inventory_item_shop_status', '(`shop_id`, `status`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_inventory_item', 'idx_t_inventory_item_warning', '(`shop_id`, `stock_quantity`, `warning_threshold`)');
|
||||
CALL sp_add_index_if_not_exists('t_inventory_record', 'idx_t_inventory_record_item_time', '(`inventory_item_id`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_inventory_record', 'idx_t_inventory_record_shop_time', '(`shop_id`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_campaign', 'idx_t_campaign_shop_status', '(`shop_id`, `status`, `is_delete`, `sort_order`)');
|
||||
CALL sp_add_index_if_not_exists('t_campaign', 'idx_t_campaign_scene_time', '(`scene`, `status`, `start_time`, `end_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_user_growth_record', 'idx_t_user_growth_user_time', '(`user_id`, `create_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_user_growth_record', 'idx_t_user_growth_source', '(`source_type`, `source_id`)');
|
||||
CALL sp_add_unique_index_if_not_exists('t_user_growth_record', 'uk_t_user_growth_source_once', '(`user_id`, `source_type`, `source_id`)');
|
||||
|
||||
INSERT INTO t_permission (id, permission_code, permission_name, permission_group, description, create_time, update_time, is_delete)
|
||||
VALUES
|
||||
(313931273555136610, 'schedule:view', '查看排班', '排班管理', '查看美甲师排班和可约时段', NOW(), NOW(), 0),
|
||||
(313931273555136611, 'schedule:edit', '编辑排班', '排班管理', '维护美甲师班次、休息日和预约容量', NOW(), NOW(), 0),
|
||||
(313931273555136612, 'payment:view', '查看支付', '支付退款', '查看订单支付状态和支付单', NOW(), NOW(), 0),
|
||||
(313931273555136613, 'payment:manage', '确认支付', '支付退款', '手工确认支付或处理支付异常', NOW(), NOW(), 0),
|
||||
(313931273555136614, 'refund:view', '查看退款', '支付退款', '查看退款申请和退款单', NOW(), NOW(), 0),
|
||||
(313931273555136615, 'refund:manage', '处理退款', '支付退款', '手工确认退款或处理退款异常', NOW(), NOW(), 0),
|
||||
(313931273555136616, 'after_sale:view', '查看售后', '售后管理', '查看订单售后和客户反馈', NOW(), NOW(), 0),
|
||||
(313931273555136617, 'after_sale:audit', '处理售后', '售后管理', '审批或驳回售后申请', NOW(), NOW(), 0),
|
||||
(313931273555136618, 'inventory:view', '查看库存', '库存管理', '查看门店耗材库存和预警', NOW(), NOW(), 0),
|
||||
(313931273555136619, 'inventory:manage', '调整库存', '库存管理', '维护耗材、入库和库存调整', NOW(), NOW(), 0),
|
||||
(313931273555136620, 'campaign:view', '查看活动', '活动管理', '查看营销活动和推荐位', NOW(), NOW(), 0),
|
||||
(313931273555136621, 'campaign:manage', '管理活动', '活动管理', '创建、编辑和发布营销活动', NOW(), NOW(), 0),
|
||||
(313931273555136622, 'growth:view', '查看成长', '用户成长', '查看用户成长值和会员权益进度', NOW(), NOW(), 0),
|
||||
(313931273555136623, 'analytics:view', '查看经营分析', '经营分析', '查看订单漏斗和经营指标', NOW(), NOW(), 0),
|
||||
(313931273555136624, 'performance:view', '查看绩效', '绩效统计', '查看门店和美甲师服务绩效', NOW(), NOW(), 0),
|
||||
(313931273555136625, 'workbench:view', '查看工作台', '门店工作台', '查看今日订单、售后待办、排班和绩效摘要', NOW(), NOW(), 0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
permission_name = VALUES(permission_name),
|
||||
permission_group = VALUES(permission_group),
|
||||
description = VALUES(description),
|
||||
is_delete = 0,
|
||||
update_time = NOW();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `t_messagehub_push_config` (
|
||||
`id` bigint unsigned NOT NULL COMMENT '主键ID',
|
||||
`scene_code` varchar(80) NOT NULL COMMENT '业务场景编码',
|
||||
@@ -1624,6 +1888,21 @@ INNER JOIN t_permission p
|
||||
'order:delete',
|
||||
'nail_artist:view',
|
||||
'nail_artist:edit',
|
||||
'schedule:view',
|
||||
'schedule:edit',
|
||||
'payment:view',
|
||||
'payment:manage',
|
||||
'refund:view',
|
||||
'refund:manage',
|
||||
'after_sale:view',
|
||||
'after_sale:audit',
|
||||
'inventory:view',
|
||||
'inventory:manage',
|
||||
'campaign:view',
|
||||
'campaign:manage',
|
||||
'growth:view',
|
||||
'analytics:view',
|
||||
'performance:view',
|
||||
'message:view',
|
||||
'message:create',
|
||||
'message:delete',
|
||||
@@ -1685,6 +1964,18 @@ INNER JOIN t_permission p
|
||||
'order:delete',
|
||||
'nail_artist:view',
|
||||
'nail_artist:edit',
|
||||
'schedule:view',
|
||||
'schedule:edit',
|
||||
'payment:view',
|
||||
'refund:view',
|
||||
'after_sale:view',
|
||||
'after_sale:audit',
|
||||
'inventory:view',
|
||||
'inventory:manage',
|
||||
'campaign:view',
|
||||
'campaign:manage',
|
||||
'analytics:view',
|
||||
'performance:view',
|
||||
'message:view',
|
||||
'message:create',
|
||||
'announcement:view',
|
||||
@@ -1715,7 +2006,10 @@ INNER JOIN t_permission p
|
||||
'comment:view',
|
||||
'order:view',
|
||||
'order:process',
|
||||
'order:artist-change'
|
||||
'order:artist-change',
|
||||
'schedule:view',
|
||||
'after_sale:view',
|
||||
'performance:view'
|
||||
)
|
||||
WHERE u.is_delete = 0
|
||||
AND u.type = 3
|
||||
@@ -1838,6 +2132,16 @@ CALL sp_drop_auto_increment_on_id_if_exists('t_system_message');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_system_message_user_state');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_announcement');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_vip_recharge_plan');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_artist_schedule');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_appointment_reservation');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_payment_order');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_refund_order');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_after_sale');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_after_sale_log');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_inventory_item');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_inventory_record');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_campaign');
|
||||
CALL sp_drop_auto_increment_on_id_if_exists('t_user_growth_record');
|
||||
|
||||
DROP PROCEDURE IF EXISTS sp_drop_auto_increment_on_id_if_exists;
|
||||
|
||||
|
||||
+14
@@ -73,6 +73,20 @@ class FrontendFileControllerTest {
|
||||
assertThat(result.getData()).isEqualTo("https://signed.test/public/a.png");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSignedUrlFallsBackToOriginalPublicExternalUrlWhenObjectNameCannotBeExtracted() throws Exception {
|
||||
ObjectStorageFileVO file = file();
|
||||
file.setFileUrl("https://acceptance.local/images/public-a.png");
|
||||
when(objectStorageFileService.getObjectStorageFileById(12L)).thenReturn(file);
|
||||
when(productMapper.countPublicImageReference(12L)).thenReturn(1L);
|
||||
|
||||
Result<String> result = controller.getSignedUrl(12L, 30);
|
||||
|
||||
assertThat(result.getCode()).isEqualTo(200);
|
||||
assertThat(result.getData()).isEqualTo("https://acceptance.local/images/public-a.png");
|
||||
verify(minioService, never()).getPresignedUrl(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.anyInt());
|
||||
}
|
||||
|
||||
private ObjectStorageFileVO file() {
|
||||
ObjectStorageFileVO file = new ObjectStorageFileVO();
|
||||
file.setId(12L);
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleApplyDTO;
|
||||
import com.xiaowang.yuminailcore.dto.AfterSaleAuditDTO;
|
||||
import com.xiaowang.yuminailcore.entity.AfterSaleDO;
|
||||
import com.xiaowang.yuminailcore.entity.AfterSaleLogDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.SystemMessageDO;
|
||||
import com.xiaowang.yuminailcore.mapper.AfterSaleLogMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.AfterSaleMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.SystemMessageMapper;
|
||||
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class AfterSaleServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private AfterSaleMapper afterSaleMapper;
|
||||
@Mock
|
||||
private AfterSaleLogMapper afterSaleLogMapper;
|
||||
@Mock
|
||||
private OrderMapper orderMapper;
|
||||
@Mock
|
||||
private SystemMessageMapper systemMessageMapper;
|
||||
|
||||
private AfterSaleServiceImpl service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
service = new AfterSaleServiceImpl(afterSaleMapper, afterSaleLogMapper, orderMapper, systemMessageMapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyCreatesPendingAfterSaleForOwnedOrder() {
|
||||
OrderDO order = order();
|
||||
when(orderMapper.selectById(1L)).thenReturn(order);
|
||||
when(afterSaleMapper.insert(any(AfterSaleDO.class))).thenAnswer(invocation -> {
|
||||
AfterSaleDO afterSale = invocation.getArgument(0);
|
||||
afterSale.setId(100L);
|
||||
return 1;
|
||||
});
|
||||
|
||||
AfterSaleApplyDTO dto = new AfterSaleApplyDTO();
|
||||
dto.setOrderId(1L);
|
||||
dto.setType("REFUND_CONSULT");
|
||||
dto.setReason("Need help");
|
||||
dto.setRefundAmount(new BigDecimal("20.00"));
|
||||
|
||||
AfterSaleVO result = service.apply(2L, dto);
|
||||
|
||||
assertThat(result.getStatus()).isEqualTo("PENDING");
|
||||
ArgumentCaptor<AfterSaleLogDO> logCaptor = ArgumentCaptor.forClass(AfterSaleLogDO.class);
|
||||
verify(afterSaleLogMapper).insert(logCaptor.capture());
|
||||
assertThat(logCaptor.getValue().getAction()).isEqualTo("CREATE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void approveChangesStatusAndNotifiesCustomer() {
|
||||
AfterSaleDO afterSale = new AfterSaleDO();
|
||||
afterSale.setId(100L);
|
||||
afterSale.setOrderId(1L);
|
||||
afterSale.setUserId(2L);
|
||||
afterSale.setShopId(9L);
|
||||
afterSale.setStatus("PENDING");
|
||||
when(afterSaleMapper.selectById(100L)).thenReturn(afterSale);
|
||||
|
||||
AfterSaleAuditDTO dto = new AfterSaleAuditDTO();
|
||||
dto.setAuditReason("OK");
|
||||
AfterSaleVO result = service.approve(900L, 100L, dto);
|
||||
|
||||
assertThat(result.getStatus()).isEqualTo("APPROVED");
|
||||
verify(afterSaleMapper).updateById(afterSale);
|
||||
verify(systemMessageMapper).insert(any(SystemMessageDO.class));
|
||||
}
|
||||
|
||||
private OrderDO order() {
|
||||
OrderDO order = new OrderDO();
|
||||
order.setId(1L);
|
||||
order.setOrderNo("ORD1");
|
||||
order.setUserId(2L);
|
||||
order.setShopId(9L);
|
||||
order.setActualAmount(new BigDecimal("88.00"));
|
||||
order.setStatus(1);
|
||||
order.setIsDelete(0);
|
||||
return order;
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.entity.AppointmentReservationDO;
|
||||
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.yuminailcore.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class AppointmentCapacityServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private AppointmentReservationMapper reservationMapper;
|
||||
@Mock
|
||||
private ArtistScheduleMapper scheduleMapper;
|
||||
|
||||
private AppointmentCapacityServiceImpl service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
service = new AppointmentCapacityServiceImpl(reservationMapper, scheduleMapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
void reserveRejectsWhenConfiguredCapacityIsFull() {
|
||||
LocalDateTime start = LocalDateTime.of(2026, 6, 1, 10, 0);
|
||||
LocalDateTime end = start.plusHours(1);
|
||||
when(scheduleMapper.selectCoveringSchedule(9L, 30L, start.toLocalDate(), start.toLocalTime(), end.toLocalTime()))
|
||||
.thenReturn(schedule(2));
|
||||
when(reservationMapper.countOverlappingActiveForUpdate(30L, start, end)).thenReturn(2);
|
||||
|
||||
assertThatThrownBy(() -> service.reserveOrThrow(1L, 10L, 9L, 30L, "French", start, end))
|
||||
.isInstanceOf(RuntimeException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void reserveCreatesConfirmedReservationWhenCapacityRemains() {
|
||||
LocalDateTime start = LocalDateTime.of(2026, 6, 1, 10, 0);
|
||||
LocalDateTime end = start.plusHours(1);
|
||||
when(scheduleMapper.selectCoveringSchedule(9L, 30L, start.toLocalDate(), start.toLocalTime(), end.toLocalTime()))
|
||||
.thenReturn(schedule(2));
|
||||
when(reservationMapper.countOverlappingActiveForUpdate(30L, start, end)).thenReturn(1);
|
||||
|
||||
service.reserveOrThrow(1L, 10L, 9L, 30L, "French", start, end);
|
||||
|
||||
ArgumentCaptor<AppointmentReservationDO> captor = ArgumentCaptor.forClass(AppointmentReservationDO.class);
|
||||
verify(reservationMapper).insert(captor.capture());
|
||||
AppointmentReservationDO reservation = captor.getValue();
|
||||
assertThat(reservation.getOrderId()).isEqualTo(1L);
|
||||
assertThat(reservation.getOrderItemId()).isEqualTo(10L);
|
||||
assertThat(reservation.getArtistId()).isEqualTo(30L);
|
||||
assertThat(reservation.getStatus()).isEqualTo("CONFIRMED");
|
||||
}
|
||||
|
||||
@Test
|
||||
void reserveRejectsWhenNoCoveringScheduleExists() {
|
||||
LocalDateTime start = LocalDateTime.of(2026, 6, 2, 10, 0);
|
||||
LocalDateTime end = start.plusHours(1);
|
||||
when(scheduleMapper.selectCoveringSchedule(9L, 30L, start.toLocalDate(), start.toLocalTime(), end.toLocalTime()))
|
||||
.thenReturn(null);
|
||||
|
||||
assertThatThrownBy(() -> service.reserveOrThrow(1L, 10L, 9L, 30L, "French", start, end))
|
||||
.isInstanceOf(RuntimeException.class)
|
||||
.hasMessageContaining("涓嶅彲棰勭害");
|
||||
|
||||
verify(reservationMapper, never()).insert(org.mockito.ArgumentMatchers.any(AppointmentReservationDO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reserveRejectsWhenCoveringScheduleIsDisabled() {
|
||||
LocalDateTime start = LocalDateTime.of(2026, 6, 1, 10, 0);
|
||||
LocalDateTime end = start.plusHours(1);
|
||||
ArtistScheduleDO disabled = schedule(1);
|
||||
disabled.setStatus(0);
|
||||
when(scheduleMapper.selectCoveringSchedule(9L, 30L, start.toLocalDate(), start.toLocalTime(), end.toLocalTime()))
|
||||
.thenReturn(disabled);
|
||||
|
||||
assertThatThrownBy(() -> service.reserveOrThrow(1L, 10L, 9L, 30L, "French", start, end))
|
||||
.isInstanceOf(RuntimeException.class)
|
||||
.hasMessageContaining("涓嶅彲棰勭害");
|
||||
|
||||
verify(reservationMapper, never()).insert(org.mockito.ArgumentMatchers.any(AppointmentReservationDO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reserveRejectsWhenCoveringScheduleHasZeroCapacity() {
|
||||
LocalDateTime start = LocalDateTime.of(2026, 6, 1, 10, 0);
|
||||
LocalDateTime end = start.plusHours(1);
|
||||
when(scheduleMapper.selectCoveringSchedule(9L, 30L, start.toLocalDate(), start.toLocalTime(), end.toLocalTime()))
|
||||
.thenReturn(schedule(0));
|
||||
|
||||
assertThatThrownBy(() -> service.reserveOrThrow(1L, 10L, 9L, 30L, "French", start, end))
|
||||
.isInstanceOf(RuntimeException.class)
|
||||
.hasMessageContaining("涓嶅彲棰勭害");
|
||||
|
||||
verify(reservationMapper, never()).insert(org.mockito.ArgumentMatchers.any(AppointmentReservationDO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void moveReservationRechecksNewArtistCapacityBeforeUpdatingArtist() {
|
||||
LocalDateTime start = LocalDateTime.of(2026, 6, 1, 10, 0);
|
||||
LocalDateTime end = start.plusHours(1);
|
||||
when(scheduleMapper.selectCoveringSchedule(9L, 31L, start.toLocalDate(), start.toLocalTime(), end.toLocalTime()))
|
||||
.thenReturn(schedule(1));
|
||||
when(reservationMapper.countOverlappingActiveForUpdateExcludingOrderItem(31L, 10L, start, end)).thenReturn(0);
|
||||
when(reservationMapper.updateActiveReservationForOrderItem(10L, 1L, 9L, 31L, "French", start, end, "CONFIRMED"))
|
||||
.thenReturn(1);
|
||||
|
||||
service.moveReservationForArtistChange(1L, 10L, 9L, 30L, 31L, "French", start, end);
|
||||
|
||||
verify(reservationMapper).updateActiveReservationForOrderItem(10L, 1L, 9L, 31L, "French", start, end, "CONFIRMED");
|
||||
verify(reservationMapper, never()).releaseByOrderItem(10L, "RELEASED");
|
||||
verify(reservationMapper, never()).insert(org.mockito.ArgumentMatchers.any(AppointmentReservationDO.class));
|
||||
}
|
||||
|
||||
private ArtistScheduleDO schedule(int capacity) {
|
||||
ArtistScheduleDO schedule = new ArtistScheduleDO();
|
||||
schedule.setShopId(9L);
|
||||
schedule.setArtistId(30L);
|
||||
schedule.setWorkDate(LocalDate.of(2026, 6, 1));
|
||||
schedule.setStartTime(LocalTime.of(10, 0));
|
||||
schedule.setEndTime(LocalTime.of(20, 0));
|
||||
schedule.setCapacity(capacity);
|
||||
schedule.setStatus(1);
|
||||
schedule.setIsDelete(0);
|
||||
return schedule;
|
||||
}
|
||||
}
|
||||
+10
@@ -8,6 +8,7 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -50,4 +51,13 @@ class BusinessEventOutboxServiceTest {
|
||||
|
||||
verify(outboxMapper).insert(any(BusinessEventOutboxDO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void processorPollsFrequentlyEnoughForOrderReviewPromptAcceptanceWindow() throws NoSuchMethodException {
|
||||
Scheduled scheduled = BusinessEventOutboxProcessor.class.getMethod("processDueEvents")
|
||||
.getAnnotation(Scheduled.class);
|
||||
|
||||
assertThat(scheduled).isNotNull();
|
||||
assertThat(scheduled.fixedDelay()).isLessThanOrEqualTo(3000L);
|
||||
}
|
||||
}
|
||||
|
||||
+59
@@ -1,6 +1,7 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.entity.NailArtistInfoDO;
|
||||
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderArtistReviewDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.OrderItemDO;
|
||||
@@ -8,6 +9,8 @@ import com.xiaowang.yuminailcore.entity.ProductDO;
|
||||
import com.xiaowang.yuminailcore.entity.ShopDO;
|
||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||
import com.xiaowang.yuminailcore.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderArtistReviewMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderItemMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
@@ -20,6 +23,7 @@ import com.xiaowang.yuminailcore.vo.NailArtistAvailabilityVO;
|
||||
import com.xiaowang.yuminailcore.vo.NailArtistProfileVO;
|
||||
import com.xiaowang.yuminailcore.vo.NailArtistReviewVO;
|
||||
import com.xiaowang.yuminailcore.vo.ObjectStorageFileVO;
|
||||
import com.xiaowang.yuminailcore.vo.ShopSimpleVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
@@ -28,6 +32,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -57,6 +62,10 @@ class NailArtistInfoServiceImplTest {
|
||||
private OrderArtistReviewMapper orderArtistReviewMapper;
|
||||
@Mock
|
||||
private ObjectStorageFileService objectStorageFileService;
|
||||
@Mock
|
||||
private ArtistScheduleMapper artistScheduleMapper;
|
||||
@Mock
|
||||
private AppointmentReservationMapper appointmentReservationMapper;
|
||||
|
||||
private NailArtistInfoServiceImpl service;
|
||||
|
||||
@@ -73,6 +82,8 @@ class NailArtistInfoServiceImplTest {
|
||||
ReflectionTestUtils.setField(service, "orderItemMapper", orderItemMapper);
|
||||
ReflectionTestUtils.setField(service, "orderArtistReviewMapper", orderArtistReviewMapper);
|
||||
ReflectionTestUtils.setField(service, "objectStorageFileService", objectStorageFileService);
|
||||
ReflectionTestUtils.setField(service, "artistScheduleMapper", artistScheduleMapper);
|
||||
ReflectionTestUtils.setField(service, "appointmentReservationMapper", appointmentReservationMapper);
|
||||
when(userShopBindingSupport.listShopOptionsByUserId(any(), anyBoolean(), anyBoolean())).thenReturn(List.of());
|
||||
}
|
||||
|
||||
@@ -224,4 +235,52 @@ class NailArtistInfoServiceImplTest {
|
||||
.noneMatch(slot -> slot.getStartTime().toLocalDate().equals(booked.getAppointmentTime().toLocalDate())
|
||||
&& slot.getStartTime().toLocalTime().equals(LocalTime.of(10, 0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAvailabilityUsesScheduleCapacityWhenConfigured() {
|
||||
NailArtistInfoDO artistInfo = new NailArtistInfoDO();
|
||||
artistInfo.setUserId(7L);
|
||||
artistInfo.setStatus(1);
|
||||
artistInfo.setWorkStartTime(LocalTime.of(10, 0));
|
||||
artistInfo.setWorkEndTime(LocalTime.of(12, 0));
|
||||
artistInfo.setIsDelete(0);
|
||||
when(nailArtistInfoMapper.selectOne(any())).thenReturn(artistInfo);
|
||||
UserDO artist = new UserDO();
|
||||
artist.setId(7L);
|
||||
artist.setType(3);
|
||||
artist.setShopId(9L);
|
||||
artist.setIsDelete(0);
|
||||
when(userMapper.selectById(7L)).thenReturn(artist);
|
||||
|
||||
ShopDO shop = new ShopDO();
|
||||
shop.setId(9L);
|
||||
shop.setShopName("Yumi Test Shop");
|
||||
ShopSimpleVO shopOption = new ShopSimpleVO();
|
||||
shopOption.setId(9L);
|
||||
shopOption.setShopName("Yumi Test Shop");
|
||||
when(shopMapper.selectById(9L)).thenReturn(shop);
|
||||
when(userShopBindingSupport.listShopOptionsByUserId(7L, true, true)).thenReturn(List.of(shopOption));
|
||||
|
||||
LocalDate workDate = LocalDate.now().plusDays(1);
|
||||
ArtistScheduleDO schedule = new ArtistScheduleDO();
|
||||
schedule.setShopId(9L);
|
||||
schedule.setArtistId(7L);
|
||||
schedule.setWorkDate(workDate);
|
||||
schedule.setStartTime(LocalTime.of(10, 0));
|
||||
schedule.setEndTime(LocalTime.of(12, 0));
|
||||
schedule.setSlotMinutes(60);
|
||||
schedule.setCapacity(1);
|
||||
schedule.setStatus(1);
|
||||
schedule.setIsDelete(0);
|
||||
when(artistScheduleMapper.selectList(any())).thenReturn(List.of(schedule));
|
||||
when(appointmentReservationMapper.countOverlappingActive(any(), any(), any()))
|
||||
.thenReturn(1)
|
||||
.thenReturn(0);
|
||||
|
||||
List<NailArtistAvailabilityVO> slots = service.getAvailability(7L);
|
||||
|
||||
assertThat(slots).hasSize(1);
|
||||
assertThat(slots.get(0).getStartTime().toLocalDate()).isEqualTo(workDate);
|
||||
assertThat(slots.get(0).getStartTime().toLocalTime()).isEqualTo(LocalTime.of(11, 0));
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -20,6 +20,7 @@ import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.SystemMessageMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||
import com.xiaowang.yuminailcore.service.AppointmentCapacityService;
|
||||
import com.xiaowang.yuminailcore.service.BusinessEventOutboxService;
|
||||
import com.xiaowang.yuminailcore.support.BookableArtistSupport;
|
||||
import com.xiaowang.yuminailcore.support.ObjectStorageUrlSupport;
|
||||
@@ -71,6 +72,8 @@ class OrderServiceImplReviewChangeTest {
|
||||
private BookableArtistSupport bookableArtistSupport;
|
||||
@Mock
|
||||
private BusinessEventOutboxService businessEventOutboxService;
|
||||
@Mock
|
||||
private AppointmentCapacityService appointmentCapacityService;
|
||||
|
||||
private OrderServiceImpl service;
|
||||
|
||||
@@ -90,6 +93,7 @@ class OrderServiceImplReviewChangeTest {
|
||||
ReflectionTestUtils.setField(service, "userShopBindingSupport", userShopBindingSupport);
|
||||
ReflectionTestUtils.setField(service, "bookableArtistSupport", bookableArtistSupport);
|
||||
ReflectionTestUtils.setField(service, "businessEventOutboxService", businessEventOutboxService);
|
||||
ReflectionTestUtils.setField(service, "appointmentCapacityService", appointmentCapacityService);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
package com.xiaowang.yuminailcore.service.impl;
|
||||
|
||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.PaymentOrderDO;
|
||||
import com.xiaowang.yuminailcore.entity.RefundOrderDO;
|
||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.PaymentOrderMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.RefundOrderMapper;
|
||||
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||
import com.xiaowang.yuminailcore.vo.RefundOrderVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class PaymentServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private OrderMapper orderMapper;
|
||||
@Mock
|
||||
private PaymentOrderMapper paymentOrderMapper;
|
||||
@Mock
|
||||
private RefundOrderMapper refundOrderMapper;
|
||||
|
||||
private PaymentServiceImpl service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
service = new PaymentServiceImpl(orderMapper, paymentOrderMapper, refundOrderMapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
void prepareOrderPaymentCreatesManualPaymentOrderForUnpaidOrder() {
|
||||
OrderDO order = order();
|
||||
when(orderMapper.selectById(1L)).thenReturn(order);
|
||||
when(paymentOrderMapper.selectLatestByOrderId(1L)).thenReturn(null);
|
||||
when(paymentOrderMapper.insert(any(PaymentOrderDO.class))).thenAnswer(invocation -> {
|
||||
PaymentOrderDO payment = invocation.getArgument(0);
|
||||
payment.setId(100L);
|
||||
return 1;
|
||||
});
|
||||
|
||||
PaymentOrderVO result = service.prepareOrderPayment(2L, 1L);
|
||||
|
||||
assertThat(result.getOrderId()).isEqualTo(1L);
|
||||
assertThat(result.getStatus()).isEqualTo("PAYING");
|
||||
assertThat(result.getPayAmount()).isEqualByComparingTo("88.00");
|
||||
ArgumentCaptor<PaymentOrderDO> captor = ArgumentCaptor.forClass(PaymentOrderDO.class);
|
||||
verify(paymentOrderMapper).insert(captor.capture());
|
||||
assertThat(captor.getValue().getChannel()).isEqualTo("MANUAL");
|
||||
}
|
||||
|
||||
@Test
|
||||
void manualConfirmOrderPaidUpdatesPaymentAndOrderSnapshot() {
|
||||
OrderDO order = order();
|
||||
PaymentOrderDO payment = new PaymentOrderDO();
|
||||
payment.setId(100L);
|
||||
payment.setOrderId(1L);
|
||||
payment.setStatus("PAYING");
|
||||
payment.setPayAmount(new BigDecimal("88.00"));
|
||||
when(orderMapper.selectById(1L)).thenReturn(order);
|
||||
when(paymentOrderMapper.selectLatestByOrderId(1L)).thenReturn(payment);
|
||||
|
||||
PaymentOrderVO result = service.manualConfirmOrderPaid(900L, 1L, "cash");
|
||||
|
||||
assertThat(result.getStatus()).isEqualTo("PAID");
|
||||
verify(paymentOrderMapper).updateById(payment);
|
||||
verify(orderMapper).updateById(order);
|
||||
assertThat(order.getPaymentStatus()).isEqualTo("PAID");
|
||||
assertThat(order.getPaidAmount()).isEqualByComparingTo("88.00");
|
||||
}
|
||||
|
||||
@Test
|
||||
void manualRefundOrderCreatesRefundAndUpdatesOrderSnapshot() {
|
||||
OrderDO order = order();
|
||||
order.setPaymentStatus("PAID");
|
||||
PaymentOrderDO payment = new PaymentOrderDO();
|
||||
payment.setId(100L);
|
||||
payment.setOrderId(1L);
|
||||
payment.setStatus("PAID");
|
||||
payment.setPayAmount(new BigDecimal("88.00"));
|
||||
payment.setPaidAmount(new BigDecimal("88.00"));
|
||||
payment.setChannel("MANUAL");
|
||||
when(orderMapper.selectById(1L)).thenReturn(order);
|
||||
when(paymentOrderMapper.selectLatestByOrderId(1L)).thenReturn(payment);
|
||||
when(refundOrderMapper.insert(any(RefundOrderDO.class))).thenAnswer(invocation -> {
|
||||
RefundOrderDO refund = invocation.getArgument(0);
|
||||
refund.setId(200L);
|
||||
return 1;
|
||||
});
|
||||
|
||||
RefundOrderVO result = service.manualRefundOrder(900L, 1L, 300L, "manual");
|
||||
|
||||
assertThat(result.getStatus()).isEqualTo("REFUNDED");
|
||||
assertThat(result.getRefundAmount()).isEqualByComparingTo("88.00");
|
||||
verify(refundOrderMapper).insert(any(RefundOrderDO.class));
|
||||
verify(orderMapper).updateById(order);
|
||||
assertThat(order.getPaymentStatus()).isEqualTo("REFUNDED");
|
||||
assertThat(order.getRefundStatus()).isEqualTo("REFUNDED");
|
||||
}
|
||||
|
||||
private OrderDO order() {
|
||||
OrderDO order = new OrderDO();
|
||||
order.setId(1L);
|
||||
order.setOrderNo("ORD1");
|
||||
order.setUserId(2L);
|
||||
order.setShopId(9L);
|
||||
order.setActualAmount(new BigDecimal("88.00"));
|
||||
order.setStatus(1);
|
||||
order.setIsDelete(0);
|
||||
order.setPaymentStatus("UNPAID");
|
||||
return order;
|
||||
}
|
||||
}
|
||||
+23
@@ -205,6 +205,29 @@ class PermissionServiceImplTest {
|
||||
assertThat(service.hasPermission(userId, "product:view")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shoplessPlatformAdminCurrentPermissionsIncludeSecurityAuditView() {
|
||||
long userId = 1L;
|
||||
UserDO user = new UserDO();
|
||||
user.setId(userId);
|
||||
user.setType(4);
|
||||
user.setIsDelete(0);
|
||||
when(userMapper.selectById(userId)).thenReturn(user);
|
||||
when(permissionMapper.selectList(any())).thenReturn(List.of(
|
||||
permission(101L, "shop:view"),
|
||||
permission(102L, "security:audit:view")
|
||||
));
|
||||
|
||||
List<PermissionVO> permissions = service.listUserPermissions(userId);
|
||||
|
||||
assertThat(permissions)
|
||||
.extracting(PermissionVO::getPermissionCode)
|
||||
.contains("security:audit:view");
|
||||
verifyNoInteractions(userPermissionMapper);
|
||||
verifyNoInteractions(userShopRoleMapper);
|
||||
verifyNoInteractions(shopRolePermissionMapper);
|
||||
}
|
||||
|
||||
private UserShopRoleDO roleBinding(long userId, long shopId, long roleId) {
|
||||
UserShopRoleDO roleBinding = new UserShopRoleDO();
|
||||
roleBinding.setUserId(userId);
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.xiaowang.yuminailcore.support;
|
||||
|
||||
import com.xiaowang.yuminailcore.config.MinioConfig;
|
||||
import com.xiaowang.yuminailcore.service.MinioService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
class ObjectStorageUrlSupportTest {
|
||||
|
||||
private MinioService minioService;
|
||||
private ObjectStorageUrlSupport support;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
minioService = mock(MinioService.class);
|
||||
MinioConfig config = new MinioConfig();
|
||||
config.setEndpoint("http://127.0.0.1:9000");
|
||||
config.setBucketName("yuminail");
|
||||
support = new ObjectStorageUrlSupport(minioService, config);
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAccessibleUrlFallsBackToOriginalExternalUrlWhenObjectNameCannotBeExtracted() {
|
||||
String externalUrl = "https://acceptance.local/assets/作品图.jpg";
|
||||
|
||||
String result = support.toAccessibleUrl(externalUrl);
|
||||
|
||||
assertThat(result).isEqualTo(externalUrl);
|
||||
verifyNoInteractions(minioService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractObjectNameStillAcceptsRawObjectName() {
|
||||
assertThat(support.extractObjectName("product/作品图.jpg?x=1")).isEqualTo("product/作品图.jpg");
|
||||
}
|
||||
}
|
||||
+15
@@ -60,6 +60,21 @@ class PermissionCatalogTest {
|
||||
assertThat(PermissionCatalog.getDefaultPermissionCodes(3)).contains("order:artist-change");
|
||||
}
|
||||
|
||||
@Test
|
||||
void vNextOperationsPermissionsAreGrantedByRole() {
|
||||
assertThat(PermissionCatalog.getDefaultPermissionCodes(4))
|
||||
.contains("schedule:view", "schedule:edit", "payment:manage", "refund:manage",
|
||||
"after_sale:view", "after_sale:audit", "inventory:view", "inventory:manage",
|
||||
"campaign:view", "campaign:manage", "growth:view", "analytics:view", "performance:view");
|
||||
assertThat(PermissionCatalog.getDefaultPermissionCodes(2))
|
||||
.contains("schedule:view", "schedule:edit", "payment:view", "refund:view",
|
||||
"after_sale:view", "after_sale:audit", "inventory:view", "inventory:manage",
|
||||
"campaign:view", "campaign:manage", "analytics:view", "performance:view");
|
||||
assertThat(PermissionCatalog.getDefaultPermissionCodes(3))
|
||||
.contains("schedule:view", "after_sale:view", "performance:view")
|
||||
.doesNotContain("payment:manage", "refund:manage", "inventory:manage", "campaign:manage");
|
||||
}
|
||||
|
||||
@Test
|
||||
void everyManagedDefaultPermissionUsesChineseDisplayText() {
|
||||
PermissionCatalog.getManagedDefinitions().forEach(definition -> {
|
||||
|
||||
+26
@@ -56,4 +56,30 @@ class YumiNailSqlSchemaTest {
|
||||
assertThat(sql).contains("CALL sp_add_column_if_not_exists('t_tag', 'scene_group'");
|
||||
assertThat(sql).contains("CALL sp_add_column_if_not_exists('t_tag', 'front_visible'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void vNextOperationsSchemasAndPermissionsAreSeeded() throws Exception {
|
||||
String sql = Files.readString(Path.of("src/main/resources/files/YumiNail.sql"));
|
||||
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_artist_schedule");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_appointment_reservation");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_payment_order");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_refund_order");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_after_sale");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_after_sale_log");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_inventory_item");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_inventory_record");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_campaign");
|
||||
assertThat(sql).contains("CREATE TABLE IF NOT EXISTS t_user_growth_record");
|
||||
assertThat(sql).contains("CALL sp_add_column_if_not_exists('t_order', 'payment_status'");
|
||||
assertThat(sql).contains("'schedule:view'");
|
||||
assertThat(sql).contains("'payment:manage'");
|
||||
assertThat(sql).contains("'after_sale:audit'");
|
||||
assertThat(sql).contains("'inventory:manage'");
|
||||
assertThat(sql).contains("'campaign:manage'");
|
||||
assertThat(sql).contains("'growth:view'");
|
||||
assertThat(sql).contains("'analytics:view'");
|
||||
assertThat(sql).contains("'performance:view'");
|
||||
assertThat(sql).contains("'workbench:view'");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user