fix(订单中心):新增注销接口逻辑
This commit is contained in:
+3
@@ -131,6 +131,9 @@ public class CouponController {
|
||||
@RequestParam(required = false) Integer discountRate,
|
||||
@RequestParam String validStartTime,
|
||||
@RequestParam String validEndTime) {
|
||||
// 打印请求参数
|
||||
log.info("携程创建券请求参数:ctripCouponId={}, userPhone={}, couponName={}, couponType={}, amount={}, minAmount={}, discountRate={}, validStartTime={}, validEndTime={}",
|
||||
ctripCouponId, userPhone, couponName, couponType, amount, minAmount, discountRate, validStartTime, validEndTime);
|
||||
// 幂等校验
|
||||
if (couponService.existsByUserPhoneAndCtripCouponId(userPhone, ctripCouponId)) {
|
||||
return Result.succeed(true);
|
||||
|
||||
+71
-2
@@ -662,6 +662,75 @@ public class OrderController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号查询订单素材
|
||||
*/
|
||||
@Operation(summary = "根据订单号查询订单素材")
|
||||
@GetMapping("/user/files/{orderNo}")
|
||||
public Result<Map<String, Object>> getOrderFilesByOrderNo(@PathVariable("orderNo") String orderNo) {
|
||||
// 校验订单是否存在
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
if (order == null) {
|
||||
return Result.failed("订单不存在");
|
||||
}
|
||||
|
||||
Map<String, Object> orderFileMap = new HashMap<>();
|
||||
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
|
||||
// 只查一次所有文件
|
||||
List<OrderFile> allFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||
|
||||
// aiVideo
|
||||
List<OrderFile> aiVideoFiles = allFiles.stream()
|
||||
.filter(f -> "ai_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
String aiVideoUrl = null;
|
||||
if (!aiVideoFiles.isEmpty()) {
|
||||
aiVideoUrl = fileCenterService.getViewUrlByPath(aiVideoFiles.get(0).getFilePath()).replace(cdnOssUrl, cdnUrl);
|
||||
}
|
||||
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||
|
||||
// 图片素材
|
||||
List<OrderFile> imgFiles = allFiles.stream()
|
||||
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||
.toList();
|
||||
List<Map<String,String>> imgList = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for (OrderFile orderFile : imgFiles){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||
imgMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||
imgMap.put("contentType", orderFile.getFileType());
|
||||
imgMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path",orderFile.getFilePath());
|
||||
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
orderFileMap.put("imgList", imgList);
|
||||
|
||||
// 视频素材
|
||||
List<OrderFile> videoFiles = allFiles.stream()
|
||||
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
List<Map<String,String>> videoList = new ArrayList<>();
|
||||
for (OrderFile orderFile : videoFiles){
|
||||
Map<String,String> videoMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||
videoMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||
videoMap.put("contentType", orderFile.getFileType());
|
||||
videoMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path",orderFile.getFilePath());
|
||||
videoMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
videoList.add(videoMap);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
return Result.succeed(orderFileMap, "查询成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将分的价格转换为元的str,方便前端显示
|
||||
* @param str
|
||||
@@ -773,8 +842,8 @@ public class OrderController {
|
||||
.toList();
|
||||
String aiVideoUrl = null;
|
||||
if (!aiVideoFiles.isEmpty()) {
|
||||
fileMap.put("path", aiVideoFiles.get(0).getFilePath());
|
||||
aiVideoUrl = fileCenterService.getViewUrlByPathStyle(fileMap).replace(cdnOssUrl, cdnUrl);
|
||||
// fileMap.put("path", aiVideoFiles.get(0).getFilePath());
|
||||
aiVideoUrl = fileCenterService.getViewUrlByPath(aiVideoFiles.get(0).getFilePath()).replace(cdnOssUrl, cdnUrl);
|
||||
}
|
||||
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||
|
||||
|
||||
+37
@@ -467,4 +467,41 @@ public class SysUserController {
|
||||
return config != null ? Result.succeed(config) : Result.failed("未找到配置");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注销账户
|
||||
*/
|
||||
@PostMapping("/users/logout")
|
||||
@Operation(summary = "用户注销账户")
|
||||
@CacheEvict(value = "user", key = "#result?.data?.username")
|
||||
@AuditLog(operation = "'用户注销账户:' + #result?.data?.username")
|
||||
public Result<String> logout() {
|
||||
try {
|
||||
SysUser currentUser = LoginUserUtils.getCurrentSysUser();
|
||||
if (currentUser != null) {
|
||||
// 检查是否为超级管理员
|
||||
if (checkAdmin(currentUser.getId())) {
|
||||
return Result.failed("超级管理员账户不能注销");
|
||||
}
|
||||
|
||||
log.info("用户 {} 执行账户注销操作", currentUser.getUsername());
|
||||
|
||||
// 执行用户账户注销(逻辑删除)
|
||||
boolean success = appUserService.delUser(currentUser.getId());
|
||||
|
||||
if (success) {
|
||||
log.info("用户 {} 账户注销成功", currentUser.getUsername());
|
||||
return Result.succeed("账户注销成功");
|
||||
} else {
|
||||
log.error("用户 {} 账户注销失败", currentUser.getUsername());
|
||||
return Result.failed("账户注销失败,请重试");
|
||||
}
|
||||
} else {
|
||||
return Result.failed("用户未登录");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("用户账户注销失败", e);
|
||||
return Result.failed("账户注销失败,请重试");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -132,7 +132,7 @@ public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
|
||||
@Override
|
||||
public SysUser selectByUsername(String username) {
|
||||
List<SysUser> users = baseMapper.selectList(
|
||||
new QueryWrapper<SysUser>().eq("username", username)
|
||||
new QueryWrapper<SysUser>().eq("username", username).eq("is_del", 0)
|
||||
);
|
||||
return getUser(users);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
|
||||
@Override
|
||||
public SysUser selectByMobile(String mobile) {
|
||||
List<SysUser> users = baseMapper.selectList(
|
||||
new QueryWrapper<SysUser>().eq("mobile", mobile)
|
||||
new QueryWrapper<SysUser>().eq("mobile", mobile).eq("is_del", 0)
|
||||
);
|
||||
return getUser(users);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
|
||||
@Override
|
||||
public SysUser selectByOpenId(String openId) {
|
||||
List<SysUser> users = baseMapper.selectList(
|
||||
new QueryWrapper<SysUser>().eq("open_id", openId)
|
||||
new QueryWrapper<SysUser>().eq("open_id", openId).eq("is_del", 0)
|
||||
);
|
||||
return getUser(users);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user