fix[任务模块]:排队信息返回价格优化,用户昵称头像更新逻辑,新增获取可查看文件接口等
This commit is contained in:
+3
-3
@@ -26,11 +26,11 @@ import java.util.Map;
|
||||
*/
|
||||
@Tag(name = "token获取")
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/token")
|
||||
@RequestMapping("/token")
|
||||
public class ApiTokenController {
|
||||
|
||||
// @Value("${jetlinks.server.url}")
|
||||
private String jetlinksServiceUrl = "http://119.45.169.13:8848/";
|
||||
@Value("${jetlinks.server.baseUrl}")
|
||||
private String jetlinksServiceUrl;//= "http://119.45.169.13:8848/";
|
||||
|
||||
@Autowired
|
||||
private HeaderUtils headerUtils;
|
||||
|
||||
+12
-2
@@ -87,11 +87,21 @@ public class FileController {
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@GetMapping("/files/{id}")
|
||||
public String getViewUrl(@PathVariable String id) {
|
||||
@GetMapping("/file/{id}")
|
||||
public String getFileViewUrl(@PathVariable String id) {
|
||||
return fileService.getViewUrl(id);
|
||||
}
|
||||
|
||||
@GetMapping("/files/{id}")
|
||||
public Result getViewUrl(@PathVariable String id) {
|
||||
return Result.succeed(fileService.getViewUrl(id),"获取成功");
|
||||
}
|
||||
|
||||
@GetMapping("/file/path")
|
||||
public Result getFileViewUrlByPath(@RequestParam String path) {
|
||||
return Result.succeed(fileService.getViewUrlByPath(path),"获取成功");
|
||||
}
|
||||
|
||||
@GetMapping("/files/path")
|
||||
public String getViewUrlByPath(@RequestParam String path) {
|
||||
return fileService.getViewUrlByPath(path);
|
||||
|
||||
@@ -4,7 +4,7 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: file-center
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 119.45.169.13
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 119.45.169.13
|
||||
|
||||
+33
-14
@@ -32,6 +32,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -52,6 +53,9 @@ import java.util.Map;
|
||||
@RequiredArgsConstructor
|
||||
public class OrderController {
|
||||
|
||||
//设备执行任务默认时间长度3分钟
|
||||
private static final long DEVICE_EXEC_TIME = 3;
|
||||
|
||||
@Autowired
|
||||
private IOrderService orderService;
|
||||
|
||||
@@ -239,30 +243,26 @@ public class OrderController {
|
||||
|
||||
@Operation(summary = "获取排队总览信息")
|
||||
@GetMapping("/queue/info")
|
||||
public Result<Map> getQueueInfo() {
|
||||
public Result<Map> getQueueInfo(@RequestParam String codeId) {
|
||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||
//@TODO 价格配置问题优化
|
||||
Double price = 19.90;
|
||||
long execTime = 3; //一单执行时间默认3分钟
|
||||
|
||||
QrCode qrCode = qrCodeService.getByCodeId(codeId);
|
||||
if (qrCode == null){
|
||||
Assert.isNull(qrCode,"二维码CODEID不能为空");
|
||||
}
|
||||
Order order = orderService.getOrderyStatusAndUser(OrderStatus.PAID.getId(), user.getId());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("price",appendPriceStr(qrCode.getPrice()));
|
||||
//如果用户存在已支付订单,则查询当前排在第几
|
||||
if (order != null){
|
||||
Integer count = orderService.getOrderRankingByOrderId(order.getId());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("count", count == 1 ? -1 : count-1 );
|
||||
map.put("time",Math.multiplyExact((count-1),execTime));
|
||||
map.put("price",price);
|
||||
return Result.succeed(map,"获取成功");
|
||||
map.put("time",Math.multiplyExact((count-1),DEVICE_EXEC_TIME));
|
||||
}else {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Long count = orderService.getOrderCountByStatus(OrderStatus.PAID.getId());
|
||||
map.put("count", count == 0 ? -1 : count);
|
||||
map.put("time",Math.multiplyExact(count,execTime));
|
||||
map.put("price",price);
|
||||
return Result.succeed(map,"获取成功");
|
||||
map.put("time",Math.multiplyExact(count,DEVICE_EXEC_TIME));
|
||||
}
|
||||
|
||||
return Result.succeed(map,"获取成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取用户是否存在排队订单")
|
||||
@@ -412,4 +412,23 @@ public class OrderController {
|
||||
}
|
||||
return Result.failed("不满足执行条件");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将分的价格转换为元的str,方便前端显示
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private String appendPriceStr(String str){
|
||||
// 获取字符串长度
|
||||
int length = str.length();
|
||||
|
||||
// 获取除了最后两位字符之外的部分
|
||||
String prefix = str.substring(0, length - 2);
|
||||
|
||||
// 获取最后两位字符
|
||||
String lastTwo = str.substring(length - 2);
|
||||
|
||||
// 在最后两位字符前添加小数点
|
||||
return prefix + "." + lastTwo;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "订单资源管理")
|
||||
@Tag(name = "任务资源管理")
|
||||
@RequestMapping("/files")
|
||||
@RequiredArgsConstructor
|
||||
public class OrderFileController {
|
||||
@@ -118,7 +118,7 @@ public class OrderFileController {
|
||||
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||
if (!CollectionUtils.isEmpty(orderFiles)) {
|
||||
for (OrderFile orderFile : orderFiles) {
|
||||
String viewUrl = fileCenterService.getViewUrl(orderFile.getFileId());
|
||||
String viewUrl = fileCenterService.getFileViewUrl(orderFile.getFileId());
|
||||
orderFile.setViewUrl(viewUrl);
|
||||
}
|
||||
}else {
|
||||
@@ -133,7 +133,7 @@ public class OrderFileController {
|
||||
List<OrderFile> orderFiles = orderFileService.getOrderFileByUserId(userId);
|
||||
if (!CollectionUtils.isEmpty(orderFiles)) {
|
||||
for (OrderFile orderFile : orderFiles) {
|
||||
String viewUrl = fileCenterService.getViewUrl(orderFile.getFileId());
|
||||
String viewUrl = fileCenterService.getFileViewUrl(orderFile.getFileId());
|
||||
orderFile.setViewUrl(viewUrl);
|
||||
}
|
||||
}else {
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
1. 待支付
|
||||
说明:用户成功提交订单,但尚未完成支付操作。此状态下,订单处于暂挂状态,可能因为用户还在选择支付方式、支付过程中出现问题等原因导致未支付。
|
||||
操作:用户可选择支付、取消订单;商家可设置订单自动取消时间,超时未支付则订单自动取消。
|
||||
|
||||
2. 已取消
|
||||
说明:订单在支付前被用户主动取消,或者因超过规定的支付时间而被系统自动取消。
|
||||
操作:一般无后续操作,订单流程结束。
|
||||
|
||||
3. 支付成功
|
||||
说明:用户成功完成支付,订单进入待处理排队(此时的状态也称作排队中)阶段。
|
||||
操作:商家开始处理订单,如确认设备状态;系统可发送支付成功通知给用户。
|
||||
|
||||
4. 设备执行中
|
||||
说明:商家正在对订单进行处理调度设备作业,包括但不限于确认订单信息、设备作业状态、设备素材上传等操作。
|
||||
操作:商家完成处理后,可将订单状态更新为素材上传完成或素材上传中(对于多素材订单)。
|
||||
|
||||
5. 素材上传中
|
||||
说明:商家已将照片上传。用户可以通过订单号查询订单对应素材。
|
||||
操作:商家上传照片中,用户可查询上传进度。
|
||||
|
||||
6. 素材上传完成
|
||||
说明:订单上传素材完成,处于用户下载状态。
|
||||
操作:用户可查询素材信息并进行下载操作;若出现上传异常,商家需及时处理。
|
||||
|
||||
7. 用户已下载完成
|
||||
说明:用户确认订单素材并下载完成且可能已完成评价,整个订单流程结束。
|
||||
操作:无后续主要操作,可作为历史订单进行存档和统计分析。
|
||||
|
||||
8. 退款中
|
||||
说明:用户发起退款申请,商家或平台正在处理该申请。
|
||||
操作:商家需审核退款申请,根据情况决定是否同意退款;若同意,需进行退款操作。
|
||||
|
||||
9. 退款成功
|
||||
说明:商家或平台已同意退款申请,并完成退款操作,款项已返还给用户。
|
||||
操作:订单流程结束,可记录退款相关信息。
|
||||
|
||||
10. 退款失败
|
||||
说明:退款申请因各种原因未能成功处理,如支付渠道问题、用户账户异常等。
|
||||
操作:商家或平台需与用户沟通,解决问题后重新发起退款操作。
|
||||
状态流转图示例
|
||||
|
||||
注意:(括号中的为订单状态),发起支付、用户支付中等为处理逻辑
|
||||
(待支付) ── 发起支付 ── 用户支付中 ── 支付回调成功或者主动查询支付成功状态 ──> (支付成功) ── 排队中 ──> (设备执行中)── 飞机拍照 ── 飞机返航 ──> (素材上传中) ──> (素材上传完成) ── 用户下载 ──> (用户下载完成)
|
||||
└─ 长时间未支付自动取消 ──> (已取消)
|
||||
└─ 退款 ──> (退款中) ── 同意 ──> (退款成功)
|
||||
└─ 拒绝并填写原因 ──> (退款失败)
|
||||
@@ -9,7 +9,16 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
public enum OrderStatus implements ZltEnum {
|
||||
UNPAID(0,"待支付"), PAID(1, "已支付排队中"), CANCELED(2, "已取消"),DOING(4,"正在服务中"),COMPLETE(3,"服务完成");
|
||||
UNPAID(0,"待支付"),
|
||||
PAID(1, "已支付排队中"),
|
||||
CANCELED(2, "已取消"),
|
||||
DOING(4,"正在服务中"),
|
||||
COMPLETE(3,"用户下载完成"),
|
||||
UPLOADING(5,"素材上传中"),
|
||||
UPLOADED(6,"素材上传完成"),
|
||||
REFUNDING(7,"退款中"),
|
||||
REFUNDED(8,"已退款"),
|
||||
REFUND_FAILED(9,"退款失败");
|
||||
|
||||
OrderStatus(Integer id, String content) {
|
||||
this.id = id;
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ public interface FileCenterService {
|
||||
* @param id 文件ID
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/files/{id}")
|
||||
String getViewUrl(@PathVariable("id") String id);
|
||||
@GetMapping("/file/{id}")
|
||||
String getFileViewUrl(@PathVariable("id") String id);
|
||||
|
||||
@GetMapping("/type/{id}")
|
||||
String getFileContentType(@PathVariable("id") String id);
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCen
|
||||
return new FileCenterService() {
|
||||
|
||||
@Override
|
||||
public String getViewUrl(String id) {
|
||||
public String getFileViewUrl(String id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: order-center
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 81.70.164.178
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 81.70.164.178
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
|
||||
+6
@@ -144,6 +144,12 @@ public class SysUserController {
|
||||
appUserService.updateById(sysUser);
|
||||
}
|
||||
|
||||
@PatchMapping("/user")
|
||||
@CachePut(value = "user", key = "#sysUser.username", unless="#result == null")
|
||||
public Result updateSysUserInfo(@RequestBody SysUser sysUser) {
|
||||
return Result.succeed(appUserService.updateById(sysUser),"更新成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理后台给用户分配角色
|
||||
*
|
||||
|
||||
@@ -4,10 +4,10 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: user-center
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 124.222.128.40
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 124.222.128.40
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
|
||||
Reference in New Issue
Block a user